changeset 1282:3904519ec161

Bugfix: #179 Repaired broken zoom-out-by-factor function for charts. flys-client/trunk@2864 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 29 Sep 2011 14:52:29 +0000
parents 4782c0ce9cec
children e8bb11976c70
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java
diffstat 2 files changed, 33 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu Sep 29 12:55:17 2011 +0000
+++ b/flys-client/ChangeLog	Thu Sep 29 14:52:29 2011 +0000
@@ -1,3 +1,10 @@
+2011-09-29  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue179 (Zoom Out funktioniert nichtzuverlässig)
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java:
+	  Repaired broken zoom-out function.
+
 2011-09-29  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java	Thu Sep 29 12:55:17 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java	Thu Sep 29 14:52:29 2011 +0000
@@ -352,7 +352,7 @@
 
         zoom[0] = x[0];
         zoom[1] = x[1];
-        zoom[2] = x[0];
+        zoom[2] = y[0];
         zoom[3] = y[1];
 
         updateChartInfo();
@@ -378,16 +378,34 @@
 
 
     public double[] zoomAxis(Axis axis, int factor) {
-        double min  = axis.getFrom();
-        double max  = axis.getTo();
+        GWT.log("Prepare Axis for zooming (factor: " + factor + ")");
 
-        double add = (max - min) / 100 * factor;
-        add = add < 0 ? (-1) * add : add;
+        double min   = axis.getMin();
+        double max   = axis.getMax();
+        double range = max > min ? max - min : min - max;
 
-        min -= add;
-        max += add;
+        double curFrom = axis.getFrom();
+        double curTo   = axis.getTo();
 
-        return computeZoom(axis, min, max);
+        double diff = curTo > curFrom ? curTo - curFrom : curFrom - curTo;
+
+        GWT.log("    max from    : " + min);
+        GWT.log("    max to      : " + max);
+        GWT.log("    max range   : " + range);
+        GWT.log("    current from: " + curFrom);
+        GWT.log("    current to  : " + curTo);
+        GWT.log("    current diff: " + diff);
+
+        double newFrom = curFrom - (diff * factor / 100);
+        double newTo   = curTo + (diff * factor / 100);
+
+        GWT.log("    new from: " + newFrom);
+        GWT.log("    new to  : " + newTo);
+
+        return new double[] {
+            (newFrom - min) / range,
+            (newTo - min) / range
+        };
     }
 
 

http://dive4elements.wald.intevation.org