# HG changeset patch # User "Tom Gottfried " # Date 1411748625 -7200 # Node ID ac7cb15e194684b70f50f540ffabca057e9b3c33 # Parent f5461750e5c7ec97e044aa8bb65d5183b3a9859f Scale second W-axis in cm according to first axis, which is expanded relative to the data, and set bounds for zooming purposes (plus a bit of cleanup in DiagramGenerator). diff -r f5461750e5c7 -r ac7cb15e1946 artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java Fri Sep 26 17:22:51 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java Fri Sep 26 18:23:45 2014 +0200 @@ -671,7 +671,7 @@ xAxis.setRange(fixedXRange); } else { - zoomX(plot, xAxis, getXBounds(0), xrange); + zoom(plot, xAxis, getXBounds(0), xrange); } for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) { @@ -693,7 +693,7 @@ } log.debug("Prepare zoom settings for y axis at index: " + i); - zoomY(plot, yaxis, getYBounds(Integer.valueOf(i)), yrange); + zoom(plot, yaxis, getYBounds(Integer.valueOf(i)), yrange); } } @@ -764,23 +764,13 @@ } - protected boolean zoomX(XYPlot plot, ValueAxis axis, Bounds bounds, Range x) { - return zoom(plot, axis, bounds, x); - } - - - protected boolean zoomY(XYPlot plot, ValueAxis axis, Bounds bounds, Range x) { - return zoom(plot, axis, bounds, x); - } - - /** - * Zooms the x axis to the range specified in the attribute document. + * Zooms the 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 that should be modified. * @param bounds 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. */ diff -r f5461750e5c7 -r ac7cb15e1946 artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java Fri Sep 26 17:22:51 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java Fri Sep 26 18:23:45 2014 +0200 @@ -12,6 +12,7 @@ import org.apache.log4j.Logger; 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.plot.XYPlot; import org.jfree.data.Range; @@ -53,13 +54,19 @@ return; } - Range range = inCm(data.getRange(), pnpValue); + Range axisRange = inCm( + plot.getRangeAxis(wAxisIndex).getRange(), + pnpValue + ); + Range dataRange = inCm(data.getRange(), pnpValue); // Do we have an index for W in cm? NumberAxis wInCmAxis = createWinCMAxis(wAxisIndex); - wInCmAxis.setRange(range.getLowerBound(), range.getUpperBound()); + wInCmAxis.setRange(axisRange); - plot.setRangeAxis(plot.getRangeAxisCount(), wInCmAxis); + int wInCmAxisIndex = plot.getRangeAxisCount(); + plot.setRangeAxis(wInCmAxisIndex, wInCmAxis); + combineYBounds(new DoubleBounds(dataRange), wInCmAxisIndex); } private static Range inCm(Range r, double pnpValue) { diff -r f5461750e5c7 -r ac7cb15e1946 artifacts/src/main/java/org/dive4elements/river/jfree/DoubleBounds.java --- a/artifacts/src/main/java/org/dive4elements/river/jfree/DoubleBounds.java Fri Sep 26 17:22:51 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/jfree/DoubleBounds.java Fri Sep 26 18:23:45 2014 +0200 @@ -32,6 +32,10 @@ this.upper = Math.max(lower, upper); } + public DoubleBounds(Range range) { + this.lower = range.getLowerBound(); + this.upper = range.getUpperBound(); + } @Override public Number getLower() {