Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java @ 745:f959faaa7c4a
Fix for flys/issue150: Invert the x axis if its guessed that water is increasing.
flys-artifacts/trunk@2247 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 27 Jun 2011 09:42:21 +0000 |
parents | 56d70e546800 |
children | 7ca4a287cd0e |
comparison
equal
deleted
inserted
replaced
744:b385577bcaca | 745:f959faaa7c4a |
---|---|
17 import org.w3c.dom.Document; | 17 import org.w3c.dom.Document; |
18 | 18 |
19 import de.intevation.artifacts.Artifact; | 19 import de.intevation.artifacts.Artifact; |
20 | 20 |
21 import de.intevation.artifactdatabase.state.Facet; | 21 import de.intevation.artifactdatabase.state.Facet; |
22 | |
23 import de.intevation.flys.model.River; | |
24 | 22 |
25 import de.intevation.flys.artifacts.FLYSArtifact; | 23 import de.intevation.flys.artifacts.FLYSArtifact; |
26 | 24 |
27 import de.intevation.flys.artifacts.model.FacetTypes; | 25 import de.intevation.flys.artifacts.model.FacetTypes; |
28 import de.intevation.flys.artifacts.model.WQKms; | 26 import de.intevation.flys.artifacts.model.WQKms; |
65 protected XYSeriesCollection w; | 63 protected XYSeriesCollection w; |
66 | 64 |
67 /** The storage for the Q series to be drawn in this chart.*/ | 65 /** The storage for the Q series to be drawn in this chart.*/ |
68 protected XYSeriesCollection q; | 66 protected XYSeriesCollection q; |
69 | 67 |
68 protected boolean inverted; | |
69 | |
70 | 70 |
71 public LongitudinalSectionGenerator() { | 71 public LongitudinalSectionGenerator() { |
72 super(); | 72 super(); |
73 | 73 |
74 this.w = new XYSeriesCollection(); | 74 this.w = new XYSeriesCollection(); |
78 | 78 |
79 protected String getChartTitle() { | 79 protected String getChartTitle() { |
80 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); | 80 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); |
81 } | 81 } |
82 | 82 |
83 public boolean isInverted() { | |
84 return inverted; | |
85 } | |
86 | |
87 public void setInverted(boolean inverted) { | |
88 this.inverted = inverted; | |
89 } | |
83 | 90 |
84 @Override | 91 @Override |
85 protected void addSubtitles(JFreeChart chart) { | 92 protected void addSubtitles(JFreeChart chart) { |
86 double[] dist = getRange(); | 93 double[] dist = getRange(); |
87 | 94 |
180 * not inverted, otherwise it is. | 187 * not inverted, otherwise it is. |
181 * | 188 * |
182 * @param xaxis The domain axis. | 189 * @param xaxis The domain axis. |
183 */ | 190 */ |
184 protected void invertXAxis(ValueAxis xaxis) { | 191 protected void invertXAxis(ValueAxis xaxis) { |
185 FLYSArtifact artifact = (FLYSArtifact) master; | 192 |
186 River river = artifact.getRiver(); | 193 if (inverted) { |
187 | 194 logger.debug("Invert X-Axis."); |
188 boolean up = river.getKmUp(); | |
189 | |
190 if (up) { | |
191 logger.info("Invert X-Axis."); | |
192 xaxis.setInverted(true); | 195 xaxis.setInverted(true); |
193 } | 196 } |
194 } | 197 } |
195 | 198 |
196 | 199 |
248 for (int i = 0; i < size; i++) { | 251 for (int i = 0; i < size; i++) { |
249 series.add(wqkms.getKms(i), wqkms.getW(i)); | 252 series.add(wqkms.getKms(i), wqkms.getW(i)); |
250 } | 253 } |
251 | 254 |
252 w.addSeries(series); | 255 w.addSeries(series); |
256 | |
257 if (wqkms.guessWaterIncreasing()) { | |
258 setInverted(true); | |
259 } | |
253 } | 260 } |
254 | 261 |
255 | 262 |
256 /** | 263 /** |
257 * Process the output for Q facets in a longitudinal section curve. | 264 * Process the output for Q facets in a longitudinal section curve. |
277 for (int i = 0; i < size; i++) { | 284 for (int i = 0; i < size; i++) { |
278 series.add(wqkms.getKms(i), wqkms.getQ(i)); | 285 series.add(wqkms.getKms(i), wqkms.getQ(i)); |
279 } | 286 } |
280 | 287 |
281 q.addSeries(series); | 288 q.addSeries(series); |
289 | |
290 if (wqkms.guessWaterIncreasing()) { | |
291 setInverted(true); | |
292 } | |
282 } | 293 } |
283 | 294 |
284 | 295 |
285 protected String getSeriesName(WQKms wqkms, String mode) { | 296 protected String getSeriesName(WQKms wqkms, String mode) { |
286 String name = wqkms.getName(); | 297 String name = wqkms.getName(); |