# HG changeset patch # User Felix Wolfsteller # Date 1323167167 0 # Node ID 82cefa3f954f55749045bef5a34cecf572e7a98d # Parent 3b08b8aacfb0276041970b8943617711fee310cc Partial fix for flys/issue420 (Mosel/DischargeCurves), do survive empty datasets when calculating axis extents. flys-artifacts/trunk@3359 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 3b08b8aacfb0 -r 82cefa3f954f flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue Dec 06 08:26:24 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue Dec 06 10:26:07 2011 +0000 @@ -1,3 +1,15 @@ +2011-12-06 Felix Wolfsteller + + Partial fix for flys/issue420 (Berechnete Abflusskurve: Kein Diagramm für + Mosel). Protect axis extent calculation from empty or invalid + datasets. + + * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: + (includeRange, includeYRange): Renamed, updated callers. + (includeYRange): Protect from merging extent with NaNs. + (debugDatasets): Be more verbose on the datasets. + (zoom): Doc. + 2011-12-06 Felix Wolfsteller Fix flys/issue423 (Diagramm: Hauptwerte bei Abflusskurve am Pegel diff -r 3b08b8aacfb0 -r 82cefa3f954f flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Tue Dec 06 08:26:24 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Tue Dec 06 10:26:07 2011 +0000 @@ -88,11 +88,16 @@ /** Add a dataset, include its range. */ public void addDataset(XYSeries dataset) { this.datasets.add(new XYSeriesCollection(dataset)); - includeRange(dataset); + includeYRange(dataset); } /** Adjust range to include given dataset. */ - public void includeRange(XYSeries dataset) { + public void includeYRange(XYSeries dataset) { + // Avoid merging NaNs, as they take min/max place forever. + if (Double.isNaN(dataset.getMinY()) || + Double.isNaN(dataset.getMaxY())) { + return; + } mergeRanges(new Range(dataset.getMinY(), dataset.getMaxY())); } @@ -258,6 +263,11 @@ continue; } logger.debug("Dataset #" + i + ":" + plot.getDataset(i)); + XYSeriesCollection series = (XYSeriesCollection) plot.getDataset(i); + logger.debug("X-Extend of Dataset: " + series.getSeries(0).getMinX() + + " " + series.getSeries(0).getMaxX()); + logger.debug("Y-Extend of Dataset: " + series.getSeries(0).getMinY() + + " " + series.getSeries(0).getMaxY()); } } @@ -335,13 +345,16 @@ datasets.put(index, axisDataset); } + logger.debug("Series-extent x " + series.getMinX() + " : " + series.getMaxX() + + " extend y " + series.getMinY() + " : " + series.getMaxY()); + if (visible) { axisDataset.addDataset(series); } else { // Do this also when not visible to have axis scaled by default such // that every data-point could be seen (except for annotations). - axisDataset.includeRange(series); + axisDataset.includeYRange(series); } combineXRanges(new Range(series.getMinX(), series.getMaxX()), 0); @@ -491,10 +504,10 @@ /** * Zooms the x axis to the range specified in the attribute document. * - * @param plot The XYPlot. - * @param axis The axis the shoud be modified. + * @param plot The XYPlot. + * @param axis The axis the shoud be modified. * @param range The whole range specified by a dataset. - * @param x A user defined range (null permitted). + * @param x A user defined range (null permitted). * * @return true, if a zoom range was specified, otherwise false. */