Mercurial > dive4elements > gnv-client
changeset 839:ac5988f27714
Added the time interval into the subtitle of timeseries charts (issue152).
gnv-artifacts/trunk@948 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 19 Apr 2010 14:19:19 +0000 |
parents | e91ebe3696ec |
children | 47578d91c4f0 |
files | gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java |
diffstat | 3 files changed, 75 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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 <ingo.weinzierl@intevation.de> + + 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 <ingo.weinzierl@intevation.de> Issue226
--- 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<String, InputData> 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 */
--- 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; }