changeset 1386:9aa1a453eed5

Issue 294. Redesigned UESK tab layout, removed superfluous map wrapper canvas. flys-client/trunk@3185 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 08 Nov 2011 13:07:56 +0000
parents 31e69ee9dd36
children 3cbc7fbfff0e
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java 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/MapPositionPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java
diffstat 6 files changed, 61 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Nov 04 11:53:13 2011 +0000
+++ b/flys-client/ChangeLog	Tue Nov 08 13:07:56 2011 +0000
@@ -1,3 +1,19 @@
+2011-11-08  Raimund Renkert <raimund.renkert@intevation.de>
+
+	Issue 294.
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java,
+	  src/main/java/de/intevation/flys/client/client/ui/map/MapPositionPanel.java,
+	  src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java:
+	  Removed the wrapper canvas. The only function of this wrapper was to
+	  calculate the mouse position. This is now done by the map itself.
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java:
+	  Update map size and center.
+	
+	* src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java:
+	  Redesigned the layout and resize handler. Removed wrapper canvas.
+
 2011-11-04  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/FLYSConstants.properties:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java	Fri Nov 04 11:53:13 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java	Tue Nov 08 13:07:56 2011 +0000
@@ -1,5 +1,7 @@
 package de.intevation.flys.client.client.ui.map;
 
+import com.google.gwt.core.client.GWT;
+
 import org.gwtopenmaps.openlayers.client.Bounds;
 import org.gwtopenmaps.openlayers.client.Map;
 import org.gwtopenmaps.openlayers.client.MapOptions;
@@ -14,6 +16,7 @@
 import org.gwtopenmaps.openlayers.client.util.Attributes;
 import org.gwtopenmaps.openlayers.client.util.JObjectArray;
 import org.gwtopenmaps.openlayers.client.util.JSObject;
+import org.gwtopenmaps.openlayers.client.LonLat;
 
 
 public class FloodMap implements VectorFeatureAddedListener {
@@ -176,6 +179,11 @@
     public void setSize(String width, String height) {
         mapWidget.setWidth(width);
         mapWidget.setHeight(height);
+        int currentZoom = map.getZoom();
+        LonLat currentCenter = map.getCenter();
+        map.updateSize();
+        map.zoomTo(currentZoom);
+        map.setCenter(currentCenter);
     }
 
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java	Fri Nov 04 11:53:13 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java	Tue Nov 08 13:07:56 2011 +0000
@@ -119,36 +119,30 @@
         rootLayout.setWidth100();
         rootLayout.setMembersMargin(2);
 
-        final Canvas  wrapper = new Canvas();
-        wrapper.setWidth100();
-        wrapper.setHeight100();
+        final HLayout hlayout = new HLayout();
+        hlayout.setHeight("*");
+        hlayout.setWidth100();
+        hlayout.setMembersMargin(2);
 
-        controlPanel = createControlPanel(wrapper);
+        final Canvas themePanelWrapper = createThemePanel();
+
+        controlPanel = createControlPanel();
         mapPanel     = floodMap.getMapWidget();
-        Canvas themePanelWrapper = createThemePanel();
-
         final HorizontalPanel layout = new HorizontalPanel();
         layout.setWidth("99%");
         layout.setHeight("99%");
         layout.add(mapPanel);
 
-        wrapper.addChild(layout);
-
-        HLayout hlayout = new HLayout();
-        hlayout.setHeight("*");
-        hlayout.setWidth100();
-        hlayout.setMembersMargin(2);
-
         hlayout.addMember(themePanelWrapper);
-        hlayout.addMember(wrapper);
+        hlayout.addMember(layout);
 
         rootLayout.addMember(controlPanel);
         rootLayout.addMember(hlayout);
 
-        wrapper.addResizedHandler(new ResizedHandler() {
+        hlayout.addResizedHandler(new ResizedHandler() {
             public void onResized(ResizedEvent e) {
-                Integer height = wrapper.getHeight();
-                Integer width  = wrapper.getWidth();
+                Integer height = hlayout.getHeight();
+                Integer width  = hlayout.getWidth() - themePanelWrapper.getWidth();
 
                 height = height * 99 / 100;
                 width  = width  * 99 / 100;
@@ -378,8 +372,8 @@
     }
 
 
-    protected MapToolbar createControlPanel(Canvas wrapper) {
-        return new MapToolbar(this, floodMap, wrapper, false);
+    protected MapToolbar createControlPanel() {
+        return new MapToolbar(this, floodMap, false);
     }
 
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java	Fri Nov 04 11:53:13 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java	Tue Nov 08 13:07:56 2011 +0000
@@ -52,7 +52,7 @@
         wrapper.setHeight100();
         wrapper.addChild(mapArea);
 
-        toolbar = new MapToolbar(floodMap, this, digitizeEnabled);
+        toolbar = new MapToolbar(floodMap, digitizeEnabled);
 
         addMember(toolbar);
         addMember(mapArea);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPositionPanel.java	Fri Nov 04 11:53:13 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPositionPanel.java	Tue Nov 08 13:07:56 2011 +0000
@@ -10,7 +10,9 @@
 import org.gwtopenmaps.openlayers.client.Map;
 import org.gwtopenmaps.openlayers.client.MapWidget;
 import org.gwtopenmaps.openlayers.client.Pixel;
-
+import org.gwtopenmaps.openlayers.client.event.EventHandler;
+import org.gwtopenmaps.openlayers.client.event.EventObject;
+import org.gwtopenmaps.openlayers.client.util.JSObject;
 
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
@@ -18,13 +20,13 @@
 public class MapPositionPanel extends HLayout {
 
     protected MapWidget mapWidget;
-    protected Map       map;
+    protected final Map map;
 
     protected Label  x;
     protected Label  y;
 
 
-    public MapPositionPanel(MapWidget mapWidget, final Canvas c) {
+    public MapPositionPanel(MapWidget mapWidget) {
         this.mapWidget = mapWidget;
         this.map       = mapWidget.getMap();
 
@@ -43,16 +45,18 @@
         addMember(d);
         addMember(y);
 
-        // TODO We should use the MousePosition control provided by
-        // GwtOpenLayers here instead of calculating the mouse pos manually.
-        c.addMouseMoveHandler(new MouseMoveHandler() {
-            public void onMouseMove(MouseMoveEvent e) {
-                int x = e.getX() - c.getPageLeft();
-                int y = e.getY() - c.getPageTop();
+        // TODO This is not an optimal way to get the mouse position but makes
+        // the wrapper canvas superfluous.
+       this.map.getEvents().register("mousemove", map, new EventHandler() {
 
-                LonLat point = map.getLonLatFromPixel(new Pixel(x, y));
-                setX(point.lon());
-                setY(point.lat());
+            @Override
+            public void onHandle(EventObject eventObject) {
+                JSObject xy = eventObject.getJSObject().getProperty("xy");
+                Pixel px = Pixel.narrowToPixel(xy);
+                LonLat lonlat = map.getLonLatFromPixel(px);
+
+                setX(lonlat.lon());
+                setY(lonlat.lat());
             }
         });
     }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Fri Nov 04 11:53:13 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Tue Nov 08 13:07:56 2011 +0000
@@ -52,20 +52,19 @@
     protected Canvas position;
 
 
-    public MapToolbar(MapOutputTab mapTab, FloodMap floodMap, Canvas wrapper) {
-        this(mapTab, floodMap, wrapper, true);
+    public MapToolbar(MapOutputTab mapTab, FloodMap floodMap) {
+        this(mapTab, floodMap, true);
     }
 
 
-    public MapToolbar(FloodMap floodMap, Canvas wrapper, boolean digitize) {
-        this(null, floodMap, wrapper, digitize);
+    public MapToolbar(FloodMap floodMap, boolean digitize) {
+        this(null, floodMap, digitize);
     }
 
 
     public MapToolbar(
         MapOutputTab   mapTab,
         FloodMap       floodMap,
-        Canvas         wrapper,
         boolean        digitize)
     {
         super(mapTab);
@@ -78,9 +77,6 @@
 
         this.floodMap = floodMap;
 
-        Canvas spacer = new Canvas();
-        spacer.setWidth("*");
-
         zoomToMaxButton = createMaxExtentControl();
         zoomBoxButton   = createZoomBoxControl();
         zoomOutButton   = createZoomOutControl();
@@ -88,7 +84,7 @@
         drawControl     = createDrawControl();
         selectButton    = createSelectFeatureControl();
         measureControl  = createMeasureControl();
-        position        = createMousePosition(wrapper);
+        position        = createMousePosition();
         removeButton    = createRemoveFeatureControl();
         elevationButton = createElevationControl();
 
@@ -110,7 +106,6 @@
         }
 
         addMember(measureControl);
-        addMember(spacer);
         addMember(position);
     }
 
@@ -440,8 +435,8 @@
     }
 
 
-    protected Canvas createMousePosition(Canvas mapWrapper) {
-        return new MapPositionPanel(floodMap.getMapWidget(), mapWrapper);
+    protected Canvas createMousePosition() {
+        return new MapPositionPanel(floodMap.getMapWidget());
     }
 
 

http://dive4elements.wald.intevation.org