comparison artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java @ 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 fa4fbd66e752
children d3a4b0d5bcd8
comparison
equal deleted inserted replaced
7700:9211f8cafe8a 7701:e47b1ea5baf4
25 import org.dive4elements.river.model.Gauge; 25 import org.dive4elements.river.model.Gauge;
26 import org.dive4elements.river.model.River; 26 import org.dive4elements.river.model.River;
27 import org.dive4elements.river.themes.ThemeDocument; 27 import org.dive4elements.river.themes.ThemeDocument;
28 import org.dive4elements.river.utils.RiverUtils; 28 import org.dive4elements.river.utils.RiverUtils;
29 29
30 import org.dive4elements.artifactdatabase.state.State;
31 import org.dive4elements.river.artifacts.GaugeDischargeCurveArtifact;
32
30 import org.apache.log4j.Logger; 33 import org.apache.log4j.Logger;
31 import org.jfree.chart.annotations.XYTextAnnotation; 34 import org.jfree.chart.annotations.XYTextAnnotation;
32 import org.jfree.chart.axis.ValueAxis; 35 import org.jfree.chart.axis.ValueAxis;
33 import org.jfree.chart.plot.XYPlot; 36 import org.jfree.chart.plot.XYPlot;
34 import org.jfree.data.Range; 37 import org.jfree.data.Range;
105 108
106 /** Overriden to show second axis also if no visible data present. */ 109 /** Overriden to show second axis also if no visible data present. */
107 @Override 110 @Override
108 protected void adjustAxes(XYPlot plot) { 111 protected void adjustAxes(XYPlot plot) {
109 super.adjustAxes(plot); 112 super.adjustAxes(plot);
113 // XXX Hacking around that there were two axes shown in official Gauge
114 // Discharge, the one from the WINFO module.
115 // This should be made unecessary in a Q Diagram refactoring with
116 // decent inheritance.
117 if (getMaster() instanceof GaugeDischargeCurveArtifact) {
118 GaugeDischargeCurveArtifact myMaster =
119 (GaugeDischargeCurveArtifact) getMaster();
120 State state = myMaster.getCurrentState(context);
121 if (myMaster.STATIC_STATE_NAME.equals(state.getID())) {
122 return;
123 }
124 }
125 // End Hack
126
110 if (getCurrentGaugeDatum() != 0d) { 127 if (getCurrentGaugeDatum() != 0d) {
111 // Show the W[*m] axis even if there is no data. 128 // Show the W[*m] axis even if there is no data.
112 plot.setRangeAxis(1, createYAxis(YAXIS.W.idx)); 129 plot.setRangeAxis(1, createYAxis(YAXIS.W.idx));
113 syncWAxisRanges(); 130 syncWAxisRanges();
114 } 131 }
117 protected void syncWAxisRanges() { 134 protected void syncWAxisRanges() {
118 // Syncronizes the ranges of both W Axes to make sure 135 // Syncronizes the ranges of both W Axes to make sure
119 // that the Data matches for both axes. 136 // that the Data matches for both axes.
120 Bounds boundsInMGauge = getYBounds(YAXIS.W.idx); 137 Bounds boundsInMGauge = getYBounds(YAXIS.W.idx);
121 Bounds boundsInCM = getYBounds(YAXIS.WCm.idx); 138 Bounds boundsInCM = getYBounds(YAXIS.WCm.idx);
139
140 if (boundsInMGauge == null || boundsInCM == null) {
141 // One axis does not exist. Nothing to sync
142 return;
143 }
122 144
123 // XXX Q-Symetry: I am assuming here that there can only 145 // XXX Q-Symetry: I am assuming here that there can only
124 // be a fixed Range for WinM as this is currently the only 146 // be a fixed Range for WinM as this is currently the only
125 // thing that is configureable. 147 // thing that is configureable.
126 Range fixedWinMRange = getRangeForAxisFromSettings( 148 Range fixedWinMRange = getRangeForAxisFromSettings(

http://dive4elements.wald.intevation.org