annotate flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java @ 3181:de67497de5a0

Completed inverse functions. flys-artifacts/trunk@4796 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 26 Jun 2012 10:54:12 +0000
parents cbaa49896eca
children b2ea89a665bc
rev   line source
1791
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.exports;
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 import org.apache.log4j.Logger;
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
4
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5 import org.jfree.data.xy.XYSeries;
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
6
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2686
diff changeset
7 import de.intevation.flys.artifacts.model.WKms;
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2686
diff changeset
8 import de.intevation.flys.artifacts.model.WQKms;
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2686
diff changeset
9 import de.intevation.flys.artifacts.model.WWQQ;
1791
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 /**
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12 * Helper to create and modify StyledXYSeries.
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 */
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 public class StyledSeriesBuilder {
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15
2601
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
16 /**
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
17 * JFreeChart and the area calculation will fail if we use Double.INFINITY
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
18 * or Double.MAX_VALUE (probably because these are really used in
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
19 * calculations). We define and use a more handy value instead.
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
20 */
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
21 final static double BIG_DOUBLE_VALUE = 1234567d;
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
22
2571
63f44b8b41a3 Partial Dontcrash on flys/issue647 (NaNs from WstValueTable interpolation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2156
diff changeset
23 private static final Logger logger = Logger.getLogger
63f44b8b41a3 Partial Dontcrash on flys/issue647 (NaNs from WstValueTable interpolation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2156
diff changeset
24 (StyledSeriesBuilder.class);
1791
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 /**
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28 * Trivial, hidden constructor.
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29 */
1886
6f047a407f84 Removed dead ';' from empty bodies.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1812
diff changeset
30 private StyledSeriesBuilder() {
6f047a407f84 Removed dead ';' from empty bodies.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1812
diff changeset
31 }
1791
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 /**
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35 * Add points to series.
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 *
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 * @param series Series to add points to.
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 * @param points Points to add to series, points[0] to 1st dim, points[1]
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 * to 2nd dim.
2686
6fda6ec9e426 Added accidentally ommitted changes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2601
diff changeset
40 * @param skipNANs if true, skip NAN values in points parameter.
1791
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 */
2686
6fda6ec9e426 Added accidentally ommitted changes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2601
diff changeset
42 public static void addPoints(XYSeries series, double[][] points, boolean skipNANs) {
1983
ddb7b7da6199 Fix/survive certain minor malconditions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1975
diff changeset
43 if (points == null || points.length <= 1) {
1975
b30e1710df1d Server-side of interactive cross-section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1942
diff changeset
44 return;
b30e1710df1d Server-side of interactive cross-section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1942
diff changeset
45 }
1791
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 double [] xPoints = points[0];
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 double [] yPoints = points[1];
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 for (int i = 0; i < xPoints.length; i++) {
2686
6fda6ec9e426 Added accidentally ommitted changes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2601
diff changeset
49 if (skipNANs &&
6fda6ec9e426 Added accidentally ommitted changes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2601
diff changeset
50 (Double.isNaN(xPoints[i]) || Double.isNaN(yPoints[i]))) {
2571
63f44b8b41a3 Partial Dontcrash on flys/issue647 (NaNs from WstValueTable interpolation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2156
diff changeset
51 logger.warn ("Skipping NaN in StyledSeriesBuilder.");
63f44b8b41a3 Partial Dontcrash on flys/issue647 (NaNs from WstValueTable interpolation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2156
diff changeset
52 continue;
63f44b8b41a3 Partial Dontcrash on flys/issue647 (NaNs from WstValueTable interpolation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2156
diff changeset
53 }
1791
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54 series.add(xPoints[i], yPoints[i], false);
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 }
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 }
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 /**
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 * Add points to series (km to 1st dim, w to 2nd dim).
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 *
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 * @param series Series to add points to.
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 * @param points Points to add to series.
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 */
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65 public static void addPoints(XYSeries series, WKms wkms) {
2156
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
66 if (wkms == null) {
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
67 return;
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
68 }
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
69
1791
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 int size = wkms.size();
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 for (int i = 0; i < size; i++) {
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 series.add(wkms.getKm(i), wkms.getW(i), false);
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 }
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 }
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76
1812
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
77
1791
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 /**
1942
be1270c10d9a Fix documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1886
diff changeset
79 * Add points to series (km to 1st dim, q to 2nd dim).
1791
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
80 *
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81 * @param series Series to add points to.
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 * @param points Points to add to series.
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83 */
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84 public static void addPointsKmQ(XYSeries series, WQKms wqkms) {
2156
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
85 if (wqkms == null) {
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
86 return;
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
87 }
1791
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
88
2156
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
89 int size = wqkms.size();
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
90
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
91 for (int i = 0; i < size; i++) {
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
92 series.add(wqkms.getKm(i), wqkms.getQ(i), false);
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
93 }
1791
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
94 }
1812
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
95
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
96
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
97 /**
3176
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
98 * Add points to series (km to 1st dim, q to 2nd dim), adding points
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
99 * to achieve a step-like curve.
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
100 *
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
101 * @param series Series to add points to.
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
102 * @param points Points to add to series.
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
103 */
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
104 public static void addStepPointsKmQ(XYSeries series, WQKms wqkms) {
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
105 if (wqkms == null) {
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
106 return;
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
107 }
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
108
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
109 int size = wqkms.size();
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
110
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
111 for (int i = 0; i < size; i++) {
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
112 if (i==0) {
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
113 series.add(wqkms.getKm(i), wqkms.getQ(i), false);
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
114 }
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
115 else {
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
116 //Add two points.
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
117 double halveX = (wqkms.getKm(i-1) + wqkms.getKm(i)) / 2d;
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
118 series.add(halveX, wqkms.getQ(i-1));
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
119 series.add(halveX, wqkms.getQ(i));
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
120 }
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
121 if (i == size-1) {
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
122 series.add(wqkms.getKm(i), wqkms.getQ(i), false);
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
123 }
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
124 }
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
125 }
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
126
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
127
cbaa49896eca Fix issue663 (step curves for longitudinal_section Qs).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
128 /**
1812
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
129 * Add points to series (q to 1st dim, w to 2nd dim).
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
130 *
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
131 * @param series Series to add points to.
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
132 * @param points Points to add to series.
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
133 */
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
134 public static void addPointsQW(XYSeries series, WQKms wqkms) {
2156
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
135 if (wqkms == null) {
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
136 return;
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
137 }
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
138
1812
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
139 int size = wqkms.size();
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
140
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
141 for (int i = 0; i < size; i++) {
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
142 series.add(wqkms.getQ(i), wqkms.getW(i));
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
143 }
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
144 }
2601
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
145
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
146
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
147 /**
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
148 * Add points to series (q to 1st dim, w to 2nd dim).
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
149 *
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
150 * @param series Series to add points to.
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
151 * @param points Points to add to series.
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
152 */
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
153 public static void addPoints(XYSeries series, WWQQ wwqq) {
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
154 if (wwqq == null) {
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
155 return;
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
156 }
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
157
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
158 int size = wwqq.size();
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
159
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
160 for (int i = 0; i < size; i++) {
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
161 series.add(wwqq.getW1(i), wwqq.getW2(i));
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
162 }
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
163 }
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
164
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
165
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
166 /**
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
167 * Create a Series such that an infinitely big area can be filled
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
168 * between the newly created and the given series.
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
169 */
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
170 public static XYSeries createGroundAtInfinity(XYSeries series) {
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
171 XYSeries ground = new XYSeries(series.getKey() + /** TODO rand + */ "INF");
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
172 ground.add(series.getMinX(), -BIG_DOUBLE_VALUE);
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
173 ground.add(series.getMaxX(), -BIG_DOUBLE_VALUE);
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
174 return ground;
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
175 }
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
176
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
177
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
178 /**
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
179 * Create a Series such that an infinitely big area can be filled
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
180 * between the newly created and the given series.
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
181 */
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
182 public static XYSeries createCeilingAtInfinity(XYSeries series) {
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
183 XYSeries ground = new XYSeries(series.getKey() + /** TODO rand + */ "INF");
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
184 ground.add(series.getMinX(), BIG_DOUBLE_VALUE);
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
185 ground.add(series.getMaxX(), BIG_DOUBLE_VALUE);
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
186 return ground;
9e8459c2e7d4 Fix flys/issue491 (areas over axis stop at zero).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2571
diff changeset
187 }
1791
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
188 }
e0e5a5b51a40 Added new StyledSeriesBuilder class and use it when adding points to XYSeries (in diagram generation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
189 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org