Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 1958:82cefa3f954f
Partial fix for flys/issue420 (Mosel/DischargeCurves), do survive empty datasets when calculating axis extents.
flys-artifacts/trunk@3359 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 06 Dec 2011 10:26:07 +0000 |
parents | 65f9d707caff |
children | eace020067da |
comparison
equal
deleted
inserted
replaced
1957:3b08b8aacfb0 | 1958:82cefa3f954f |
---|---|
86 } | 86 } |
87 | 87 |
88 /** Add a dataset, include its range. */ | 88 /** Add a dataset, include its range. */ |
89 public void addDataset(XYSeries dataset) { | 89 public void addDataset(XYSeries dataset) { |
90 this.datasets.add(new XYSeriesCollection(dataset)); | 90 this.datasets.add(new XYSeriesCollection(dataset)); |
91 includeRange(dataset); | 91 includeYRange(dataset); |
92 } | 92 } |
93 | 93 |
94 /** Adjust range to include given dataset. */ | 94 /** Adjust range to include given dataset. */ |
95 public void includeRange(XYSeries dataset) { | 95 public void includeYRange(XYSeries dataset) { |
96 // Avoid merging NaNs, as they take min/max place forever. | |
97 if (Double.isNaN(dataset.getMinY()) || | |
98 Double.isNaN(dataset.getMaxY())) { | |
99 return; | |
100 } | |
96 mergeRanges(new Range(dataset.getMinY(), dataset.getMaxY())); | 101 mergeRanges(new Range(dataset.getMinY(), dataset.getMaxY())); |
97 } | 102 } |
98 | 103 |
99 /** True if no datasets given. */ | 104 /** True if no datasets given. */ |
100 public boolean isEmpty() { | 105 public boolean isEmpty() { |
256 if (plot.getDataset(i) == null) { | 261 if (plot.getDataset(i) == null) { |
257 logger.debug("Dataset #" + i + " is null"); | 262 logger.debug("Dataset #" + i + " is null"); |
258 continue; | 263 continue; |
259 } | 264 } |
260 logger.debug("Dataset #" + i + ":" + plot.getDataset(i)); | 265 logger.debug("Dataset #" + i + ":" + plot.getDataset(i)); |
266 XYSeriesCollection series = (XYSeriesCollection) plot.getDataset(i); | |
267 logger.debug("X-Extend of Dataset: " + series.getSeries(0).getMinX() | |
268 + " " + series.getSeries(0).getMaxX()); | |
269 logger.debug("Y-Extend of Dataset: " + series.getSeries(0).getMinY() | |
270 + " " + series.getSeries(0).getMaxY()); | |
261 } | 271 } |
262 } | 272 } |
263 | 273 |
264 | 274 |
265 /** | 275 /** |
333 if (axisDataset == null) { | 343 if (axisDataset == null) { |
334 axisDataset = new AxisDataset(index); | 344 axisDataset = new AxisDataset(index); |
335 datasets.put(index, axisDataset); | 345 datasets.put(index, axisDataset); |
336 } | 346 } |
337 | 347 |
348 logger.debug("Series-extent x " + series.getMinX() + " : " + series.getMaxX() | |
349 + " extend y " + series.getMinY() + " : " + series.getMaxY()); | |
350 | |
338 if (visible) { | 351 if (visible) { |
339 axisDataset.addDataset(series); | 352 axisDataset.addDataset(series); |
340 } | 353 } |
341 else { | 354 else { |
342 // Do this also when not visible to have axis scaled by default such | 355 // Do this also when not visible to have axis scaled by default such |
343 // that every data-point could be seen (except for annotations). | 356 // that every data-point could be seen (except for annotations). |
344 axisDataset.includeRange(series); | 357 axisDataset.includeYRange(series); |
345 } | 358 } |
346 | 359 |
347 combineXRanges(new Range(series.getMinX(), series.getMaxX()), 0); | 360 combineXRanges(new Range(series.getMinX(), series.getMaxX()), 0); |
348 } | 361 } |
349 | 362 |
489 | 502 |
490 | 503 |
491 /** | 504 /** |
492 * Zooms the x axis to the range specified in the attribute document. | 505 * Zooms the x axis to the range specified in the attribute document. |
493 * | 506 * |
494 * @param plot The XYPlot. | 507 * @param plot The XYPlot. |
495 * @param axis The axis the shoud be modified. | 508 * @param axis The axis the shoud be modified. |
496 * @param range The whole range specified by a dataset. | 509 * @param range The whole range specified by a dataset. |
497 * @param x A user defined range (null permitted). | 510 * @param x A user defined range (null permitted). |
498 * | 511 * |
499 * @return true, if a zoom range was specified, otherwise false. | 512 * @return true, if a zoom range was specified, otherwise false. |
500 */ | 513 */ |
501 protected boolean zoom(XYPlot plot, ValueAxis axis, Range range, Range x) { | 514 protected boolean zoom(XYPlot plot, ValueAxis axis, Range range, Range x) { |
502 | 515 |