Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java @ 1327:8a93fb299e64
#288 Added legend symbols to the MapThemePanel.
flys-client/trunk@2971 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 14 Oct 2011 12:46:46 +0000 |
parents | 84c50f1d939b |
children | b0fe35d4ce6b |
comparison
equal
deleted
inserted
replaced
1326:974c6b3700de | 1327:8a93fb299e64 |
---|---|
1 package de.intevation.flys.client.client.ui.map; | 1 package de.intevation.flys.client.client.ui.map; |
2 | 2 |
3 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
4 | 4 |
5 import com.smartgwt.client.types.ImageStyle; | |
5 import com.smartgwt.client.types.ListGridFieldType; | 6 import com.smartgwt.client.types.ListGridFieldType; |
7 import com.smartgwt.client.types.VerticalAlignment; | |
8 import com.smartgwt.client.widgets.Canvas; | |
9 import com.smartgwt.client.widgets.Img; | |
10 import com.smartgwt.client.widgets.grid.ListGrid; | |
6 import com.smartgwt.client.widgets.grid.ListGridField; | 11 import com.smartgwt.client.widgets.grid.ListGridField; |
12 import com.smartgwt.client.widgets.grid.ListGridRecord; | |
13 import com.smartgwt.client.widgets.layout.HLayout; | |
7 import com.smartgwt.client.widgets.layout.VLayout; | 14 import com.smartgwt.client.widgets.layout.VLayout; |
8 | 15 |
16 import de.intevation.flys.client.shared.MapUtils; | |
17 import de.intevation.flys.client.shared.model.AttributedTheme; | |
9 import de.intevation.flys.client.shared.model.Collection; | 18 import de.intevation.flys.client.shared.model.Collection; |
19 import de.intevation.flys.client.shared.model.FacetRecord; | |
10 import de.intevation.flys.client.shared.model.Theme; | 20 import de.intevation.flys.client.shared.model.Theme; |
11 import de.intevation.flys.client.shared.model.OutputMode; | 21 import de.intevation.flys.client.shared.model.OutputMode; |
12 | 22 |
13 import de.intevation.flys.client.client.FLYSConstants; | 23 import de.intevation.flys.client.client.FLYSConstants; |
14 import de.intevation.flys.client.client.ui.ThemePanel; | 24 import de.intevation.flys.client.client.ui.ThemePanel; |
16 | 26 |
17 /** | 27 /** |
18 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 28 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
19 */ | 29 */ |
20 public class MapThemePanel extends ThemePanel { | 30 public class MapThemePanel extends ThemePanel { |
31 | |
32 public static final int CELL_HEIGHT = 75; | |
33 public static final int STYLE_CELL_WIDTH = 125; | |
34 | |
21 | 35 |
22 public interface ActivateCallback { | 36 public interface ActivateCallback { |
23 void activate(Theme theme, boolean activate); | 37 void activate(Theme theme, boolean activate); |
24 } | 38 } |
25 | 39 |
36 protected ActivateCallback activateCallback; | 50 protected ActivateCallback activateCallback; |
37 protected ThemeMovedCallback themeMovedCallback; | 51 protected ThemeMovedCallback themeMovedCallback; |
38 | 52 |
39 | 53 |
40 public static final String GRID_FIELD_ACTIVE = "active"; | 54 public static final String GRID_FIELD_ACTIVE = "active"; |
55 public static final String GRID_FIELD_STYLE = "style"; | |
41 public static final String GRID_FIELD_NAME = "name"; | 56 public static final String GRID_FIELD_NAME = "name"; |
42 | 57 |
43 | 58 |
44 protected MapOutputTab mapOut; | 59 protected MapOutputTab mapOut; |
45 | 60 |
94 list.setShowHeader(true); | 109 list.setShowHeader(true); |
95 list.setShowHeaderContextMenu(false); | 110 list.setShowHeaderContextMenu(false); |
96 list.setWidth100(); | 111 list.setWidth100(); |
97 list.setHeight100(); | 112 list.setHeight100(); |
98 | 113 |
114 list.setCellHeight(CELL_HEIGHT); | |
115 list.setShowRecordComponents(true); | |
116 list.setShowRecordComponentsByCell(true); | |
117 list.setShowAllRecords(true); | |
118 | |
99 list.addEditCompleteHandler(this); | 119 list.addEditCompleteHandler(this); |
100 | 120 |
101 ListGridField active = new ListGridField(GRID_FIELD_ACTIVE, " ", 20); | 121 ListGridField active = new ListGridField(GRID_FIELD_ACTIVE, " ", 20); |
102 active.setType(ListGridFieldType.BOOLEAN); | 122 active.setType(ListGridFieldType.BOOLEAN); |
123 active.setCanDragResize(false); | |
124 | |
125 ListGridField style = new ListGridField( | |
126 GRID_FIELD_STYLE, | |
127 MSG.map_themepanel_header_style(), | |
128 STYLE_CELL_WIDTH); | |
129 style.setCanEdit(false); | |
130 style.setCanDragResize(false); | |
103 | 131 |
104 ListGridField name = new ListGridField( | 132 ListGridField name = new ListGridField( |
105 GRID_FIELD_NAME, MSG.chart_themepanel_header_themes()); | 133 GRID_FIELD_NAME, MSG.chart_themepanel_header_themes()); |
106 name.setType(ListGridFieldType.TEXT); | 134 name.setType(ListGridFieldType.TEXT); |
107 | 135 |
108 list.setFields(active, name); | 136 list.setFields(active, style, name); |
137 } | |
138 | |
139 | |
140 @Override | |
141 protected ListGrid createNewGrid() { | |
142 ListGrid grid = new ListGrid() { | |
143 @Override | |
144 protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) { | |
145 String fieldname = getFieldName(colNum); | |
146 | |
147 if (fieldname.equals(GRID_FIELD_STYLE)) { | |
148 FacetRecord r = (FacetRecord) record; | |
149 AttributedTheme at = (AttributedTheme) r.getTheme(); | |
150 | |
151 String imgUrl = MapUtils.getLegendGraphicUrl( | |
152 at.getAttr("url"), | |
153 at.getAttr("layers")); | |
154 | |
155 HLayout layout = new HLayout(); | |
156 layout.setAlign(VerticalAlignment.CENTER); | |
157 layout.setLayoutAlign(VerticalAlignment.CENTER); | |
158 | |
159 Img img = new Img(imgUrl); | |
160 img.setImageType(ImageStyle.CENTER); | |
161 | |
162 layout.addMember(img); | |
163 | |
164 return layout; | |
165 } | |
166 | |
167 return super.createRecordComponent(record, colNum); | |
168 } | |
169 }; | |
170 | |
171 return grid; | |
109 } | 172 } |
110 | 173 |
111 | 174 |
112 @Override | 175 @Override |
113 public void activateTheme(Theme theme, boolean active) { | 176 public void activateTheme(Theme theme, boolean active) { |