# HG changeset patch # User Tom Gottfried # Date 1430930817 -7200 # Node ID e6d0fc817e20a084ccb9e680937dacdc826974aa # Parent afa2096a1f156026c34ac21cd866a4f1bbee92c1 (issue1798) Handle the case when there are no data in the diagram. diff -r afa2096a1f15 -r e6d0fc817e20 artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java Wed May 06 17:59:38 2015 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java Wed May 06 18:46:57 2015 +0200 @@ -14,7 +14,9 @@ import org.dive4elements.river.exports.injector.InjectorConstants; import org.dive4elements.river.jfree.AxisDataset; import org.dive4elements.river.jfree.DoubleBounds; + import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; @@ -109,19 +111,24 @@ @Override protected void autoZoom(XYPlot plot) { super.autoZoom(plot); - IdentifiableNumberAxis idA = (IdentifiableNumberAxis) plot.getRangeAxis(wAxisIndex); - Range fixedRange = getRangeForAxisFromSettings(idA.getId()); - if (fixedRange == null) { - return; + + ValueAxis wAxis = plot.getRangeAxis(wAxisIndex); + if (wAxis instanceof IdentifiableNumberAxis) { + IdentifiableNumberAxis idA = (IdentifiableNumberAxis)wAxis; + Range fixedRange = getRangeForAxisFromSettings(idA.getId()); + if (fixedRange == null) { + return; + } + + log.debug("Adjusting helper centimeter axis to fixed range."); + Range adjustedRange = inCm( + fixedRange, + pnpValue + ); + IdentifiableNumberAxis wInCmAxis= + (IdentifiableNumberAxis) plot.getRangeAxis(wInCmAxisIndex); + wInCmAxis.setRange(adjustedRange); } - log.debug("Adjusting helper centimeter axis to fixed range."); - Range adjustedRange = inCm( - fixedRange, - pnpValue - ); - IdentifiableNumberAxis wInCmAxis= - (IdentifiableNumberAxis) plot.getRangeAxis(wInCmAxisIndex); - wInCmAxis.setRange(adjustedRange); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :