Mercurial > dive4elements > river
changeset 8338:ac7cb15e1946
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).
author | "Tom Gottfried <tom@intevation.de>" |
---|---|
date | Fri, 26 Sep 2014 18:23:45 +0200 |
parents | f5461750e5c7 |
children | d6e71158222a |
files | artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java artifacts/src/main/java/org/dive4elements/river/jfree/DoubleBounds.java |
diffstat | 3 files changed, 20 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- 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. */
--- 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) {
--- 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() {