# HG changeset patch # User Felix Wolfsteller # Date 1372257943 -7200 # Node ID 192fbd23d97fbd7b368b404a2153a2148b00a1f8 # Parent 3681ae5dcfd4e8b7e3f3d4301819c30a749e5301 Moved code from ComputedDischargeCurveGenerator to DischargeCurveGenerator. diff -r 3681ae5dcfd4 -r 192fbd23d97f artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveGenerator.java Wed Jun 26 16:44:30 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveGenerator.java Wed Jun 26 16:45:43 2013 +0200 @@ -90,19 +90,6 @@ } - /** - * Returns the PNP (Datum) of gauge, if at gauge, 0 otherwise. - */ - protected int getCurrentGaugeDatum() { - // Code borrowed from FixATWriter. - Gauge gauge = RiverUtils.getGauge((D4EArtifact) getMaster()); - int subtractPNP = 0; - if (Math.abs(getRange()[0] - gauge.getStation().doubleValue()) < 1e-4) { - subtractPNP = (int) Math.round(gauge.getDatum().doubleValue() /** 100*/); - } - return subtractPNP; - } - @Override protected String getDefaultYAxisLabel(int pos) { @@ -253,9 +240,9 @@ logger.debug("ComputedDischargeCurveGenerator: doDischargeQOut"); XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); - int subtractPNP = getCurrentGaugeDatum(); + double subtractPNP = getCurrentGaugeDatum(); - if (subtractPNP == 0) { + if (subtractPNP == 0d) { StyledSeriesBuilder.addPointsQW(series, wqkms); addAxisSeries(series, YAXIS.W.idx, visible); } diff -r 3681ae5dcfd4 -r 192fbd23d97f artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java Wed Jun 26 16:44:30 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java Wed Jun 26 16:45:43 2013 +0200 @@ -66,6 +66,24 @@ public static final String I18N_YAXIS_LABEL_DEFAULT = "W [cm]"; + /** + * Returns the PNP (Datum) of gauge, if at gauge, 0 otherwise. + */ + public static double getCurrentGaugeDatum(double km, D4EArtifact artifact) { + // Code borrowed from FixATWriter. + Gauge gauge = RiverUtils.getGauge(artifact); + double subtractPNP = 0d; + if (Math.abs(km - gauge.getStation().doubleValue()) < 1e-4) { + subtractPNP = gauge.getDatum().doubleValue(); + } + return subtractPNP; + } + + public double getCurrentGaugeDatum() { + return getCurrentGaugeDatum(getRange()[0], (D4EArtifact) getMaster()); + } + + public DischargeCurveGenerator() { super(); }