diff flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java @ 610:ea2191b1299d

#170 Changed the DOM manipulation while zoom and drag operation. flys-client/trunk@2223 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 23 Jun 2011 17:46:08 +0000
parents 460b8e0f0563
children 854312c0528c
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java	Thu Jun 23 17:16:08 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java	Thu Jun 23 17:46:08 2011 +0000
@@ -7,6 +7,8 @@
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
+import com.smartgwt.client.types.Overflow;
+
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Img;
 
@@ -72,6 +74,8 @@
     /** The canvas that wraps the chart.*/
     protected Canvas right;
 
+    protected Img chart;
+
 
     /** Chart zoom options.*/
     protected int[] xrange;
@@ -122,7 +126,10 @@
         ChartThemePanel ctp = new ChartThemePanel(collection, mode);
         ctp.addOutputParameterChangeHandler(this);
 
-        right.addChild(createChartPanel());
+        chart = createChartImg();
+        right.addChild(chart);
+        right.setOverflow(Overflow.HIDDEN);
+        //right.addChild(createChartPanel());
         left.addChild(ctp);
 
         vLayout.addMember(tbarPanel);
@@ -357,7 +364,7 @@
             getChartAttributes(),
             new AsyncCallback<ChartInfo>() {
                 public void onFailure(Throwable caught) {
-                    GWT.log("ERROR: " + caught.getMessage());
+                    GWT.log("ChartInfo ERROR: " + caught.getMessage());
                 }
 
                 public void onSuccess(ChartInfo chartInfo) {
@@ -368,12 +375,10 @@
 
 
     public void updateChartPanel() {
-        Canvas[] children = right.getChildren();
-        for (Canvas child: children) {
-            right.removeChild(child);
-        }
+        int w = right.getWidth();
+        int h = right.getHeight();
 
-        right.addChild(createChartPanel(right.getWidth(), right.getHeight()));
+        chart.setSrc(getImgUrl(w, h));
     }
 
 
@@ -383,14 +388,12 @@
      * @return the existing chart panel.
      */
     public Canvas getChartPanel() {
-        Canvas[] children = right.getChildren();
+        return right;
+    }
 
-        if (children == null || children.length == 0) {
-            GWT.log("=> No chart image in the panel.");
-            return right;
-        }
 
-        return children[0];
+    public Canvas getChartImg() {
+        return chart;
     }
 
 
@@ -435,8 +438,8 @@
      *
      * @return the created chart panel.
      */
-    protected Canvas createChartPanel() {
-        return createChartPanel(DEFAULT_CHART_WIDTH, DEFAULT_CHART_HEIGHT);
+    protected Img createChartImg() {
+        return createChartImg(DEFAULT_CHART_WIDTH, DEFAULT_CHART_HEIGHT);
     }
 
 
@@ -448,7 +451,7 @@
      *
      * @return the created chart panel.
      */
-    protected Canvas createChartPanel(int width, int height) {
+    protected Img createChartImg(int width, int height) {
         Img chart  = getChartImg(width, height);
         chart.setWidth100();
         chart.setHeight100();
@@ -496,8 +499,6 @@
         double[] zoom = getZoomValues();
 
         if (zoom != null) {
-            GWT.log("Zoom to specified range.");
-
             imgUrl += "&minx=" + Double.toString(zoom[0]);
             imgUrl += "&maxx=" + Double.toString(zoom[1]);
             imgUrl += "&miny=" + Double.toString(zoom[2]);

http://dive4elements.wald.intevation.org