annotate flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java @ 2230:59af81364eb1

Improved the 'historical discharge' calculation: implemented findValueForW(). flys-artifacts/trunk@3872 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 01 Feb 2012 15:41:11 +0000
parents 4e0878695c5f
children 63f44b8b41a3
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
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 private static final Logger logger = Logger.getLogger(StyledSeriesBuilder.class);
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
16
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 * 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
20 */
1886
6f047a407f84 Removed dead ';' from empty bodies.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1812
diff changeset
21 private StyledSeriesBuilder() {
6f047a407f84 Removed dead ';' from empty bodies.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1812
diff changeset
22 }
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
23
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 * 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
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 * @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
29 * @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
30 * 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
31 */
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 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
33 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
34 return;
b30e1710df1d Server-side of interactive cross-section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1942
diff changeset
35 }
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
36 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
37 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
38 for (int i = 0; i < xPoints.length; 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
39 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
40 }
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 }
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
42
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
43
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 /**
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 * 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
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 * @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
48 * @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
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 public static void addPoints(XYSeries series, WKms wkms) {
2156
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
51 if (wkms == null) {
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
52 return;
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
53 }
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
54
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
55 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
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 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
58 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
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 }
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
1812
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
62
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
63 /**
1942
be1270c10d9a Fix documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1886
diff changeset
64 * 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
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 * @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
67 * @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
68 */
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
69 public static void addPointsKmQ(XYSeries series, WQKms wqkms) {
2156
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
70 if (wqkms == null) {
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
71 return;
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
72 }
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
73
2156
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
74 int size = wqkms.size();
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
75
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
76 for (int i = 0; i < size; i++) {
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
77 series.add(wqkms.getKm(i), wqkms.getQ(i), false);
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
78 }
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
79 }
1812
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
80
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
81
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
82 /**
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
83 * 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
84 *
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
85 * @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
86 * @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
87 */
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
88 public static void addPointsQW(XYSeries series, WQKms wqkms) {
2156
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
89 if (wqkms == null) {
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
90 return;
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
91 }
4e0878695c5f Made StyledSeriesBuilder more robust.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1983
diff changeset
92
1812
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
93 int size = wqkms.size();
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
94
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
95 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
96 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
97 }
dd084cf3f284 Refactored to allow mainvalues in discharge curve diagrams, too.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1791
diff changeset
98 }
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
99 }
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
100 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org