diff flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 652:8fa4c5c9cd1a

Charts are zoomed to a specified view if the attribute document for the chart creation contains an x and/or y range. flys-artifacts/trunk@2047 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 03 Jun 2011 06:47:51 +0000
parents bab867fb37e8
children 67c7020f4ed3
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Thu Jun 02 15:47:08 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Fri Jun 03 06:47:51 2011 +0000
@@ -11,8 +11,10 @@
 import org.jfree.chart.ChartFactory;
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.axis.ValueAxis;
 import org.jfree.chart.plot.PlotOrientation;
 import org.jfree.chart.plot.XYPlot;
+import org.jfree.data.Range;
 
 import de.intevation.flys.exports.ChartExportHelper;
 
@@ -89,6 +91,8 @@
 
         int[] size = getSize();
 
+        zoom(plot);
+
         ChartExportHelper.exportImage(
             out,
             chart,
@@ -97,6 +101,27 @@
     }
 
 
+    protected void zoom(XYPlot plot) {
+        logger.debug("Zoom to specified ranges.");
+
+        Range xrange = getDomainAxisRange();
+        if (xrange != null) {
+            ValueAxis xaxis = plot.getDomainAxis();
+            xaxis.setRange(xrange);
+
+            logger.debug("Zoom chart to X: " + xrange);
+        }
+
+        Range yrange = getValueAxisRange();
+        if (yrange != null) {
+            ValueAxis yaxis = plot.getRangeAxis();
+            yaxis.setRange(yrange);
+
+            logger.debug("Zoom chart to Y: " + yrange);
+        }
+    }
+
+
     /**
      * Adjusts the axes of a plot.
      *

http://dive4elements.wald.intevation.org