Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChart.java @ 767:79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
gnv-artifacts/trunk@823 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 24 Mar 2010 14:48:55 +0000 |
parents | b98d1adee7a6 |
children | 9a828e5a2390 |
comparison
equal
deleted
inserted
replaced
766:a23ce49423d5 | 767:79401c871da4 |
---|---|
18 import de.intevation.gnv.geobackend.base.Result; | 18 import de.intevation.gnv.geobackend.base.Result; |
19 import de.intevation.gnv.utils.DistanceCalculator; | 19 import de.intevation.gnv.utils.DistanceCalculator; |
20 | 20 |
21 | 21 |
22 /** | 22 /** |
23 * @author Ingo Weinzierl <ingo.weinzierl@intevation.de> | 23 * This class is used to create xy-charts of horizontal profiles. |
24 * | |
25 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
24 */ | 26 */ |
25 public class HorizontalProfileChart | 27 public class HorizontalProfileChart |
26 extends VerticalProfileChart | 28 extends VerticalProfileChart |
27 { | 29 { |
30 /** | |
31 * Logger used for logging with log4j. | |
32 */ | |
28 private static Logger log = Logger.getLogger(HorizontalProfileChart.class); | 33 private static Logger log = Logger.getLogger(HorizontalProfileChart.class); |
29 | 34 |
35 /** | |
36 * <code>WKTReader</code> used to turn wkt strings into geometries. | |
37 */ | |
30 private static WKTReader wktReader = new WKTReader(); | 38 private static WKTReader wktReader = new WKTReader(); |
39 | |
40 /** | |
41 * The first point in a HorizontalProfileChart. It is used to calculate the | |
42 * distance between the currently processed point an the start. | |
43 */ | |
31 private Point firstPoint; | 44 private Point firstPoint; |
32 | 45 |
46 /** | |
47 * Constructor used to create horizontal profile charts. | |
48 * | |
49 * @param labels Labels used to be displayed in title, subtitle and so on. | |
50 * @param theme ChartTheme used to adjust the rendering of this chart. | |
51 * @param parameters Collection containing a bunch of parameters. | |
52 * @param measurements Collection containing a bunch of measurements. | |
53 * @param dates Collection containing a bunch of date objects. | |
54 * @param result Collection containing a bunch of <code>Result</code> | |
55 * objects which contain the actual data items to be displayed. | |
56 * @param timeGaps Collection with timegap definitions. | |
57 * @param locale Locale used to specify the format of labels, numbers, ... | |
58 * @param linesVisible Render lines between data points if true, otherwise | |
59 * not. | |
60 * @param shapesVisible Render vertices as points if true, otherwise not. | |
61 */ | |
33 public HorizontalProfileChart( | 62 public HorizontalProfileChart( |
34 ChartLabels labels, | 63 ChartLabels labels, |
35 ChartTheme theme, | 64 ChartTheme theme, |
36 Collection parameters, | 65 Collection parameters, |
37 Collection measurements, | 66 Collection measurements, |
56 ); | 85 ); |
57 this.PLOT_ORIENTATION = PlotOrientation.VERTICAL; | 86 this.PLOT_ORIENTATION = PlotOrientation.VERTICAL; |
58 } | 87 } |
59 | 88 |
60 | 89 |
90 /** | |
91 * @see de.intevation.gnv.chart.VerticalProfileChart#getValue(Result) | |
92 */ | |
61 @Override | 93 @Override |
62 protected Object getValue(Result row) { | 94 protected Object getValue(Result row) { |
63 try { | 95 try { |
64 return (Point) wktReader.read(row.getString("SHAPE")); | 96 return (Point) wktReader.read(row.getString("SHAPE")); |
65 } | 97 } |
68 return null; | 100 return null; |
69 } | 101 } |
70 } | 102 } |
71 | 103 |
72 | 104 |
105 /** | |
106 * @see de.intevation.gnv.chart.VerticalProfileChart#gapDetection(Result, | |
107 * Series, int, int) | |
108 */ | |
109 @Override | |
73 protected void gapDetection( | 110 protected void gapDetection( |
74 Result[] results, | 111 Result[] results, |
75 Series series, | 112 Series series, |
76 int startPos, | 113 int startPos, |
77 int endPos | 114 int endPos |
101 | 138 |
102 log.debug("Gap detection finished."); | 139 log.debug("Gap detection finished."); |
103 } | 140 } |
104 | 141 |
105 | 142 |
143 /** | |
144 * @see de.intevation.gnv.chart.AbstractXYLineChart(Result, Series) | |
145 */ | |
146 @Override | |
106 protected void addValue(Result row, Series series) { | 147 protected void addValue(Result row, Series series) { |
107 double distance = 0; | 148 double distance = 0; |
108 | 149 |
109 try { | 150 try { |
110 Point point = (Point) wktReader.read(row.getString("SHAPE")); | 151 Point point = (Point) wktReader.read(row.getString("SHAPE")); |
126 log.warn("No data found while parsing."); | 167 log.warn("No data found while parsing."); |
127 } | 168 } |
128 } | 169 } |
129 | 170 |
130 | 171 |
172 | |
173 /** | |
174 * @see de.intevation.gnv.chart.AbstractXYLineChart#addSeries(Series, | |
175 * String, int) | |
176 */ | |
177 @Override | |
131 protected void addSeries(Series series, String label, int idx) { | 178 protected void addSeries(Series series, String label, int idx) { |
132 super.addSeries(series, label, idx); | 179 super.addSeries(series, label, idx); |
133 | 180 |
134 // reset firstPoint for next series | 181 // reset firstPoint for next series |
135 firstPoint = null; | 182 firstPoint = null; |
136 } | 183 } |
137 | 184 |
138 | 185 |
186 /** | |
187 * @see de.intevation.gnv.chart.VerticalProfileChart#prepareRangeAxis(String, | |
188 * int) | |
189 */ | |
139 @Override | 190 @Override |
140 protected void prepareRangeAxis(String seriesKey, int idx) { | 191 protected void prepareRangeAxis(String seriesKey, int idx) { |
141 return; | 192 return; |
142 // do nothing here | 193 // do nothing here |
143 } | 194 } |
144 | 195 |
145 | 196 |
197 /** | |
198 * @see de.intevation.gnv.chart.VerticalProfileChart#storeMaxValue(Map, | |
199 * Object, String) | |
200 */ | |
146 @Override | 201 @Override |
147 protected void storeMaxValue(Map values, Object value, String parameter) { | 202 protected void storeMaxValue(Map values, Object value, String parameter) { |
148 return; | 203 return; |
149 // do nothing here | 204 // do nothing here |
150 } | 205 } |
151 | 206 |
152 | 207 |
208 /** | |
209 * @see de.intevation.gnv.chart.AbstractXYLineChart#createSeriesName(String, | |
210 * String, String) | |
211 */ | |
212 @Override | |
153 protected String createSeriesName( | 213 protected String createSeriesName( |
154 String breakPoint1, | 214 String breakPoint1, |
155 String breakPoint2, | 215 String breakPoint2, |
156 String breakPoint3 | 216 String breakPoint3 |
157 ) { | 217 ) { |
163 " " + | 223 " " + |
164 findValueTitle(dates, breakPoint3); | 224 findValueTitle(dates, breakPoint3); |
165 } | 225 } |
166 | 226 |
167 | 227 |
228 /** | |
229 * @see de.intevation.gnv.chart.VerticalProfileChart#addGapsOnGrid(Result[], | |
230 * Series, int, int) | |
231 */ | |
232 @Override | |
168 protected void addGapsOnGrid( | 233 protected void addGapsOnGrid( |
169 Result[] results, | 234 Result[] results, |
170 Series series, | 235 Series series, |
171 int startPos, | 236 int startPos, |
172 int endPos | 237 int endPos |
224 } | 289 } |
225 } | 290 } |
226 } | 291 } |
227 | 292 |
228 | 293 |
294 /** | |
295 * Method to add gaps between two data points. The real detection is done by | |
296 * {@link #simpleDetection} and {@link #specialDetection}. | |
297 * | |
298 * @param results All data points in this dataset. | |
299 * @param series Series to be processed. | |
300 * @param startValue <code>Point</code> where the scan for gaps should begin. | |
301 * @param endValue <code>Point</code> where the scan should end. | |
302 * @param startPos Start position of this series in <code>results</code>. | |
303 * @param endPos End position of a series in <code>results</code> | |
304 */ | |
229 protected void addGaps( | 305 protected void addGaps( |
230 Result[] results, | 306 Result[] results, |
231 Series series, | 307 Series series, |
232 Point startValue, | 308 Point startValue, |
233 Point endValue, | 309 Point endValue, |
274 | 350 |
275 } | 351 } |
276 } | 352 } |
277 | 353 |
278 | 354 |
355 /** | |
356 * Simple method to detect gaps. A gap is detected if the delta between two | |
357 * data points (current, last) is bigger than <code>PERCENTAGE</code> percent | |
358 * of delta of start and end. | |
359 * <br> | |
360 * (smallDelta > delta / 100 * PERCENTAGE) | |
361 * | |
362 * @param start First data point in a series | |
363 * @param end Last data point in a series | |
364 * @param last Left point | |
365 * @param current Right point | |
366 * | |
367 * @return true, if a gap is detected between last and current - otherwise | |
368 * false. | |
369 */ | |
279 protected boolean simpleDetection( | 370 protected boolean simpleDetection( |
280 Point start, | 371 Point start, |
281 Point end, | 372 Point end, |
282 Point last, | 373 Point last, |
283 Point current | 374 Point current |
287 | 378 |
288 return (deltaSmall > (delta / 100 * PERCENTAGE)); | 379 return (deltaSmall > (delta / 100 * PERCENTAGE)); |
289 } | 380 } |
290 | 381 |
291 | 382 |
383 /** | |
384 * Method to detect gaps between two data points. Following formula is used | |
385 * for detection:<br> | |
386 * smallDelta > (3.0 / (count - 1) * delta)<br> | |
387 * smallDelta = distance between <code>current</code> and <code>last</code> | |
388 * <br> | |
389 * delta = distance between <code>start</code> and <code>end</code> | |
390 * | |
391 * @param start First data point in a series | |
392 * @param end Last data point in a series | |
393 * @param last Left point | |
394 * @param current Right point | |
395 * | |
396 * @return true, if a gap is detected between last and current - otherwise | |
397 * false. | |
398 */ | |
292 protected boolean specialDetection( | 399 protected boolean specialDetection( |
293 Point start, | 400 Point start, |
294 Point end, | 401 Point end, |
295 Point last, | 402 Point last, |
296 Point current, | 403 Point current, |
304 ); | 411 ); |
305 | 412 |
306 return (smallDelta > (3.0 / (count - 1) * delta)); | 413 return (smallDelta > (3.0 / (count - 1) * delta)); |
307 } | 414 } |
308 | 415 |
416 /** | |
417 * @see de.intevation.gnv.chart.VerticalProfileChart#getDependendAxisName(Result, | |
418 * Result) | |
419 */ | |
309 @Override | 420 @Override |
310 protected String getDependendAxisName(Result first, Result second) { | 421 protected String getDependendAxisName(Result first, Result second) { |
311 if (first.getInteger("IPOSITION") == second.getInteger("IPOSITION")) | 422 if (first.getInteger("IPOSITION") == second.getInteger("IPOSITION")) |
312 return "JPOSITION"; | 423 return "JPOSITION"; |
313 | 424 |
314 return "IPOSITION"; | 425 return "IPOSITION"; |
315 } | 426 } |
316 | 427 |
428 /** | |
429 * This method returns a point from a given wkt string stored in | |
430 * <code>result</code>. | |
431 * | |
432 * @param result <code>Result</code> object which contains the wkt string. | |
433 * The wkt string needs to be available under the key SHAPE. | |
434 * | |
435 * @return Point representation of wkt string. | |
436 */ | |
317 private Point getPoint(Result result) | 437 private Point getPoint(Result result) |
318 throws ParseException | 438 throws ParseException |
319 { | 439 { |
320 return (Point) wktReader.read(result.getString("SHAPE")); | 440 return (Point) wktReader.read(result.getString("SHAPE")); |
321 } | 441 } |