Mercurial > dive4elements > river
changeset 4237:640adb7bced5
Merged.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 24 Oct 2012 14:27:21 +0200 |
parents | 6942a8b31d95 (current diff) d952372e7083 (diff) |
children | 50273de4cf63 |
files | |
diffstat | 13 files changed, 328 insertions(+), 221 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml Wed Oct 24 10:47:24 2012 +0200 +++ b/flys-artifacts/doc/conf/artifacts/winfo.xml Wed Oct 24 14:27:21 2012 +0200 @@ -570,6 +570,8 @@ <facets> <facet name="historical_discharge.historicalq"/> <facet name="historical_discharge.historicalq.diff"/> + <facet name="historical_discharge.historicalw"/> + <facet name="historical_discharge.historicalw.diff"/> <facet name="historical_discharge.manualpoints"/> </facets> </outputmode>
--- a/flys-artifacts/doc/conf/default-themes.xml Wed Oct 24 10:47:24 2012 +0200 +++ b/flys-artifacts/doc/conf/default-themes.xml Wed Oct 24 14:27:21 2012 +0200 @@ -53,6 +53,32 @@ </fields> </theme> + <theme name="HistoricalDischargeCurveW"> + <inherits> + <inherit from="HiddenColorLines" /> + <inherit from="MinMaxPoints" /> + </inherits> + <fields> + <field name="linecolor" type="Color" display="Linienfarbe" + default="100, 100, 153" /> + <field name="linesize" type="int" display="Liniendicke" + default="2" hints="h" /> + </fields> + </theme> + + <theme name="HistoricalDischargeCurveWDiff"> + <inherits> + <inherit from="HiddenColorLines" /> + <inherit from="MinMaxPoints" /> + </inherits> + <fields> + <field name="linecolor" type="Color" display="Linienfarbe" + default="250, 250, 204" /> + <field name="linesize" type="int" display="Liniendicke" + default="2" hints="h" /> + </fields> + </theme> + <!-- Discharge Longitudinal Section --> <theme name="LongitudinalSectionW">
--- a/flys-artifacts/doc/conf/second-themes.xml Wed Oct 24 10:47:24 2012 +0200 +++ b/flys-artifacts/doc/conf/second-themes.xml Wed Oct 24 14:27:21 2012 +0200 @@ -40,6 +40,32 @@ </fields> </theme> + <theme name="HistoricalDischargeCurveW"> + <inherits> + <inherit from="HiddenColorLines" /> + <inherit from="MinMaxPoints" /> + </inherits> + <fields> + <field name="linecolor" type="Color" display="Linienfarbe" + default="153, 200, 153" /> + <field name="linesize" type="int" display="Liniendicke" + default="1" hints="h" /> + </fields> + </theme> + + <theme name="HistoricalDischargeCurveWDiff"> + <inherits> + <inherit from="HiddenColorLines" /> + <inherit from="MinMaxPoints" /> + </inherits> + <fields> + <field name="linecolor" type="Color" display="Linienfarbe" + default="2000, 204, 204" /> + <field name="linesize" type="int" display="Liniendicke" + default="1" hints="h" /> + </fields> + </theme> + <!-- Discharge Longitudinal Section --> <theme name="LongitudinalSectionW">
--- a/flys-artifacts/doc/conf/themes.xml Wed Oct 24 10:47:24 2012 +0200 +++ b/flys-artifacts/doc/conf/themes.xml Wed Oct 24 14:27:21 2012 +0200 @@ -130,6 +130,8 @@ <mapping from="discharge_curve.curve" to="DischargeCurve" /> <mapping from="historical_discharge.historicalq" to="HistoricalDischargeCurveQ" /> <mapping from="historical_discharge.historicalq.diff" to="HistoricalDischargeCurveQDiff" /> + <mapping from="historical_discharge.historicalw" to="HistoricalDischargeCurveW" /> + <mapping from="historical_discharge.historicalw.diff" to="HistoricalDischargeCurveWDiff" /> <mapping from="cross_section" to="CrossSection" /> <mapping from="cross_section_water_line" to="CrossSectionWaterLine" /> <mapping from="computed_discharge_curve.q" to="ComputedDischargeCurve" />
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/HistoricalDischargeAccess.java Wed Oct 24 10:47:24 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/HistoricalDischargeAccess.java Wed Oct 24 14:27:21 2012 +0200 @@ -8,14 +8,48 @@ public class HistoricalDischargeAccess extends RiverAccess { + public static enum EvaluationMode { + W, Q + } + public static final String DATA_EVALUATION_TIME = "year_range"; + public static final String DATA_EVALUATION_MODE = "historical_mode"; + public static final String DATA_INPUT_VALUES = "historical_values"; private Timerange evaluationTimerange; + private EvaluationMode evaluationMode; + + private double[] qs; + private double[] ws; public HistoricalDischargeAccess(FLYSArtifact artifact) { super(artifact); } + /** + * This method returns the evaluation mode. The evaluation mode W is set, if + * the <b>DATA_EVALUATION_MODE</b> is 0. Otherwise, the evaluation mode Q is + * set. + * + * @return EvaluationMode.W if the parameter <i>historical_mode</i> is set + * to 0, otherwise EvaluationMode.Q. + */ + public EvaluationMode getEvaluationMode() { + if (evaluationMode == null) { + int mode = getInteger(DATA_EVALUATION_MODE); + evaluationMode = mode == 0 ? EvaluationMode.W : EvaluationMode.Q; + } + + return evaluationMode; + } + + /** + * This method returns the time range specified by <i>year_range</i> + * parameter. This parameter has to be a string that consists of two long + * values (time millis since 1970) separated by a ';'. + * + * @return the evaluation time range specified by <i>year_range</i>. + */ public Timerange getEvaluationTimerange() { if (evaluationTimerange == null) { long[] startend = getLongArray(DATA_EVALUATION_TIME); @@ -30,4 +64,46 @@ return evaluationTimerange; } + + /** + * This method returns the input Q values if the evaluation mode Q is set. + * Otherwise, this method will return a double array of length 0. The values + * returned by this method are extracted from string parameter + * <i>historical_values</i>. + * + * @return the input Q values or a double array of length 0. + */ + public double[] getQs() { + if (qs == null) { + if (getEvaluationMode() == EvaluationMode.Q) { + qs = getDoubleArray(DATA_INPUT_VALUES); + } + else { + qs = new double[0]; + } + } + + return qs; + } + + /** + * This method returns the input W values if the evaluation mode W is set. + * Otherwise, this method will return a double array of length 0. The values + * returned by this method are extracted from string parameter + * <i>historical_values</i>. + * + * @return the input W values or a double array of length 0. + */ + public double[] getWs() { + if (ws == null) { + if (getEvaluationMode() == EvaluationMode.W) { + ws = getDoubleArray(DATA_INPUT_VALUES); + } + else { + ws = new double[0]; + } + } + + return ws; + } }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation6.java Wed Oct 24 10:47:24 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation6.java Wed Oct 24 14:27:21 2012 +0200 @@ -18,24 +18,21 @@ private static final Logger logger = Logger.getLogger(Calculation6.class); - private int mode; - private long[] timerange; + private int mode; + private long[] timerange; private double[] values; - public static final int MODE_W = 0; public static final int MODE_Q = 1; public static final double SCALE = 1d; - public Calculation6(int mode, long[] timerange, double[] values) { - this.mode = mode; + this.mode = mode; this.timerange = timerange; - this.values = values; + this.values = values; } - public CalculationResult calculate(Gauge gauge) { if (!checkParameters() || gauge == null) { logger.warn("Parameters not valid for calculation."); @@ -47,7 +44,7 @@ debug(); } - DischargeTable refTable = fetchReferenceTable(gauge); + DischargeTable refTable = fetchReferenceTable(gauge); List<DischargeTable> dts = fetchDischargeTables(gauge); int numTables = dts.size(); @@ -65,7 +62,6 @@ return new CalculationResult(wqt, this); } - protected boolean checkParameters() { if (!(mode == MODE_W || mode == MODE_Q)) { logger.warn("Invalid mode '" + mode + "' for calculation."); @@ -85,17 +81,15 @@ return true; } - protected DischargeTable fetchReferenceTable(Gauge gauge) { return gauge.fetchMasterDischargeTable(); } - protected List<DischargeTable> fetchDischargeTables(Gauge gauge) { List<DischargeTable> relevant = new ArrayList<DischargeTable>(); - List<DischargeTable> all = gauge.getDischargeTables(); + List<DischargeTable> all = gauge.getDischargeTables(); - for (DischargeTable dt: all) { + for (DischargeTable dt : all) { if (isDischargeTableRelevant(dt)) { relevant.add(dt); } @@ -104,7 +98,6 @@ return relevant; } - protected boolean isDischargeTableRelevant(DischargeTable dt) { TimeInterval ti = dt.getTimeInterval(); @@ -112,14 +105,14 @@ return false; } - Date start = ti.getStartTime(); + Date start = ti.getStartTime(); long startTime = start.getTime(); if (startTime >= timerange[0] && startTime <= timerange[1]) { return true; } - Date stop = ti.getStopTime(); + Date stop = ti.getStopTime(); long stopTime = stop != null ? stop.getTime() : -1l; if (stopTime >= timerange[0] && stopTime <= timerange[1]) { @@ -131,11 +124,8 @@ return false; } - - protected WQTimerange[] prepareCalculationData( - DischargeTable refTable, - List<DischargeTable> dts - ) { + protected WQTimerange[] prepareCalculationData(DischargeTable refTable, + List<DischargeTable> dts) { if (refTable == null) { addProblem("cannot.find.hist.q.reftable"); return prepareSimpleData(dts); @@ -145,22 +135,20 @@ } } - protected WQTimerange[] prepareSimpleData(List<DischargeTable> dts) { - List<WQTimerange> wqts = - new ArrayList<WQTimerange>(values.length); + List<WQTimerange> wqts = new ArrayList<WQTimerange>(values.length); - for (double value: values) { + for (double value : values) { logger.debug("Prepare data for value: " + value); - String name = mode == MODE_W ? "W=" + value : "Q=" + value; - WQTimerange wqt = null; + String name = mode == MODE_W ? "W=" + value : "Q=" + value; + WQTimerange wqt = null; - for (DischargeTable dt: dts) { - Date[] ti = prepareTimeInterval(dt); + for (DischargeTable dt : dts) { + Date[] ti = prepareTimeInterval(dt); Timerange t = new Timerange(ti[0], ti[1]); - double w; - double q; + double w; + double q; if (mode == MODE_W) { w = value; @@ -174,7 +162,7 @@ } else { q = value; - w = findValueForQ(dt, q); + w = findValueForQ(dt, q, DischargeTables.HISTORICAL_SCALE); } logger.debug("Q=" + q + " | W=" + w); @@ -194,43 +182,42 @@ return wqts.toArray(new WQTimerange[wqts.size()]); } + protected HistoricalWQTimerange[] prepareData(DischargeTable refTable, + List<DischargeTable> dts) { + List<HistoricalWQTimerange> wqts = new ArrayList<HistoricalWQTimerange>( + values.length); - protected HistoricalWQTimerange[] prepareData( - DischargeTable refTable, - List<DischargeTable> dts - ) { - List<HistoricalWQTimerange> wqts = - new ArrayList<HistoricalWQTimerange>(values.length); - - for (double value: values) { + for (double value : values) { logger.debug("Prepare data plus diff for value: " + value); String name = mode == MODE_W ? "W=" + value : "Q=" + value; - HistoricalWQTimerange wqt = null; + HistoricalWQTimerange wqt = null; double ref; double diff; if (refTable != null && mode == MODE_W) { - ref = findValueForW(refTable, value, DischargeTables.MASTER_SCALE); + ref = findValueForW(refTable, value, + DischargeTables.MASTER_SCALE); } else if (refTable != null) { - ref = findValueForQ(refTable, value); + ref = findValueForQ(refTable, value, + DischargeTables.MASTER_SCALE); } else { ref = Double.NaN; } - for (DischargeTable dt: dts) { + for (DischargeTable dt : dts) { Date[] ti = prepareTimeInterval(dt); - Timerange t = new Timerange(ti[0] ,ti[1]); - double w; - double q; + Timerange t = new Timerange(ti[0], ti[1]); + double w; + double q; if (mode == MODE_W) { - w = value; - q = findValueForW(dt, w, DischargeTables.HISTORICAL_SCALE); + w = value; + q = findValueForW(dt, w, DischargeTables.HISTORICAL_SCALE); if (Double.isNaN(q)) { logger.warn("Cannot find Q for W: " + w); @@ -238,12 +225,18 @@ continue; } - diff = ref-q; + diff = ref - q; } else { - q = value; - w = findValueForQ(dt, q); - diff = ref-w; + q = value; + w = findValueForQ(dt, q, DischargeTables.HISTORICAL_SCALE); + + if (Double.isNaN(w)) { + logger.warn("Cannot find W for Q: " + q); + addProblem("cannot.find.hist.w.for.q", q, ti[0], ti[1]); + continue; + } + diff = ref - w; } logger.debug("Q=" + q + " | W=" + w + " | Ref = " + ref); @@ -260,16 +253,15 @@ } } - return (HistoricalWQTimerange[]) - wqts.toArray(new HistoricalWQTimerange[wqts.size()]); + return (HistoricalWQTimerange[]) wqts + .toArray(new HistoricalWQTimerange[wqts.size()]); } - protected Date[] prepareTimeInterval(DischargeTable dt) { TimeInterval ti = dt.getTimeInterval(); Date start = ti.getStartTime(); - Date end = ti.getStopTime(); + Date end = ti.getStopTime(); if (end == null) { logger.warn("TimeInterval has no stop time set!"); @@ -280,28 +272,25 @@ return new Date[] { start, end }; } - protected double findValueForW(DischargeTable dt, double w, double scale) { double[][] vs = DischargeTables.loadDischargeTableValues(dt, scale); - double [] qs = DischargeTables.getQsForW(vs, w); + double[] qs = DischargeTables.getQsForW(vs, w); return qs.length == 0 ? Double.NaN : qs[0]; } + protected double findValueForQ(DischargeTable dt, double q, double scale) { + double[][] vs = DischargeTables.loadDischargeTableValues(dt, scale); + double[] ws = DischargeTables.getWsForQ(vs, q); - protected double findValueForQ(DischargeTable dt, double q) { - double[][] vs = DischargeTables.loadDischargeTableValues(dt, SCALE); - logger.warn("TODO: IMPLEMENT ME!"); - - return 10; + return ws.length == 0 ? Double.NaN : ws[0]; } - /** * Writes the parameters used for this calculation to logger. */ public void debug() { StringBuilder sb = new StringBuilder(); - for (double value: values) { + for (double value : values) { sb.append(String.valueOf(value) + " "); }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Wed Oct 24 10:47:24 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Wed Oct 24 14:27:21 2012 +0200 @@ -216,6 +216,8 @@ String HISTORICAL_DISCHARGE_Q = "historical_discharge.historicalq"; String HISTORICAL_DISCHARGE_Q_DIFF = "historical_discharge.historicalq.diff"; + String HISTORICAL_DISCHARGE_W = "historical_discharge.historicalw"; + String HISTORICAL_DISCHARGE_W_DIFF = "historical_discharge.historicalw.diff"; String REFERENCE_CURVE = "reference_curve"; String REFERENCE_CURVE_NORMALIZED = "reference_curve_normalized";
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeComputeState.java Wed Oct 24 10:47:24 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeComputeState.java Wed Oct 24 14:27:21 2012 +0200 @@ -2,24 +2,22 @@ import java.util.List; +import org.apache.log4j.Logger; import org.w3c.dom.Element; -import org.apache.log4j.Logger; - +import de.intevation.artifactdatabase.state.Facet; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; - import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; - -import de.intevation.artifactdatabase.state.Facet; - import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.WINFOArtifact; +import de.intevation.flys.artifacts.access.HistoricalDischargeAccess; +import de.intevation.flys.artifacts.access.HistoricalDischargeAccess.EvaluationMode; import de.intevation.flys.artifacts.model.CalculationResult; import de.intevation.flys.artifacts.model.DataFacet; import de.intevation.flys.artifacts.model.FacetTypes; +import de.intevation.flys.artifacts.model.HistoricalDischargeDifferenceFacet; import de.intevation.flys.artifacts.model.HistoricalDischargeFacet; -import de.intevation.flys.artifacts.model.HistoricalDischargeDifferenceFacet; import de.intevation.flys.artifacts.model.HistoricalWQTimerange; import de.intevation.flys.artifacts.model.ReportFacet; import de.intevation.flys.artifacts.model.WQTimerange; @@ -27,45 +25,31 @@ /** * State to calculate historical discharge curves. + * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ -public class HistoricalDischargeComputeState -extends DefaultState -implements FacetTypes -{ +public class HistoricalDischargeComputeState extends DefaultState implements + FacetTypes { - private static final Logger logger = - Logger.getLogger(HistoricalDischargeComputeState.class); + private static final Logger logger = Logger + .getLogger(HistoricalDischargeComputeState.class); public static final String DEFAULT_UNIT = "cm"; - @Override - protected void appendItems( - Artifact artifact, - ElementCreator creator, - String name, - CallContext context, - Element select - ) { + protected void appendItems(Artifact artifact, ElementCreator creator, + String name, CallContext context, Element select) { // TODO IMPLEMENT ME } - @Override - public Object computeAdvance( - FLYSArtifact artifact, - String hash, - CallContext context, - List<Facet> facets, - Object old - ) { + public Object computeAdvance(FLYSArtifact artifact, String hash, + CallContext context, List<Facet> facets, Object old) { logger.debug("HistoricalDischargeComputeState.computeAdvance"); WINFOArtifact winfo = (WINFOArtifact) artifact; - CalculationResult res = old instanceof CalculationResult - ? (CalculationResult) old + CalculationResult res = old instanceof CalculationResult ? (CalculationResult) old : winfo.getHistoricalDischargeData(); if (facets == null) { @@ -82,60 +66,68 @@ return res; } - facets.add( - new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); + facets + .add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id)); - facets.add( - new DataFacet(PDF, "PDF data", ComputeType.ADVANCE, hash, id)); + facets + .add(new DataFacet(PDF, "PDF data", ComputeType.ADVANCE, hash, id)); - prepareFacets(facets, data); + prepareFacets(facets, data, new HistoricalDischargeAccess(artifact)); return res; } - - protected void prepareFacets(List<Facet> facets, WQTimerange[] wqts) { + protected void prepareFacets(List<Facet> facets, WQTimerange[] wqts, + HistoricalDischargeAccess access) { int i = 0; - for (WQTimerange wqt: wqts) { + for (WQTimerange wqt : wqts) { logger.debug("Prepare facet for: " + wqt.getName()); - // TODO CREATE BETTER TITLE FOR FACETS - - facets.add(new HistoricalDischargeFacet( - i, - HISTORICAL_DISCHARGE_Q, - createFacetTitle(wqt))); + EvaluationMode evalMode = access.getEvaluationMode(); + if (evalMode == EvaluationMode.W) { + facets.add(new HistoricalDischargeFacet(i, + HISTORICAL_DISCHARGE_Q, createFacetTitle(wqt))); - if (wqt instanceof HistoricalWQTimerange) { - logger.debug("Create another facet for historical differences."); + if (wqt instanceof HistoricalWQTimerange) { + logger + .debug("Create another facet for historical differences."); - facets.add(new HistoricalDischargeDifferenceFacet( - i, - HISTORICAL_DISCHARGE_Q_DIFF, - "DIFF: " + wqt.getName())); + // TODO CREATE BETTER TITLE FOR FACETS + facets.add(new HistoricalDischargeDifferenceFacet(i, + HISTORICAL_DISCHARGE_Q_DIFF, "DIFF: " + wqt.getName())); + } + } + else { + facets.add(new HistoricalDischargeFacet(i, + HISTORICAL_DISCHARGE_W, createFacetTitle(wqt))); + + if (wqt instanceof HistoricalWQTimerange) { + logger + .debug("Create another facet for historical differences."); + + // TODO CREATE BETTER TITLE FOR FACETS + facets.add(new HistoricalDischargeDifferenceFacet(i, + HISTORICAL_DISCHARGE_W_DIFF, "DIFF: " + wqt.getName())); + } } i++; } } - protected String createFacetTitle(WQTimerange wqt) { String name = wqt.getName(); - return name != null && name.indexOf("W") >= 0 - ? createFacetTitleW(wqt) + return name != null && name.indexOf("W") >= 0 ? createFacetTitleW(wqt) : createFacetTitleQ(wqt); } - protected String createFacetTitleW(WQTimerange wqt) { String name = wqt.getName(); return name + " " + DEFAULT_UNIT; } - protected String createFacetTitleQ(WQTimerange wqt) { return wqt.getName(); }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java Wed Oct 24 10:47:24 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java Wed Oct 24 14:27:21 2012 +0200 @@ -25,42 +25,36 @@ /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ -public class HistoricalDischargeCurveGenerator -extends TimeseriesChartGenerator -implements FacetTypes -{ - private static Logger logger = - Logger.getLogger(HistoricalDischargeCurveGenerator.class); - - - public static final String I18N_CHART_TITLE = - "chart.historical.discharge.title"; +public class HistoricalDischargeCurveGenerator extends TimeseriesChartGenerator + implements FacetTypes { - public static final String I18N_CHART_SUBTITLE = - "chart.historical.discharge.subtitle"; - - public static final String I18N_XAXIS_LABEL = - "chart.historical.discharge.xaxis.label"; + private static Logger logger = Logger + .getLogger(HistoricalDischargeCurveGenerator.class); - public static final String I18N_YAXIS_LABEL = - "chart.historical.discharge.yaxis.label"; + public static final String I18N_CHART_TITLE = "chart.historical.discharge.title"; - public static final String I18N_YAXIS_SECOND_LABEL = - "chart.historical.discharge.yaxis.second.label"; + public static final String I18N_CHART_SUBTITLE = "chart.historical.discharge.subtitle"; + public static final String I18N_XAXIS_LABEL = "chart.historical.discharge.xaxis.label"; + + public static final String I18N_YAXIS_LABEL = "chart.historical.discharge.yaxis.label"; + + public static final String I18N_YAXIS_SECOND_LABEL = "chart.historical.discharge.yaxis.second.label"; public static enum YAXIS { - Q(0); + W(0), Q(1); + protected int idx; + private YAXIS(int c) { idx = c; } } - @Override protected YAxisWalker getYAxisWalker() { return new YAxisWalker() { + @Override public int length() { return YAXIS.values().length; @@ -74,29 +68,23 @@ }; } - @Override protected String getDefaultChartTitle() { return msg(I18N_CHART_TITLE, I18N_CHART_TITLE); } - @Override protected String getDefaultChartSubtitle() { - FLYSArtifact flys = (FLYSArtifact) master; - Timerange evalTime = - new HistoricalDischargeAccess(flys).getEvaluationTimerange(); + FLYSArtifact flys = (FLYSArtifact) master; + Timerange evalTime = new HistoricalDischargeAccess(flys) + .getEvaluationTimerange(); - Object[] args = new Object[] { - FLYSUtils.getReferenceGaugeName(flys), - evalTime.getStart(), - evalTime.getEnd() - }; + Object[] args = new Object[] { FLYSUtils.getReferenceGaugeName(flys), + evalTime.getStart(), evalTime.getEnd() }; return msg(I18N_CHART_SUBTITLE, "", args); } - @Override protected String getDefaultXAxisLabel() { return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL); @@ -121,88 +109,95 @@ plot.setRangeZeroBaselineVisible(true); } - @Override - public void doOut( - ArtifactAndFacet artifactFacet, - Document theme, - boolean visible - ) { + public void doOut(ArtifactAndFacet artifactFacet, Document theme, + boolean visible) { String name = artifactFacet.getFacetName(); logger.debug("HistoricalDischargeCurveGenerator.doOut: " + name); - logger.debug("Theme description is: " + artifactFacet.getFacetDescription()); - + logger.debug("Theme description is: " + + artifactFacet.getFacetDescription()); if (name.equals(HISTORICAL_DISCHARGE_Q)) { - doHistoricalDischargeOut( + doHistoricalDischargeOutQ( (FLYSArtifact) artifactFacet.getArtifact(), artifactFacet.getData(context), - artifactFacet.getFacetDescription(), - theme, - visible); + artifactFacet.getFacetDescription(), theme, visible); } - else if (name.equals(HISTORICAL_DISCHARGE_Q_DIFF)) { - doHistoricalDischargeDifferenceOut( + else if (name.equals(HISTORICAL_DISCHARGE_W)) { + doHistoricalDischargeOutW( (FLYSArtifact) artifactFacet.getArtifact(), artifactFacet.getData(context), - artifactFacet.getFacetDescription(), - theme, - visible); + artifactFacet.getFacetDescription(), theme, visible); + } + else if (name.equals(HISTORICAL_DISCHARGE_Q_DIFF)) { + doHistoricalDischargeDifferenceOutQ( + (FLYSArtifact) artifactFacet.getArtifact(), + artifactFacet.getData(context), + artifactFacet.getFacetDescription(), theme, visible); + } + else if (name.equals(HISTORICAL_DISCHARGE_W_DIFF)) { + doHistoricalDischargeDifferenceOutW( + (FLYSArtifact) artifactFacet.getArtifact(), + artifactFacet.getData(context), + artifactFacet.getFacetDescription(), theme, visible); } else if (FacetTypes.IS.MANUALPOINTS(name)) { - doPoints (artifactFacet.getData(context), - artifactFacet, - theme, visible, YAXIS.Q.idx); + doPoints(artifactFacet.getData(context), artifactFacet, theme, + visible, YAXIS.Q.idx); } - // TODO ADD THE CASE FOR DISPLAYING W VALUES else { - logger.warn("doOut(): unknown facet name: " + name); - return; + logger.warn("doOut(): unknown facet name: " + name); + return; } } - - protected void doHistoricalDischargeOut( - FLYSArtifact artifact, - Object data, - String desc, - Document theme, - boolean visible) - { + protected void doHistoricalDischargeOutQ(FLYSArtifact artifact, + Object data, String desc, Document theme, boolean visible) { logger.debug("doHistoricalDischargeOut(): description = " + desc); WQTimerange wqt = (WQTimerange) data; - TimeSeriesCollection tsc = newTimeSeriesCollection( - wqt.getTimeranges(), - wqt.getQs(), - theme, - desc); + TimeSeriesCollection tsc = newTimeSeriesCollection(wqt.getTimeranges(), + wqt.getQs(), theme, desc); - addAxisDataset(tsc, 0, visible); + addAxisDataset(tsc, YAXIS.Q.idx, visible); } + protected void doHistoricalDischargeOutW(FLYSArtifact artifact, + Object data, String desc, Document theme, boolean visible) { + logger.debug("doHistoricalDischargeOut(): description = " + desc); - protected void doHistoricalDischargeDifferenceOut( - FLYSArtifact artifact, - Object data, - String desc, - Document theme, - boolean visible - ) { + WQTimerange wqt = (WQTimerange) data; + + TimeSeriesCollection tsc = newTimeSeriesCollection(wqt.getTimeranges(), + wqt.getWs(), theme, desc); + + addAxisDataset(tsc, YAXIS.W.idx, visible); + } + + protected void doHistoricalDischargeDifferenceOutQ(FLYSArtifact artifact, + Object data, String desc, Document theme, boolean visible) { logger.debug("doHistoricalDischargeDifferenceOut: desc = " + desc); HistoricalWQTimerange wqt = (HistoricalWQTimerange) data; - TimeSeriesCollection tsc = newTimeSeriesCollection( - wqt.getTimeranges(), - wqt.getDiffs(), - theme, - desc); + TimeSeriesCollection tsc = newTimeSeriesCollection(wqt.getTimeranges(), + wqt.getDiffs(), theme, desc); - addAxisDataset(tsc, 0, visible); + addAxisDataset(tsc, YAXIS.Q.idx, visible); } + protected void doHistoricalDischargeDifferenceOutW(FLYSArtifact artifact, + Object data, String desc, Document theme, boolean visible) { + logger.debug("doHistoricalDischargeDifferenceOut: desc = " + desc); + + HistoricalWQTimerange wqt = (HistoricalWQTimerange) data; + + TimeSeriesCollection tsc = newTimeSeriesCollection(wqt.getTimeranges(), + wqt.getDiffs(), theme, desc); + + addAxisDataset(tsc, YAXIS.W.idx, visible); + } /** * Creates a new TimeSeriesCollection with a single TimeSeries. The @@ -211,15 +206,11 @@ * looks like a "step chart". */ protected TimeSeriesCollection newTimeSeriesCollection( - Timerange[] timeranges, - double[] values, - Document theme, - String desc - ) { + Timerange[] timeranges, double[] values, Document theme, String desc) { logger.debug("Create new TimeSeriesCollection for: " + desc); TimeSeriesCollection tsc = new TimeSeriesCollection(); - TimeSeries series = new StyledTimeSeries(desc, theme); + TimeSeries series = new StyledTimeSeries(desc, theme); for (int i = 0, n = timeranges.length; i < n; i++) { RegularTimePeriod[] rtp = newRegularTimePeriod(timeranges[i]); @@ -249,22 +240,19 @@ return tsc; } - /** * Creates an array that consists of two <i>Minute</i> periods [start, end]. - * - * @param timerange Supports start and end time. - * + * + * @param timerange + * Supports start and end time. + * * @return an array with two <i>Minute</i> periods [start, end]. */ protected RegularTimePeriod[] newRegularTimePeriod(Timerange timerange) { Date start = new Date(timerange.getStart()); - Date end = new Date(timerange.getEnd() - 1000 * 60 * 60 * 24); + Date end = new Date(timerange.getEnd() - 1000 * 60 * 60 * 24); - return new RegularTimePeriod[] { - new Day(start), - new Day(end) - }; + return new RegularTimePeriod[] { new Day(start), new Day(end) }; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/resources/messages.properties Wed Oct 24 10:47:24 2012 +0200 +++ b/flys-artifacts/src/main/resources/messages.properties Wed Oct 24 14:27:21 2012 +0200 @@ -381,6 +381,7 @@ w.w.wkm2.failed = Calculating W for Q = {0,number,#.##} / WST index {1,number,#.##} failed. cannot.find.hist.q.for.w = Cannot find Q for W = {0,number,#.##} in timerange {1, date} - {2, date} +cannot.find.hist.w.for.q = Cannot find W for Q = {0,number,#.##} in timerange {1, date} - {2, date} cannot.find.hist.q.tables = Cannot find Discharge Tables for given timerange. cannot.find.hist.q.reftable = Cannot find reference Discharge Table for specified Gauge.
--- a/flys-artifacts/src/main/resources/messages_de.properties Wed Oct 24 10:47:24 2012 +0200 +++ b/flys-artifacts/src/main/resources/messages_de.properties Wed Oct 24 14:27:21 2012 +0200 @@ -380,7 +380,8 @@ w.w.qkm2.failed = Berechnung von Q f\u00fcr WST-Index {0,number,#.##} fehlgeschlagen. w.w.wkm2.failed = Berechnung von W f\u00fcr Q = {0,number,#.##} / WST-Index {1,number,#.##} fehlgeschlagen. -cannot.find.hist.q.for.w = Konnte zu W = {0,number,#.##} im Zeitraum ({1,date} - {2,date}) kein Abfluss ermitteln. +cannot.find.hist.q.for.w = Konnte zu W = {0,number,#.##} im Zeitraum ({1,date} - {2,date}) keinen Abfluss ermitteln. +cannot.find.hist.w.for.q = Konnte zu Q = {0,number,#.##} im Zeitraum ({1,date} - {2,date}) keinen Wasserstand ermitteln. cannot.find.hist.q.tables = Konnte f\u00fcr den angegebenen Zeitraum keine Abflusstafeln finden. cannot.find.hist.q.reftable = Konnte f\u00fcr den gew\u00e4hlten Pegel keine Bezugs-Abflusstafel ermitteln.
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties Wed Oct 24 10:47:24 2012 +0200 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Wed Oct 24 14:27:21 2012 +0200 @@ -377,7 +377,8 @@ w.w.qkm2.failed = Berechnung von Q f\u00fcr WST-Index {0,number,#.##} fehlgeschlagen. w.w.wkm2.failed = Berechnung von W f\u00fcr Q = {0,number,#.##} / WST-Index {1,number,#.##} fehlgeschlagen. -cannot.find.hist.q.for.w = Konnte zu W = {0,number,#.##} im Zeitraum ({1,date} - {2,date}) kein Abfluss ermitteln. +cannot.find.hist.q.for.w = Konnte zu W = {0,number,#.##} im Zeitraum ({1,date} - {2,date}) keinen Abfluss ermitteln. +cannot.find.hist.w.for.q = Konnte zu Q = {0,number,#.##} im Zeitraum ({1,date} - {2,date}) keinen Wasserstand ermitteln. cannot.find.hist.q.tables = Konnte f\u00fcr den angegebenen Zeitraum keine Abflusstafeln finden. cannot.find.hist.q.reftable = Konnte f\u00fcr den gew\u00e4hlten Pegel keine Bezugs-Abflusstafel ermitteln.
--- a/flys-artifacts/src/main/resources/messages_en.properties Wed Oct 24 10:47:24 2012 +0200 +++ b/flys-artifacts/src/main/resources/messages_en.properties Wed Oct 24 14:27:21 2012 +0200 @@ -382,6 +382,7 @@ w.w.wkm2.failed = Calculating W for Q = {0,number,#.##} / WST index {1,number,#.##} failed. cannot.find.hist.q.for.w = Cannot find Q for W = {0,number,#.##} in timerange {1, date} - {2, date} +cannot.find.hist.w.for.q = Cannot find W for Q = {0,number,#.##} in timerange {1, date} - {2, date} cannot.find.hist.q.tables = Cannot find Discharge Tables for given timerange. cannot.find.hist.q.reftable = Cannot find reference Discharge Table for specified Gauge.