comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java @ 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 47280aff0eb7
comparison
equal deleted inserted replaced
838:e91ebe3696ec 839:ac5988f27714
1 package de.intevation.gnv.state.timeseries; 1 package de.intevation.gnv.state.timeseries;
2 2
3 import java.io.IOException; 3 import java.io.IOException;
4 import java.io.OutputStream; 4 import java.io.OutputStream;
5 import java.io.UnsupportedEncodingException; 5 import java.io.UnsupportedEncodingException;
6
7 import java.text.DateFormat;
8 import java.text.ParseException;
9
6 import java.util.ArrayList; 10 import java.util.ArrayList;
7 import java.util.Collection; 11 import java.util.Collection;
12 import java.util.Date;
8 import java.util.HashMap; 13 import java.util.HashMap;
9 import java.util.Iterator; 14 import java.util.Iterator;
10 import java.util.List; 15 import java.util.List;
11 import java.util.Locale; 16 import java.util.Locale;
12 import java.util.Map; 17 import java.util.Map;
196 CSVWriter.NO_QUOTE_CHARACTER, 201 CSVWriter.NO_QUOTE_CHARACTER,
197 CSVWriter.NO_ESCAPE_CHARACTER, 202 CSVWriter.NO_ESCAPE_CHARACTER,
198 "ODV", 203 "ODV",
199 "ISO-8859-1"); 204 "ISO-8859-1");
200 205
206
201 /** 207 /**
202 * Constructor 208 * Constructor
203 */ 209 */
204 public TimeSeriesOutputState() { 210 public TimeSeriesOutputState() {
205 super(); 211 super();
1048 1054
1049 } 1055 }
1050 1056
1051 1057
1052 /** 1058 /**
1053 * Creates and returns the subtitle of a chart. 1059 * Creates and returns the subtitle of a chart. The subtitle in this class
1060 * contains the station and the time interval.
1054 * 1061 *
1055 * @param locale The Locale used to adjust the language of the subtitle. 1062 * @param locale The Locale used to adjust the language of the subtitle.
1056 * @param uuid The UUID of the current artifact. 1063 * @param uuid The UUID of the current artifact.
1057 * @return the selected feature. 1064 * @return the selected feature.
1058 */ 1065 */
1059 protected String createChartSubtitle(Locale locale, String uuid) { 1066 protected String createChartSubtitle(Locale locale, String uuid) {
1060 return getSelectedFeatureName(uuid); 1067 String subtitle = "";
1068 subtitle += getSelectedFeatureName(uuid);
1069
1070 InputData data = inputData.get(timeIntervalValueName);
1071 if (data != null){
1072 Object describeData = data.getObject();
1073 if (describeData instanceof MinMaxDescribeData) {
1074 MinMaxDescribeData tmp = (MinMaxDescribeData) describeData;
1075
1076 DateFormat format = DateFormat.getDateTimeInstance(
1077 DateFormat.MEDIUM, DateFormat.SHORT, locale);
1078
1079 String lDateStr = (String) tmp.getMinValue();
1080 String rDateStr = (String) tmp.getMaxValue();
1081
1082 try {
1083 Date lDate = srcFormat.parse(lDateStr);
1084 Date rDate = srcFormat.parse(rDateStr);
1085
1086 String interval = format.format(lDate);
1087 interval += " - ";
1088 interval += format.format(rDate);
1089
1090 if (subtitle != null && subtitle.length() > 0)
1091 subtitle += ", ";
1092
1093 subtitle += interval;
1094 }
1095 catch (ParseException pe) {
1096 log.error(pe, pe);
1097 }
1098 }
1099 }
1100
1101 return subtitle;
1061 } 1102 }
1062 1103
1063 1104
1064 /** 1105 /**
1065 * Creates and returns labels to decorate histograms. 1106 * Creates and returns labels to decorate histograms.

http://dive4elements.wald.intevation.org