changeset 7701:e47b1ea5baf4

(issue1579) Add Hack to not syncronize and add second axis in static GaugeDischarge
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 16 Dec 2013 19:09:50 +0100
parents 9211f8cafe8a
children c6f89989de84
files artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java	Mon Dec 16 19:08:39 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java	Mon Dec 16 19:09:50 2013 +0100
@@ -27,6 +27,9 @@
 import org.dive4elements.river.themes.ThemeDocument;
 import org.dive4elements.river.utils.RiverUtils;
 
+import org.dive4elements.artifactdatabase.state.State;
+import org.dive4elements.river.artifacts.GaugeDischargeCurveArtifact;
+
 import org.apache.log4j.Logger;
 import org.jfree.chart.annotations.XYTextAnnotation;
 import org.jfree.chart.axis.ValueAxis;
@@ -107,6 +110,20 @@
     @Override
     protected void adjustAxes(XYPlot plot) {
         super.adjustAxes(plot);
+        // XXX Hacking around that there were two axes shown in official Gauge
+        // Discharge, the one from the WINFO module.
+        // This should be made unecessary in a Q Diagram refactoring with
+        // decent inheritance.
+        if (getMaster() instanceof GaugeDischargeCurveArtifact) {
+            GaugeDischargeCurveArtifact myMaster =
+                (GaugeDischargeCurveArtifact) getMaster();
+            State state = myMaster.getCurrentState(context);
+            if (myMaster.STATIC_STATE_NAME.equals(state.getID())) {
+                return;
+            }
+        }
+        // End Hack
+
         if (getCurrentGaugeDatum() != 0d) {
             // Show the W[*m] axis even if there is no data.
             plot.setRangeAxis(1, createYAxis(YAXIS.W.idx));
@@ -120,6 +137,11 @@
         Bounds boundsInMGauge = getYBounds(YAXIS.W.idx);
         Bounds boundsInCM = getYBounds(YAXIS.WCm.idx);
 
+        if (boundsInMGauge == null || boundsInCM == null) {
+            // One axis does not exist. Nothing to sync
+            return;
+        }
+
         // XXX Q-Symetry: I am assuming here that there can only
         // be a fixed Range for WinM as this is currently the only
         // thing that is configureable.

http://dive4elements.wald.intevation.org