diff flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 653:67c7020f4ed3

Refactored the chart creation in the ChartInfoGenerators. Now, every chart is created by the XYChartGenerator again. flys-artifacts/trunk@2048 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 03 Jun 2011 07:20:39 +0000
parents 8fa4c5c9cd1a
children bbc966c81809
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Fri Jun 03 06:47:51 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Fri Jun 03 07:20:39 2011 +0000
@@ -69,6 +69,21 @@
     {
         logger.debug("XYChartGenerator.generate");
 
+        JFreeChart chart = generateChart();
+
+        int[] size = getSize();
+
+        ChartExportHelper.exportImage(
+            out,
+            chart,
+            "png",
+            size[0], size[1]);
+    }
+
+
+    public JFreeChart generateChart() {
+        logger.debug("XYChartGenerator.generateChart");
+
         JFreeChart chart = ChartFactory.createXYLineChart(
             getChartTitle(),
             getXAxisLabel(),
@@ -88,22 +103,30 @@
         addSubtitles(chart);
         adjustPlot(plot);
         adjustAxes(plot);
-
-        int[] size = getSize();
-
         zoom(plot);
 
-        ChartExportHelper.exportImage(
-            out,
-            chart,
-            "png",
-            size[0], size[1]);
+        return chart;
     }
 
 
+    /**
+     * Zooms the chart to the ranges specified in the attribute document.
+     *
+     * @param plot The XYPlot.
+     */
     protected void zoom(XYPlot plot) {
         logger.debug("Zoom to specified ranges.");
+        zoomX(plot);
+        zoomY(plot);
+    }
 
+
+    /**
+     * Zooms the x axis to the range specified in the attribute document.
+     *
+     * @param plot The XYPlot.
+     */
+    protected void zoomX(XYPlot plot) {
         Range xrange = getDomainAxisRange();
         if (xrange != null) {
             ValueAxis xaxis = plot.getDomainAxis();
@@ -111,7 +134,15 @@
 
             logger.debug("Zoom chart to X: " + xrange);
         }
+    }
 
+
+    /**
+     * Zooms the y axis to the range specified in the attribute document.
+     *
+     * @param plot The XYPlot.
+     */
+    protected void zoomY(XYPlot plot) {
         Range yrange = getValueAxisRange();
         if (yrange != null) {
             ValueAxis yaxis = plot.getRangeAxis();

http://dive4elements.wald.intevation.org