diff flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java @ 1281:4782c0ce9cec

Re-added the function to zoom-out charts by a given factor (10%). flys-client/trunk@2863 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 29 Sep 2011 12:55:17 +0000
parents 66192d170c79
children 3904519ec161
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java	Thu Sep 29 11:12:04 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java	Thu Sep 29 12:55:17 2011 +0000
@@ -320,6 +320,8 @@
 
 
     public void resetRanges() {
+        zoomStack.push(new ZoomObj(zoom[0], zoom[1], zoom[2], zoom[3]));
+
         zoom[0] = 0d;
         zoom[1] = 1d;
         zoom[2] = 0d;
@@ -331,6 +333,34 @@
 
 
     /**
+     * This method zooms the current chart out by a given <i>factor</i>.
+     *
+     * @param factor The factor should be between 0-100.
+     */
+    public void zoomOut(int factor) {
+        if (factor < 0 || factor > 100 || chartInfo == null) {
+            return;
+        }
+
+        zoomStack.push(new ZoomObj(zoom[0], zoom[1], zoom[2], zoom[3]));
+
+        Axis xAxis = chartInfo.getXAxis(0);
+        Axis yAxis = chartInfo.getYAxis(0);
+
+        double[] x = zoomAxis(xAxis, factor);
+        double[] y = zoomAxis(yAxis, factor);
+
+        zoom[0] = x[0];
+        zoom[1] = x[1];
+        zoom[2] = x[0];
+        zoom[3] = y[1];
+
+        updateChartInfo();
+        updateChartPanel();
+    }
+
+
+    /**
      * This method is used to zoom out. Zooming out is realizied with a stacked
      * logic. Initially, you cannot zoom out. For each time you start a zoom-in
      * action, the extent of the chart is stored and pushed onto a stack. A
@@ -351,16 +381,12 @@
         double min  = axis.getFrom();
         double max  = axis.getTo();
 
-        GWT.log("ZOOM CURRENT: " + min + " - " + max);
-
         double add = (max - min) / 100 * factor;
         add = add < 0 ? (-1) * add : add;
 
         min -= add;
         max += add;
 
-        GWT.log("ZOOM TO: " + min + " - " + max);
-
         return computeZoom(axis, min, max);
     }
 

http://dive4elements.wald.intevation.org