changeset 3694:0a277b041770

Improved panning in TimeseriesCharts (issue715). flys-client/trunk@5390 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 07 Sep 2012 13:15:28 +0000
parents b63e6fdd8cd0
children 5e4d91304484
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java
diffstat 2 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Sep 07 13:02:46 2012 +0000
+++ b/flys-client/ChangeLog	Fri Sep 07 13:15:28 2012 +0000
@@ -1,3 +1,11 @@
+2012-09-07	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Improved panning in TimeseriesCharts (issue715).
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java
+	  (computeZoom): Prevent confusion of scoped 'zoom' variable.
+	  (divide): Cast to double, we do not want long precision divisions.
+
 2012-09-07	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/shared/model/ChartInfo.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java	Fri Sep 07 13:02:46 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java	Fri Sep 07 13:15:28 2012 +0000
@@ -115,8 +115,8 @@
         zoomStack = new Stack<ZoomObj>();
 
         zoom = new Number[] {
-            new Integer(0), new Integer(1),
-            new Integer(0), new Integer(1) };
+            new Double(0), new Double(1),
+            new Double(0), new Double(1) };
 
         left.setBorder("1px solid gray");
         left.setWidth(THEMEPANEL_MIN_WIDTH);
@@ -328,6 +328,7 @@
         Number[] x = panAxis(xAxis, diffX);
         Number[] y = panAxis(yAxis, diffY);
 
+        // Set the zoom coordinates.
         zoom[0] = x[0];
         zoom[1] = x[1];
         zoom[2] = y[0];
@@ -441,7 +442,7 @@
 
 
     public static Number[] computeZoom(Axis axis, Number min, Number max) {
-        Number[] zoom = new Number[2];
+        Number[] hereZoom = new Number[2];
 
         Number absMin = axis.getMin();
         Number absMax = axis.getMax();
@@ -449,10 +450,10 @@
             ? subtract(absMax, absMin)
             : subtract(absMin, absMax);
 
-        zoom[0] = divide(subtract(min, absMin), diff);
-        zoom[1] = divide(subtract(max, absMin), diff);
+        hereZoom[0] = divide(subtract(min, absMin), diff);
+        hereZoom[1] = divide(subtract(max, absMin), diff);
 
-        return zoom;
+        return hereZoom;
     }
 
 
@@ -707,6 +708,7 @@
     }
 
 
+    /** Add two numbers, casting to Type of param left. */
     public static Number add(Number left, Number right) {
         if (left instanceof Double) {
             return new Double(left.doubleValue() + right.doubleValue());
@@ -720,12 +722,13 @@
     }
 
 
+    /** Divde left by right. Note that Long will be casted to double. */
     public static Number divide(Number left, Number right) {
         if (left instanceof Double) {
             return new Double(left.doubleValue() / right.doubleValue());
         }
         else if (left instanceof Long) {
-            return new Long(left.longValue() / right.longValue());
+            return new Double(left.doubleValue() / right.doubleValue());
         }
         else {
             return new Integer(left.intValue() / right.intValue());

http://dive4elements.wald.intevation.org