Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java @ 2424:092e519ff461
merged flys-artifacts/2.6.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:26 +0200 |
parents | 4e0878695c5f |
children | 63f44b8b41a3 |
comparison
equal
deleted
inserted
replaced
2392:8112ec686a9a | 2424:092e519ff461 |
---|---|
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(StyledSeriesBuilder.class); | |
16 | |
17 | |
18 /** | |
19 * Trivial, hidden constructor. | |
20 */ | |
21 private StyledSeriesBuilder() { | |
22 } | |
23 | |
24 | |
25 /** | |
26 * Add points to series. | |
27 * | |
28 * @param series Series to add points to. | |
29 * @param points Points to add to series, points[0] to 1st dim, points[1] | |
30 * to 2nd dim. | |
31 */ | |
32 public static void addPoints(XYSeries series, double[][] points) { | |
33 if (points == null || points.length <= 1) { | |
34 return; | |
35 } | |
36 double [] xPoints = points[0]; | |
37 double [] yPoints = points[1]; | |
38 for (int i = 0; i < xPoints.length; i++) { | |
39 series.add(xPoints[i], yPoints[i], false); | |
40 } | |
41 } | |
42 | |
43 | |
44 /** | |
45 * Add points to series (km to 1st dim, w to 2nd dim). | |
46 * | |
47 * @param series Series to add points to. | |
48 * @param points Points to add to series. | |
49 */ | |
50 public static void addPoints(XYSeries series, WKms wkms) { | |
51 if (wkms == null) { | |
52 return; | |
53 } | |
54 | |
55 int size = wkms.size(); | |
56 | |
57 for (int i = 0; i < size; i++) { | |
58 series.add(wkms.getKm(i), wkms.getW(i), false); | |
59 } | |
60 } | |
61 | |
62 | |
63 /** | |
64 * Add points to series (km to 1st dim, q to 2nd dim). | |
65 * | |
66 * @param series Series to add points to. | |
67 * @param points Points to add to series. | |
68 */ | |
69 public static void addPointsKmQ(XYSeries series, WQKms wqkms) { | |
70 if (wqkms == null) { | |
71 return; | |
72 } | |
73 | |
74 int size = wqkms.size(); | |
75 | |
76 for (int i = 0; i < size; i++) { | |
77 series.add(wqkms.getKm(i), wqkms.getQ(i), false); | |
78 } | |
79 } | |
80 | |
81 | |
82 /** | |
83 * Add points to series (q to 1st dim, w to 2nd dim). | |
84 * | |
85 * @param series Series to add points to. | |
86 * @param points Points to add to series. | |
87 */ | |
88 public static void addPointsQW(XYSeries series, WQKms wqkms) { | |
89 if (wqkms == null) { | |
90 return; | |
91 } | |
92 | |
93 int size = wqkms.size(); | |
94 | |
95 for (int i = 0; i < size; i++) { | |
96 series.add(wqkms.getQ(i), wqkms.getW(i)); | |
97 } | |
98 } | |
99 } | |
100 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |