Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeTablesOverview.java @ 5379:61bf64b102bc mapgenfix
Merge with default branch
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Fri, 22 Mar 2013 11:25:54 +0100 |
parents | 02f6741f80d4 |
children | 2fe120e1e4df |
comparison
equal
deleted
inserted
replaced
5175:cfc5540a4eec | 5379:61bf64b102bc |
---|---|
11 | 11 |
12 import org.apache.log4j.Logger; | 12 import org.apache.log4j.Logger; |
13 import org.hibernate.Session; | 13 import org.hibernate.Session; |
14 import org.jfree.chart.ChartFactory; | 14 import org.jfree.chart.ChartFactory; |
15 import org.jfree.chart.JFreeChart; | 15 import org.jfree.chart.JFreeChart; |
16 import org.jfree.chart.plot.Marker; | |
16 import org.jfree.chart.plot.PlotOrientation; | 17 import org.jfree.chart.plot.PlotOrientation; |
17 import org.jfree.chart.plot.XYPlot; | 18 import org.jfree.chart.plot.XYPlot; |
18 import org.jfree.data.xy.XYSeries; | 19 import org.jfree.data.xy.XYSeries; |
19 import org.jfree.data.xy.XYSeriesCollection; | 20 import org.jfree.data.xy.XYSeriesCollection; |
20 import org.w3c.dom.Document; | 21 import org.w3c.dom.Document; |
22 import org.w3c.dom.NodeList; | 23 import org.w3c.dom.NodeList; |
23 | 24 |
24 import de.intevation.artifacts.CallMeta; | 25 import de.intevation.artifacts.CallMeta; |
25 import de.intevation.artifacts.GlobalContext; | 26 import de.intevation.artifacts.GlobalContext; |
26 import de.intevation.flys.artifacts.model.DischargeTables; | 27 import de.intevation.flys.artifacts.model.DischargeTables; |
28 import de.intevation.flys.artifacts.model.GaugeRange; | |
27 import de.intevation.flys.artifacts.model.GaugesFactory; | 29 import de.intevation.flys.artifacts.model.GaugesFactory; |
28 import de.intevation.flys.artifacts.resources.Resources; | 30 import de.intevation.flys.artifacts.resources.Resources; |
29 import de.intevation.flys.backend.SessionHolder; | 31 import de.intevation.flys.backend.SessionHolder; |
30 import de.intevation.flys.model.DischargeTable; | 32 import de.intevation.flys.model.DischargeTable; |
31 import de.intevation.flys.model.Gauge; | 33 import de.intevation.flys.model.Gauge; |
34 import de.intevation.flys.model.MainValue; | |
32 import de.intevation.flys.model.TimeInterval; | 35 import de.intevation.flys.model.TimeInterval; |
33 | 36 |
34 | 37 |
38 /** Generate Discharge Table chart. */ | |
35 public class DischargeTablesOverview extends AbstractChartService { | 39 public class DischargeTablesOverview extends AbstractChartService { |
36 | 40 |
37 private static final Logger log = Logger | 41 private static final Logger log = Logger |
38 .getLogger(DischargeTablesOverview.class); | 42 .getLogger(DischargeTablesOverview.class); |
39 | 43 |
121 plot.setDomainGridlinePaint(Color.gray); | 125 plot.setDomainGridlinePaint(Color.gray); |
122 plot.setRangeGridlinePaint(Color.gray); | 126 plot.setRangeGridlinePaint(Color.gray); |
123 plot.setDomainGridlinesVisible(true); | 127 plot.setDomainGridlinesVisible(true); |
124 plot.setRangeGridlinesVisible(true); | 128 plot.setRangeGridlinesVisible(true); |
125 | 129 |
130 applyMainValueMarkers( | |
131 plot, | |
132 gauge, | |
133 callMeta); | |
134 | |
126 return chart; | 135 return chart; |
127 } | 136 } |
128 | 137 |
129 protected XYSeries createSeries(CallMeta callMeta, DischargeTable dt) | 138 protected XYSeries createSeries(CallMeta callMeta, DischargeTable dt) |
130 throws IllegalArgumentException { | 139 throws IllegalArgumentException { |
144 for (int i = 0, n = xy[0].length; i < n; i++) { | 153 for (int i = 0, n = xy[0].length; i < n; i++) { |
145 series.add(xy[0][i], xy[1][i]); | 154 series.add(xy[0][i], xy[1][i]); |
146 } | 155 } |
147 | 156 |
148 return series; | 157 return series; |
158 } | |
159 | |
160 | |
161 /** Add domain markers to plot that indicate mainvalues. */ | |
162 protected static void applyMainValueMarkers( | |
163 XYPlot plot, | |
164 Gauge gauge, | |
165 CallMeta meta | |
166 ) { | |
167 String river = gauge.getRiver().getName(); | |
168 double km = gauge.getStation().doubleValue(); | |
169 | |
170 // Get Gauge s mainvalues. | |
171 List<MainValue> mainValues = gauge.getMainValues(); | |
172 for (MainValue mainValue : mainValues) { | |
173 if (mainValue.getMainValue().getType().getName().equals("Q")) { | |
174 // Its a Q main value. | |
175 Marker m = FixingsKMChartService.createQSectorMarker( | |
176 mainValue.getValue().doubleValue(), | |
177 mainValue.getMainValue().getName()); | |
178 plot.addDomainMarker(m); | |
179 } | |
180 else if (mainValue.getMainValue().getType().getName().equals("W")) { | |
181 // Its a W main value. | |
182 Marker m = FixingsKMChartService.createQSectorMarker( | |
183 mainValue.getValue().doubleValue(), | |
184 mainValue.getMainValue().getName()); | |
185 plot.addRangeMarker(m); | |
186 } | |
187 } | |
149 } | 188 } |
150 | 189 |
151 protected String createSeriesTitle(CallMeta callMeta, DischargeTable dt) | 190 protected String createSeriesTitle(CallMeta callMeta, DischargeTable dt) |
152 throws IllegalArgumentException { | 191 throws IllegalArgumentException { |
153 TimeInterval timeInterval = dt.getTimeInterval(); | 192 TimeInterval timeInterval = dt.getTimeInterval(); |
257 } | 296 } |
258 | 297 |
259 return dts; | 298 return dts; |
260 } | 299 } |
261 } | 300 } |
301 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |