Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
1316:956605001cfb | 1317:45b9b1fc26e2 |
---|---|
20 | 20 |
21 public static final String LAYER_BARRIERS = "vector_layer_barriers"; | 21 public static final String LAYER_BARRIERS = "vector_layer_barriers"; |
22 | 22 |
23 public static final String MARK_SELECTED = "mark.selected"; | 23 public static final String MARK_SELECTED = "mark.selected"; |
24 | 24 |
25 public static final int SELECTED_STROKE_WIDTH = 2; | |
26 | |
25 protected MapWidget mapWidget; | 27 protected MapWidget mapWidget; |
26 protected Map map; | 28 protected Map map; |
27 protected Vector barrierLayer; | 29 protected Vector barrierLayer; |
28 protected String srid; | 30 protected String srid; |
29 protected Bounds maxExtent; | 31 protected Bounds maxExtent; |
156 return barrierLayer; | 158 return barrierLayer; |
157 } | 159 } |
158 | 160 |
159 | 161 |
160 public String getFeaturesAsGeoJSON() { | 162 public String getFeaturesAsGeoJSON() { |
163 // disable features before exporting to GeoJSON | |
164 disableFeatures(); | |
165 | |
161 VectorFeature[] features = barrierLayer.getFeatures(); | 166 VectorFeature[] features = barrierLayer.getFeatures(); |
162 | 167 |
163 if (features == null || features.length == 0) { | 168 if (features == null || features.length == 0) { |
164 return null; | 169 return null; |
165 } | 170 } |
183 public void showBarrierLayer () { | 188 public void showBarrierLayer () { |
184 if (barrierLayer != null) { | 189 if (barrierLayer != null) { |
185 barrierLayer.setIsVisible(true); | 190 barrierLayer.setIsVisible(true); |
186 } | 191 } |
187 } | 192 } |
193 | |
194 | |
195 public void selectFeature(VectorFeature feature) { | |
196 if (feature != null) { | |
197 selectFeatures(new VectorFeature[] { feature } ); | |
198 } | |
199 } | |
200 | |
201 | |
202 public void selectFeatures(VectorFeature[] features) { | |
203 if (features == null || features.length == 0) { | |
204 return; | |
205 } | |
206 | |
207 for (VectorFeature feature: features) { | |
208 Attributes attr = feature.getAttributes(); | |
209 | |
210 if (attr.getAttributeAsInt(MARK_SELECTED) == 1) { | |
211 continue; | |
212 } | |
213 | |
214 attr.setAttribute(MARK_SELECTED, 1); | |
215 | |
216 Style style = feature.getStyle(); | |
217 double strokeWidth = style.getStrokeWidth(); | |
218 | |
219 style.setStrokeWidth(strokeWidth+SELECTED_STROKE_WIDTH); | |
220 } | |
221 | |
222 getBarrierLayer().redraw(); | |
223 } | |
224 | |
225 | |
226 public void disableFeatures() { | |
227 Vector barriers = getBarrierLayer(); | |
228 VectorFeature[] features = barriers.getFeatures(); | |
229 | |
230 if (features == null || features.length == 0) { | |
231 return; | |
232 } | |
233 | |
234 disableFeatures(features); | |
235 } | |
236 | |
237 | |
238 public void disableFeature(VectorFeature feature) { | |
239 if (feature != null) { | |
240 disableFeatures(new VectorFeature[] { feature }); | |
241 } | |
242 } | |
243 | |
244 | |
245 public void disableFeatures(VectorFeature[] features) { | |
246 if (features == null || features.length == 0) { | |
247 return; | |
248 } | |
249 | |
250 for (VectorFeature feature: features) { | |
251 Attributes attr = feature.getAttributes(); | |
252 | |
253 if (attr.getAttributeAsInt(MARK_SELECTED) == 0) { | |
254 continue; | |
255 } | |
256 | |
257 attr.setAttribute(FloodMap.MARK_SELECTED, 0); | |
258 | |
259 Style style = feature.getStyle(); | |
260 double strokeWidth = style.getStrokeWidth(); | |
261 | |
262 style.setStrokeWidth(strokeWidth-SELECTED_STROKE_WIDTH); | |
263 } | |
264 | |
265 getBarrierLayer().redraw(); | |
266 } | |
188 } | 267 } |
189 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 268 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |