annotate flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java @ 2581:afebbe9c2fce

Added a new Artifact for loading existing 'floodmaps' via datacage. flys-artifacts/trunk@4130 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 08 Mar 2012 13:44:51 +0000
parents 63f44b8b41a3
children 9e8459c2e7d4
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
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
7 import de.intevation.flys.artifacts.model.WKms;
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
8 import de.intevation.flys.artifacts.model.WQKms;
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
9
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 * 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
12 */
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 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
14
2571
63f44b8b41a3 Partial Dontcrash on flys/issue647 (NaNs from WstValueTable interpolation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2156
diff changeset
15 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
16 (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
17
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
18
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
19 /**
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
20 * 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
21 */
1886
6f047a407f84 Removed dead ';' from empty bodies.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1812
diff changeset
22 private StyledSeriesBuilder() {
6f047a407f84 Removed dead ';' from empty bodies.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1812
diff changeset
23 }
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
24
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 * 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
28 *
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 * @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
30 * @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
31 * 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
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 public static void addPoints(XYSeries series, double[][] points) {
1983
ddb7b7da6199 Fix/survive certain minor malconditions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1975
diff changeset
34 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
35 return;
b30e1710df1d Server-side of interactive cross-section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1942
diff changeset
36 }
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
37 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
38 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
39 for (int i = 0; i < xPoints.length; i++) {
2571
63f44b8b41a3 Partial Dontcrash on flys/issue647 (NaNs from WstValueTable interpolation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2156
diff changeset
40 if (Double.isNaN(xPoints[i]) || Double.isNaN(yPoints[i])) {
63f44b8b41a3 Partial Dontcrash on flys/issue647 (NaNs from WstValueTable interpolation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2156
diff changeset
41 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
42 continue;
63f44b8b41a3 Partial Dontcrash on flys/issue647 (NaNs from WstValueTable interpolation).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2156
diff changeset
43 }
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
44 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
45 }
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 }
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
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
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
49 /**
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
50 * 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
51 *
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
52 * @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
53 * @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
54 */
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 public static void addPoints(XYSeries series, WKms wkms) {
2156
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
56 if (wkms == null) {
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
57 return;
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
58 }
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
59
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
60 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
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 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
63 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
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 }
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
66
1812
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
67
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
68 /**
1942
be1270c10d9a Fix documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1886
diff changeset
69 * 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
70 *
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 * @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
72 * @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
73 */
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 public static void addPointsKmQ(XYSeries series, WQKms wqkms) {
2156
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
75 if (wqkms == null) {
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
76 return;
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
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
2156
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
79 int size = wqkms.size();
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
80
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
81 for (int i = 0; i < size; i++) {
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
82 series.add(wqkms.getKm(i), wqkms.getQ(i), false);
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
83 }
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
84 }
1812
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
85
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
86
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
87 /**
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
88 * 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
89 *
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
90 * @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
91 * @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
92 */
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
93 public static void addPointsQW(XYSeries series, WQKms wqkms) {
2156
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
94 if (wqkms == null) {
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
95 return;
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
96 }
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
97
1812
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
98 int size = wqkms.size();
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
99
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
100 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
101 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
102 }
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
103 }
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
104 }
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
105 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org