Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java @ 1317:45b9b1fc26e2
Improved error handling while using the elevation control - Make selected features in the map visible.
flys-client/trunk@2956 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 13 Oct 2011 10:22:39 +0000 |
parents | cf0f906921de |
children | 9aa1a453eed5 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java Thu Oct 13 09:46:03 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java Thu Oct 13 10:22:39 2011 +0000 @@ -22,6 +22,8 @@ public static final String MARK_SELECTED = "mark.selected"; + public static final int SELECTED_STROKE_WIDTH = 2; + protected MapWidget mapWidget; protected Map map; protected Vector barrierLayer; @@ -158,6 +160,9 @@ public String getFeaturesAsGeoJSON() { + // disable features before exporting to GeoJSON + disableFeatures(); + VectorFeature[] features = barrierLayer.getFeatures(); if (features == null || features.length == 0) { @@ -185,5 +190,79 @@ barrierLayer.setIsVisible(true); } } + + + public void selectFeature(VectorFeature feature) { + if (feature != null) { + selectFeatures(new VectorFeature[] { feature } ); + } + } + + + public void selectFeatures(VectorFeature[] features) { + if (features == null || features.length == 0) { + return; + } + + for (VectorFeature feature: features) { + Attributes attr = feature.getAttributes(); + + if (attr.getAttributeAsInt(MARK_SELECTED) == 1) { + continue; + } + + attr.setAttribute(MARK_SELECTED, 1); + + Style style = feature.getStyle(); + double strokeWidth = style.getStrokeWidth(); + + style.setStrokeWidth(strokeWidth+SELECTED_STROKE_WIDTH); + } + + getBarrierLayer().redraw(); + } + + + public void disableFeatures() { + Vector barriers = getBarrierLayer(); + VectorFeature[] features = barriers.getFeatures(); + + if (features == null || features.length == 0) { + return; + } + + disableFeatures(features); + } + + + public void disableFeature(VectorFeature feature) { + if (feature != null) { + disableFeatures(new VectorFeature[] { feature }); + } + } + + + public void disableFeatures(VectorFeature[] features) { + if (features == null || features.length == 0) { + return; + } + + for (VectorFeature feature: features) { + Attributes attr = feature.getAttributes(); + + if (attr.getAttributeAsInt(MARK_SELECTED) == 0) { + continue; + } + + attr.setAttribute(FloodMap.MARK_SELECTED, 0); + + Style style = feature.getStyle(); + double strokeWidth = style.getStrokeWidth(); + + style.setStrokeWidth(strokeWidth-SELECTED_STROKE_WIDTH); + } + + getBarrierLayer().redraw(); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :