annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/charts/TimeseriesStepChart.java @ 4255:670e98f5a441

Fixed leak while merging facets. The ThemeList that is used by OutputHelper to sort the Facets for an Output now uses a list to store the ManagedFacets. The correct order is made up by sorting the List using Collections.sort() function of the Java JDK. Therfore, the ManagedFacet class implements the Comparable interface. The return value of its compareTo(other) method depends on the value of the 'position' field.
author Ingo Weinzierl <weinzierl.ingo@googlemail.com>
date Thu, 25 Oct 2012 14:01:46 +0200
parents 6d8c7a00e74e
children
rev   line source
2232
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.charts;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.awt.Dimension;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.util.Date;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import java.util.GregorianCalendar;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import org.jfree.chart.ChartFactory;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import org.jfree.chart.ChartPanel;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import org.jfree.chart.JFreeChart;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import org.jfree.ui.ApplicationFrame;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import org.jfree.data.time.SimpleTimePeriod;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import org.jfree.data.time.Second;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import org.jfree.data.time.TimeSeries;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import org.jfree.data.time.TimeSeriesCollection;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import org.jfree.data.time.TimePeriodValues;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import org.jfree.data.time.TimePeriodValuesCollection;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import org.apache.log4j.Logger;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import org.apache.log4j.PropertyConfigurator;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 public class TimeseriesStepChart extends ApplicationFrame {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 private static final Logger logger =
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 Logger.getLogger(TimeseriesStepChart.class);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 public static final String LOG4J_PROPERTIES = "FLYS_CLIENT_LOG4J_PROPERIES";
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 public static final int USER_CHART_TYPE =
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 Integer.getInteger("chart.type", -1);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 public static final int CHART_TYPE_TIMEPERIOD = 1;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 public static final int CHART_TYPE_TIMESERIES = 2;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 public static void main(String[] args) {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 configureLogging();
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 logger.info("Start TimeseriesStepChart demo.");
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 if (USER_CHART_TYPE <= 0) {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 logger.error("Unknown chart type: " + USER_CHART_TYPE);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 logger.debug("Create Chart from type: " + USER_CHART_TYPE);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 TimeseriesStepChart tsc = new TimeseriesStepChart();
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 tsc.build(USER_CHART_TYPE);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 logger.info("End of TimeseriesStepChart demo.");
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55
4052
6d8c7a00e74e Do cumentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3083
diff changeset
56 /** Setup the log4j logging (read LOG4J_PROPERIES envvar). */
2232
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 public static void configureLogging() {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 String log4jProperties = System.getenv(LOG4J_PROPERTIES);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 if (log4jProperties != null && log4jProperties.length() > 0) {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 PropertyConfigurator.configure(log4jProperties);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 logger.info("Log4J logging initialized.");
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 else {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 System.out.println("Error while setting up Log4J configuration.");
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 System.out.println("LoggingConfigurator.init finished");
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 public TimeseriesStepChart() {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 super("TimeseriesStepChart");
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 public void build(int type) {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 ChartPanel chartPanel = createChartPanel(type);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 chartPanel.setPreferredSize(new Dimension(500, 300));
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 setContentPane(chartPanel);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 pack();
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 setVisible(true);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 protected ChartPanel createChartPanel(int type) {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 JFreeChart chart = createJFreeChart(type);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 ChartPanel panel = new ChartPanel(chart);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 return panel;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 protected JFreeChart createJFreeChart(int type) {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 if (type == CHART_TYPE_TIMEPERIOD) {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 return createTimePeriodValuesChart();
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 else if (type == CHART_TYPE_TIMESERIES) {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 return createTimeSeriesChart();
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 logger.error("Unknown chart type: " + type);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 return null;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 public static Date createDate(int year, int month, int day) {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 GregorianCalendar cal = new GregorianCalendar(year, month, day);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 return cal.getTime();
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 //
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 // XXX FOLLOWING METHODS ARE USED FOR "TimePeriodValues" CHART TYPE
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 //
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 protected JFreeChart createTimePeriodValuesChart() {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 return ChartFactory.createTimeSeriesChart(
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 "TimePeriodValues Chart",
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 "Time Axis",
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 "Y Axis",
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 createTimePeriodValuesDataset(),
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 true,
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126 false,
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 false);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131 protected TimePeriodValuesCollection createTimePeriodValuesDataset() {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132 TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133 TimePeriodValues series = createTimePeriodValues();
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 dataset.addSeries(series);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137 return dataset;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141 protected TimePeriodValues createTimePeriodValues() {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 TimePeriodValues series1 = new TimePeriodValues("Series 1");
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 Date start1 = createDate(2000, 0, 1);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 Date end1 = createDate(2000, 11, 31);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 logger.debug("START DATE 1 = " + start1);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 logger.debug("END DATE 1 = " + end1);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 SimpleTimePeriod period1 = new SimpleTimePeriod(start1, end1);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 Date start2 = createDate(2001, 0, 1);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 Date end2 = createDate(2001, 11, 31);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 SimpleTimePeriod period2 = new SimpleTimePeriod(start2, end2);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 Date start3 = createDate(2002, 0, 1);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 Date end3 = createDate(2002, 11, 31);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 SimpleTimePeriod period3 = new SimpleTimePeriod(start3, end3);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 series1.add(period1, 100);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 series1.add(period2, 200);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162 series1.add(period3, 150);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 return series1;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168 //
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 // XXX FOLLOWING METHODS ARE USED FOR "TimePeriodValues" CHART TYPE
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 //
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171 protected JFreeChart createTimeSeriesChart() {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172 return ChartFactory.createTimeSeriesChart(
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173 "TimeSeriesCollection Chart",
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174 "Time Axis",
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175 "Y Axis",
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176 createTimeSeriesCollectionDataset(),
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177 true,
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 false,
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 false);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
180 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 protected TimeSeriesCollection createTimeSeriesCollectionDataset() {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184 TimeSeriesCollection dataset = new TimeSeriesCollection();
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 TimeSeries[] series = createTimeSeries();
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
186
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
187 for (TimeSeries tmp: series) {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
188 dataset.addSeries(tmp);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191 return dataset;
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
194
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
195 protected TimeSeries[] createTimeSeries() {
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
196 TimeSeries series1 = new TimeSeries("Series 1");
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197 series1.add(new Second(0, 0, 0, 1, 1, 2000), 100);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 series1.add(new Second(59, 59, 23, 31, 12, 2000), 100);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 series1.add(new Second(0, 0, 0, 1, 1, 2001), 200);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 series1.add(new Second(59, 59, 23, 31, 12, 2001), 200);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 series1.add(new Second(0, 0, 0, 1, 1, 2002), 150);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 series1.add(new Second(59, 59, 23, 31, 12, 2002), 150);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 TimeSeries series2 = new TimeSeries("Series 2");
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207 series2.add(new Second(0, 0, 0, 1, 1, 2000), 10);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208 series2.add(new Second(59, 59, 23, 31, 12, 2000), 10);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 series2.add(new Second(0, 0, 0, 1, 1, 2001), 20);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 series2.add(new Second(59, 59, 23, 31, 12, 2001), 20);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 series2.add(new Second(0, 0, 0, 1, 1, 2002), 15);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 series2.add(new Second(59, 59, 23, 31, 12, 2002), 15);
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216 return new TimeSeries[] { series1, series2 };
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 }
78ac5058da67 Added demo standalone app for evaluating different timeseries charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218 }
3083
4bd3d8bbb60c Added missing vim lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2232
diff changeset
219 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org