Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChart.java @ 298:80f7c5dc09c6
Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
gnv-artifacts/trunk@352 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 19 Nov 2009 15:30:27 +0000 |
parents | |
children | 45625b5cd6d4 |
comparison
equal
deleted
inserted
replaced
297:3f43392df3f6 | 298:80f7c5dc09c6 |
---|---|
1 package de.intevation.gnv.chart; | |
2 | |
3 import java.util.Collection; | |
4 import java.util.Locale; | |
5 | |
6 import com.vividsolutions.jts.geom.Point; | |
7 import com.vividsolutions.jts.io.WKTReader; | |
8 import com.vividsolutions.jts.io.ParseException; | |
9 | |
10 import org.apache.log4j.Logger; | |
11 | |
12 import org.jfree.chart.ChartTheme; | |
13 import org.jfree.chart.plot.PlotOrientation; | |
14 import org.jfree.data.general.Series; | |
15 import org.jfree.data.xy.XYSeries; | |
16 | |
17 import de.intevation.gnv.geobackend.base.Result; | |
18 import de.intevation.gnv.utils.DistanceCalculator; | |
19 | |
20 | |
21 /** | |
22 * @author Ingo Weinzierl <ingo.weinzierl@intevation.de> | |
23 */ | |
24 public class HorizontalProfileChart | |
25 extends VerticalProfileChart | |
26 { | |
27 private static Logger log = Logger.getLogger(HorizontalProfileChart.class); | |
28 | |
29 private static WKTReader wktReader = new WKTReader(); | |
30 private Point lastPoint; | |
31 private double distance; | |
32 | |
33 | |
34 public HorizontalProfileChart( | |
35 ChartLabels labels, | |
36 ChartTheme theme, | |
37 Collection parameters, | |
38 Collection measurements, | |
39 Collection result, | |
40 Collection dates, | |
41 Locale locale | |
42 ) { | |
43 super(labels, theme, parameters, measurements, result, dates, locale); | |
44 this.PLOT_ORIENTATION = PlotOrientation.VERTICAL; | |
45 this.distance = 0; | |
46 } | |
47 | |
48 | |
49 protected void addValue(Result row, Series series) { | |
50 // TODO look for gaps between two values | |
51 try { | |
52 Point point = (Point) wktReader.read(row.getString("SHAPE")); | |
53 if (lastPoint != null) | |
54 distance = distance + DistanceCalculator.calculateDistance( | |
55 lastPoint, point | |
56 ); | |
57 lastPoint = point; | |
58 | |
59 ((XYSeries) series).add( | |
60 distance, | |
61 row.getDouble("YORDINATE") | |
62 ); | |
63 } | |
64 catch(ParseException pe) { | |
65 log.warn("No data found while parsing."); | |
66 } | |
67 } | |
68 | |
69 | |
70 protected void addSeries(Series series, int idx) { | |
71 super.addSeries(series, idx); | |
72 | |
73 // reset values used by current series for next series | |
74 lastPoint = null; | |
75 distance = 0; | |
76 } | |
77 | |
78 | |
79 protected String createSeriesName( | |
80 String breakPoint1, | |
81 String breakPoint2, | |
82 String breakPoint3 | |
83 ) { | |
84 log.debug("create seriesname of horizontalprofile chart"); | |
85 return super.createSeriesName( | |
86 breakPoint1, | |
87 breakPoint2, | |
88 breakPoint3) + | |
89 " " + | |
90 findValueTitle(dates, breakPoint3); | |
91 } | |
92 } | |
93 // vim:set ts=4 sw=4 si et sta sts=4 fenc=latin1 : |