changeset 2431:90c339e26a0a

#459 Take the current zoom into account for chart exports. flys-client/trunk@4073 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 17 Feb 2012 09:41:38 +0000
parents ea6065c2dabe
children 61c8e517671e
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/ImgLink.java flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java
diffstat 3 files changed, 52 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Feb 17 09:26:34 2012 +0000
+++ b/flys-client/ChangeLog	Fri Feb 17 09:41:38 2012 +0000
@@ -1,3 +1,16 @@
+2012-02-17  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue459 (Diagramm-Export hat nicht die gleiche Axenskalierung wie
+	Diagramm-Ansicht)
+
+	* src/main/java/de/intevation/flys/client/client/ui/ImgLink.java: Added a
+	  method setSource() that allows to reset the url of the export.
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java:
+	  Implements ZoomHandler to update the export url of PNG, PDF and SVG
+	  download links. This is necessary to take the current zoom information
+	  into account.
+
 2012-02-17  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ImgLink.java	Fri Feb 17 09:26:34 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ImgLink.java	Fri Feb 17 09:41:38 2012 +0000
@@ -1,17 +1,42 @@
 package de.intevation.flys.client.client.ui;
 
+import com.google.gwt.core.client.GWT;
+
 import com.smartgwt.client.types.Overflow;
 import com.smartgwt.client.widgets.HTMLPane;
 
 
 public class ImgLink extends HTMLPane {
 
+    private int width;
+    private int height;
+
+    private String href;
+    private String imgUrl;
+
+
     public ImgLink(String imgUrl, String href, int width, int height) {
         super();
 
+        this.width  = width;
+        this.height = height;
+        this.href   = href;
+        this.imgUrl = imgUrl;
+
+        update();
+    }
+
+
+    protected void update() {
         setContents("<a href='" + href + "'><img src='" + imgUrl + "'></a>");
         setWidth(width);
         setHeight(height);
         setOverflow(Overflow.VISIBLE);
     }
+
+
+    public void setSource(String href) {
+        this.href = href;
+        update();
+    }
 }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java	Fri Feb 17 09:26:34 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java	Fri Feb 17 09:41:38 2012 +0000
@@ -10,6 +10,8 @@
 import com.smartgwt.client.widgets.events.ClickHandler;
 
 import de.intevation.flys.client.client.FLYSConstants;
+import de.intevation.flys.client.client.event.ZoomEvent;
+import de.intevation.flys.client.client.event.ZoomHandler;
 import de.intevation.flys.client.client.ui.ImgLink;
 import de.intevation.flys.client.client.ui.Toolbar;
 
@@ -20,7 +22,7 @@
  *
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
-public class ChartToolbar extends Toolbar {
+public class ChartToolbar extends Toolbar implements ZoomHandler {
 
     protected static FLYSConstants MSG = GWT.create(FLYSConstants.class);
 
@@ -30,11 +32,11 @@
 
     protected Button datacage;
 
-    protected Canvas downloadPNG;
+    protected ImgLink downloadPNG;
 
-    protected Canvas downloadPDF;
+    protected ImgLink downloadPDF;
 
-    protected Canvas downloadSVG;
+    protected ImgLink downloadSVG;
 
     protected Canvas downloadCSV;
 
@@ -134,6 +136,7 @@
         });
 
         zoombox.addZoomHandler(chartTab);
+        zoombox.addZoomHandler(this);
         zoombox.addClickHandler(new ClickHandler() {
             public void onClick(ClickEvent event) {
                 panControl.deselect();
@@ -220,5 +223,12 @@
         new ManualPointsEditor(chartTab.getView().getCollection(),
             this.chartTab, this.chartTab.getMode().getName()).show();
     }
+
+
+    public void onZoom(ZoomEvent evt) {
+        downloadPNG.setSource(chartTab.getExportUrl(-1, -1, "png"));
+        downloadPDF.setSource(chartTab.getExportUrl(-1, -1, "pdf"));
+        downloadSVG.setSource(chartTab.getExportUrl(-1, -1, "svg"));
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org