[PATCH 41 of 45] (issue1798) Adjust WinCM according to W in NHN axis on explicit zoom
Wald Commits
scm-commit at wald.intevation.org
Tue Mar 10 17:06:09 CET 2015
# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1425060445 -3600
# Node ID bc803f4b6784b1634443eeafe497c0ce55cb1b58
# Parent 1655588ed479dc3e637c8d9d69a4ff680a28d051
(issue1798) Adjust WinCM according to W in NHN axis on explicit zoom
diff -r 1655588ed479 -r bc803f4b6784 artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java Thu Feb 26 15:53:28 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeGenerator.java Fri Feb 27 19:07:25 2015 +0100
@@ -26,6 +26,10 @@
private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.cm.label";
+ private int wAxisIndex;
+ private int wInCmAxisIndex;
+ double pnpValue;
+
public DischargeGenerator() {
}
@@ -38,9 +42,9 @@
return;
}
- double pnpValue = ((Number)pnp).doubleValue();
+ pnpValue = ((Number)pnp).doubleValue();
- int wAxisIndex = diagramAttributes.getAxisIndex("W");
+ wAxisIndex = diagramAttributes.getAxisIndex("W");
if (wAxisIndex == -1) {
log.warn("No W axis found.");
return;
@@ -67,7 +71,7 @@
NumberAxis wInCmAxis = createWinCMAxis(wAxisIndex);
wInCmAxis.setRange(axisRange);
- int wInCmAxisIndex = plot.getRangeAxisCount();
+ wInCmAxisIndex = plot.getRangeAxisCount();
plot.setRangeAxis(wInCmAxisIndex, wInCmAxis);
combineYBounds(new DoubleBounds(dataRange), wInCmAxisIndex);
}
@@ -100,5 +104,24 @@
return axis;
}
+
+ /** We need to override this to keep both axis synced. */
+ @Override
+ protected void autoZoom(XYPlot plot) {
+ super.autoZoom(plot);
+ IdentifiableNumberAxis idA = (IdentifiableNumberAxis) plot.getRangeAxis(wAxisIndex);
+ 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);
+ }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
More information about the Dive4Elements-commits
mailing list