# HG changeset patch # User Ingo Weinzierl # Date 1271686759 0 # Node ID ac5988f27714fe14e7071def79fa273a69b660e6 # Parent e91ebe3696ecb002e4c1ed9672430b1c9a9f2010 Added the time interval into the subtitle of timeseries charts (issue152). gnv-artifacts/trunk@948 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r e91ebe3696ec -r ac5988f27714 gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Mon Apr 19 12:31:02 2010 +0000 +++ b/gnv-artifacts/ChangeLog Mon Apr 19 14:19:19 2010 +0000 @@ -1,3 +1,14 @@ +2010-04-19 Ingo Weinzierl + + Issue152 + + * src/main/java/de/intevation/gnv/state/StateBase.java: + Added a date formatter for parsing dates from internal data objects. + + * src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java: + Added the time interval of timeseries charts into the subtitle of this + charts. + 2010-04-19 Ingo Weinzierl Issue226 diff -r e91ebe3696ec -r ac5988f27714 gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Mon Apr 19 12:31:02 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Mon Apr 19 14:19:19 2010 +0000 @@ -1,5 +1,8 @@ package de.intevation.gnv.state; +import java.text.DateFormat; +import java.text.SimpleDateFormat; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -109,6 +112,24 @@ protected Map preSettings = null; + + /** + * The source date format as string. + */ + public static String srcDateFormat = "yyyy.MM.dd hh:mm:ss"; + + + /** + * The source date format used to read string represented strings. + */ + public static DateFormat srcFormat; + + + static { + srcFormat = new SimpleDateFormat(srcDateFormat); + } + + /** * Constructor */ diff -r e91ebe3696ec -r ac5988f27714 gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java Mon Apr 19 12:31:02 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java Mon Apr 19 14:19:19 2010 +0000 @@ -3,8 +3,13 @@ import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; + +import java.text.DateFormat; +import java.text.ParseException; + import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -198,6 +203,7 @@ "ODV", "ISO-8859-1"); + /** * Constructor */ @@ -1050,14 +1056,49 @@ /** - * Creates and returns the subtitle of a chart. + * Creates and returns the subtitle of a chart. The subtitle in this class + * contains the station and the time interval. * * @param locale The Locale used to adjust the language of the subtitle. * @param uuid The UUID of the current artifact. * @return the selected feature. */ protected String createChartSubtitle(Locale locale, String uuid) { - return getSelectedFeatureName(uuid); + String subtitle = ""; + subtitle += getSelectedFeatureName(uuid); + + InputData data = inputData.get(timeIntervalValueName); + if (data != null){ + Object describeData = data.getObject(); + if (describeData instanceof MinMaxDescribeData) { + MinMaxDescribeData tmp = (MinMaxDescribeData) describeData; + + DateFormat format = DateFormat.getDateTimeInstance( + DateFormat.MEDIUM, DateFormat.SHORT, locale); + + String lDateStr = (String) tmp.getMinValue(); + String rDateStr = (String) tmp.getMaxValue(); + + try { + Date lDate = srcFormat.parse(lDateStr); + Date rDate = srcFormat.parse(rDateStr); + + String interval = format.format(lDate); + interval += " - "; + interval += format.format(rDate); + + if (subtitle != null && subtitle.length() > 0) + subtitle += ", "; + + subtitle += interval; + } + catch (ParseException pe) { + log.error(pe, pe); + } + } + } + + return subtitle; }