changeset 8738:e6d0fc817e20

(issue1798) Handle the case when there are no data in the diagram.
author Tom Gottfried <tom@intevation.de>
date Wed, 06 May 2015 18:46:57 +0200
parents afa2096a1f15
children f1250a55acd6
files artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java
diffstat 1 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java	Wed May 06 17:59:38 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java	Wed May 06 18:46:57 2015 +0200
@@ -14,7 +14,9 @@
 import org.dive4elements.river.exports.injector.InjectorConstants;
 import org.dive4elements.river.jfree.AxisDataset;
 import org.dive4elements.river.jfree.DoubleBounds;
+
 import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.axis.ValueAxis;
 import org.jfree.chart.plot.XYPlot;
 import org.jfree.data.Range;
 
@@ -109,19 +111,24 @@
     @Override
     protected void autoZoom(XYPlot plot) {
         super.autoZoom(plot);
-        IdentifiableNumberAxis idA = (IdentifiableNumberAxis) plot.getRangeAxis(wAxisIndex);
-        Range fixedRange = getRangeForAxisFromSettings(idA.getId());
-        if (fixedRange == null) {
-            return;
+
+        ValueAxis wAxis = plot.getRangeAxis(wAxisIndex);
+        if (wAxis instanceof IdentifiableNumberAxis) {
+            IdentifiableNumberAxis idA = (IdentifiableNumberAxis)wAxis;
+            Range fixedRange = getRangeForAxisFromSettings(idA.getId());
+            if (fixedRange == null) {
+                return;
+            }
+
+            log.debug("Adjusting helper centimeter axis to fixed range.");
+            Range adjustedRange = inCm(
+                fixedRange,
+                pnpValue
+            );
+            IdentifiableNumberAxis wInCmAxis=
+                (IdentifiableNumberAxis) plot.getRangeAxis(wInCmAxisIndex);
+            wInCmAxis.setRange(adjustedRange);
         }
-        log.debug("Adjusting helper centimeter axis to fixed range.");
-        Range adjustedRange = inCm(
-            fixedRange,
-            pnpValue
-        );
-        IdentifiableNumberAxis wInCmAxis=
-            (IdentifiableNumberAxis) plot.getRangeAxis(wInCmAxisIndex);
-        wInCmAxis.setRange(adjustedRange);
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org