annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeTablesOverview.java @ 5421:420c553bc86d

Cosmetics, fix typo in i18n.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 26 Mar 2013 11:25:44 +0100
parents 02f6741f80d4
children 2fe120e1e4df
rev   line source
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.services;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.awt.Color;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.text.DateFormat;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import java.text.ParseException;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import java.util.ArrayList;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import java.util.Collections;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import java.util.Date;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import java.util.List;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import java.util.Locale;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import org.apache.log4j.Logger;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import org.hibernate.Session;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import org.jfree.chart.ChartFactory;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import org.jfree.chart.JFreeChart;
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
16 import org.jfree.chart.plot.Marker;
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import org.jfree.chart.plot.PlotOrientation;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import org.jfree.chart.plot.XYPlot;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import org.jfree.data.xy.XYSeries;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import org.jfree.data.xy.XYSeriesCollection;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import org.w3c.dom.Document;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import org.w3c.dom.Element;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 import org.w3c.dom.NodeList;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 import de.intevation.artifacts.CallMeta;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 import de.intevation.artifacts.GlobalContext;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 import de.intevation.flys.artifacts.model.DischargeTables;
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
28 import de.intevation.flys.artifacts.model.GaugeRange;
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 import de.intevation.flys.artifacts.model.GaugesFactory;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 import de.intevation.flys.artifacts.resources.Resources;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 import de.intevation.flys.backend.SessionHolder;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 import de.intevation.flys.model.DischargeTable;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 import de.intevation.flys.model.Gauge;
5360
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
34 import de.intevation.flys.model.MainValue;
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 import de.intevation.flys.model.TimeInterval;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
5342
7b119fa1e29f Doc and vim-magiv.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4230
diff changeset
38 /** Generate Discharge Table chart. */
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 public class DischargeTablesOverview extends AbstractChartService {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 private static final Logger log = Logger
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 .getLogger(DischargeTablesOverview.class);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 private static final long serialVersionUID = 1L;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 public static final String I18N_CHART_TITLE = "gauge.discharge.service.chart.title";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 public static final String DEFAULT_CHART_TITLE = "Pegel: XXX";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 public static final String I18N_CHART_X_AXIS_TITLE = "gauge.discharge.service.chart.x.title";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 public static final String DEFAULT_X_AXIS_TITLE = "Q [m^3/s]";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 public static final String I18N_CHART_Y_AXIS_TITLE = "gauge.discharge.service.chart.y.title";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 public static final String DEFAULT_Y_AXIS_TITLE = "W [cm]";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 public static final String I18N_CHART_SERIES_TITLE = "gauge.discharge.service.chart.series.title";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 public static final String DEFAULT_CHART_SERIES_TITLE = "Abflusskurve";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 public static final String I18N_CHART_SERIES_TITLE_MASTER = "gauge.discharge.service.chart.series.title.master";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 public static final String DEFAULT_CHART_SERIES_TITLE_MASTER = "Aktuelle Abflusskurve";
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 public static final DateFormat DATE_FORMAT = DateFormat.getDateInstance(
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 DateFormat.SHORT, Locale.GERMANY);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 private Session session;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 @Override
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 protected void init() {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 session = SessionHolder.acquire();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 @Override
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 protected void finish() {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 if (session != null) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 session.close();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 SessionHolder.release();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 protected JFreeChart createChart(Document data,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 GlobalContext globalContext, CallMeta callMeta) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 Gauge gauge = extractGauge(data);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 if (gauge == null) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 log.warn("Could not determine Gauge from request!");
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 return null;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 log.info("create discharge chart for gauge '" + gauge.getName() + "'");
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 TimeInterval timerange = extractTimeInterval(data);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 List<DischargeTable> dts = getDischargeTables(gauge, timerange);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 XYSeriesCollection dataset = new XYSeriesCollection();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 for (DischargeTable dt : dts) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 try {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 XYSeries series = createSeries(callMeta, dt);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 if (series != null) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 dataset.addSeries(series);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 catch (IllegalArgumentException iae) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 log.warn("unable to create discharge curve: "
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 + iae.getMessage());
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 String title = Resources.format(callMeta, I18N_CHART_TITLE,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 DEFAULT_CHART_TITLE, gauge.getName());
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 String xAxis = Resources.getMsg(callMeta, I18N_CHART_X_AXIS_TITLE,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 DEFAULT_X_AXIS_TITLE);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 String yAxis = Resources.format(callMeta, I18N_CHART_Y_AXIS_TITLE,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 DEFAULT_Y_AXIS_TITLE);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 JFreeChart chart = ChartFactory.createXYLineChart(title, xAxis, yAxis,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 null, PlotOrientation.VERTICAL, true, true, false);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 chart.setBackgroundPaint(Color.white);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 XYPlot plot = (XYPlot) chart.getPlot();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 plot.setDataset(0, dataset);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 plot.setBackgroundPaint(Color.white);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 plot.setDomainGridlinePaint(Color.gray);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126 plot.setRangeGridlinePaint(Color.gray);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 plot.setDomainGridlinesVisible(true);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 plot.setRangeGridlinesVisible(true);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
130 applyMainValueMarkers(
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
131 plot,
5360
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
132 gauge,
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
133 callMeta);
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
134
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 return chart;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 protected XYSeries createSeries(CallMeta callMeta, DischargeTable dt)
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139 throws IllegalArgumentException {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141 double[][] xy = null;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 if (dt.getKind() == DischargeTables.MASTER) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 xy = DischargeTables.loadDischargeTableValues(dt,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 DischargeTables.MASTER_SCALE);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 else {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 xy = DischargeTables.loadDischargeTableValues(dt,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 DischargeTables.HISTORICAL_SCALE);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 XYSeries series = new XYSeries(createSeriesTitle(callMeta, dt), false);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 for (int i = 0, n = xy[0].length; i < n; i++) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 series.add(xy[0][i], xy[1][i]);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 return series;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
160
5360
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
161 /** Add domain markers to plot that indicate mainvalues. */
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
162 protected static void applyMainValueMarkers(
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
163 XYPlot plot,
5360
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
164 Gauge gauge,
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
165 CallMeta meta
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
166 ) {
5360
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
167 String river = gauge.getRiver().getName();
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
168 double km = gauge.getStation().doubleValue();
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
169
5360
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
170 // Get Gauge s mainvalues.
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
171 List<MainValue> mainValues = gauge.getMainValues();
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
172 for (MainValue mainValue : mainValues) {
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
173 if (mainValue.getMainValue().getType().getName().equals("Q")) {
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
174 // Its a Q main value.
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
175 Marker m = FixingsKMChartService.createQSectorMarker(
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
176 mainValue.getValue().doubleValue(),
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
177 mainValue.getMainValue().getName());
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
178 plot.addDomainMarker(m);
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
179 }
5360
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
180 else if (mainValue.getMainValue().getType().getName().equals("W")) {
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
181 // Its a W main value.
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
182 Marker m = FixingsKMChartService.createQSectorMarker(
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
183 mainValue.getValue().doubleValue(),
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
184 mainValue.getMainValue().getName());
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
185 plot.addRangeMarker(m);
02f6741f80d4 DischargeTablesOverview: Show main values from gauge in dischargetablesoverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5344
diff changeset
186 }
5344
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
187 }
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
188 }
f987d25627aa Show some Q mainvalues in DischargeTablesOverview.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5342
diff changeset
189
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190 protected String createSeriesTitle(CallMeta callMeta, DischargeTable dt)
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191 throws IllegalArgumentException {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192 TimeInterval timeInterval = dt.getTimeInterval();
4227
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4217
diff changeset
193
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4217
diff changeset
194 if (timeInterval == null) {
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4217
diff changeset
195 return Resources.format(callMeta, DEFAULT_CHART_SERIES_TITLE);
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4217
diff changeset
196 }
8138a90a674a Be more tolerant with empty time intervals in discharge tables while comparing discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4217
diff changeset
197
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 Date start = timeInterval.getStartTime();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199 Date end = timeInterval.getStopTime();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 if (start != null && end != null) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202 return Resources.format(callMeta, I18N_CHART_SERIES_TITLE,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 DEFAULT_CHART_SERIES_TITLE, start, end);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 else if (start != null) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 return Resources.format(callMeta, I18N_CHART_SERIES_TITLE_MASTER,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207 DEFAULT_CHART_SERIES_TITLE, start);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 else {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 throw new IllegalArgumentException(
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 "Missing start date of DischargeTable " + dt.getId());
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215 protected Gauge extractGauge(Document data) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216 NodeList gauges = data.getElementsByTagName("gauge");
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218 if (gauges.getLength() > 0) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
219 String name = ((Element) gauges.item(0)).getAttribute("name");
4217
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
220
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
221 try {
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
222 long officialNumber = Long.valueOf(name);
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
223 return Gauge.getGaugeByOfficialNumber(officialNumber);
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
224 }
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
225 catch (NumberFormatException nfe) {
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
226 // it seems, that the client uses the name of the gauge instead
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
227 // of its official number
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
228 }
08b6458909a9 The service 'DischargeTablesOverview' now accepts the official number of a gauge, too.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4213
diff changeset
229
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
230 if (name != null && name.length() > 0) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
231 return GaugesFactory.getGauge(name);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
232 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
233 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
234
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
235 return null;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
236 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
237
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
238 protected TimeInterval extractTimeInterval(Document data) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
239 NodeList timeranges = data.getElementsByTagName("timerange");
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
240
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
241 if (timeranges != null && timeranges.getLength() > 0) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
242 Element timerange = (Element) timeranges.item(0);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
243
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
244 String lower = timerange.getAttribute("lower");
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
245 String upper = timerange.getAttribute("upper");
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
246
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
247 if (lower != null && upper != null) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
248 try {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
249 Date d1 = DATE_FORMAT.parse(lower);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
250 Date d2 = DATE_FORMAT.parse(upper);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
251
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
252 return new TimeInterval(d1, d2);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
253 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
254 catch (ParseException pe) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
255 log.warn("Wrong time format: " + pe.getMessage());
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
256 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
257 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
258 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
259
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
260 return null;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
261 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
262
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
263 protected List<DischargeTable> getDischargeTables(Gauge gauge,
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264 TimeInterval timerange) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
265 List<DischargeTable> all = gauge.getDischargeTables();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
266 Collections.sort(all);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
267
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
268 if (timerange == null) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
269 return all;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
270 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
271
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
272 List<DischargeTable> dts = new ArrayList<DischargeTable>(all.size());
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
273 long startDate = timerange.getStartTime().getTime();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
274 long stopDate = timerange.getStopTime().getTime();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
275
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
276 for (DischargeTable dt : all) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
277 TimeInterval tmp = dt.getTimeInterval();
4230
eab85cf85b10 Ignore discharge table without time interval set while discharge tables overview chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4227
diff changeset
278 if (tmp == null) {
eab85cf85b10 Ignore discharge table without time interval set while discharge tables overview chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4227
diff changeset
279 // this should never happen because all discharge tables should
eab85cf85b10 Ignore discharge table without time interval set while discharge tables overview chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4227
diff changeset
280 // have a time interval set!
eab85cf85b10 Ignore discharge table without time interval set while discharge tables overview chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4227
diff changeset
281 continue;
eab85cf85b10 Ignore discharge table without time interval set while discharge tables overview chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4227
diff changeset
282 }
eab85cf85b10 Ignore discharge table without time interval set while discharge tables overview chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4227
diff changeset
283
4213
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
284 Date start = tmp.getStartTime();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
285 Date stop = tmp.getStartTime();
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
286
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
287 if (start.getTime() > startDate && start.getTime() < stopDate) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
288 dts.add(dt);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
289 continue;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
290 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
291 else if (stop != null && stop.getTime() < stopDate
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
292 && stop.getTime() > startDate) {
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
293 dts.add(dt);
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
294 continue;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
295 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
296 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
297
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
298 return dts;
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
299 }
0674d89210f5 Added a new service to query a diagram with discharge tables.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
300 }
5342
7b119fa1e29f Doc and vim-magiv.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4230
diff changeset
301 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org