Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeTablesOverview.java @ 5344:f987d25627aa
Show some Q mainvalues in DischargeTablesOverview.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 20 Mar 2013 12:27:45 +0100 |
parents | 7b119fa1e29f |
children | 02f6741f80d4 |
comparison
equal
deleted
inserted
replaced
5343:61f4d4164a30 | 5344:f987d25627aa |
---|---|
6 import java.util.ArrayList; | 6 import java.util.ArrayList; |
7 import java.util.Collections; | 7 import java.util.Collections; |
8 import java.util.Date; | 8 import java.util.Date; |
9 import java.util.List; | 9 import java.util.List; |
10 import java.util.Locale; | 10 import java.util.Locale; |
11 import java.util.Map; | |
11 | 12 |
12 import org.apache.log4j.Logger; | 13 import org.apache.log4j.Logger; |
13 import org.hibernate.Session; | 14 import org.hibernate.Session; |
14 import org.jfree.chart.ChartFactory; | 15 import org.jfree.chart.ChartFactory; |
15 import org.jfree.chart.JFreeChart; | 16 import org.jfree.chart.JFreeChart; |
17 import org.jfree.chart.plot.Marker; | |
16 import org.jfree.chart.plot.PlotOrientation; | 18 import org.jfree.chart.plot.PlotOrientation; |
17 import org.jfree.chart.plot.XYPlot; | 19 import org.jfree.chart.plot.XYPlot; |
18 import org.jfree.data.xy.XYSeries; | 20 import org.jfree.data.xy.XYSeries; |
19 import org.jfree.data.xy.XYSeriesCollection; | 21 import org.jfree.data.xy.XYSeriesCollection; |
20 import org.w3c.dom.Document; | 22 import org.w3c.dom.Document; |
22 import org.w3c.dom.NodeList; | 24 import org.w3c.dom.NodeList; |
23 | 25 |
24 import de.intevation.artifacts.CallMeta; | 26 import de.intevation.artifacts.CallMeta; |
25 import de.intevation.artifacts.GlobalContext; | 27 import de.intevation.artifacts.GlobalContext; |
26 import de.intevation.flys.artifacts.model.DischargeTables; | 28 import de.intevation.flys.artifacts.model.DischargeTables; |
29 import de.intevation.flys.artifacts.model.GaugeFinder; | |
30 import de.intevation.flys.artifacts.model.GaugeFinderFactory; | |
31 import de.intevation.flys.artifacts.model.GaugeRange; | |
27 import de.intevation.flys.artifacts.model.GaugesFactory; | 32 import de.intevation.flys.artifacts.model.GaugesFactory; |
28 import de.intevation.flys.artifacts.resources.Resources; | 33 import de.intevation.flys.artifacts.resources.Resources; |
29 import de.intevation.flys.backend.SessionHolder; | 34 import de.intevation.flys.backend.SessionHolder; |
30 import de.intevation.flys.model.DischargeTable; | 35 import de.intevation.flys.model.DischargeTable; |
31 import de.intevation.flys.model.Gauge; | 36 import de.intevation.flys.model.Gauge; |
122 plot.setDomainGridlinePaint(Color.gray); | 127 plot.setDomainGridlinePaint(Color.gray); |
123 plot.setRangeGridlinePaint(Color.gray); | 128 plot.setRangeGridlinePaint(Color.gray); |
124 plot.setDomainGridlinesVisible(true); | 129 plot.setDomainGridlinesVisible(true); |
125 plot.setRangeGridlinesVisible(true); | 130 plot.setRangeGridlinesVisible(true); |
126 | 131 |
132 applyMainValueMarkers( | |
133 plot, | |
134 gauge.getRiver().getName(), | |
135 gauge.getStation().doubleValue(), | |
136 callMeta); | |
137 | |
127 return chart; | 138 return chart; |
128 } | 139 } |
129 | 140 |
130 protected XYSeries createSeries(CallMeta callMeta, DischargeTable dt) | 141 protected XYSeries createSeries(CallMeta callMeta, DischargeTable dt) |
131 throws IllegalArgumentException { | 142 throws IllegalArgumentException { |
145 for (int i = 0, n = xy[0].length; i < n; i++) { | 156 for (int i = 0, n = xy[0].length; i < n; i++) { |
146 series.add(xy[0][i], xy[1][i]); | 157 series.add(xy[0][i], xy[1][i]); |
147 } | 158 } |
148 | 159 |
149 return series; | 160 return series; |
161 } | |
162 | |
163 | |
164 /** Add domain markers to plot that indicate (only some Q) mainvalues. */ | |
165 protected static void applyMainValueMarkers( | |
166 XYPlot plot, | |
167 String river, | |
168 double km, | |
169 CallMeta meta | |
170 ) { | |
171 GaugeFinderFactory ggf = GaugeFinderFactory.getInstance(); | |
172 GaugeFinder gf = ggf.getGaugeFinder(river); | |
173 | |
174 if (gf == null) { | |
175 log.warn("No gauge finder found for river '" + river + "'"); | |
176 return; | |
177 } | |
178 | |
179 GaugeRange gr = gf.find(km); | |
180 if (gr == null) { | |
181 log.debug("No gauge range found for km " | |
182 + km + " on river " + river + "."); | |
183 return; | |
184 } | |
185 | |
186 if (log.isDebugEnabled()) { | |
187 log.debug(gr); | |
188 } | |
189 | |
190 for (Map.Entry<String, Double> entry: gr.getMainValues().entrySet()) { | |
191 Marker m = FixingsKMChartService.createQSectorMarker( | |
192 entry.getValue(), | |
193 entry.getKey()); | |
194 | |
195 if (m != null) { | |
196 plot.addDomainMarker(m); | |
197 } | |
198 } | |
150 } | 199 } |
151 | 200 |
152 protected String createSeriesTitle(CallMeta callMeta, DischargeTable dt) | 201 protected String createSeriesTitle(CallMeta callMeta, DischargeTable dt) |
153 throws IllegalArgumentException { | 202 throws IllegalArgumentException { |
154 TimeInterval timeInterval = dt.getTimeInterval(); | 203 TimeInterval timeInterval = dt.getTimeInterval(); |