changeset 1315:cf0f906921de

#297 Implemented a window to adjust elevations of geometries in the map. flys-client/trunk@2954 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 13 Oct 2011 09:08:43 +0000
parents 4c716bec7822
children 956605001cfb
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/map/DrawControl.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ElevationWindow.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java flys-client/src/main/webapp/images/adjustElevation.png
diffstat 10 files changed, 587 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed Oct 12 12:42:53 2011 +0000
+++ b/flys-client/ChangeLog	Thu Oct 13 09:08:43 2011 +0000
@@ -1,3 +1,30 @@
+2011-10-12  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue297 (ÜSK: Eingabe von Höhen ermöglichen)
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java,
+	  src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java:
+	  Made those classes more robust while setting Styles for features without
+	  barrier type.
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/DrawControl.java:
+	  Moved the constant to mark features to FloodMap. Added a new control to
+	  adjust the elevation values of features.
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/ElevationWindow.java:
+	  New. This Window displays a grid that contains the vertices of the
+	  specified vector feature. Users are able to modify the elevation value
+	  for each vertex in the grid.
+
+	* 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:
+	  New strings used for the elevation control button/icon.
+
+	* src/main/webapp/images/adjustElevation.png: A new icon used for the
+	  control to adjust the elevation values of features in the map.
+
 2011-10-12  Ingo Weinzierl <ingo@intevation.de>
 
 	flys/issue331 (ÜSK: OpenLayers innerhalb der eigenen Distribution bereitstellen)
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Wed Oct 12 12:42:53 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Thu Oct 13 09:08:43 2011 +0000
@@ -234,6 +234,28 @@
 
     String label_cancel();
 
+    // Elevation window
+
+    String ele_window_title();
+
+    String ele_window_label();
+
+    String ele_window_x_col();
+
+    String ele_window_y_col();
+
+    String ele_window_z_col();
+
+    String ele_window_ok_button();
+
+    String ele_window_cancel_button();
+
+    String ele_window_format_error();
+
+    String ele_window_save_error();
+
+    String ele_window_geometry_error();
+
     // OUTPUT TYPES
 
     String discharge_curve();
@@ -392,6 +414,10 @@
 
     String removeFeature();
 
+    String adjustElevation();
+
+    String adjustElevationTooltip();
+
     String measureLine();
 
     String measurePolygon();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Wed Oct 12 12:42:53 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Thu Oct 13 09:08:43 2011 +0000
@@ -149,6 +149,17 @@
 chart_themepanel_header_themes = Theme
 chart_themepanel_header_actions = Actions
 
+ele_window_title = Elevation Node
+ele_window_label = Elevation settings in m \u00fc. NN.
+ele_window_x_col = X
+ele_window_y_col = Y
+ele_window_z_col = Z-Coordinate
+ele_window_ok_button = Set elevations
+ele_window_cancel_button = Cancel
+ele_window_format_error = The elevation you have entered is invalid:
+ele_window_save_error = Error while saving elevations.
+ele_window_geometry_error = The geometry is not supported:
+
 unexpected_exception = There occured an unexpected exception
 error_read_minmax_values = Error while reading min/max values for the location input.
 error_validate_range = The value $1 needs to be smaller than $3 and bigger than $2.
@@ -198,6 +209,7 @@
 ring_dike = Ringdike
 selectFeature = images/selectFeature.png
 removeFeature = images/removeFeature.png
+adjustElevation = images/adjustElevation.png
 measureLine = images/measureLine.png
 measurePolygon = images/measurePolygon.png
 step = Step
@@ -210,5 +222,6 @@
 digitizeObjects = Creation of pipes, ditches, dams and ringdikes
 selectObject = Select tool
 removeObject = Remove selected object
+adjustElevationTooltip = Define elevations for barriers
 measureDistance = Measure line
 measureArea = Measure area
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Wed Oct 12 12:42:53 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Thu Oct 13 09:08:43 2011 +0000
@@ -150,6 +150,17 @@
 chart_themepanel_header_themes = Thema
 chart_themepanel_header_action = Aktionen
 
+ele_window_title = H\u00f6henknoten setzen
+ele_window_label = H\u00f6henangaben in m \u00fc. NN.
+ele_window_x_col = X
+ele_window_y_col = Y
+ele_window_z_col = Z-Koordinate
+ele_window_ok_button = H\u00f6he setzen
+ele_window_cancel_button = Abbrechen
+ele_window_format_error = Die von Ihnen eigegebene H\u00f6he ist ung\u00fcltig:
+ele_window_save_error = Fehler beim Speichern der H\u00f6hen.
+ele_window_geometry_error = Die Geometrie wird nicht unterst\u00fctzt:
+
 unexpected_exception = Ein unerwarteter Fehler ist aufgetreten
 error_read_minmax_values = Fehler beim Lesen der min/max Werte. Es kann keine Validierung der eingegebenen Strecke durchgef\u00fchrt werden.
 error_validate_range = Der Wert $1 muss kleiner als $3 und gr\u00f6\u00dfer als $2 sein.
@@ -199,6 +210,7 @@
 ring_dike = Ringdeich
 selectFeature = images/selectFeature.png
 removeFeature = images/removeFeature.png
+adjustElevation = images/adjustElevation.png
 measureLine = images/measureLine.png
 measurePolygon = images/measurePolygon.png
 step = Schritt
@@ -211,5 +223,6 @@
 digitizeObjects = Erstellung von Rohren, Gr\u00e4ben, D\u00e4mmen und Ringdeichen
 selectObject = Auswahlwerkzeug
 removeObject = Ausgew\u00e4hltes Objekt l\u00f6schen
+adjustElevationTooltip = Festlegen von H\u00f6hen für D\u00e4mme, Ringeiche, Gr\u00e4ben und Rohre
 measureDistance = L\u00e4ngenmessung
 measureArea = Streckenmessung
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Wed Oct 12 12:42:53 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Thu Oct 13 09:08:43 2011 +0000
@@ -144,6 +144,17 @@
 chart_themepanel_header_themes = Theme
 chart_themepanel_header_actions = Actions
 
+ele_window_title = Elevation Node
+ele_window_label = Elevation settings in m \u00fc. NN.
+ele_window_x_col = X
+ele_window_y_col = Y
+ele_window_z_col = Z-Coordinate
+ele_window_ok_button = Set elevations
+ele_window_cancel_button = Cancel
+ele_window_format_error = The elevation you have entered is invalid:
+ele_window_save_error = Error while saving elevations.
+ele_window_geometry_error = The geometry is not supported:
+
 unexpected_exception = There occured an unexpected exception
 error_read_minmax_values = Error while reading min/max values for the location input.
 error_validate_range = The value $1 needs to be smaller than $3 and bigger than $2.
@@ -193,6 +204,7 @@
 ring_dike = Ringdike
 selectFeature = images/selectFeature.png
 removeFeature = images/removeFeature.png
+adjustElevation = images/adjustElevation.png
 measureLine = images/measureLine.png
 measurePolygon = images/measurePolygon.png
 step = Step
@@ -205,5 +217,6 @@
 digitizeObjects = Creation of pipes, ditches, dams and ringdikes
 selectObject = Select tool
 removeObject = Remove selected object
+adjustElevationTooltip = Define elevations for barriers
 measureDistance = Measure line
 measureArea = Measure area
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/DrawControl.java	Wed Oct 12 12:42:53 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/DrawControl.java	Thu Oct 13 09:08:43 2011 +0000
@@ -16,6 +16,7 @@
 import com.smartgwt.client.widgets.layout.HLayout;
 
 import org.gwtopenmaps.openlayers.client.Map;
+import org.gwtopenmaps.openlayers.client.Style;
 import org.gwtopenmaps.openlayers.client.control.Control;
 import org.gwtopenmaps.openlayers.client.control.DrawFeature;
 import org.gwtopenmaps.openlayers.client.event.VectorFeatureAddedListener;
@@ -155,7 +156,10 @@
         if (type == null || type.length() == 0) {
             type = getSelectedType();
 
-            feature.setStyle(FloodMap.getStyle(type));
+            Style style = FloodMap.getStyle(type);
+            if (style != null) {
+                feature.setStyle(style);
+            }
 
             if (type.equals(BARRIER_PIPE1)) {
                 attrs.setAttribute("typ", BARRIER_PIPE1_VALUE);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ElevationWindow.java	Thu Oct 13 09:08:43 2011 +0000
@@ -0,0 +1,432 @@
+package de.intevation.flys.client.client.ui.map;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.i18n.client.NumberFormat;
+
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.types.SortArrow;
+import com.smartgwt.client.types.SortDirection;
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+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.grid.events.EditCompleteEvent;
+import com.smartgwt.client.widgets.grid.events.EditCompleteHandler;
+import com.smartgwt.client.widgets.grid.events.RowOutEvent;
+import com.smartgwt.client.widgets.grid.events.RowOutHandler;
+import com.smartgwt.client.widgets.grid.events.RowOverEvent;
+import com.smartgwt.client.widgets.grid.events.RowOverHandler;
+
+import org.gwtopenmaps.openlayers.client.Style;
+import org.gwtopenmaps.openlayers.client.feature.VectorFeature;
+import org.gwtopenmaps.openlayers.client.geometry.Geometry;
+import org.gwtopenmaps.openlayers.client.geometry.LinearRing;
+import org.gwtopenmaps.openlayers.client.geometry.LineString;
+import org.gwtopenmaps.openlayers.client.geometry.Point;
+import org.gwtopenmaps.openlayers.client.geometry.Polygon;
+import org.gwtopenmaps.openlayers.client.layer.Vector;
+import org.gwtopenmaps.openlayers.client.layer.VectorOptions;
+import org.gwtopenmaps.openlayers.client.util.Attributes;
+
+import de.intevation.flys.client.client.FLYSConstants;
+
+
+
+public class ElevationWindow extends Window {
+
+    public static FLYSConstants MSG = GWT.create(FLYSConstants.class);
+
+    public static final int WINDOW_WIDTH  = 250;
+    public static final int WINDOW_HEIGHT = 250;
+
+    protected FloodMap      floodmap;
+    protected Vector        layer;
+    protected VectorFeature feature;
+
+    protected ListGrid grid;
+
+
+    private class PointRecord extends ListGridRecord {
+        protected VectorFeature point;
+
+        public PointRecord(VectorFeature point, double x, double y, String z) {
+            super();
+
+            this.point = point;
+            setAttribute("x", x);
+            setAttribute("y", y);
+            setAttribute("z", z);
+        }
+
+        public VectorFeature getPoint() {
+            return point;
+        }
+    }
+
+
+    public ElevationWindow(FloodMap floodmap, VectorFeature feature) {
+        super();
+        this.feature  = feature;
+        this.floodmap = floodmap;
+
+        init();
+    }
+
+
+    protected void init() {
+        addCloseClickHandler(new CloseClickHandler() {
+            public void onCloseClick(CloseClientEvent evt) {
+                doClose();
+            }
+        });
+
+        initLayout();
+        initEdit();
+        updateGrid();
+    }
+
+
+    protected void initLayout() {
+        setWidth(WINDOW_WIDTH);
+        setHeight(WINDOW_HEIGHT);
+        setTitle(MSG.ele_window_title());
+
+        VLayout root = new VLayout();
+        root.setMembersMargin(5);
+        root.setPadding(5);
+
+        root.addMember(getLabel());
+        root.addMember(getGrid());
+        root.addMember(getButtonBar());
+
+        addItem(root);
+        centerInPage();
+    }
+
+
+    protected void initEdit() {
+        VectorOptions opts = new VectorOptions();
+        opts.setProjection(floodmap.getRiverProjection());
+        opts.setMaxExtent(floodmap.getMaxExtent());
+
+        layer = new Vector("tmp", opts);
+        layer.setIsBaseLayer(false);
+
+        floodmap.getMap().addLayer(layer);
+    }
+
+
+    public Style getStyle() {
+        Style style = new Style();
+        style.setStrokeColor("#000000");
+        style.setStrokeWidth(1);
+        style.setFillColor("#FF0000");
+        style.setFillOpacity(0.5);
+        style.setPointRadius(5);
+        style.setStrokeOpacity(1.0);
+        return style;
+    }
+
+
+    public Style getHighStyle() {
+        Style style = new Style();
+        style.setStrokeColor("#000000");
+        style.setStrokeWidth(1);
+        style.setFillColor("#FFFF22");
+        style.setFillOpacity(0.5);
+        style.setPointRadius(5);
+        style.setStrokeOpacity(1.0);
+        return style;
+    }
+
+
+    protected Label getLabel() {
+        Label label = new Label(MSG.ele_window_label());
+        label.setHeight(25);
+
+        return label;
+    }
+
+
+    protected ListGrid getGrid() {
+        if (grid == null) {
+            grid = new ListGrid();
+            grid.setCanEdit(true);
+            grid.setCanReorderFields(false);
+            grid.setAutoFitMaxWidth(WINDOW_WIDTH);
+            grid.setShowHeaderContextMenu(false);
+            grid.setShowSortArrow(SortArrow.NONE);
+            grid.setSortDirection(SortDirection.DESCENDING);
+            grid.setSelectionType(SelectionStyle.NONE);
+
+            ListGridField x = new ListGridField("x", MSG.ele_window_x_col());
+            x.setCanEdit(false);
+
+            ListGridField y = new ListGridField("y", MSG.ele_window_y_col());
+            y.setCanEdit(false);
+
+            ListGridField z = new ListGridField("z", MSG.ele_window_z_col());
+            z.setCanEdit(true);
+
+            grid.setFields(x, y, z);
+
+            grid.addRowOverHandler(new RowOverHandler() {
+                public void onRowOver(RowOverEvent evt) {
+                    PointRecord   pr = (PointRecord) evt.getRecord();
+                    VectorFeature p  = pr.getPoint();
+
+                    p.setStyle(getHighStyle());
+                    layer.redraw();
+                }
+            });
+
+            grid.addRowOutHandler(new RowOutHandler() {
+                public void onRowOut(RowOutEvent evt) {
+                    PointRecord   pr = (PointRecord) evt.getRecord();
+                    VectorFeature p  = pr.getPoint();
+
+                    p.setStyle(getStyle());
+                    layer.redraw();
+                }
+            });
+
+            grid.addEditCompleteHandler(new EditCompleteHandler() {
+                public void onEditComplete(EditCompleteEvent evt) {
+                    NumberFormat nf = NumberFormat.getDecimalFormat();
+                    String        z = (String) evt.getNewValues().get("z");
+
+                    try {
+                        nf.parse(z);
+                    }
+                    catch (NumberFormatException nfe) {
+                        SC.warn(MSG.ele_window_format_error() + " " + z);
+
+                        PointRecord old = (PointRecord) evt.getOldRecord();
+
+                        ListGridRecord[] records = grid.getRecords();
+                        records[evt.getRowNum()] = old;
+
+                        grid.setRecords(records);
+                    }
+
+                }
+            });
+        }
+
+        return grid;
+    }
+
+
+    protected HLayout getButtonBar() {
+        HLayout bar = new HLayout();
+        bar.setAlign(Alignment.CENTER);
+        bar.setHeight(25);
+        bar.setMembersMargin(15);
+
+        bar.addMember(getOKButton());
+        bar.addMember(getCancelButton());
+
+        return bar;
+    }
+
+
+    protected IButton getOKButton() {
+        IButton btn = new IButton(MSG.ele_window_ok_button());
+
+        btn.addClickHandler(new ClickHandler() {
+            public void onClick(ClickEvent evt) {
+                if (saveElevation()) {
+                    doClose();
+                }
+
+            }
+        });
+
+        return btn;
+    }
+
+
+    protected IButton getCancelButton() {
+        IButton btn = new IButton(MSG.ele_window_cancel_button());
+
+        btn.addClickHandler(new ClickHandler() {
+            public void onClick(ClickEvent evt) {
+                doClose();
+            }
+        });
+
+        return btn;
+    }
+
+
+    public void updateGrid() {
+        Attributes attr = feature.getAttributes();
+        Geometry   geom = feature.getGeometry();
+
+        String barrierType = null;
+
+        if (attr != null) {
+            barrierType = attr.getAttributeAsString("typ");
+        }
+        else {
+            barrierType = DrawControl.BARRIER_DAM_VALUE;
+        }
+
+        GWT.log("Geometry is from type: " + geom.getClassName());
+        GWT.log("Barrier  is from type: " + barrierType);
+
+        double[][] points = getPointsFromGeometry(geom);
+        double[]   ele    = extractElevations(attr);
+
+        if (points == null) {
+            return;
+        }
+
+        NumberFormat nf = NumberFormat.getDecimalFormat();
+
+        ListGrid grid = getGrid();
+
+        int zLen = ele != null ? ele.length : 0;
+
+        for (int i = 0, len = points.length; i < len; i++) {
+            double[]  point = points[i];
+            VectorFeature p = addPoint(point[0], point[1]);
+
+            String value = null;
+
+            if (zLen > i) {
+                value = nf.format(ele[i]);
+            }
+            else if (barrierType.equals(DrawControl.BARRIER_DITCH_VALUE)) {
+                value = "-9999";
+            }
+            else {
+                value = "9999";
+            }
+
+            grid.addData(new PointRecord(p, point[0], point[1], value));
+        }
+
+        grid.redraw();
+    }
+
+
+    public static double[] extractElevations(Attributes attr) {
+        if (attr == null) {
+            return null;
+        }
+
+        String   elevationStr = attr.getAttributeAsString("elevation");
+
+        if (elevationStr == null || elevationStr.length() == 0) {
+            return null;
+        }
+
+        String[] elevations   = elevationStr.split(" ");
+
+        int len = elevations != null ? elevations.length : 0;
+
+        if (len == 0) {
+            return null;
+        }
+
+        double[] res = new double[len];
+
+        for (int i = 0; i < len; i++) {
+            try {
+                res[i] = Double.valueOf(elevations[i]);
+            }
+            catch (NumberFormatException nfe) {
+                // go on
+            }
+        }
+
+        return res;
+    }
+
+
+    public static double[][] getPointsFromGeometry(Geometry geom) {
+        String clazz = geom.getClassName();
+
+        if (clazz != null && clazz.equals(Geometry.LINESTRING_CLASS_NAME)) {
+            return getPointsFromLineString(
+                LineString.narrowToLineString(geom.getJSObject()));
+        }
+        else if (clazz != null && clazz.equals(Geometry.POLYGON_CLASS_NAME)) {
+            return getPointsFromPolygon(
+                Polygon.narrowToPolygon(geom.getJSObject()));
+        }
+        else {
+            SC.warn(MSG.ele_window_geometry_error() + " " + clazz);
+        }
+
+        return null;
+    }
+
+
+    public static double[][] getPointsFromLineString(LineString line) {
+        return line.getCoordinateArray();
+    }
+
+
+    public static double[][] getPointsFromPolygon(Polygon polygon) {
+        LinearRing[] rings = polygon.getComponents();
+
+        return getPointsFromLineString(rings[0]);
+    }
+
+
+    protected VectorFeature addPoint(double x, double y) {
+        VectorFeature point = new VectorFeature(new Point(x, y), getStyle());
+        layer.addFeature(point);
+
+        return point;
+    }
+
+
+    protected boolean saveElevation() {
+        ListGridRecord[] records = grid.getRecords();
+
+        NumberFormat nf = NumberFormat.getDecimalFormat();
+
+        StringBuilder sb = new StringBuilder();
+
+        for (ListGridRecord record: records) {
+            PointRecord pr = (PointRecord) record;
+            String value   = pr.getAttributeAsString("z");
+
+            try {
+                double z = nf.parse(value);
+                sb.append(String.valueOf(z));
+            }
+            catch (NumberFormatException nfe) {
+                SC.warn(MSG.ele_window_save_error());
+                return false;
+            }
+
+            sb.append(" ");
+        }
+
+        Attributes attr = feature.getAttributes();
+        attr.setAttribute("elevation", sb.toString());
+
+        return true;
+    }
+
+
+    protected void doClose() {
+        floodmap.getMap().removeLayer(layer);
+        destroy();
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java	Wed Oct 12 12:42:53 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java	Thu Oct 13 09:08:43 2011 +0000
@@ -20,6 +20,8 @@
 
     public static final String LAYER_BARRIERS = "vector_layer_barriers";
 
+    public static final String MARK_SELECTED = "mark.selected";
+
     protected MapWidget mapWidget;
     protected Map       map;
     protected Vector    barrierLayer;
@@ -57,7 +59,10 @@
             return;
         }
 
-        feature.setStyle(getStyle(type));
+        Style style = getStyle(type);
+        if (style != null) {
+            feature.setStyle(style);
+        }
 
         // necessary, otherwise the setStyle() has no effect
         barrierLayer.redraw();
@@ -75,6 +80,10 @@
     public static Style getStyle(String type) {
         Style style = new Style();
 
+        if (type == null) {
+            return null;
+        }
+
         if (type.equals(DrawControl.BARRIER_PIPE1)
             || type.equals(DrawControl.BARRIER_PIPE1_VALUE)
         ) {
@@ -125,11 +134,16 @@
     }
 
 
+    public Bounds getMaxExtent() {
+        return maxExtent;
+    }
+
+
     public Vector getBarrierLayer() {
         if (barrierLayer == null) {
             VectorOptions opts = new VectorOptions();
             opts.setProjection(getRiverProjection());
-            opts.setMaxExtent(maxExtent);
+            opts.setMaxExtent(getMaxExtent());
 
             barrierLayer = new Vector(LAYER_BARRIERS, opts);
             barrierLayer.setIsBaseLayer(true);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Wed Oct 12 12:42:53 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Thu Oct 13 09:08:43 2011 +0000
@@ -3,6 +3,7 @@
 import com.google.gwt.core.client.GWT;
 
 import com.smartgwt.client.types.SelectionType;
+import com.smartgwt.client.util.SC;
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.ImgButton;
 import com.smartgwt.client.widgets.events.ClickEvent;
@@ -27,8 +28,6 @@
  */
 public class MapToolbar extends HLayout {
 
-    public static final String MARK_TO_DELETE = "mark.delete";
-
     protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
 
     protected FloodMap      floodMap;
@@ -42,6 +41,7 @@
     protected ImgButton panButton;
     protected ImgButton selectButton;
     protected ImgButton removeButton;
+    protected ImgButton elevationButton;
 
     protected DrawControl    drawControl;
     protected MeasureControl measureControl;
@@ -77,6 +77,7 @@
         measureControl  = createMeasureControl();
         position        = createMousePosition(wrapper);
         removeButton    = createRemoveFeatureControl();
+        elevationButton = createElevationControl();
 
         addMember(zoomToMaxButton);
         addMember(zoomBoxButton);
@@ -87,6 +88,7 @@
             addMember(drawControl);
             addMember(selectButton);
             addMember(removeButton);
+            addMember(elevationButton);
         }
 
         addMember(measureControl);
@@ -310,14 +312,14 @@
         opts.onSelect(new SelectFeature.SelectFeatureListener() {
             public void onFeatureSelected(VectorFeature feature) {
                 Attributes attr = feature.getAttributes();
-                attr.setAttribute(MARK_TO_DELETE, 1);
+                attr.setAttribute(FloodMap.MARK_SELECTED, 1);
             }
         });
 
         opts.onUnSelect(new SelectFeature.UnselectFeatureListener() {
             public void onFeatureUnselected(VectorFeature feature) {
                 Attributes attr = feature.getAttributes();
-                attr.setAttribute(MARK_TO_DELETE, 0);
+                attr.setAttribute(FloodMap.MARK_SELECTED, 0);
             }
         });
 
@@ -359,7 +361,7 @@
                     VectorFeature feature = features[i];
 
                     Attributes attr = feature.getAttributes();
-                    int        del  = attr.getAttributeAsInt(MARK_TO_DELETE);
+                    int del = attr.getAttributeAsInt(FloodMap.MARK_SELECTED);
 
                     if (del == 1) {
                         barriers.removeFeature(feature);
@@ -375,6 +377,41 @@
     }
 
 
+    protected ImgButton createElevationControl() {
+        ImgButton btn = createButton(MSG.adjustElevation(), new ClickHandler() {
+            public void onClick(ClickEvent evt) {
+                Vector          barriers = floodMap.getBarrierLayer();
+                VectorFeature[] features = barriers.getFeatures();
+
+                VectorFeature feature = null;
+
+                if (features == null || features.length == 0) {
+                    SC.warn("No Feature selected!");
+                    return;
+                }
+
+                for (VectorFeature f: features) {
+                    Attributes attr = f.getAttributes();
+                    if (attr.getAttributeAsInt(FloodMap.MARK_SELECTED) == 1) {
+                        if (feature == null) {
+                            feature = f;
+                        }
+                        else {
+                            SC.warn("More than 1 Feature selected!");
+                        }
+                    }
+                }
+
+                new ElevationWindow(floodMap, feature).show();
+            }
+        });
+
+        btn.setTooltip(MSG.adjustElevationTooltip());
+
+        return btn;
+    }
+
+
     protected Canvas createMousePosition(Canvas mapWrapper) {
         return new MapPositionPanel(floodMap.getMapWidget(), mapWrapper);
     }
Binary file flys-client/src/main/webapp/images/adjustElevation.png has changed

http://dive4elements.wald.intevation.org