changeset 779:f1a559d13eef

#185 Repaired zooming for IE8 and Chrome. flys-client/trunk@2268 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 29 Jun 2011 12:33:58 +0000
parents e14dc5fed6bb
children a39c2f531755
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ZoomboxControl.java
diffstat 3 files changed, 61 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed Jun 29 11:14:43 2011 +0000
+++ b/flys-client/ChangeLog	Wed Jun 29 12:33:58 2011 +0000
@@ -1,4 +1,16 @@
-2011-06-26	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+2011-06-29  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue185 (IE8 + Chromium: Kein Zoomen von Diagrammen möglich)
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java:
+	  Create the chart image first before initialising listeners on it.
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/ZoomboxControl.java:
+	  The zoombox that is displayed in while zooming is 2 pixel smaller than
+	  the area between start and end point now. This should avoid the zoombox
+	  absorbing mouse events.
+
+2011-06-29	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/ProjectList.java:
 	  Reordered delete and rename in project context menu, add separator.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java	Wed Jun 29 11:14:43 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java	Wed Jun 29 12:33:58 2011 +0000
@@ -102,7 +102,6 @@
         view      = collectionView;
         left      = new Canvas();
         right     = new Canvas();
-        tbarPanel = new ChartToolbar(collectionView, this);
         xrange    = new int[2];
         yrange    = new int[2];
         zoom      = new double[4];
@@ -132,6 +131,7 @@
         //right.addChild(createChartPanel());
         left.addChild(ctp);
 
+        tbarPanel = new ChartToolbar(collectionView, this);
         vLayout.addMember(tbarPanel);
         vLayout.addMember(hLayout);
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ZoomboxControl.java	Wed Jun 29 11:14:43 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ZoomboxControl.java	Wed Jun 29 12:33:58 2011 +0000
@@ -53,7 +53,7 @@
 
         this.handlers = new ArrayList<ZoomHandler>();
         this.chartTab = chartTab;
-        this.start    = new int[2];
+        this.start    = new int[] { -1, -1 };
         this.end      = new int[2];
         this.zoombox  = new Canvas();
 
@@ -66,10 +66,11 @@
         setShowRollOver(false);
         setSelected(false);
 
-        chartTab.getChartPanel().addMouseDownHandler(this);
-        chartTab.getChartPanel().addMouseOutHandler(this);
-        chartTab.getChartPanel().addMouseMoveHandler(this);
-        chartTab.getChartPanel().addMouseUpHandler(this);
+        Canvas chart = chartTab.getChartPanel();
+        chart.addMouseDownHandler(this);
+        chart.addMouseOutHandler(this);
+        chart.addMouseMoveHandler(this);
+        chart.addMouseUpHandler(this);
     }
 
 
@@ -80,11 +81,16 @@
      * position.
      */
     protected void initZoombox() {
+        Canvas chart = chartTab.getChartPanel();
+        chart.addChild(zoombox);
+
         zoombox.setPosition(Positioning.ABSOLUTE);
         zoombox.setBorder("2px solid black");
         zoombox.setOpacity(50);
-        zoombox.setWidth(0);
-        zoombox.setHeight(0);
+        zoombox.setWidth(1);
+        zoombox.setHeight(1);
+        zoombox.setLeft(-10000);
+        zoombox.setTop(-10000);
     }
 
 
@@ -112,16 +118,11 @@
             return;
         }
 
-        start[0] = getRelativeX(event.getX());
-        start[1] = getRelativeY(event.getY());
+        start[0] = getRelativeX(event.getX()) - 1;
+        start[1] = getRelativeY(event.getY()) + 1;
 
         end[0] = start[0];
         end[1] = start[1];
-
-        Canvas c = getChartPanel();
-        c.addChild(zoombox);
-
-        positionZoombox();
     }
 
 
@@ -134,12 +135,15 @@
      * the observed area.
      */
     public void onMouseMove(MouseMoveEvent event) {
-        if (!isSelected()) {
+        if (!isSelected() || !isZooming()) {
             return;
         }
 
-        end[0] = getRelativeX(event.getX());
-        end[1] = getRelativeY(event.getY());
+        int x = getRelativeX(event.getX());
+        int y = getRelativeY(event.getY());
+
+        end[0] = x > start[0] ? x-1 : x+1;
+        end[1] = y > start[1] ? y-1 : y+1;
 
         positionZoombox();
     }
@@ -162,7 +166,7 @@
 
         fireZoomEvent();
 
-        clearZoombox();
+        reset();
     }
 
 
@@ -176,12 +180,7 @@
             return;
         }
 
-        start[0] = 0;
-        start[1] = 0;
-        end[0] = 0;
-        end[1] = 0;
-
-        clearZoombox();
+        reset();
     }
 
 
@@ -224,6 +223,16 @@
 
 
     /**
+     * Returns true, if a zoom action is in process.
+     *
+     * @return true, if a zoom action is in process.
+     */
+    public boolean isZooming() {
+        return start[0] > 0 && start[1] > 0;
+    }
+
+
+    /**
      * Returns the X coordinate relative to the left border.
      *
      * @param x The X coordinate relative to the window.
@@ -281,13 +290,21 @@
      * Clears the zoombox (set position and size to null).
      */
     protected void clearZoombox() {
-        zoombox.setLeft(0);
-        zoombox.setTop(0);
-        zoombox.setWidth(0);
-        zoombox.setHeight(0);
+        zoombox.setLeft(-10000);
+        zoombox.setTop(-10000);
+        zoombox.setWidth(1);
+        zoombox.setHeight(1);
+    }
 
-        Canvas c = getChartPanel();
-        c.removeChild(zoombox);
+
+    /**
+     * Resets the zoom control (start point and zoombox).
+     */
+    protected void reset() {
+        start[0] = -1;
+        start[1] = -1;
+
+        clearZoombox();
     }
 
 

http://dive4elements.wald.intevation.org