changeset 1684:bdb05dc9b763

Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained. flys-artifacts/trunk@2902 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 07 Oct 2011 10:51:09 +0000
parents acb4d20b130e
children 022f62c75878
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/OutGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/ReportGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java
diffstat 17 files changed, 299 insertions(+), 128 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/ChangeLog	Fri Oct 07 10:51:09 2011 +0000
@@ -1,3 +1,41 @@
+2011-10-07  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue353 (W-INFO / Wasserspiegellagenberechnung, Diagramm)
+
+	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
+	  Adapted the process of collecting outs for Artifacts/Facets. We will now
+	  call OutGenerator.doOut() for each Artifact and Facet - never mind if
+	  the facet is activated (visible) or not. The OutGenerator should decide
+	  on its own whtat to do with facets which are "marked" as _not_ visible.
+
+	* src/main/java/de/intevation/flys/exports/OutGenerator.java,
+	  src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java,
+	  src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java,
+	  src/main/java/de/intevation/flys/exports/ChartGenerator.java,
+	  src/main/java/de/intevation/flys/exports/ReportGenerator.java,
+	  src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java,
+	  src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java,
+	  src/main/java/de/intevation/flys/exports/AbstractExporter.java,
+	  src/main/java/de/intevation/flys/exports/ATExporter.java,
+	  src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java,
+	  src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java,
+	  src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java,
+	  src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java:
+	  Adapted the signature of OutGenerator.doOut(). There will be a new
+	  boolean parameter "visible" that determines if the facet specified in
+	  this method is visible for this output or not.
+
+	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java: Now,
+	  that we walk over every Artifact/Facet, we are able to collect min/max
+	  data for all axes. We store these information and use them to set the
+	  ranges of x and y axes. The result of this: a chart can have proper axes
+	  set without any data in it.
+
+	* src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java: Use
+	  min/max ranges stored while calling doOut() for each Artifact/Facet
+	  instead of fetching those information from chart's Datasets (which could
+	  be null).
+
 2011-10-07  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/utils/Formatter.java: Changed the max
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Fri Oct 07 10:51:09 2011 +0000
@@ -280,10 +280,6 @@
                     generator.setMasterArtifact(artifact);
                 }
 
-                if (theme.getActive() == 0) {
-                    continue;
-                }
-
                 generator.doOut(
                     artifact,
                     theme,
@@ -292,7 +288,8 @@
                         outName,
                         facetName,
                         theme.getIndex(),
-                        context));
+                        context),
+                    theme.getActive() == 1);
             }
         }
         catch (ArtifactDatabaseException ade) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java	Fri Oct 07 10:51:09 2011 +0000
@@ -47,7 +47,12 @@
     }
 
     @Override
-    public void doOut(Artifact artifact, Facet facet, Document attr) {
+    public void doOut(
+        Artifact artifact,
+        Facet    facet,
+        Document attr,
+        boolean  visible
+    ) {
 
         FLYSArtifact flys = (FLYSArtifact)artifact;
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java	Fri Oct 07 10:51:09 2011 +0000
@@ -111,7 +111,12 @@
      * @param attr The attr document.
      */
     @Override
-    public void doOut(Artifact artifact, Facet facet, Document attr) {
+    public void doOut(
+        Artifact artifact,
+        Facet    facet,
+        Document attr,
+        boolean  visible
+    ) {
         String name = facet.getName();
 
         logger.debug("AbstractExporter.doOut: " + name);
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Fri Oct 07 10:51:09 2011 +0000
@@ -263,7 +263,11 @@
     }
 
 
-    public abstract void doOut(Artifact artifact, Facet facet, Document attr);
+    public abstract void doOut(
+        Artifact artifact,
+        Facet    facet,
+        Document attr,
+        boolean  visible);
 
     public abstract void generate() throws IOException;
 }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java	Fri Oct 07 10:51:09 2011 +0000
@@ -79,8 +79,13 @@
      * @param facet
      * @param attr
      */
-    public void doOut(Artifact artifact, Facet facet, Document attr) {
-        generator.doOut(artifact, facet, attr);
+    public void doOut(
+        Artifact artifact,
+        Facet    facet,
+        Document attr,
+        boolean  visible
+    ) {
+        generator.doOut(artifact, facet, attr, visible);
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java	Fri Oct 07 10:51:09 2011 +0000
@@ -81,7 +81,12 @@
 
 
     @Override
-    public void doOut(Artifact artifact, Facet facet, Document attr) {
+    public void doOut(
+        Artifact artifact,
+        Facet    facet,
+        Document attr,
+        boolean  visible
+    ) {
         String name = (facet != null) ? facet.getName() : null;
 
         logger.debug("ComputedDischargeCurveGenerator.doOut: " + name);
@@ -95,13 +100,13 @@
         Facet        f    = flys.getNativeFacet(facet);
 
         if (name.equals(COMPUTED_DISCHARGE_Q)) {
-            doQOut((WQKms) f.getData(artifact, context), attr);
+            doQOut((WQKms) f.getData(artifact, context), attr, visible);
         }
         else if (name.equals(COMPUTED_DISCHARGE_MAINVALUES_Q)) {
-            doMainValueQAnnotations(f.getData(artifact, context), attr);
+            doMainValueQAnnotations(f.getData(artifact, context), attr,visible);
         }
         else if (name.equals(COMPUTED_DISCHARGE_MAINVALUES_W)) {
-            doMainValueWAnnotations(f.getData(artifact, context), attr);
+            doMainValueWAnnotations(f.getData(artifact, context), attr,visible);
         }
         else {
             logger.warn("Unknown facet type for computed discharge: " + name);
@@ -113,24 +118,32 @@
     /**
      * Store W MainValues as annotations for later plotting.
      */
-    protected void doMainValueWAnnotations(Object o, Document theme) {
+    protected void doMainValueWAnnotations(
+        Object   o,
+        Document theme,
+        boolean  visible
+    ) {
         logger.debug("ComputedDischargeCurveGenerator set W MainValues.");
 
         FLYSAnnotation fa = (FLYSAnnotation) o;
         fa.setTheme(theme);
-        addAnnotations(fa);
+        addAnnotations(fa, visible);
     }
 
 
     /**
      * Store Q MainValues as annotations for later plotting.
      */
-    protected void doMainValueQAnnotations(Object o, Document theme) {
+    protected void doMainValueQAnnotations(
+        Object   o,
+        Document theme,
+        boolean  visible
+    ) {
         logger.debug("ComputedDischargeCurveGenerator set Q MainValues.");
 
         FLYSAnnotation fa = (FLYSAnnotation) o;
         fa.setTheme(theme);
-        addAnnotations(fa);
+        addAnnotations(fa, visible);
     }
 
 
@@ -139,7 +152,7 @@
      * @param wqkms actual data
      * @param theme theme to use.
      */
-    protected void doQOut(WQKms wqkms, Document theme) {
+    protected void doQOut(WQKms wqkms, Document theme, boolean visible) {
         int size = wqkms.size();
 
         double[]   res  = new double[3];
@@ -150,7 +163,7 @@
             series.add(res[1], res[0]);
         }
 
-        addFirstAxisSeries(series);
+        addFirstAxisSeries(series, visible);
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Fri Oct 07 10:51:09 2011 +0000
@@ -4,10 +4,8 @@
 
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.axis.NumberAxis;
-import org.jfree.chart.axis.ValueAxis;
 import org.jfree.chart.plot.XYPlot;
 import org.jfree.chart.title.TextTitle;
-import org.jfree.data.Range;
 import org.jfree.data.xy.XYSeries;
 
 import org.w3c.dom.Document;
@@ -127,23 +125,14 @@
 
 
     /**
-     * Overrides XYChartGenerators.zoomY() to include the 0 value on the Q axis.
-     */
-    @Override
-    protected boolean zoomY(XYPlot plot, ValueAxis axis, Range range, Range x) {
-        if (plot.getRangeAxisIndex(axis) == 1) {
-            // we want the Q axis to start at 0 if no zooming has been done
-            range = new Range(0d, range.getUpperBound());
-        }
-
-        return super.zoomY(plot, axis, range, x);
-    }
-
-
-    /**
      * Let one facet do its job.
      */
-    public void doOut(Artifact artifact, Facet facet, Document attr) {
+    public void doOut(
+        Artifact artifact,
+        Facet    facet,
+        Document attr,
+        boolean  visible
+    ) {
         String name = facet.getName();
 
         logger.debug("CrossSectionGenerator.doOut: " + name);
@@ -161,10 +150,18 @@
         }
 
         if (name.equals(CROSS_SECTION)) {
-            doCrossSectionOut(f.getData(artifact, context), f.getDescription(), attr);
+            doCrossSectionOut(
+                f.getData(artifact, context),
+                f.getDescription(),
+                attr,
+                visible);
         }
         else if (name.equals(CROSS_SECTION_WATER_LINE)) {
-            doCrossSectionWaterLineOut(f.getData(artifact, context), f.getDescription(), attr);
+            doCrossSectionWaterLineOut(
+                f.getData(artifact, context),
+                f.getDescription(),
+                attr,
+                visible);
         }
         else {
             logger.warn("CrossSection.doOut: Unknown facet name: " + name);
@@ -179,7 +176,12 @@
      * @param seriesName name of the data (line) to display in legend.
      * @param theme Theme for the data series.
      */
-    protected void doCrossSectionWaterLineOut(Object o, String seriesName, Document theme) {
+    protected void doCrossSectionWaterLineOut(
+        Object     o,
+        String     seriesName,
+        Document   theme,
+        boolean    visible
+    ) {
         logger.debug("CrossSectionGenerator.doCrossSectionWaterLineOut");
 
         XYSeries series = new StyledXYSeries(seriesName, theme);
@@ -189,7 +191,7 @@
         for (int i = 0; i < pxs.length; i++) {
             series.add (a[0][i], a[1][i]);
         }
-        addFirstAxisSeries(series);
+        addFirstAxisSeries(series, visible);
     }
 
 
@@ -199,7 +201,12 @@
      * @param seriesName name of the data (line) to display in legend.
      * @param theme Theme for the data series.
      */
-    protected void doCrossSectionOut(Object o, String seriesName, Document theme) {
+    protected void doCrossSectionOut(
+        Object     o,
+        String     seriesName,
+        Document   theme,
+        boolean    visible
+    ) {
         logger.debug("CrossSectionGenerator.doCrossSectionOut");
 
         XYSeries series = new StyledXYSeries(seriesName, theme);
@@ -209,7 +216,7 @@
         for (int i = 0; i < pxs.length; i++) {
             series.add (a[0][i], a[1][i]);
         }
-        addFirstAxisSeries(series);
+        addFirstAxisSeries(series, visible);
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java	Fri Oct 07 10:51:09 2011 +0000
@@ -96,7 +96,12 @@
     }
 
 
-    public void doOut(Artifact artifact, Facet facet, Document attr) {
+    public void doOut(
+        Artifact artifact,
+        Facet    facet,
+        Document attr,
+        boolean  visible
+    ) {
         logger.debug("DischargeCurveGenerator.doOut: " + facet.getName());
 
         if (!(artifact instanceof WINFOArtifact)) {
@@ -144,7 +149,7 @@
             series.add(values[0][i], values[1][i]);
         }
 
-        addFirstAxisSeries(series);
+        addFirstAxisSeries(series, visible);
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java	Fri Oct 07 10:51:09 2011 +0000
@@ -34,7 +34,12 @@
 
 
     @Override
-    public void doOut(Artifact artifact, Facet facet, Document attr) {
+    public void doOut(
+        Artifact artifact,
+        Facet    facet,
+        Document attr,
+        boolean  visible
+    ) {
         logger.debug("DischargeLongitudinalSectionGenerator.doOut");
 
         if (facet == null) {
@@ -51,13 +56,16 @@
         Facet        f    = flys.getNativeFacet(facet);
 
         if (name.equals(DISCHARGE_LONGITUDINAL_W)) {
-            doWOut((WQKms) f.getData(artifact, context), attr);
+            doWOut((WQKms) f.getData(artifact, context), attr, visible);
         }
         else if (name.equals(DISCHARGE_LONGITUDINAL_Q)) {
-            doQOut((WQKms) f.getData(artifact, context), attr);
+            doQOut((WQKms) f.getData(artifact, context), attr, visible);
         }
         else if (name.equals(DISCHARGE_LONGITUDINAL_C)) {
-            doCorrectedWOut((WQCKms) f.getData(artifact, context), attr);
+            doCorrectedWOut(
+                (WQCKms) f.getData(artifact, context),
+                attr,
+                visible);
         }
         else {
             logger.warn("Unknown facet name: " + name);
@@ -71,7 +79,11 @@
      * @param wqckms The object that contains the corrected W values.
      * @param theme The theme that contains styling information.
      */
-    protected void doCorrectedWOut(WQCKms wqckms, Document theme) {
+    protected void doCorrectedWOut(
+        WQCKms   wqckms,
+        Document theme,
+        boolean  visible
+    ) {
         logger.debug("DischargeLongitudinalSectionGenerator.doCorrectedWOut");
 
         int size = wqckms.size();
@@ -85,7 +97,7 @@
                 series.add(wqckms.getKm(i), wqckms.getC(i));
             }
 
-            addFirstAxisSeries(series);
+            addFirstAxisSeries(series, visible);
         }
 
         if (wqckms.guessWaterIncreasing()) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Fri Oct 07 10:51:09 2011 +0000
@@ -119,7 +119,12 @@
 
 
     @Override
-    public void doOut(Artifact artifact, Facet facet, Document attr) {
+    public void doOut(
+        Artifact artifact,
+        Facet    facet,
+        Document attr,
+        boolean  visible
+    ) {
         String name = facet != null ? facet.getName() : null;
 
         logger.debug("DurationCurveGenerator.doOut: " + name);
@@ -133,10 +138,10 @@
         Facet        f    = flys.getNativeFacet(facet);
 
         if (name.equals(DURATION_W)) {
-            doWOut((WQDay) f.getData(artifact, context), attr);
+            doWOut((WQDay) f.getData(artifact, context), attr, visible);
         }
         else if (name.equals(DURATION_Q)) {
-            doQOut((WQDay) f.getData(artifact, context), attr);
+            doQOut((WQDay) f.getData(artifact, context), attr, visible);
         }
         else {
             logger.warn("Unknown facet name: " + name);
@@ -151,7 +156,7 @@
      * @param wqdays The WQDay store that contains the Ws.
      * @param theme
      */
-    protected void doWOut(WQDay wqdays, Document theme) {
+    protected void doWOut(WQDay wqdays, Document theme, boolean visible) {
         logger.debug("DurationCurveGenerator.doWOut");
 
         // TODO find the correct series name
@@ -166,7 +171,7 @@
             series.add((double) day, w);
         }
 
-        addFirstAxisSeries(series);
+        addFirstAxisSeries(series, visible);
     }
 
 
@@ -176,7 +181,7 @@
      * @param wqdays The WQDay store that contains the Qs.
      * @param theme
      */
-    protected void doQOut(WQDay wqdays, Document theme) {
+    protected void doQOut(WQDay wqdays, Document theme, boolean visible) {
         logger.debug("DurationCurveGenerator.doQOut");
 
         // TODO find the correct series name
@@ -191,7 +196,7 @@
             series.add((double) day, q);
         }
 
-        addSecondAxisSeries(series);
+        addSecondAxisSeries(series, visible);
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java	Fri Oct 07 10:51:09 2011 +0000
@@ -146,7 +146,8 @@
         cr.addAttr(e, "from", String.valueOf(range.getLowerBound()), true);
         cr.addAttr(e, "to", String.valueOf(range.getUpperBound()), true);
 
-        Range[] rs = generator.getRangesForDataset(dataset);
+        //Range[] rs = generator.getRangesForDataset(dataset);
+        Range[] rs = generator.getRangesForDataset(pos);
         Range   r  = null;
 
         if (type.equals("range")) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Fri Oct 07 10:51:09 2011 +0000
@@ -172,7 +172,12 @@
     }
 
 
-    public void doOut(Artifact artifact, Facet facet, Document attr) {
+    public void doOut(
+        Artifact artifact,
+        Facet    facet,
+        Document attr,
+        boolean  visible
+    ) {
         String name = facet.getName();
 
         logger.debug("LongitudinalSectionGenerator.doOut: " + name);
@@ -190,13 +195,13 @@
         }
 
         if (name.equals(LONGITUDINAL_W)) {
-            doWOut((WQKms) f.getData(artifact, context), attr);
+            doWOut((WQKms) f.getData(artifact, context), attr, visible);
         }
         else if (name.equals(LONGITUDINAL_Q)) {
-            doQOut((WQKms) f.getData(artifact, context), attr);
+            doQOut((WQKms) f.getData(artifact, context), attr, visible);
         }
         else if (name.equals(LONGITUDINAL_ANNOTATION)) {
-            doAnnotationsOut(f.getData(artifact, context), attr);
+            doAnnotationsOut(f.getData(artifact, context), attr, visible);
         }
         else {
             logger.warn("Unknown facet name: " + name);
@@ -211,12 +216,12 @@
      * @param o     list of annotations (data of facet).
      * @param theme yet ignored.
      */
-    protected void doAnnotationsOut(Object o, Document theme) {
+    protected void doAnnotationsOut(Object o, Document theme, boolean visible) {
         logger.debug("LongitudinalSectionGenerator.doAnnotationsOut");
 
         // Add all annotations in list o to our annotation pool.
         FLYSAnnotation fa = (FLYSAnnotation) o;
-        addAnnotations(fa);
+        addAnnotations(fa, visible);
     }
 
 
@@ -226,7 +231,7 @@
      * @param wqkms An array of WQKms values.
      * @param theme The theme that contains styling information.
      */
-    protected void doWOut(WQKms wqkms, Document theme) {
+    protected void doWOut(WQKms wqkms, Document theme, boolean visible) {
         logger.debug("LongitudinalSectionGenerator.doWOut");
 
         XYSeries series = new StyledXYSeries(getSeriesName(wqkms, "W"), theme);
@@ -246,7 +251,7 @@
             series.add(wqkms.getKm(i), wqkms.getW(i));
         }
 
-        addFirstAxisSeries(series);
+        addFirstAxisSeries(series, visible);
 
         if (wqkms.guessWaterIncreasing()) {
             setInverted(true);
@@ -260,7 +265,7 @@
      * @param wqkms An array of WQKms values.
      * @param theme The theme that contains styling information.
      */
-    protected void doQOut(WQKms wqkms, Document theme) {
+    protected void doQOut(WQKms wqkms, Document theme, boolean visible) {
         logger.debug("LongitudinalSectionGenerator.doQOut");
 
         XYSeries series = new StyledXYSeries(getSeriesName(wqkms, "Q"), theme);
@@ -280,7 +285,7 @@
             series.add(wqkms.getKm(i), wqkms.getQ(i));
         }
 
-        addSecondAxisSeries(series);
+        addSecondAxisSeries(series, visible);
 
         if (wqkms.guessWaterIncreasing()) {
             setInverted(true);
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/OutGenerator.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/OutGenerator.java	Fri Oct 07 10:51:09 2011 +0000
@@ -45,8 +45,9 @@
      * single output.
      * @param attr A document that might contain some attributes used while
      * producing the output.
+     * @param visible Specifies, if this output should be visible or not.
      */
-    void doOut(Artifact artifact, Facet facet, Document attr);
+    void doOut(Artifact artifact, Facet facet, Document attr, boolean visible);
 
     /**
      * Writes the collected output of all artifacts specified in the
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ReportGenerator.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ReportGenerator.java	Fri Oct 07 10:51:09 2011 +0000
@@ -44,7 +44,12 @@
     }
 
     @Override
-    public void doOut(Artifact artifact, Facet facet, Document attr) {
+    public void doOut(
+        Artifact artifact,
+        Facet    facet,
+        Document attr,
+        boolean  visible
+    ) {
         logger.debug("doOut");
         facet = ((FLYSArtifact)artifact).getNativeFacet(facet);
         if (facet != null) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java	Fri Oct 07 10:51:09 2011 +0000
@@ -69,7 +69,13 @@
     /**
      * Add (themed) data for chart generation.
      */
-    public void doOut(Artifact artifact, Facet facet, Document attr) {
+    @Override
+    public void doOut(
+        Artifact artifact,
+        Facet    facet,
+        Document attr,
+        boolean  visible
+    ) {
         String name = facet.getName();
 
         logger.debug("WDifferencesCurveGenerator.doOut: " + name);
@@ -87,13 +93,22 @@
         }
 
         if (name.equals(W_DIFFERENCES)) {
-            doWDifferencesOut((WKms) f.getData(artifact, context), f.getDescription(), attr);
+            doWDifferencesOut(
+                (WKms) f.getData(artifact, context),
+                f.getDescription(),
+                attr,
+                visible);
         }
         else if (name.equals(LONGITUDINAL_W)) {
             WINFOArtifact flysArtifact = (WINFOArtifact) artifact;
             facet = flysArtifact.getNativeFacet(facet);
 
-	    doWaterlevelOut((WQKms) facet.getData(artifact, context), f.getDescription(), attr, flysArtifact);
+            doWaterlevelOut(
+                (WQKms) facet.getData(artifact, context),
+                f.getDescription(),
+                attr,
+                flysArtifact,
+                visible);
 
         }
        else {
@@ -109,9 +124,11 @@
      * @param wqkms The wqkms to add to the diagram.
      */
     public void doWaterlevelOut(WQKms wqkms,
-         String description,
-         Document theme,
-         WINFOArtifact flysArtifact) {
+         String        description,
+         Document      theme,
+         WINFOArtifact flysArtifact,
+         boolean       visible
+    ) {
         String wqkmsName = wqkms.getName();
 
         River river = FLYSUtils.getRiver(flysArtifact);
@@ -147,13 +164,18 @@
             series.add(values[0][i], values[1][i]);
         }
 
-        addSecondAxisSeries(series);
+        addSecondAxisSeries(series, visible);
     }
 
     /**
      * Add items to dataseries which describes the differences.
      */
-    protected void doWDifferencesOut(WKms wkms, String seriesName, Document theme) {
+    protected void doWDifferencesOut(
+        WKms       wkms,
+        String     seriesName,
+        Document   theme,
+        boolean    visible
+    ) {
         logger.debug("WDifferencesCurveGenerator.doWDifferencesOut");
         if (wkms == null) {
             logger.warn("No data to add to WDifferencesChart.");
@@ -176,7 +198,7 @@
             series.add(wkms.getKm(i), wkms.getW(i));
         }
 
-        addFirstAxisSeries(series);
+        addFirstAxisSeries(series, visible);
         if (DataUtil.guessWaterIncreasing(wkms.allWs())) {
             setInverted(true);
         }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Fri Oct 07 09:40:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Fri Oct 07 10:51:09 2011 +0000
@@ -9,7 +9,9 @@
 import java.text.NumberFormat;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.w3c.dom.Document;
 
@@ -27,7 +29,6 @@
 import org.jfree.chart.renderer.xy.XYItemRenderer;
 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
 import org.jfree.data.Range;
-import org.jfree.data.xy.XYDataset;
 import org.jfree.data.xy.XYSeries;
 import org.jfree.data.xy.XYSeriesCollection;
 
@@ -58,6 +59,12 @@
     /** List of annotations to insert in plot. */
     protected List<FLYSAnnotation> annotations;
 
+    /** The max X range that includes all X values of all series for each axis.*/
+    protected Map<Integer, Range> xRanges;
+
+    /** The max Y range that includes all Y values of all series for each axis.*/
+    protected Map<Integer, Range> yRanges;
+
 
     public static final Color DEFAULT_GRID_COLOR      = Color.GRAY;
     public static final float DEFAULT_GRID_LINE_WIDTH = 0.3f;
@@ -149,29 +156,89 @@
     }
 
 
-    public void addFirstAxisSeries(XYSeries series) {
+    public void addFirstAxisSeries(XYSeries series, boolean visible) {
         if (first == null) {
             first = new XYSeriesCollection();
         }
 
         if (series != null) {
-            first.addSeries(series);
+            if (visible) {
+                first.addSeries(series);
+            }
+
+            combineYRanges(new Range(series.getMinY(), series.getMaxY()), 0);
+            combineXRanges(new Range(series.getMinX(), series.getMaxX()), 0);
         }
     }
 
 
-    public void addSecondAxisSeries(XYSeries series) {
+    public void addSecondAxisSeries(XYSeries series, boolean visible) {
         if (second == null) {
             second = new XYSeriesCollection();
         }
 
         if (series != null) {
-            second.addSeries(series);
+            if (visible) {
+                second.addSeries(series);
+            }
+
+            combineYRanges(new Range(series.getMinY(), series.getMaxY()), 1);
+            combineXRanges(new Range(series.getMinX(), series.getMaxX()), 0);
         }
     }
 
 
-    public void addAnnotations(FLYSAnnotation annotation) {
+    private void combineXRanges(Range range, int index) {
+        Integer key = new Integer(index);
+
+        if (xRanges == null) {
+            xRanges = new HashMap<Integer, Range>();
+            xRanges.put(key, range);
+            return;
+        }
+
+        Range newX = null;
+        Range oldX = xRanges.get(key);
+
+        if (oldX != null) {
+            newX = Range.combine(oldX, range);
+        }
+        else {
+            newX = range;
+        }
+
+        xRanges.put(key, newX);
+    }
+
+
+    private void combineYRanges(Range range, int index) {
+        Integer key = new Integer(index);
+
+        if (yRanges == null) {
+            yRanges = new HashMap<Integer, Range>();
+            yRanges.put(key, range);
+            return;
+        }
+
+        Range newY = null;
+        Range oldY = yRanges.get(key);
+
+        if (oldY != null) {
+            newY = Range.combine(oldY, range);
+        }
+        else {
+            newY = range;
+        }
+
+        yRanges.put(key, newY);
+    }
+
+
+    public void addAnnotations(FLYSAnnotation annotation, boolean visible) {
+        if (!visible) {
+            return;
+        }
+
         if (annotations == null) {
             annotations = new ArrayList<FLYSAnnotation>();
         }
@@ -206,14 +273,14 @@
         Range xrange = getDomainAxisRange();
         Range yrange = getValueAxisRange();
 
-        for (int i = 0, num = plot.getDatasetCount(); i < num; i++) {
-            XYDataset dataset = plot.getDataset(i);
+        logger.debug("XXX: CLIENT X RANGE = " + xrange);
+        logger.debug("XXX: CLIENT Y RANGE = " + yrange);
 
-            if (dataset == null) {
-                continue;
-            }
+        for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) {
+            Range[] ranges = new Range[] {
+                xRanges.get(0),
+                yRanges.get(new Integer(i)) };
 
-            Range[]   ranges  = getRangesForDataset(dataset);
 
             if (i == 0) {
                 ValueAxis xaxis = plot.getDomainAxis();
@@ -226,6 +293,8 @@
                 continue;
             }
 
+            logger.debug("XXX Zoom y axis for index: " + i);
+            logger.debug("XXX    Y MAX RANGE = " + ranges[1]);
             zoomY(plot, yaxis, ranges[1], yrange);
         }
     }
@@ -274,46 +343,18 @@
 
 
     /**
-     * This method extracts the minimum and maximum values for x and y axes.
+     * This method extracts the minimum and maximum values for x and y axes
+     * which are stored in <i>xRanges</i> and <i>yRanges</i>.
      *
-     * @param dataset The dataset that should be observed.
+     * @param index The index of the y-Axis.
      *
      * @return a Range[] as follows: [x-Range, y-Range].
      */
-    public static Range[] getRangesForDataset(XYDataset dataset) {
-        double[] xr = new double[] { Double.MAX_VALUE, -Double.MAX_VALUE };
-        double[] yr = new double[] { Double.MAX_VALUE, -Double.MAX_VALUE };
-
-        if (dataset != null) {
-            int sCount = dataset.getSeriesCount();
-
-            for (int i = 0; i < sCount; i++) {
-                int iCount = dataset.getItemCount(i);
-    
-                for (int j = 0; j < iCount; j++) {
-                    double x = dataset.getX(i, j).doubleValue();
-                    double y = dataset.getY(i, j).doubleValue();
-    
-                    if (!Double.isNaN(x)) {
-                        xr[0] = xr[0] < x ? xr[0] : x;
-                        xr[1] = xr[1] > x ? xr[1] : x;
-                    }
-    
-                    if (!Double.isNaN(y)) {
-                        yr[0] = yr[0] < y ? yr[0] : y;
-                        yr[1] = yr[1] > y ? yr[1] : y;
-                    }
-                }
-            }
-        }
-
-        // this is only required, if there are no items in the dataset.
-        xr[0] = xr[0] < xr[1] ? xr[0] : xr[1];
-        xr[1] = xr[1] > xr[0] ? xr[1] : xr[0];
-        yr[0] = yr[0] < yr[1] ? yr[0] : yr[1];
-        yr[1] = yr[1] > yr[0] ? yr[1] : yr[0];
-
-        return new Range[] {new Range(xr[0], xr[1]), new Range(yr[0], yr[1])};
+    public Range[] getRangesForDataset(int index) {
+        return new Range[] {
+            xRanges.get(new Integer(0)),
+            yRanges.get(new Integer(index))
+        };
     }
 
 

http://dive4elements.wald.intevation.org