diff flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java @ 5609:80e8ef91223c

Fix for #802: digitized pipes and dikes should be visible now
author Christian Lins <christian.lins@intevation.de>
date Tue, 09 Apr 2013 12:44:57 +0200
parents 4bf3b89b38d5
children 4f935415bb20
line wrap: on
line diff
--- 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("");

http://dive4elements.wald.intevation.org