annotate gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChart.java @ 656:b98d1adee7a6

Added an offset of five percent between values and chart border in vertical profile charts (issue186). gnv-artifacts/trunk@749 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 08 Mar 2010 15:15:08 +0000
parents f3882e94c7e0
children 79401c871da4
rev   line source
298
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.chart;
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.util.Collection;
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.util.Locale;
656
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
5 import java.util.Map;
298
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import com.vividsolutions.jts.geom.Point;
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import com.vividsolutions.jts.io.WKTReader;
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import com.vividsolutions.jts.io.ParseException;
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import org.apache.log4j.Logger;
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import org.jfree.chart.ChartTheme;
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import org.jfree.chart.plot.PlotOrientation;
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import org.jfree.data.general.Series;
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import org.jfree.data.xy.XYSeries;
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import de.intevation.gnv.geobackend.base.Result;
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import de.intevation.gnv.utils.DistanceCalculator;
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 /**
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 * @author Ingo Weinzierl <ingo.weinzierl@intevation.de>
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 */
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 public class HorizontalProfileChart
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 extends VerticalProfileChart
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 {
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 private static Logger log = Logger.getLogger(HorizontalProfileChart.class);
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 private static WKTReader wktReader = new WKTReader();
644
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
31 private Point firstPoint;
298
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 public HorizontalProfileChart(
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 ChartLabels labels,
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 ChartTheme theme,
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 Collection parameters,
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 Collection measurements,
310
45625b5cd6d4 Added timegap definitions to charts. Adapted constructors and constructor calls.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
38 Collection dates,
298
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 Collection result,
310
45625b5cd6d4 Added timegap definitions to charts. Adapted constructors and constructor calls.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
40 Collection timeGaps,
327
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 324
diff changeset
41 Locale locale,
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 324
diff changeset
42 boolean linesVisible,
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 324
diff changeset
43 boolean shapesVisible
298
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 ) {
310
45625b5cd6d4 Added timegap definitions to charts. Adapted constructors and constructor calls.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
45 super(
45625b5cd6d4 Added timegap definitions to charts. Adapted constructors and constructor calls.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
46 labels,
45625b5cd6d4 Added timegap definitions to charts. Adapted constructors and constructor calls.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
47 theme,
45625b5cd6d4 Added timegap definitions to charts. Adapted constructors and constructor calls.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
48 parameters,
45625b5cd6d4 Added timegap definitions to charts. Adapted constructors and constructor calls.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
49 measurements,
45625b5cd6d4 Added timegap definitions to charts. Adapted constructors and constructor calls.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
50 dates,
45625b5cd6d4 Added timegap definitions to charts. Adapted constructors and constructor calls.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
51 result,
45625b5cd6d4 Added timegap definitions to charts. Adapted constructors and constructor calls.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
52 timeGaps,
327
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 324
diff changeset
53 locale,
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 324
diff changeset
54 linesVisible,
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 324
diff changeset
55 shapesVisible
310
45625b5cd6d4 Added timegap definitions to charts. Adapted constructors and constructor calls.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 298
diff changeset
56 );
298
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 this.PLOT_ORIENTATION = PlotOrientation.VERTICAL;
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 }
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
656
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
61 @Override
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
62 protected Object getValue(Result row) {
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
63 try {
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
64 return (Point) wktReader.read(row.getString("SHAPE"));
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
65 }
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
66 catch(ParseException pe) {
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
67 log.warn("No data found while parsing.");
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
68 return null;
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
69 }
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
70 }
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
71
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
72
340
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
73 protected void gapDetection(
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
74 Result[] results,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
75 Series series,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
76 int startPos,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
77 int endPos
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
78 ) {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
79 log.debug("Start gap detection.");
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
80 try {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
81 Point startValue = getPoint(results[startPos]);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
82 Point endValue = getPoint(results[endPos-1]);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
83 if (results[0].getInteger("DATAID") == 2)
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
84 addGapsOnGrid(results, series, startPos, endPos);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
85 else
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
86 addGaps(
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
87 results,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
88 series,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
89 startValue,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
90 endValue,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
91 startPos,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
92 endPos
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
93 );
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
94 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
95 catch (ParseException pe) {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
96 log.warn(
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
97 "Error while parsing points for gap detection. " +
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
98 "No gaps for current series will be detected."
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
99 );
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
100 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
101
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
102 log.debug("Gap detection finished.");
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
103 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
104
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
105
298
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 protected void addValue(Result row, Series series) {
644
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
107 double distance = 0;
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
108
298
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 try {
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 Point point = (Point) wktReader.read(row.getString("SHAPE"));
644
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
111 if (firstPoint != null) {
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
112 distance = DistanceCalculator.calculateDistance(
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
113 firstPoint, point
298
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 );
644
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
115 }
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
116 else {
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
117 firstPoint = point;
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
118 }
298
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 ((XYSeries) series).add(
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 distance,
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 row.getDouble("YORDINATE")
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 );
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 }
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 catch(ParseException pe) {
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126 log.warn("No data found while parsing.");
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 }
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 }
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130
334
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 327
diff changeset
131 protected void addSeries(Series series, String label, int idx) {
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 327
diff changeset
132 super.addSeries(series, label, idx);
298
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133
644
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
134 // reset firstPoint for next series
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
135 firstPoint = null;
298
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 }
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138
656
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
139 @Override
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
140 protected void prepareRangeAxis(String seriesKey, int idx) {
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
141 return;
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
142 // do nothing here
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
143 }
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
144
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
145
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
146 @Override
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
147 protected void storeMaxValue(Map values, Object value, String parameter) {
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
148 return;
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
149 // do nothing here
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
150 }
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
151
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 644
diff changeset
152
298
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 protected String createSeriesName(
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 String breakPoint1,
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155 String breakPoint2,
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 String breakPoint3
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 ) {
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 log.debug("create seriesname of horizontalprofile chart");
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 return super.createSeriesName(
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 breakPoint1,
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 breakPoint2,
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162 breakPoint3) +
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163 " " +
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 findValueTitle(dates, breakPoint3);
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 }
340
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
166
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
167
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
168 protected void addGapsOnGrid(
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
169 Result[] results,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
170 Series series,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
171 int startPos,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
172 int endPos
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
173 ) {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
174 String axis = getDependendAxisName(
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
175 results[startPos],
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
176 results[startPos+1]
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
177 );
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
178
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
179 int last = 0;
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
180 int current = 0;
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
181 Point lastPoint = null;
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
182 Point currentPoint = null;
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
183
644
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
184 try {
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
185 firstPoint = getPoint(results[0]);
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
186 }
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
187 catch (ParseException pe) {
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
188 log.error("Unable to parse start point for gap detection.");
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
189 return;
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
190 }
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
191
340
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
192 for (int i = startPos+1; i < endPos; i++) {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
193 try {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
194 last = results[i-1].getInteger(axis);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
195 lastPoint = getPoint(results[i-1]);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
196 current = results[i].getInteger(axis);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
197 currentPoint = getPoint(results[i]);
644
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
198 double distance = DistanceCalculator.calculateDistance(
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
199 firstPoint,
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
200 currentPoint);
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
201 double distanceOld = DistanceCalculator.calculateDistance(
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
202 firstPoint,
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
203 lastPoint);
340
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
204
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
205 boolean detected = gridDetection(last, current);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
206
643
24a85678bd39 Added some more debug information while gap detection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 370
diff changeset
207 if (log.isDebugEnabled()) {
24a85678bd39 Added some more debug information while gap detection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 370
diff changeset
208 log.debug("Last point: " + lastPoint.toString());
24a85678bd39 Added some more debug information while gap detection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 370
diff changeset
209 log.debug("Current point: " + currentPoint.toString());
644
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
210 log.debug("Current distance from start: " + distance);
643
24a85678bd39 Added some more debug information while gap detection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 370
diff changeset
211 }
24a85678bd39 Added some more debug information while gap detection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 370
diff changeset
212
340
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
213 if (detected) {
643
24a85678bd39 Added some more debug information while gap detection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 370
diff changeset
214 log.info(
644
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
215 "Gap detected on grid between " + distanceOld +
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
216 " and " + distance);
340
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
217
644
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
218 ((XYSeries) series).add(distance-1d, null);
f3882e94c7e0 Changed the way of calculating the total distance in 'Horizontalprofil'-charts (issue171).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 643
diff changeset
219 ((XYSeries) series).add(distanceOld+1d, null);
340
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
220 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
221 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
222 catch (ParseException pe) {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
223 log.warn("Error while parsing point for gap detection.", pe);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
224 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
225 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
226 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
227
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
228
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
229 protected void addGaps(
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
230 Result[] results,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
231 Series series,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
232 Point startValue,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
233 Point endValue,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
234 int startPos,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
235 int endPos
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
236 ) {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
237 double range = 0;
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
238 Point last = null;
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
239 Point now = null;
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
240
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
241 for (int i = startPos+1; i < endPos; i++) {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
242 boolean detected = false;
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
243
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
244 try {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
245 last = (Point) getPoint(results[i-1]);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
246 now = (Point) getPoint(results[i]);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
247
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
248 // gap detection for more than GAP_MAX_VALUES values
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
249 if (results.length > GAP_MAX_VALUES)
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
250 detected = simpleDetection(startValue, endValue, last, now);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
251 // gap detection for less than GAP_MAX_VALUES values
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
252 else
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
253 detected = specialDetection(
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
254 startValue,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
255 endValue,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
256 last,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
257 now,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
258 results.length
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
259 );
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
260
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
261 // gap detected, insert null value to break line
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
262 if (detected) {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
263 log.info("Gap after " + range);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
264 double x = range + 0.0001;
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
265
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
266 ((XYSeries)series).add(x, null);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
267 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
268
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
269 range += DistanceCalculator.calculateDistance(last,now);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
270 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
271 catch (ParseException pe) {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
272 log.warn("Error while parsing point.");
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
273 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
274
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
275 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
276 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
277
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
278
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
279 protected boolean simpleDetection(
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
280 Point start,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
281 Point end,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
282 Point last,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
283 Point current
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
284 ) {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
285 double delta = DistanceCalculator.calculateDistance(start, end);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
286 double deltaSmall = DistanceCalculator.calculateDistance(last,current);
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
287
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
288 return (deltaSmall > (delta / 100 * PERCENTAGE));
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
289 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
290
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
291
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
292 protected boolean specialDetection(
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
293 Point start,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
294 Point end,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
295 Point last,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
296 Point current,
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
297 int count
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
298 ) {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
299 double delta = Math.abs(
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
300 DistanceCalculator.calculateDistance(end, start)
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
301 );
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
302 double smallDelta = Math.abs(
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
303 DistanceCalculator.calculateDistance(current, last)
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
304 );
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
305
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
306 return (smallDelta > (3.0 / (count - 1) * delta));
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
307 }
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
308
370
061355435075 Changed depending value for gap detection in verticalprofile charts on meshes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 340
diff changeset
309 @Override
061355435075 Changed depending value for gap detection in verticalprofile charts on meshes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 340
diff changeset
310 protected String getDependendAxisName(Result first, Result second) {
061355435075 Changed depending value for gap detection in verticalprofile charts on meshes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 340
diff changeset
311 if (first.getInteger("IPOSITION") == second.getInteger("IPOSITION"))
061355435075 Changed depending value for gap detection in verticalprofile charts on meshes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 340
diff changeset
312 return "JPOSITION";
061355435075 Changed depending value for gap detection in verticalprofile charts on meshes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 340
diff changeset
313
061355435075 Changed depending value for gap detection in verticalprofile charts on meshes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 340
diff changeset
314 return "IPOSITION";
061355435075 Changed depending value for gap detection in verticalprofile charts on meshes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 340
diff changeset
315 }
340
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
316
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
317 private Point getPoint(Result result)
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
318 throws ParseException
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
319 {
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
320 return (Point) wktReader.read(result.getString("SHAPE"));
07a64cfafdf1 Added gap detection in horizontal and vertical profile charts. Distinguish between meshes and other data sources.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 334
diff changeset
321 }
298
80f7c5dc09c6 Implementation of classes for creating timeseries, verticalprofile and horizontalprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
322 }
327
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 324
diff changeset
323 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org