changeset 4475:6fb4e29a2a9b

Resize MapWidget in MapPanel manually using a ResizedHandler. This should fix parts of Flys/#802.
author Christian Lins <christian.lins@intevation.de>
date Mon, 12 Nov 2012 10:53:32 +0100
parents bd78d2b0e309
children 099d136b215b
files flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java
diffstat 2 files changed, 29 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java	Sun Nov 11 14:44:12 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java	Mon Nov 12 10:53:32 2012 +0100
@@ -1,28 +1,30 @@
 package de.intevation.flys.client.client.ui.map;
 
-import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.core.client.GWT;
 
-import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.ResizedEvent;
+import com.smartgwt.client.widgets.events.ResizedHandler;
 import com.smartgwt.client.widgets.layout.VLayout;
 
 import de.intevation.flys.client.shared.model.BBox;
 import de.intevation.flys.client.shared.model.MapInfo;
 
 import org.gwtopenmaps.openlayers.client.Bounds;
+import org.gwtopenmaps.openlayers.client.MapWidget;
 
-
+/**
+ * Panel that contains a MapWidget and a MapToolbar.
+ * This panel is used by the flood map calculation input helper.
+ */
 public class MapPanel extends VLayout {
 
     protected MapToolbar      toolbar;
-    protected HorizontalPanel mapArea;
 
-    protected FloodMap floodMap;
-    protected boolean  digitizeEnabled;
-
+    protected FloodMap  floodMap;
+    protected MapWidget floodMapWidget;
+    protected boolean   digitizeEnabled;
 
     public MapPanel(MapInfo mapInfo, boolean digitizeEnabled) {
-        super();
-
         BBox bbox = mapInfo.getBBox();
 
         this.digitizeEnabled = digitizeEnabled;
@@ -43,21 +45,27 @@
         setWidth100();
         setHeight100();
 
-        mapArea = new HorizontalPanel();
-        mapArea.setWidth("99%");
-        mapArea.setHeight("99%");
-        mapArea.add(floodMap.getMapWidget());
-
-        Canvas wrapper = new Canvas();
-        wrapper.setWidth100();
-        wrapper.setHeight100();
-        wrapper.addChild(mapArea);
-        wrapper.setRedrawOnResize(true);
-
+        floodMapWidget = floodMap.getMapWidget();
         toolbar = new MapToolbar(floodMap, digitizeEnabled);
 
         addMember(toolbar);
-        addMember(wrapper);
+        addMember(floodMapWidget);
+
+        addResizedHandler(new ResizedHandler() {
+
+            @Override
+            public void onResized(ResizedEvent event) {
+                doLayout();
+            }
+        });
+    }
+
+
+    protected void doLayout() {
+        GWT.log("MapPanel.size: " + getWidth() + "x" + getHeight());
+
+        this.floodMapWidget.setWidth(getWidthAsString());
+        this.floodMapWidget.setHeight(getHeightAsString());
     }
 
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Sun Nov 11 14:44:12 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Mon Nov 12 10:53:32 2012 +0100
@@ -79,11 +79,6 @@
     protected Canvas position;
 
 
-    public MapToolbar(MapOutputTab mapTab, FloodMap floodMap) {
-        this(mapTab, floodMap, true);
-    }
-
-
     public MapToolbar(FloodMap floodMap, boolean digitize) {
         this(null, floodMap, digitize);
     }

http://dive4elements.wald.intevation.org