# HG changeset patch # User Ingo Weinzierl # Date 1350384172 -7200 # Node ID 5ff3b2f5fb1c1e70c4726239e4a6fab8d1e61a6f # Parent 0182916dcb0128287423c0eae37ea79781108f51 Added evaluation timerange to subtitle of historical discharge curve charts. diff -r 0182916dcb01 -r 5ff3b2f5fb1c flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue Oct 16 12:25:48 2012 +0200 +++ b/flys-artifacts/ChangeLog Tue Oct 16 12:42:52 2012 +0200 @@ -1,3 +1,24 @@ +2012-10-16 Ingo Weinzierl + + flys/issue930 + + * src/main/java/de/intevation/flys/artifacts/access/Access.java: Added new + method to retrieve long[] values separated with a ';'. + + * src/main/java/de/intevation/flys/artifacts/access/HistoricalDischargeAccess.java: + New. Access class to retrieve information for historical discharge + curves. + + * src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java: + Add the evaluation timerange provided by HistoricalDischargeAccess to + the subtitle of those charts. + + * src/main/resources/messages.properties, + src/main/resources/messages_de.properties, + src/main/resources/messages_de_DE.properties, + src/main/resources/messages_en.properties: Added start and end date to + subtitle of historical discharge curve charts. + 2012-10-16 Christian Lins * src/main/java/de/intevation/flys/artifacts/access/BedHeightAccess.java, diff -r 0182916dcb01 -r 5ff3b2f5fb1c flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/Access.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/Access.java Tue Oct 16 12:25:48 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/Access.java Tue Oct 16 12:42:52 2012 +0200 @@ -9,6 +9,7 @@ import de.intevation.flys.utils.FLYSUtils; import gnu.trove.TDoubleArrayList; +import gnu.trove.TLongArrayList; import java.util.ArrayList; import java.util.Date; @@ -170,5 +171,24 @@ } return list.toNativeArray(); } + + protected long [] getLongArray(String key) { + StateData sd = artifact.getData(key); + if (sd == null) { + log.warn("missing '" + key + "'"); + return null; + } + String [] parts = ((String)sd.getValue()).split("[\\s;]+"); + TLongArrayList list = new TLongArrayList(parts.length); + for (String part: parts) { + try { + list.add(Long.parseLong(part)); + } + catch (NumberFormatException nfe) { + log.warn("'" + part + "' is not numeric."); + } + } + return list.toNativeArray(); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 0182916dcb01 -r 5ff3b2f5fb1c flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/HistoricalDischargeAccess.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/HistoricalDischargeAccess.java Tue Oct 16 12:42:52 2012 +0200 @@ -0,0 +1,33 @@ +package de.intevation.flys.artifacts.access; + +import java.util.Date; + +import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.model.Timerange; + + +public class HistoricalDischargeAccess extends RiverAccess { + + public static final String DATA_EVALUATION_TIME = "year_range"; + + private Timerange evaluationTimerange; + + public HistoricalDischargeAccess(FLYSArtifact artifact) { + super(artifact); + } + + public Timerange getEvaluationTimerange() { + if (evaluationTimerange == null) { + long[] startend = getLongArray(DATA_EVALUATION_TIME); + + if (startend != null && startend.length > 1) { + Date start = new Date(startend[0]); + Date end = new Date(startend[1]); + + evaluationTimerange = new Timerange(start, end); + } + } + + return evaluationTimerange; + } +} diff -r 0182916dcb01 -r 5ff3b2f5fb1c flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java Tue Oct 16 12:25:48 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java Tue Oct 16 12:42:52 2012 +0200 @@ -2,6 +2,7 @@ import de.intevation.artifactdatabase.state.ArtifactAndFacet; import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.access.HistoricalDischargeAccess; import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.artifacts.model.HistoricalWQTimerange; import de.intevation.flys.artifacts.model.Timerange; @@ -81,8 +82,14 @@ @Override protected String getDefaultChartSubtitle() { - String[] args = new String[] { - FLYSUtils.getReferenceGaugeName((FLYSArtifact) master) + FLYSArtifact flys = (FLYSArtifact) master; + Timerange evalTime = + new HistoricalDischargeAccess(flys).getEvaluationTimerange(); + + Object[] args = new Object[] { + FLYSUtils.getReferenceGaugeName(flys), + evalTime.getStart(), + evalTime.getEnd() }; return msg(I18N_CHART_SUBTITLE, "", args); diff -r 0182916dcb01 -r 5ff3b2f5fb1c flys-artifacts/src/main/resources/messages.properties --- a/flys-artifacts/src/main/resources/messages.properties Tue Oct 16 12:25:48 2012 +0200 +++ b/flys-artifacts/src/main/resources/messages.properties Tue Oct 16 12:42:52 2012 +0200 @@ -156,7 +156,7 @@ chart.duration.curve.curve.w = Waterlevel duration curve for {0} (km: {1}) chart.duration.curve.curve.q = Discharge duration curve for {0} (km: {1}) chart.historical.discharge.title = Historical Discharge Curves -chart.historical.discharge.subtitle = Gauge {0} +chart.historical.discharge.subtitle = Gauge {0} {1,date,medium} - {2,date,medium} chart.historical.discharge.xaxis.label = Time chart.historical.discharge.yaxis.label = Q [m\u00b3/s] chart.historical.discharge.yaxis.second.label = W [cm] diff -r 0182916dcb01 -r 5ff3b2f5fb1c flys-artifacts/src/main/resources/messages_de.properties --- a/flys-artifacts/src/main/resources/messages_de.properties Tue Oct 16 12:25:48 2012 +0200 +++ b/flys-artifacts/src/main/resources/messages_de.properties Tue Oct 16 12:42:52 2012 +0200 @@ -155,7 +155,7 @@ chart.duration.curve.curve.w = Wasserstandsdauerline f\u00fcr {0} (km:{1}) chart.duration.curve.curve.q = Abflussdauerline f\u00fcr {0} (km:{1}) chart.historical.discharge.title = Historische Abflusskurven -chart.historical.discharge.subtitle = Pegel {0} +chart.historical.discharge.subtitle = Pegel {0} {1,date,medium} - {2,date,medium} chart.historical.discharge.xaxis.label = Zeit chart.historical.discharge.yaxis.label = Q [m\u00b3/s] chart.historical.discharge.yaxis.second.label = W [cm] diff -r 0182916dcb01 -r 5ff3b2f5fb1c flys-artifacts/src/main/resources/messages_de_DE.properties --- a/flys-artifacts/src/main/resources/messages_de_DE.properties Tue Oct 16 12:25:48 2012 +0200 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Tue Oct 16 12:42:52 2012 +0200 @@ -155,7 +155,7 @@ chart.duration.curve.curve.w = Wasserstandsdauerline f\u00fcr {0} (km:{1}) chart.duration.curve.curve.q = Abflussdauerline f\u00fcr {0} (km:{1}) chart.historical.discharge.title = Historische Abflusskurven -chart.historical.discharge.subtitle = Pegel {0} +chart.historical.discharge.subtitle = Pegel {0} {1,date,medium} - {2,date,medium} chart.historical.discharge.xaxis.label = Zeit chart.historical.discharge.yaxis.label = Q [m\u00b3/s] chart.historical.discharge.yaxis.second.label = W [cm] diff -r 0182916dcb01 -r 5ff3b2f5fb1c flys-artifacts/src/main/resources/messages_en.properties --- a/flys-artifacts/src/main/resources/messages_en.properties Tue Oct 16 12:25:48 2012 +0200 +++ b/flys-artifacts/src/main/resources/messages_en.properties Tue Oct 16 12:42:52 2012 +0200 @@ -155,7 +155,7 @@ chart.duration.curve.curve.w = Waterlevel duration curve for {0} (km: {1}) chart.duration.curve.curve.q = Discharge duration curve for {0} (km: {1}) chart.historical.discharge.title = Historical Discharge Curves for Gauge {0} -chart.historical.discharge.subtitle = Gauge {0} +chart.historical.discharge.subtitle = Gauge {0} {1,date,medium} - {2,date,medium} chart.historical.discharge.xaxis.label = Time chart.historical.discharge.yaxis.label = Q [m\u00b3/s] chart.historical.discharge.yaxis.second.label = W [cm]