# HG changeset patch # User Felix Wolfsteller # Date 1347023728 0 # Node ID 0a277b04177050f0a731059f35247f5ce9a71568 # Parent b63e6fdd8cd04b7c02af39849afb938746bc9a4c Improved panning in TimeseriesCharts (issue715). flys-client/trunk@5390 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r b63e6fdd8cd0 -r 0a277b041770 flys-client/ChangeLog --- 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 + + 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 * src/main/java/de/intevation/flys/client/shared/model/ChartInfo.java, diff -r b63e6fdd8cd0 -r 0a277b041770 flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.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(); 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());