Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 3811:1558ef7b0e7b
Picked rev3357, rev3359 and rev3360 from trunk.
flys-artifacts/tags/pre2.6-2011-12-05@3362 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 07 Dec 2011 13:36:36 +0000 |
parents | 65f9d707caff |
children | b7b8e625ec82 |
comparison
equal
deleted
inserted
replaced
3810:b6431052a694 | 3811:1558ef7b0e7b |
---|---|
76 datasets = new ArrayList<XYDataset>(); | 76 datasets = new ArrayList<XYDataset>(); |
77 } | 77 } |
78 | 78 |
79 /** Merge (or create given range with range so far (if any). */ | 79 /** Merge (or create given range with range so far (if any). */ |
80 private void mergeRanges(Range subRange) { | 80 private void mergeRanges(Range subRange) { |
81 // Avoid merging NaNs, as they take min/max place forever. | |
82 if (subRange == null || | |
83 Double.isNaN(subRange.getLowerBound()) || | |
84 Double.isNaN(subRange.getUpperBound())) { | |
85 return; | |
86 } | |
81 if (range == null) { | 87 if (range == null) { |
82 range = subRange; | 88 range = subRange; |
83 return; | 89 return; |
84 } | 90 } |
85 range = Range.combine(range, subRange); | 91 range = Range.combine(range, subRange); |
86 } | 92 } |
87 | 93 |
88 /** Add a dataset, include its range. */ | 94 /** Add a dataset, include its range. */ |
89 public void addDataset(XYSeries dataset) { | 95 public void addDataset(XYSeries dataset) { |
90 this.datasets.add(new XYSeriesCollection(dataset)); | 96 this.datasets.add(new XYSeriesCollection(dataset)); |
91 includeRange(dataset); | 97 includeYRange(dataset); |
92 } | 98 } |
93 | 99 |
94 /** Adjust range to include given dataset. */ | 100 /** Adjust range to include given dataset. */ |
95 public void includeRange(XYSeries dataset) { | 101 public void includeYRange(XYSeries dataset) { |
96 mergeRanges(new Range(dataset.getMinY(), dataset.getMaxY())); | 102 mergeRanges(new Range(dataset.getMinY(), dataset.getMaxY())); |
97 } | 103 } |
98 | 104 |
99 /** True if no datasets given. */ | 105 /** True if no datasets given. */ |
100 public boolean isEmpty() { | 106 public boolean isEmpty() { |
256 if (plot.getDataset(i) == null) { | 262 if (plot.getDataset(i) == null) { |
257 logger.debug("Dataset #" + i + " is null"); | 263 logger.debug("Dataset #" + i + " is null"); |
258 continue; | 264 continue; |
259 } | 265 } |
260 logger.debug("Dataset #" + i + ":" + plot.getDataset(i)); | 266 logger.debug("Dataset #" + i + ":" + plot.getDataset(i)); |
267 XYSeriesCollection series = (XYSeriesCollection) plot.getDataset(i); | |
268 logger.debug("X-Extend of Dataset: " + series.getSeries(0).getMinX() | |
269 + " " + series.getSeries(0).getMaxX()); | |
270 logger.debug("Y-Extend of Dataset: " + series.getSeries(0).getMinY() | |
271 + " " + series.getSeries(0).getMaxY()); | |
261 } | 272 } |
262 } | 273 } |
263 | 274 |
264 | 275 |
265 /** | 276 /** |
333 if (axisDataset == null) { | 344 if (axisDataset == null) { |
334 axisDataset = new AxisDataset(index); | 345 axisDataset = new AxisDataset(index); |
335 datasets.put(index, axisDataset); | 346 datasets.put(index, axisDataset); |
336 } | 347 } |
337 | 348 |
349 logger.debug("Series-extent x " + series.getMinX() + " : " + series.getMaxX() | |
350 + " extend y " + series.getMinY() + " : " + series.getMaxY()); | |
351 | |
338 if (visible) { | 352 if (visible) { |
339 axisDataset.addDataset(series); | 353 axisDataset.addDataset(series); |
340 } | 354 } |
341 else { | 355 else { |
342 // Do this also when not visible to have axis scaled by default such | 356 // Do this also when not visible to have axis scaled by default such |
343 // that every data-point could be seen (except for annotations). | 357 // that every data-point could be seen (except for annotations). |
344 axisDataset.includeRange(series); | 358 axisDataset.includeYRange(series); |
345 } | 359 } |
346 | 360 |
347 combineXRanges(new Range(series.getMinX(), series.getMaxX()), 0); | 361 combineXRanges(new Range(series.getMinX(), series.getMaxX()), 0); |
348 } | 362 } |
349 | 363 |
352 * Effect: extend range of x axis to include given limits. | 366 * Effect: extend range of x axis to include given limits. |
353 * @param range the given ("minimal") range. | 367 * @param range the given ("minimal") range. |
354 * @param index index of axis to be merged. | 368 * @param index index of axis to be merged. |
355 */ | 369 */ |
356 private void combineXRanges(Range range, int index) { | 370 private void combineXRanges(Range range, int index) { |
371 | |
372 if (range == null | |
373 || Double.isNaN(range.getLowerBound()) | |
374 || Double.isNaN(range.getUpperBound())) { | |
375 return; | |
376 } | |
357 | 377 |
358 Range old = xRanges.get(index); | 378 Range old = xRanges.get(index); |
359 | 379 |
360 if (old != null) { | 380 if (old != null) { |
361 range = Range.combine(old, range); | 381 range = Range.combine(old, range); |
489 | 509 |
490 | 510 |
491 /** | 511 /** |
492 * Zooms the x axis to the range specified in the attribute document. | 512 * Zooms the x axis to the range specified in the attribute document. |
493 * | 513 * |
494 * @param plot The XYPlot. | 514 * @param plot The XYPlot. |
495 * @param axis The axis the shoud be modified. | 515 * @param axis The axis the shoud be modified. |
496 * @param range The whole range specified by a dataset. | 516 * @param range The whole range specified by a dataset. |
497 * @param x A user defined range (null permitted). | 517 * @param x A user defined range (null permitted). |
498 * | 518 * |
499 * @return true, if a zoom range was specified, otherwise false. | 519 * @return true, if a zoom range was specified, otherwise false. |
500 */ | 520 */ |
501 protected boolean zoom(XYPlot plot, ValueAxis axis, Range range, Range x) { | 521 protected boolean zoom(XYPlot plot, ValueAxis axis, Range range, Range x) { |
502 | 522 |