comparison gnv-artifacts/src/main/java/de/intevation/gnv/chart/TimeSeriesChart.java @ 505:7ff916744f40

Solved issue152. Time intervals of timeseries axis are defined by JFreeChart automatically. gnv-artifacts/trunk@588 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 20 Jan 2010 17:54:48 +0000
parents f14c5d1b5b71
children d9d933e06875
comparison
equal deleted inserted replaced
504:efab67e68bba 505:7ff916744f40
5 import java.util.Collection; 5 import java.util.Collection;
6 import java.util.Date; 6 import java.util.Date;
7 import java.util.HashMap; 7 import java.util.HashMap;
8 import java.util.Iterator; 8 import java.util.Iterator;
9 import java.util.Locale; 9 import java.util.Locale;
10 import java.util.TimeZone;
10 11
11 import org.apache.log4j.Logger; 12 import org.apache.log4j.Logger;
12 13
13 import org.jfree.chart.ChartTheme; 14 import org.jfree.chart.ChartTheme;
14 import org.jfree.chart.ChartFactory; 15 import org.jfree.chart.ChartFactory;
79 null, 80 null,
80 true, 81 true,
81 false, 82 false,
82 false 83 false
83 ); 84 );
85
86 XYPlot plot = (XYPlot) chart.getPlot();
87 plot.setDomainAxis(0, new DateAxis(
88 labels.getDomainAxisLabel(), TimeZone.getDefault(), locale));
84 } 89 }
85 90
86 91
87 protected void initData() { 92 protected void initData() {
88 log.debug("init data for timeseries chart"); 93 log.debug("init data for timeseries chart");
214 } 219 }
215 } 220 }
216 221
217 222
218 protected void localizeDomainAxis(Axis axis, Locale locale) { 223 protected void localizeDomainAxis(Axis axis, Locale locale) {
219 if (locale == null) 224 // do nothing
220 return;
221
222 log.debug(
223 "Set language of axis [" + axis.getLabel() + "] " +
224 "to " + locale.toString()
225 );
226
227 String dateFormat = getMessage(locale, DATE_FORMAT,DEFAULT_DATE_FORMAT);
228 DateFormat format = new SimpleDateFormat(dateFormat, locale);
229 ((DateAxis) axis).setDateFormatOverride(format);
230 } 225 }
231 226
232 227
233 protected String getMessage(Locale locale, String key, String def) { 228 protected String getMessage(Locale locale, String key, String def) {
234 return RessourceFactory.getInstance().getRessource(locale, key, def); 229 return RessourceFactory.getInstance().getRessource(locale, key, def);

http://dive4elements.wald.intevation.org