[Dive4elements-commits] [PATCH] Resize MapWidget in MapPanel manually using a ResizedHandler

Wald Commits scm-commit at wald.intevation.org
Mon Nov 12 10:53:34 CET 2012


# HG changeset patch
# User Christian Lins <christian.lins at intevation.de>
# Date 1352714012 -3600
# Node ID 6fb4e29a2a9ba10be9434c8b7b3233c46433346c
# Parent  bd78d2b0e309cae4b8edff964f1239c3636ecca2
Resize MapWidget in MapPanel manually using a ResizedHandler.

This should fix parts of Flys/#802.

diff -r bd78d2b0e309 -r 6fb4e29a2a9b flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java
--- 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());
     }
 
 
diff -r bd78d2b0e309 -r 6fb4e29a2a9b flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java
--- 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);
     }


More information about the Dive4elements-commits mailing list