# HG changeset patch # User Ingo Weinzierl # Date 1317307949 0 # Node ID 3904519ec161f29698d64851d0a2ce38f78f728a # Parent 4782c0ce9cecd75329a4d105e829cc51a67ae550 Bugfix: #179 Repaired broken zoom-out-by-factor function for charts. flys-client/trunk@2864 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 4782c0ce9cec -r 3904519ec161 flys-client/ChangeLog --- 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 + + 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 * src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java: diff -r 4782c0ce9cec -r 3904519ec161 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 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 + }; }