Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java Fri Oct 14 08:36:29 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java Fri Oct 14 12:46:46 2011 +0000 @@ -2,11 +2,21 @@ import com.google.gwt.core.client.GWT; +import com.smartgwt.client.types.ImageStyle; import com.smartgwt.client.types.ListGridFieldType; +import com.smartgwt.client.types.VerticalAlignment; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Img; +import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; +import de.intevation.flys.client.shared.MapUtils; +import de.intevation.flys.client.shared.model.AttributedTheme; import de.intevation.flys.client.shared.model.Collection; +import de.intevation.flys.client.shared.model.FacetRecord; import de.intevation.flys.client.shared.model.Theme; import de.intevation.flys.client.shared.model.OutputMode; @@ -19,6 +29,10 @@ */ public class MapThemePanel extends ThemePanel { + public static final int CELL_HEIGHT = 75; + public static final int STYLE_CELL_WIDTH = 125; + + public interface ActivateCallback { void activate(Theme theme, boolean activate); } @@ -38,6 +52,7 @@ public static final String GRID_FIELD_ACTIVE = "active"; + public static final String GRID_FIELD_STYLE = "style"; public static final String GRID_FIELD_NAME = "name"; @@ -96,16 +111,64 @@ list.setWidth100(); list.setHeight100(); + list.setCellHeight(CELL_HEIGHT); + list.setShowRecordComponents(true); + list.setShowRecordComponentsByCell(true); + list.setShowAllRecords(true); + list.addEditCompleteHandler(this); ListGridField active = new ListGridField(GRID_FIELD_ACTIVE, " ", 20); active.setType(ListGridFieldType.BOOLEAN); + active.setCanDragResize(false); + + ListGridField style = new ListGridField( + GRID_FIELD_STYLE, + MSG.map_themepanel_header_style(), + STYLE_CELL_WIDTH); + style.setCanEdit(false); + style.setCanDragResize(false); ListGridField name = new ListGridField( GRID_FIELD_NAME, MSG.chart_themepanel_header_themes()); name.setType(ListGridFieldType.TEXT); - list.setFields(active, name); + list.setFields(active, style, name); + } + + + @Override + protected ListGrid createNewGrid() { + ListGrid grid = new ListGrid() { + @Override + protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) { + String fieldname = getFieldName(colNum); + + if (fieldname.equals(GRID_FIELD_STYLE)) { + FacetRecord r = (FacetRecord) record; + AttributedTheme at = (AttributedTheme) r.getTheme(); + + String imgUrl = MapUtils.getLegendGraphicUrl( + at.getAttr("url"), + at.getAttr("layers")); + + HLayout layout = new HLayout(); + layout.setAlign(VerticalAlignment.CENTER); + layout.setLayoutAlign(VerticalAlignment.CENTER); + + Img img = new Img(imgUrl); + img.setImageType(ImageStyle.CENTER); + + layout.addMember(img); + + return layout; + } + + return super.createRecordComponent(record, colNum); + } + }; + + return grid; }