Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java @ 7691:fa4fbd66e752
(issue1579) Fix axes syncronisation at Gauges
The SyncNumberAxis was completely broken. It only synced
in one direction and even that did not work correctly when
data was added to the axis (and the syncAxis rescaled but
forgot the old axis) then there were lots of ways to bypass
that scaling. And i also think the trans calculation was wrong.
It has been replaced by a "mostly" simple method to just keep
the W in M and W in CM+Datum axes in sync. I say "Mostly" because
it had to deal with the Bounds interface.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 13 Dec 2013 19:03:00 +0100 |
parents | 2fed93751ecb |
children | e47b1ea5baf4 |
comparison
equal
deleted
inserted
replaced
7690:4bbd222e6b7f | 7691:fa4fbd66e752 |
---|---|
16 import org.dive4elements.river.artifacts.model.FacetTypes; | 16 import org.dive4elements.river.artifacts.model.FacetTypes; |
17 import org.dive4elements.river.artifacts.model.WQKms; | 17 import org.dive4elements.river.artifacts.model.WQKms; |
18 import org.dive4elements.river.exports.process.DischargeProcessor; | 18 import org.dive4elements.river.exports.process.DischargeProcessor; |
19 import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation; | 19 import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation; |
20 import org.dive4elements.river.jfree.Bounds; | 20 import org.dive4elements.river.jfree.Bounds; |
21 import org.dive4elements.river.jfree.DoubleBounds; | |
21 import org.dive4elements.river.jfree.RiverAnnotation; | 22 import org.dive4elements.river.jfree.RiverAnnotation; |
22 import org.dive4elements.river.jfree.StickyAxisAnnotation; | 23 import org.dive4elements.river.jfree.StickyAxisAnnotation; |
23 import org.dive4elements.river.jfree.StyledXYSeries; | 24 import org.dive4elements.river.jfree.StyledXYSeries; |
24 import org.dive4elements.river.model.Gauge; | 25 import org.dive4elements.river.model.Gauge; |
25 import org.dive4elements.river.model.River; | 26 import org.dive4elements.river.model.River; |
107 protected void adjustAxes(XYPlot plot) { | 108 protected void adjustAxes(XYPlot plot) { |
108 super.adjustAxes(plot); | 109 super.adjustAxes(plot); |
109 if (getCurrentGaugeDatum() != 0d) { | 110 if (getCurrentGaugeDatum() != 0d) { |
110 // Show the W[*m] axis even if there is no data. | 111 // Show the W[*m] axis even if there is no data. |
111 plot.setRangeAxis(1, createYAxis(YAXIS.W.idx)); | 112 plot.setRangeAxis(1, createYAxis(YAXIS.W.idx)); |
112 } | 113 syncWAxisRanges(); |
113 } | 114 } |
114 | 115 } |
116 | |
117 protected void syncWAxisRanges() { | |
118 // Syncronizes the ranges of both W Axes to make sure | |
119 // that the Data matches for both axes. | |
120 Bounds boundsInMGauge = getYBounds(YAXIS.W.idx); | |
121 Bounds boundsInCM = getYBounds(YAXIS.WCm.idx); | |
122 | |
123 // XXX Q-Symetry: I am assuming here that there can only | |
124 // be a fixed Range for WinM as this is currently the only | |
125 // thing that is configureable. | |
126 Range fixedWinMRange = getRangeForAxisFromSettings( | |
127 getYAxisWalker().getId(YAXIS.W.idx)); | |
128 | |
129 // The combination of Range and Bounds is crazy.. | |
130 if (fixedWinMRange != null) { | |
131 boundsInMGauge = new DoubleBounds(fixedWinMRange.getLowerBound(), | |
132 fixedWinMRange.getUpperBound()); | |
133 } | |
134 | |
135 logger.debug("Syncing Axis Bounds. Bounds W: " + boundsInMGauge.toString() + | |
136 " Bounds Wcm: " + boundsInCM.toString()); | |
137 | |
138 double datum = getCurrentGaugeDatum(); | |
139 | |
140 // Convert boundsInMGauge to Datum+cm | |
141 double convertedLower = ((Double)boundsInMGauge.getLower() - datum) * 100; | |
142 double convertedUpper = ((Double)boundsInMGauge.getUpper() - datum) * 100; | |
143 Bounds convertedBounds = new DoubleBounds(convertedLower, convertedUpper); | |
144 | |
145 // Now combine both Ranges | |
146 boundsInCM = boundsInCM.combine(convertedBounds); | |
147 | |
148 // Recalculate absolute bounds | |
149 boundsInMGauge = new DoubleBounds((Double)boundsInCM.getLower() / 100d + datum, | |
150 (Double)boundsInCM.getUpper() / 100d + datum); | |
151 | |
152 // Set the new combined bounds | |
153 setYBounds(YAXIS.W.idx, boundsInMGauge); | |
154 setYBounds(YAXIS.WCm.idx, boundsInCM); | |
155 logger.debug("Synced Bounds W: " + boundsInMGauge.toString() + | |
156 " Bounds Wcm: " + boundsInCM.toString()); | |
157 } | |
115 | 158 |
116 public DischargeCurveGenerator() { | 159 public DischargeCurveGenerator() { |
117 super(); | 160 super(); |
118 } | 161 } |
119 | 162 |