# HG changeset patch # User Felix Wolfsteller # Date 1317134238 0 # Node ID 73794985a899bddf402fcd310a0cfcc4e1d0e1e6 # Parent 46a2a5dc98b7e50b83082b20c22755e86df9fd2b Enable auto-scaling axis for waterlevels in WDifference-plots. flys-artifacts/trunk@2845 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 46a2a5dc98b7 -r 73794985a899 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue Sep 27 14:03:06 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue Sep 27 14:37:18 2011 +0000 @@ -1,3 +1,15 @@ +2011-09-27 Felix Wolfsteller + + Enable "auto-scaling" axis for waterlevels in WDifference-plots. + + * src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java: + (createSecondaryAxis, zoomY): Refactored to allow modification in + siblings. + + * src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java: + (createSecondaryAxisRange): Override to achieve expected behavior. + Also adjusted label. + 2011-09-27 Felix Wolfsteller In W-Difference Calculation, respect indices of selected facets. diff -r 46a2a5dc98b7 -r 73794985a899 flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Tue Sep 27 14:03:06 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Tue Sep 27 14:37:18 2011 +0000 @@ -177,14 +177,24 @@ /** - * This method overrides the XYChartGenerators zoomY method to include the 0 - * value on the Q axis. + * Create a range that includes 0 (for the Q axis). + * @param range range with which to look up upper bound. + * @return range with 0 included. + */ + protected Range createSecondAxisRange(Range range) { + return new Range(0d, range.getUpperBound()); + } + + + /** + * This method overrides the XYChartGenerators zoomY method to be able to + * modify the range of the Q axis (here, it shall include 0). */ @Override protected boolean zoomY(XYPlot plot, ValueAxis axis, Range range, Range x) { if (plot.getRangeAxisIndex(axis) == 1) { - // we want the Q axis to start at 0 if no zooming has been done - range = new Range(0d, range.getUpperBound()); + // We want the Q axis to start at 0 if no zooming has been done. + range = createSecondAxisRange(range); } return super.zoomY(plot, axis, range, x); diff -r 46a2a5dc98b7 -r 73794985a899 flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java Tue Sep 27 14:03:06 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java Tue Sep 27 14:37:18 2011 +0000 @@ -6,6 +6,7 @@ import org.jfree.chart.plot.XYPlot; import org.jfree.chart.title.TextTitle; import org.jfree.data.xy.XYSeries; +import org.jfree.data.Range; import org.w3c.dom.Document; @@ -51,6 +52,7 @@ public static final String I18N_CHART_TITLE_DEFAULT = "W-Differenzen"; public static final String I18N_XAXIS_LABEL_DEFAULT = "km"; public static final String I18N_YAXIS_LABEL_DEFAULT = "W [m]"; + public static final String I18N_2YAXIS_LABEL_DEFAULT = "W [NN + m]"; /** @@ -180,7 +182,17 @@ } } + /** + * Disable Longitudinals behaviour to include "0" in the Q axis. + * @param range range with which to look up upper bound. + * @return range to be used for "auto-scaling" axis. + */ + @Override + protected Range createSecondAxisRange(Range range) { + return new Range(range.getLowerBound(), range.getUpperBound()); + } + /** * */