[Dive4elements-commits] [PATCH] Fix for #802: digitized pipes and dikes should be visible now

Wald Commits scm-commit at wald.intevation.org
Tue Apr 9 12:45:02 CEST 2013


# HG changeset patch
# User Christian Lins <christian.lins at intevation.de>
# Date 1365504297 -7200
# Node ID 80e8ef91223c2ab4af1c673396dc73f81afb6021
# Parent  62513c9183ba2f595d55e7b566431d17eb6140b3
Fix for #802: digitized pipes and dikes should be visible now

diff -r 62513c9183ba -r 80e8ef91223c flys-client/src/main/java/de/intevation/flys/client/client/ui/map/DrawControl.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/DrawControl.java	Tue Apr 09 12:00:52 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/DrawControl.java	Tue Apr 09 12:44:57 2013 +0200
@@ -1,7 +1,6 @@
 package de.intevation.flys.client.client.ui.map;
 
 import com.google.gwt.core.client.GWT;
-
 import com.smartgwt.client.types.SelectionType;
 import com.smartgwt.client.widgets.ImgButton;
 import com.smartgwt.client.widgets.events.ClickEvent;
@@ -30,7 +29,9 @@
 import org.gwtopenmaps.openlayers.client.layer.Vector;
 import org.gwtopenmaps.openlayers.client.util.Attributes;
 
-
+/**
+ * Widget that handles the drawing of pipes and dikes in the DigitizePanel (MapPanel).
+ */
 public class DrawControl extends HLayout implements VectorFeatureAddedListener {
 
     public static final String BARRIER_PIPE1    = "pipe1";
@@ -39,6 +40,7 @@
     public static final String BARRIER_DAM      = "dam";
     public static final String BARRIER_RINGDIKE = "ring_dike";
 
+    // FIXME: i18n
     public static final String BARRIER_PIPE1_VALUE    = "Rohr 1";
     public static final String BARRIER_PIPE2_VALUE    = "Rohr 2";
     public static final String BARRIER_DITCH_VALUE    = "Graben";
@@ -76,7 +78,7 @@
 
         button = new ImgButton();
 
-        String baseUrl = GWT.getHostPageBaseURL();
+        final String baseUrl = GWT.getHostPageBaseURL();
         button.setSrc(baseUrl + MSG.digitize());
         button.setActionType(SelectionType.CHECKBOX);
         button.setSize(20);
@@ -101,21 +103,21 @@
         form.setTitlePrefix("");
         form.setTitleSuffix("");
 
-        LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
+        final LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
         map.put(BARRIER_PIPE1, MSG.getString(BARRIER_PIPE1));
         map.put(BARRIER_PIPE2, MSG.getString(BARRIER_PIPE2));
         map.put(BARRIER_DITCH, MSG.getString(BARRIER_DITCH));
         map.put(BARRIER_DAM, MSG.getString(BARRIER_DAM));
         map.put(BARRIER_RINGDIKE, MSG.getString(BARRIER_RINGDIKE));
 
-        LinkedHashMap<String, String> ics = new LinkedHashMap<String, String>();
+        final LinkedHashMap<String, String> ics = new LinkedHashMap<String, String>();
         ics.put(BARRIER_PIPE1, BARRIER_PIPE1);
         ics.put(BARRIER_PIPE2, BARRIER_PIPE2);
         ics.put(BARRIER_DITCH, BARRIER_DITCH);
         ics.put(BARRIER_DAM, BARRIER_DAM);
         ics.put(BARRIER_RINGDIKE, BARRIER_RINGDIKE);
 
-        SelectItem box = new SelectItem(FIELD_BARRIER_TYPE);
+        final SelectItem box = new SelectItem(FIELD_BARRIER_TYPE);
         box.setTitle("");
         box.setWidth(100);
         box.setValueMap(map);
@@ -152,13 +154,13 @@
 
 
     protected void setCurrentType(VectorFeature feature) {
-        Attributes attrs = feature.getAttributes();
+        final Attributes attrs = feature.getAttributes();
         String     type  = attrs.getAttributeAsString("typ");
 
         if (type == null || type.length() == 0) {
             type = getSelectedType();
 
-            Style style = FloodMap.getStyle(type);
+            final Style style = FloodMap.getStyle(type);
             if (style != null) {
                 feature.setStyle(style);
             }
@@ -195,7 +197,7 @@
     protected void setSelectedControl() {
         removeControl();
 
-        String type = getSelectedType();
+        final String type = getSelectedType();
 
         if (type == null || type.length() == 0) {
             return;
@@ -210,6 +212,9 @@
 
         map.addControl(control);
         control.activate();
+
+        // Make sure the barrier layer is on top; sometime it looses it z-index...
+        layer.setZIndex(1000);
     }
 
 
@@ -229,7 +234,7 @@
 
 
     public void activate(boolean activate) {
-        FormItem item = form.getField(FIELD_BARRIER_TYPE);
+        final FormItem item = form.getField(FIELD_BARRIER_TYPE);
 
         if (activate) {
             button.select();
diff -r 62513c9183ba -r 80e8ef91223c flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java	Tue Apr 09 12:00:52 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java	Tue Apr 09 12:44:57 2013 +0200
@@ -44,7 +44,7 @@
 
 
     public void recreateWidget(int width, int height) {
-        MapOptions opts = new MapOptions();
+        final MapOptions opts = new MapOptions();
         opts.setControls(new JObjectArray(new JSObject[] {}));
         opts.setNumZoomLevels(16);
         opts.setProjection(getRiverProjection());
@@ -63,22 +63,22 @@
 
     @Override
     public void onFeatureAdded(FeatureAddedEvent evt) {
-        VectorFeature feature = evt.getVectorFeature();
+        final VectorFeature feature = evt.getVectorFeature();
 
-        Attributes attrs = feature.getAttributes();
-        String     type  = attrs.getAttributeAsString("typ");
+        final Attributes attrs = feature.getAttributes();
+        final String     type  = attrs.getAttributeAsString("typ");
 
         if (type == null || type.length() == 0) {
             return;
         }
 
-        Style style = getStyle(type);
+        final Style style = getStyle(type);
         if (style != null) {
             feature.setStyle(style);
         }
 
         // necessary, otherwise the setStyle() has no effect
-        barrierLayer.redraw();
+        getBarrierLayer().redraw();
     }
 
 
@@ -91,7 +91,7 @@
      * @return an OpenLayers.Style object.
      */
     public static Style getStyle(String type) {
-        Style style = new Style();
+        final Style style = new Style();
 
         if (type == null) {
             return null;
@@ -154,7 +154,7 @@
 
     public Vector getBarrierLayer() {
         if (barrierLayer == null) {
-            VectorOptions opts = new VectorOptions();
+            final VectorOptions opts = new VectorOptions();
             opts.setProjection(getRiverProjection());
             opts.setMaxExtent(getMaxExtent());
 
@@ -175,7 +175,7 @@
         // disable features before exporting to GeoJSON
         disableFeatures();
 
-        VectorFeature[] features = barrierLayer.getFeatures();
+        final VectorFeature[] features = barrierLayer.getFeatures();
 
         if (features == null || features.length == 0) {
             return null;
@@ -188,8 +188,8 @@
     public void setSize(String width, String height) {
         mapWidget.setWidth(width);
         mapWidget.setHeight(height);
-        int currentZoom = map.getZoom();
-        LonLat currentCenter = map.getCenter();
+        final int currentZoom = map.getZoom();
+        final LonLat currentCenter = map.getCenter();
         map.updateSize();
         map.zoomTo(currentZoom);
         map.setCenter(currentCenter);
@@ -200,8 +200,8 @@
         if (layer != null) {
             map.addLayer(layer);
 
-            int index    = map.getLayerIndex(layer);
-            int newIndex = index * (-1) + 1;
+            final int index    = map.getLayerIndex(layer);
+            final int newIndex = index * (-1) + 1;
 
             map.raiseLayer(layer, newIndex);
 
@@ -211,13 +211,13 @@
 
 
     public void hideBarrierLayer () {
-        if (barrierLayer != null) {
+        if (getBarrierLayer() != null) {
             barrierLayer.setIsVisible(false);
         }
     }
 
     public void showBarrierLayer () {
-        if (barrierLayer != null) {
+        if (getBarrierLayer() != null) {
             barrierLayer.setIsVisible(true);
         }
     }
@@ -235,8 +235,8 @@
             return;
         }
 
-        for (VectorFeature feature: features) {
-            Attributes attr = feature.getAttributes();
+        for (final VectorFeature feature: features) {
+            final Attributes attr = feature.getAttributes();
 
             if (attr.getAttributeAsInt(MARK_SELECTED) == 1) {
                 continue;
@@ -244,8 +244,8 @@
 
             attr.setAttribute(MARK_SELECTED, 1);
 
-            Style style        = feature.getStyle();
-            double strokeWidth = style.getStrokeWidth();
+            final Style style        = feature.getStyle();
+            final double strokeWidth = style.getStrokeWidth();
 
             style.setStrokeWidth(strokeWidth+SELECTED_STROKE_WIDTH);
         }
@@ -255,8 +255,8 @@
 
 
     public void disableFeatures() {
-        Vector          barriers = getBarrierLayer();
-        VectorFeature[] features = barriers.getFeatures();
+        final Vector          barriers = getBarrierLayer();
+        final VectorFeature[] features = barriers.getFeatures();
 
         if (features == null || features.length == 0) {
             return;
@@ -278,8 +278,8 @@
             return;
         }
 
-        for (VectorFeature feature: features) {
-            Attributes attr = feature.getAttributes();
+        for (final VectorFeature feature: features) {
+            final Attributes attr = feature.getAttributes();
 
             if (attr.getAttributeAsInt(MARK_SELECTED) == 0) {
                 continue;
@@ -287,8 +287,8 @@
 
             attr.setAttribute(FloodMap.MARK_SELECTED, 0);
 
-            Style style        = feature.getStyle();
-            double strokeWidth = style.getStrokeWidth();
+            final Style style        = feature.getStyle();
+            final double strokeWidth = style.getStrokeWidth();
 
             style.setStrokeWidth(strokeWidth-SELECTED_STROKE_WIDTH);
         }
@@ -298,17 +298,19 @@
 
 
     public void update() {
-        Layer[] layers = map.getLayers();
+        final Layer[] layers = map.getLayers();
 
-        for (Layer l: layers) {
+        for (final Layer l: layers) {
             l.redraw();
         }
+
+        getBarrierLayer(); // Raises Z-Index to 1000 again
     }
 
 
     public void activateScaleLine(boolean activate) {
         if (activate) {
-            ScaleLineOptions slOpts = new ScaleLineOptions();
+            final ScaleLineOptions slOpts = new ScaleLineOptions();
             slOpts.setBottomInUnits("m");
             slOpts.setBottomOutUnits("km");
             slOpts.setTopInUnits("");


More information about the Dive4elements-commits mailing list