annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java @ 4570:8ca06d3040d0

flys-client: Map.updateSize() is now called on every windows movement which fixes the cursor offset problem (flys/#422).
author Christian Lins <christian.lins@intevation.de>
date Tue, 20 Nov 2012 14:30:33 +0100
parents fac54b8470d4
children 95e23bcf6a50
rev   line source
832
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.client.ui.map;
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
4475
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
3 import com.google.gwt.core.client.GWT;
4570
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
4 import com.smartgwt.client.widgets.Canvas;
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
5 import com.smartgwt.client.widgets.WidgetCanvas;
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
6 import com.smartgwt.client.widgets.events.ParentMovedEvent;
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
7 import com.smartgwt.client.widgets.events.ParentMovedHandler;
4475
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
8 import com.smartgwt.client.widgets.events.ResizedEvent;
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
9 import com.smartgwt.client.widgets.events.ResizedHandler;
832
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import com.smartgwt.client.widgets.layout.VLayout;
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import de.intevation.flys.client.shared.model.BBox;
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import de.intevation.flys.client.shared.model.MapInfo;
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
3347
6d749af6a9c2 Issue #726 work.
Christian Lins <christian.lins@intevation.de>
parents: 1389
diff changeset
15 import org.gwtopenmaps.openlayers.client.Bounds;
4475
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
16 import org.gwtopenmaps.openlayers.client.MapWidget;
3347
6d749af6a9c2 Issue #726 work.
Christian Lins <christian.lins@intevation.de>
parents: 1389
diff changeset
17
4475
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
18 /**
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
19 * Panel that contains a MapWidget and a MapToolbar.
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
20 * This panel is used by the flood map calculation input helper.
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
21 */
832
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 public class MapPanel extends VLayout {
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 protected MapToolbar toolbar;
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
4475
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
26 protected FloodMap floodMap;
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
27 protected MapWidget floodMapWidget;
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
28 protected boolean digitizeEnabled;
832
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 public MapPanel(MapInfo mapInfo, boolean digitizeEnabled) {
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 BBox bbox = mapInfo.getBBox();
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 this.digitizeEnabled = digitizeEnabled;
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 this.floodMap = new FloodMap(
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 String.valueOf(mapInfo.getSrid()),
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 new Bounds(
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 bbox.getLowerX(),
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 bbox.getLowerY(),
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 bbox.getUpperX(),
4402
c84630d544a1 Get rid of HorizontalLayout in MapOutputTab and use manual resizing.
Christian Lins <christian.lins@intevation.de>
parents: 4064
diff changeset
40 bbox.getUpperY()),
4476
099d136b215b Try to fix resize problems with MapWidget in DigitizePanel (#802).
Christian Lins <christian.lins@intevation.de>
parents: 4475
diff changeset
41 640, 480);
832
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 initLayout();
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 }
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 private void initLayout() {
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 setWidth100();
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 setHeight100();
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
4475
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
51 floodMapWidget = floodMap.getMapWidget();
1386
9aa1a453eed5 Issue 294.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 832
diff changeset
52 toolbar = new MapToolbar(floodMap, digitizeEnabled);
832
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 addMember(toolbar);
4475
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
55 addMember(floodMapWidget);
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
56
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
57 addResizedHandler(new ResizedHandler() {
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
58 @Override
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
59 public void onResized(ResizedEvent event) {
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
60 doLayout();
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
61 }
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
62 });
4570
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
63
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
64 addParentMovedHandler(new ParentMovedHandler() {
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
65 @Override
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
66 public void onParentMoved(ParentMovedEvent event) {
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
67 floodMapWidget.getMap().updateSize();
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
68 }
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
69 });
4475
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
70 }
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
71
4570
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
72 /**
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
73 * Due to the fact that SmartGWT Layout misses a removeMember(Widget)
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
74 * method we use this method to remove all WidgetCanvas members.
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
75 * WidgetCanvas is the wrapper class used by Layout to handle Widget
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
76 * objects.
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
77 */
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
78 protected void removeWidgetCanvasMember() {
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
79 Canvas[] allCanvas = getMembers();
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
80 for (Canvas canvas : allCanvas) {
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
81 if (canvas instanceof WidgetCanvas) {
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
82 removeMember(canvas);
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
83 }
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
84 }
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
85 }
4475
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
86
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
87 protected void doLayout() {
4541
7b454c6e2bcb MapPanel position and size now properly aligned (#568).
Christian Lins <christian.lins@intevation.de>
parents: 4476
diff changeset
88 int width = getWidth();
7b454c6e2bcb MapPanel position and size now properly aligned (#568).
Christian Lins <christian.lins@intevation.de>
parents: 4476
diff changeset
89 int height = getHeight();
7b454c6e2bcb MapPanel position and size now properly aligned (#568).
Christian Lins <christian.lins@intevation.de>
parents: 4476
diff changeset
90 GWT.log("MapPanel.size: " + width + "x" + height);
4475
6fb4e29a2a9b Resize MapWidget in MapPanel manually using a ResizedHandler.
Christian Lins <christian.lins@intevation.de>
parents: 4402
diff changeset
91
4541
7b454c6e2bcb MapPanel position and size now properly aligned (#568).
Christian Lins <christian.lins@intevation.de>
parents: 4476
diff changeset
92 width -= 2; // minus black borders
7b454c6e2bcb MapPanel position and size now properly aligned (#568).
Christian Lins <christian.lins@intevation.de>
parents: 4476
diff changeset
93 height -= toolbar.getHeight() + 4;
7b454c6e2bcb MapPanel position and size now properly aligned (#568).
Christian Lins <christian.lins@intevation.de>
parents: 4476
diff changeset
94
4570
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
95 // Recreate Map widget
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
96 /*removeWidgetCanvasMember();
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
97 floodMap.recreateWidget(width, height);
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
98 floodMapWidget = floodMap.getMapWidget();
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
99 addMember(floodMapWidget);
8ca06d3040d0 flys-client: Map.updateSize() is now called on every windows movement
Christian Lins <christian.lins@intevation.de>
parents: 4553
diff changeset
100 */
4553
fac54b8470d4 Map view in DigitizePanel now shows OSM background, river axis and
Christian Lins <christian.lins@intevation.de>
parents: 4541
diff changeset
101 floodMapWidget.setSize(Integer.toString(width), Integer.toString(height));
fac54b8470d4 Map view in DigitizePanel now shows OSM background, river axis and
Christian Lins <christian.lins@intevation.de>
parents: 4541
diff changeset
102 floodMapWidget.getMap().updateSize();
832
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 }
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 public FloodMap getFloodMap() {
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 return floodMap;
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 }
1389
d29a9fa10313 Issue 265.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1386
diff changeset
109
d29a9fa10313 Issue 265.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1386
diff changeset
110 public MapToolbar getMapToolbar () {
d29a9fa10313 Issue 265.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1386
diff changeset
111 return toolbar;
d29a9fa10313 Issue 265.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1386
diff changeset
112 }
832
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 }
303a923d232b Added a panel that wraps all the stuff to combine SmartGWT and GWT-OpenLayers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org