Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java @ 3818:dc18457b1cef
merged flys-artifacts/pre2.7-2012-03-16
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:59 +0200 |
parents | 63f44b8b41a3 |
children | 9e8459c2e7d4 |
comparison
equal
deleted
inserted
replaced
2456:60ab1054069d | 3818:dc18457b1cef |
---|---|
1 package de.intevation.flys.exports; | |
2 | |
3 import org.apache.log4j.Logger; | |
4 | |
5 import org.jfree.data.xy.XYSeries; | |
6 | |
7 import de.intevation.flys.artifacts.model.WKms; | |
8 import de.intevation.flys.artifacts.model.WQKms; | |
9 | |
10 /** | |
11 * Helper to create and modify StyledXYSeries. | |
12 */ | |
13 public class StyledSeriesBuilder { | |
14 | |
15 private static final Logger logger = Logger.getLogger | |
16 (StyledSeriesBuilder.class); | |
17 | |
18 | |
19 /** | |
20 * Trivial, hidden constructor. | |
21 */ | |
22 private StyledSeriesBuilder() { | |
23 } | |
24 | |
25 | |
26 /** | |
27 * Add points to series. | |
28 * | |
29 * @param series Series to add points to. | |
30 * @param points Points to add to series, points[0] to 1st dim, points[1] | |
31 * to 2nd dim. | |
32 */ | |
33 public static void addPoints(XYSeries series, double[][] points) { | |
34 if (points == null || points.length <= 1) { | |
35 return; | |
36 } | |
37 double [] xPoints = points[0]; | |
38 double [] yPoints = points[1]; | |
39 for (int i = 0; i < xPoints.length; i++) { | |
40 if (Double.isNaN(xPoints[i]) || Double.isNaN(yPoints[i])) { | |
41 logger.warn ("Skipping NaN in StyledSeriesBuilder."); | |
42 continue; | |
43 } | |
44 series.add(xPoints[i], yPoints[i], false); | |
45 } | |
46 } | |
47 | |
48 | |
49 /** | |
50 * Add points to series (km to 1st dim, w to 2nd dim). | |
51 * | |
52 * @param series Series to add points to. | |
53 * @param points Points to add to series. | |
54 */ | |
55 public static void addPoints(XYSeries series, WKms wkms) { | |
56 if (wkms == null) { | |
57 return; | |
58 } | |
59 | |
60 int size = wkms.size(); | |
61 | |
62 for (int i = 0; i < size; i++) { | |
63 series.add(wkms.getKm(i), wkms.getW(i), false); | |
64 } | |
65 } | |
66 | |
67 | |
68 /** | |
69 * Add points to series (km to 1st dim, q to 2nd dim). | |
70 * | |
71 * @param series Series to add points to. | |
72 * @param points Points to add to series. | |
73 */ | |
74 public static void addPointsKmQ(XYSeries series, WQKms wqkms) { | |
75 if (wqkms == null) { | |
76 return; | |
77 } | |
78 | |
79 int size = wqkms.size(); | |
80 | |
81 for (int i = 0; i < size; i++) { | |
82 series.add(wqkms.getKm(i), wqkms.getQ(i), false); | |
83 } | |
84 } | |
85 | |
86 | |
87 /** | |
88 * Add points to series (q to 1st dim, w to 2nd dim). | |
89 * | |
90 * @param series Series to add points to. | |
91 * @param points Points to add to series. | |
92 */ | |
93 public static void addPointsQW(XYSeries series, WQKms wqkms) { | |
94 if (wqkms == null) { | |
95 return; | |
96 } | |
97 | |
98 int size = wqkms.size(); | |
99 | |
100 for (int i = 0; i < size; i++) { | |
101 series.add(wqkms.getQ(i), wqkms.getW(i)); | |
102 } | |
103 } | |
104 } | |
105 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |