Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java @ 1382:78542ff1f562
Update map and theme panel when new layers are added via datacage or removed by context menu.
flys-client/trunk@3155 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 03 Nov 2011 14:51:16 +0000 |
parents | b0fe35d4ce6b |
children | 9aa1a453eed5 |
comparison
equal
deleted
inserted
replaced
1381:4459901e4ec0 | 1382:78542ff1f562 |
---|---|
100 } | 100 } |
101 | 101 |
102 setFloodmap(new FloodMap(c.getSrid(), max)); | 102 setFloodmap(new FloodMap(c.getSrid(), max)); |
103 | 103 |
104 initLayout(); | 104 initLayout(); |
105 initLayers(); | |
106 initBarriers(); | 105 initBarriers(); |
107 | 106 |
108 GWT.log("MAX EXTENT: " + max); | 107 GWT.log("MAX EXTENT: " + max); |
109 GWT.log("ZOOM TO: " + initial); | 108 GWT.log("ZOOM TO: " + initial); |
110 getMap().zoomToExtent(initial); | 109 getMap().zoomToExtent(initial); |
160 floodMap.setSize(w, h); | 159 floodMap.setSize(w, h); |
161 } | 160 } |
162 }); | 161 }); |
163 | 162 |
164 setPane(rootLayout); | 163 setPane(rootLayout); |
165 } | |
166 | |
167 | |
168 protected void initLayers() { | |
169 ThemeList themeList = themePanel.getThemeList(); | |
170 | |
171 int num = themeList.getThemeCount(); | |
172 Map map = floodMap.getMap(); | |
173 | |
174 for (int i = num; i >= 0; i--) { | |
175 Theme theme = themeList.getThemeAt(i); | |
176 Layer layer = createWMSLayer(theme); | |
177 | |
178 if (layer == null) { | |
179 continue; | |
180 } | |
181 | |
182 map.addLayer(layer); | |
183 } | |
184 } | 164 } |
185 | 165 |
186 | 166 |
187 protected void initBarriers() { | 167 protected void initBarriers() { |
188 Vector vector = floodMap.getBarrierLayer(); | 168 Vector vector = floodMap.getBarrierLayer(); |
224 | 204 |
225 vector.addFeatures(features); | 205 vector.addFeatures(features); |
226 } | 206 } |
227 | 207 |
228 | 208 |
209 public void addLayer(Layer layer) { | |
210 Map map = getMap(); | |
211 | |
212 if (map != null) { | |
213 GWT.log("Add new layer '" + layer.getName() + "' to map."); | |
214 map.addLayer(layer); | |
215 } | |
216 } | |
217 | |
218 | |
219 public void removeLayer(String name) { | |
220 Map map = getMap(); | |
221 | |
222 Layer[] layers = map.getLayers(); | |
223 | |
224 for (Layer layer: layers) { | |
225 if (name.equals(layer.getName())) { | |
226 map.removeLayer(layer); | |
227 } | |
228 } | |
229 } | |
230 | |
231 | |
229 @Override | 232 @Override |
230 public void onRedrawRequest(RedrawRequestEvent event) { | 233 public void onRedrawRequest(RedrawRequestEvent event) { |
231 // TODO FILL ME | 234 mapService.doOut(collection, new AsyncCallback<MapConfig>() { |
232 GWT.log("TODO: Request redraw."); | 235 public void onFailure(Throwable caught) { |
236 GWT.log("MAP ERROR: " + caught.getMessage()); | |
237 } | |
238 | |
239 public void onSuccess(MapConfig c) { | |
240 themePanel.updateCollection(); | |
241 } | |
242 }); | |
233 } | 243 } |
234 | 244 |
235 | 245 |
236 protected void setFloodmap(FloodMap floodMap) { | 246 protected void setFloodmap(FloodMap floodMap) { |
237 this.floodMap = floodMap; | 247 this.floodMap = floodMap; |
238 } | 248 } |
239 | 249 |
240 | 250 |
241 protected Map getMap() { | 251 protected Map getMap() { |
242 return floodMap.getMap(); | 252 return floodMap.getMap(); |
253 } | |
254 | |
255 | |
256 protected ThemePanel getThemePanel() { | |
257 return themePanel; | |
243 } | 258 } |
244 | 259 |
245 | 260 |
246 protected String getGeoJSONFromDynamic(ArtifactDescription desc) { | 261 protected String getGeoJSONFromDynamic(ArtifactDescription desc) { |
247 DataList list = desc.getCurrentData(); | 262 DataList list = desc.getCurrentData(); |
325 | 340 |
326 return null; | 341 return null; |
327 } | 342 } |
328 | 343 |
329 | 344 |
330 protected Layer createWMSLayer(Theme theme) { | 345 public Layer createWMSLayer(Theme theme) { |
331 if (theme == null) { | 346 if (theme == null) { |
332 return null; | 347 return null; |
333 } | 348 } |
334 | 349 |
335 AttributedTheme at = (AttributedTheme) theme; | 350 AttributedTheme at = (AttributedTheme) theme; |
377 c.setBorder("1px solid black"); | 392 c.setBorder("1px solid black"); |
378 | 393 |
379 themePanel = new MapThemePanel( | 394 themePanel = new MapThemePanel( |
380 collection, | 395 collection, |
381 mode, | 396 mode, |
397 this, | |
382 new MapThemePanel.ActivateCallback() { | 398 new MapThemePanel.ActivateCallback() { |
383 public void activate(Theme theme, boolean active) { | 399 public void activate(Theme theme, boolean active) { |
384 activateTheme(theme, active); | 400 activateTheme(theme, active); |
385 } | 401 } |
386 }, | 402 }, |
423 | 439 |
424 protected void activateTheme(Theme theme, boolean active) { | 440 protected void activateTheme(Theme theme, boolean active) { |
425 String name = theme.getDescription(); | 441 String name = theme.getDescription(); |
426 Layer layer = floodMap.getMap().getLayerByName(name); | 442 Layer layer = floodMap.getMap().getLayerByName(name); |
427 | 443 |
444 GWT.log("Set visibility of '" + name + "': " + active); | |
445 | |
428 if (layer != null) { | 446 if (layer != null) { |
429 layer.setIsVisible(active); | 447 layer.setIsVisible(active); |
430 } | 448 } |
431 } | 449 } |
432 | 450 |