changeset 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 974c6b3700de
children ab93960ac2fb
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java
diffstat 8 files changed, 107 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Oct 14 08:36:29 2011 +0000
+++ b/flys-client/ChangeLog	Fri Oct 14 12:46:46 2011 +0000
@@ -1,3 +1,26 @@
+2011-10-14  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue288 (ÜSK: Legende hinzufügen)
+
+	* src/main/java/de/intevation/flys/client/shared/MapUtils.java: New.
+	  Helper class for maps.
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java:
+	  Set width and min width of MapThemePanel to 300px and allow to resize it.
+
+	* src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java: Moved
+	  Record and ListGrid creation out to own methods which subclasses can
+	  override.
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java:
+	  Override createNewGrid() to add a column for displaying legend items.
+
+	* src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.java,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties:
+	  Added string for the "style" header in the MapThemePanel.
+
 2011-10-14  Raimund Renkert <raimund.renkert@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/shared/model/Style.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Fri Oct 14 08:36:29 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Fri Oct 14 12:46:46 2011 +0000
@@ -452,6 +452,8 @@
 
     String measureArea();
 
+    String map_themepanel_header_style();
+
     // data cage
 
     String old_calculations();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Fri Oct 14 08:36:29 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Fri Oct 14 12:46:46 2011 +0000
@@ -228,3 +228,4 @@
 adjustElevationTooltip = Define elevations for barriers
 measureDistance = Measure line
 measureArea = Measure area
+map_themepanel_header_style = Style
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Fri Oct 14 08:36:29 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Fri Oct 14 12:46:46 2011 +0000
@@ -229,6 +229,7 @@
 adjustElevationTooltip = Festlegen von H\u00f6hen für D\u00e4mme, Ringeiche, Gr\u00e4ben und Rohre
 measureDistance = L\u00e4ngenmessung
 measureArea = Streckenmessung
+map_themepanel_header_style = Stil
 
 # data cage
 old_calculations = Alte Berechnungen
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Fri Oct 14 08:36:29 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Fri Oct 14 12:46:46 2011 +0000
@@ -223,6 +223,7 @@
 adjustElevationTooltip = Define elevations for barriers
 measureDistance = Measure line
 measureArea = Measure area
+map_themepanel_header_style = Style
 
 # data cage
 old_calculations = Former calculations
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java	Fri Oct 14 08:36:29 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java	Fri Oct 14 12:46:46 2011 +0000
@@ -193,13 +193,18 @@
                 continue;
             }
 
-            list.addData(new FacetRecord(theme));
+            list.addData(createRecord(theme));
         }
 
         fireOutputParameterChanged();
     }
 
 
+    protected ListGridRecord createRecord(Theme theme) {
+        return new FacetRecord(theme);
+    }
+
+
     /**
      * This method triggers the CollectionAttributeService. Based on the current
      * collectin settings, the attribute of the collection is modified or not.
@@ -238,7 +243,7 @@
      * Create and configure the Grid to display.
      */
     protected ListGrid createGrid() {
-        ListGrid grid =  new ListGrid();
+        ListGrid grid = createNewGrid();
         grid.addRowContextClickHandler(new RowContextClickHandler() {
             public void onRowContextClick(RowContextClickEvent event) {
                 ListGridRecord[] records = list.getSelection();
@@ -268,6 +273,11 @@
     }
 
 
+    protected ListGrid createNewGrid() {
+        return new ListGrid();
+    }
+
+
     /**
      * A method that removes all records from theme grid.
      */
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java	Fri Oct 14 08:36:29 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java	Fri Oct 14 12:46:46 2011 +0000
@@ -401,8 +401,10 @@
 
     protected Canvas createThemePanel() {
         Canvas c = new Canvas();
-        c.setWidth(200);
+        c.setMinWidth(300);
+        c.setWidth(300);
         c.setHeight100();
+        c.setCanDragResize(true);
         c.setBorder("1px solid black");
 
         themePanel = new MapThemePanel(
--- 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;
     }
 
 

http://dive4elements.wald.intevation.org