Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/StyledSeriesBuilder.java @ 9617:1d4262a68f1f
#12 Minuend/Subtrahend + MergeConflict #19 CollisionCalculation
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Thu, 10 Oct 2019 15:29:02 +0200 |
parents | 3f0803009a8f |
children |
comparison
equal
deleted
inserted
replaced
9616:cedcee24a21a | 9617:1d4262a68f1f |
---|---|
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.exports; | 9 package org.dive4elements.river.exports; |
10 | 10 |
11 import org.apache.log4j.Logger; | 11 import org.apache.log4j.Logger; |
12 | |
13 import org.jfree.data.xy.XYSeries; | |
14 | |
15 import org.dive4elements.river.artifacts.model.WKms; | 12 import org.dive4elements.river.artifacts.model.WKms; |
16 import org.dive4elements.river.artifacts.model.WQKms; | 13 import org.dive4elements.river.artifacts.model.WQKms; |
17 import org.dive4elements.river.artifacts.model.WWQQ; | 14 import org.dive4elements.river.artifacts.model.WWQQ; |
15 import org.jfree.data.xy.XYSeries; | |
18 | 16 |
19 /** | 17 /** |
20 * Helper to create and modify StyledXYSeries. | 18 * Helper to create and modify StyledXYSeries. |
21 */ | 19 */ |
22 public class StyledSeriesBuilder { | 20 public class StyledSeriesBuilder { |
26 * or Double.MAX_VALUE (probably because these are really used in | 24 * or Double.MAX_VALUE (probably because these are really used in |
27 * calculations). We define and use a more handy value instead. | 25 * calculations). We define and use a more handy value instead. |
28 */ | 26 */ |
29 final static double BIG_DOUBLE_VALUE = 1234567d; | 27 final static double BIG_DOUBLE_VALUE = 1234567d; |
30 | 28 |
31 private static final Logger log = Logger.getLogger | 29 private static final Logger log = Logger.getLogger(StyledSeriesBuilder.class); |
32 (StyledSeriesBuilder.class); | |
33 | |
34 | 30 |
35 /** | 31 /** |
36 * Trivial, hidden constructor. | 32 * Trivial, hidden constructor. |
37 */ | 33 */ |
38 private StyledSeriesBuilder() { | 34 private StyledSeriesBuilder() { |
39 } | 35 } |
40 | |
41 | 36 |
42 /** | 37 /** |
43 * Add points to series, create gaps if certain distance | 38 * Add points to series, create gaps if certain distance |
44 * between points is met. | 39 * between points is met. |
45 * | 40 * |
46 * @param series Series to add points to. | 41 * @param series |
47 * @param points Points to add to series, points[0] to 1st dim, points[1] | 42 * Series to add points to. |
48 * to 2nd dim. | 43 * @param points |
49 * @param skipNANs if true, skip NAN values in points parameter. Otherwise, | 44 * Points to add to series, points[0] to 1st dim, points[1] |
50 * the NaNs lead to gaps in graph. | 45 * to 2nd dim. |
51 * @param distance if two consecutive entries in points[0] are more | 46 * @param skipNANs |
52 * than distance apart, create a NaN value to skip | 47 * if true, skip NAN values in points parameter. Otherwise, |
53 * in display. | 48 * the NaNs lead to gaps in graph. |
54 */ | 49 * @param distance |
55 public static void addPoints( | 50 * if two consecutive entries in points[0] are more |
56 XYSeries series, | 51 * than distance apart, create a NaN value to skip |
57 double[][] points, | 52 * in display. |
58 boolean skipNANs, | 53 */ |
59 double distance | 54 public static void addPoints(final XYSeries series, final double[][] points, final boolean skipNANs, final double distance) { |
60 ) { | |
61 if (points == null || points.length <= 1) { | 55 if (points == null || points.length <= 1) { |
62 return; | 56 return; |
63 } | 57 } |
64 double [] xPoints = points[0]; | 58 final double[] xPoints = points[0]; |
65 double [] yPoints = points[1]; | 59 final double[] yPoints = points[1]; |
66 | 60 |
67 Integer lastNonNaNIndex = null; | 61 Integer lastNonNaNIndex = null; |
68 | 62 |
69 for (int i = 0; i < xPoints.length; i++) { | 63 for (int i = 0; i < xPoints.length; i++) { |
70 if (skipNANs && | 64 if (skipNANs && (Double.isNaN(xPoints[i]) || Double.isNaN(yPoints[i]))) { |
71 (Double.isNaN(xPoints[i]) || Double.isNaN(yPoints[i]))) { | |
72 continue; | 65 continue; |
73 } | 66 } |
74 | 67 |
75 // Create gap if distance between points > distance. | 68 // Create gap if distance between points > distance. |
76 if (i > 0 && lastNonNaNIndex != null) | 69 if (i > 0 && lastNonNaNIndex != null) { |
77 { | 70 final double distanceToLastNonNan = Math.abs(xPoints[lastNonNaNIndex] - xPoints[i]); |
78 double distanceToLastNonNan = Math.abs(xPoints[lastNonNaNIndex] - xPoints[i] ); | |
79 if (distanceToLastNonNan > distance && !Double.isNaN(yPoints[lastNonNaNIndex]) && !Double.isNaN(yPoints[i])) | 71 if (distanceToLastNonNan > distance && !Double.isNaN(yPoints[lastNonNaNIndex]) && !Double.isNaN(yPoints[i])) |
80 series.add((xPoints[i-1] + xPoints[i])/2, Double.NaN, false); | 72 series.add((xPoints[i - 1] + xPoints[i]) / 2, Double.NaN, false); |
81 } | 73 } |
82 series.add(xPoints[i], yPoints[i], false); | 74 series.add(xPoints[i], yPoints[i], false); |
83 | 75 |
84 // if (skipNANs && !Double.isNaN(xPoints[i]) && !Double.isNaN(yPoints[i])) | 76 // if (skipNANs && !Double.isNaN(xPoints[i]) && !Double.isNaN(yPoints[i])) |
85 if (!Double.isNaN(xPoints[i]) && !Double.isNaN(yPoints[i])) // skipNaN-State irrelevant, since lastNonNaNIndex is used for interpolation after gap-distance-comparison | 77 if (!Double.isNaN(xPoints[i]) && !Double.isNaN(yPoints[i])) // skipNaN-State irrelevant, since lastNonNaNIndex is used for interpolation |
78 // after gap-distance-comparison | |
86 lastNonNaNIndex = i; | 79 lastNonNaNIndex = i; |
87 } | 80 } |
88 } | 81 } |
89 | 82 |
90 /** | 83 /** |
91 * Add points to series. | 84 * Add points to series. |
92 * | 85 * |
93 * @param series Series to add points to. | 86 * @param series |
94 * @param points Points to add to series, points[0] to 1st dim, points[1] | 87 * Series to add points to. |
95 * to 2nd dim. | 88 * @param points |
96 * @param skipNANs if true, skip NAN values in points parameter. | 89 * Points to add to series, points[0] to 1st dim, points[1] |
97 * @param transY translate y-values by this value (before scale). | 90 * to 2nd dim. |
98 * @param factorY scale y-values by this value (after translation). | 91 * @param skipNANs |
99 */ | 92 * if true, skip NAN values in points parameter. |
100 public static void addPoints(XYSeries series, double[][] points, | 93 * @param transY |
101 boolean skipNANs, double transY, double factorY) { | 94 * translate y-values by this value (before scale). |
95 * @param factorY | |
96 * scale y-values by this value (after translation). | |
97 */ | |
98 public static void addPoints(final XYSeries series, final double[][] points, final boolean skipNANs, final double transY, final double factorY) { | |
102 if (transY == 0d && factorY == 1d) { | 99 if (transY == 0d && factorY == 1d) { |
103 addPoints(series, points, skipNANs); | 100 addPoints(series, points, skipNANs); |
104 return; | 101 return; |
105 } | 102 } |
106 if (points == null || points.length <= 1) { | 103 if (points == null || points.length <= 1) { |
107 return; | 104 return; |
108 } | 105 } |
109 double [] xPoints = points[0]; | 106 final double[] xPoints = points[0]; |
110 double [] yPoints = points[1]; | 107 final double[] yPoints = points[1]; |
111 for (int i = 0; i < xPoints.length; i++) { | 108 for (int i = 0; i < xPoints.length; i++) { |
112 if (skipNANs && | 109 if (skipNANs && (Double.isNaN(xPoints[i]) || Double.isNaN(yPoints[i]))) { |
113 (Double.isNaN(xPoints[i]) || Double.isNaN(yPoints[i]))) { | |
114 continue; | 110 continue; |
115 } | 111 } |
116 series.add(xPoints[i], factorY * (transY+yPoints[i]), false); | 112 series.add(xPoints[i], factorY * (transY + yPoints[i]), false); |
117 } | 113 } |
118 } | 114 } |
119 | 115 |
120 /** | 116 /** |
121 * Add points to series. | 117 * Add points to series. |
122 * | 118 * |
123 * @param series Series to add points to. | 119 * @param series |
124 * @param points Points to add to series, points[0] to 1st dim, points[1] | 120 * Series to add points to. |
125 * to 2nd dim. | 121 * @param points |
126 * @param skipNANs if true, skip NAN values in points parameter. | 122 * Points to add to series, points[0] to 1st dim, points[1] |
127 */ | 123 * to 2nd dim. |
128 public static void addPoints( | 124 * @param skipNANs |
129 XYSeries series, | 125 * if true, skip NAN values in points parameter. |
130 double[][] points, | 126 */ |
131 boolean skipNANs | 127 public static void addPoints(final XYSeries series, final double[][] points, final boolean skipNANs) { |
132 ) { | |
133 if (points == null || points.length <= 1) { | 128 if (points == null || points.length <= 1) { |
134 return; | 129 return; |
135 } | 130 } |
136 double [] xPoints = points[0]; | 131 final double[] xPoints = points[0]; |
137 double [] yPoints = points[1]; | 132 final double[] yPoints = points[1]; |
138 for (int i = 0; i < xPoints.length; i++) { | 133 for (int i = 0; i < xPoints.length; i++) { |
139 if (skipNANs && | 134 if (skipNANs && (Double.isNaN(xPoints[i]) || Double.isNaN(yPoints[i]))) { |
140 (Double.isNaN(xPoints[i]) || Double.isNaN(yPoints[i]))) { | |
141 continue; | 135 continue; |
142 } | 136 } |
143 series.add(xPoints[i], yPoints[i], false); | 137 series.add(xPoints[i], yPoints[i], false); |
144 } | 138 } |
145 } | 139 } |
146 | 140 |
147 | |
148 /** | 141 /** |
149 * Add points to series (km to 1st dim, w to 2nd dim). | 142 * Add points to series (km to 1st dim, w to 2nd dim). |
150 * | 143 * |
151 * @param series Series to add points to. | 144 * @param series |
152 * @param wkms WKms to add to series. | 145 * Series to add points to. |
153 */ | 146 * @param wkms |
154 public static void addPoints(XYSeries series, WKms wkms) { | 147 * WKms to add to series. |
148 */ | |
149 public static void addPoints(final XYSeries series, final WKms wkms) { | |
155 if (wkms == null) { | 150 if (wkms == null) { |
156 return; | 151 return; |
157 } | 152 } |
158 | 153 |
159 int size = wkms.size(); | 154 final int size = wkms.size(); |
160 | 155 |
161 for (int i = 0; i < size; i++) { | 156 for (int i = 0; i < size; i++) { |
162 series.add(wkms.getKm(i), wkms.getW(i), false); | 157 series.add(wkms.getKm(i), wkms.getW(i), false); |
163 } | 158 } |
164 } | 159 } |
165 | 160 |
166 | |
167 /** | 161 /** |
168 * Add points to dataset with an offset (shift all points by given amount). | 162 * Add points to dataset with an offset (shift all points by given amount). |
169 * @param series series to add data to. | 163 * |
170 * @param wkms WKms of which the Ws will be shifted. | 164 * @param series |
171 * @param off the offset. | 165 * series to add data to. |
172 */ | 166 * @param wkms |
173 public static void addUpperBand(XYSeries series, WKms wkms, double off) { | 167 * WKms of which the Ws will be shifted. |
168 * @param off | |
169 * the offset. | |
170 */ | |
171 public static void addUpperBand(final XYSeries series, final WKms wkms, final double off) { | |
174 if (wkms == null) { | 172 if (wkms == null) { |
175 return; | 173 return; |
176 } | 174 } |
177 | 175 |
178 int size = wkms.size(); | 176 final int size = wkms.size(); |
179 | 177 |
180 for (int i = 0; i < size; i++) { | 178 for (int i = 0; i < size; i++) { |
181 series.add(wkms.getKm(i), wkms.getW(i)+off, false); | 179 series.add(wkms.getKm(i), wkms.getW(i) + off, false); |
182 } | 180 } |
183 } | 181 } |
184 | |
185 | 182 |
186 /** | 183 /** |
187 * Add points to dataset with an offset (shift all points 'down' by given | 184 * Add points to dataset with an offset (shift all points 'down' by given |
188 * amount). | 185 * amount). |
189 * @param series series to add data to. | 186 * |
190 * @param wkms WKms of which the Ws will be shifted. | 187 * @param series |
191 * @param off the offset. | 188 * series to add data to. |
192 */ | 189 * @param wkms |
193 public static void addLowerBand(XYSeries series, WKms wkms, double off) { | 190 * WKms of which the Ws will be shifted. |
191 * @param off | |
192 * the offset. | |
193 */ | |
194 public static void addLowerBand(final XYSeries series, final WKms wkms, final double off) { | |
194 addUpperBand(series, wkms, -off); | 195 addUpperBand(series, wkms, -off); |
195 } | 196 } |
196 | 197 |
197 | |
198 /** | 198 /** |
199 * Add points to series (km to 1st dim, q to 2nd dim). | 199 * Add points to series (km to 1st dim, q to 2nd dim). |
200 * | 200 * |
201 * @param series Series to add points to. | 201 * @param series |
202 * @param wqkms WQKms to add to series. | 202 * Series to add points to. |
203 */ | 203 * @param wqkms |
204 public static void addPointsKmQ(XYSeries series, WQKms wqkms) { | 204 * WQKms to add to series. |
205 */ | |
206 public static void addPointsKmQ(final XYSeries series, final WQKms wqkms) { | |
205 if (wqkms == null) { | 207 if (wqkms == null) { |
206 return; | 208 return; |
207 } | 209 } |
208 | 210 |
209 int size = wqkms.size(); | 211 final int size = wqkms.size(); |
210 | 212 |
211 for (int i = 0; i < size; i++) { | 213 for (int i = 0; i < size; i++) { |
212 series.add(wqkms.getKm(i), wqkms.getQ(i), false); | 214 series.add(wqkms.getKm(i), wqkms.getQ(i), false); |
213 } | 215 } |
214 } | 216 } |
215 | |
216 | 217 |
217 /** | 218 /** |
218 * Add points to series (km to 1st dim, q to 2nd dim), adding points | 219 * Add points to series (km to 1st dim, q to 2nd dim), adding points |
219 * to achieve a step-like curve. | 220 * to achieve a step-like curve. |
220 * | 221 * |
221 * @param series Series to add points to. | 222 * @param series |
222 * @param wqkms WQKms to add to series. | 223 * Series to add points to. |
223 */ | 224 * @param wqkms |
224 public static void addStepPointsKmQ(XYSeries series, WQKms wqkms) { | 225 * WQKms to add to series. |
226 */ | |
227 public static void addStepPointsKmQ(final XYSeries series, final WQKms wqkms) { | |
225 if (wqkms == null) { | 228 if (wqkms == null) { |
226 return; | 229 return; |
227 } | 230 } |
228 | 231 |
229 int size = wqkms.size(); | 232 final int size = wqkms.size(); |
230 | 233 |
231 for (int i = 0; i < size; i++) { | 234 for (int i = 0; i < size; i++) { |
232 if (i==0) { | 235 if (i == 0) { |
233 series.add(wqkms.getKm(i), wqkms.getQ(i), false); | 236 series.add(wqkms.getKm(i), wqkms.getQ(i), false); |
234 } else if (i == size-1) { | 237 } else if (i == size - 1) { |
235 series.add(wqkms.getKm(i), wqkms.getQ(i), false); | 238 series.add(wqkms.getKm(i), wqkms.getQ(i), false); |
236 } else { | 239 } else { |
237 //Add two points. | 240 // Add two points. |
238 double prevX; | 241 double prevX; |
239 double prevQ; | 242 double prevQ; |
240 if (wqkms.getKm(i + 1) < wqkms.getKm(i)) { | 243 if (wqkms.getKm(i + 1) < wqkms.getKm(i)) { |
241 /* Depending on the data direction the previous km / q | 244 /* |
245 * Depending on the data direction the previous km / q | |
242 * might have a larger index when we draw | 246 * might have a larger index when we draw |
243 * right to left data. */ | 247 * right to left data. |
248 */ | |
244 prevX = wqkms.getKm(i + 1); | 249 prevX = wqkms.getKm(i + 1); |
245 prevQ = wqkms.getQ(i + 1); | 250 prevQ = wqkms.getQ(i + 1); |
246 } else { | 251 } else { |
247 prevX = wqkms.getKm(i - 1); | 252 prevX = wqkms.getKm(i - 1); |
248 prevQ = wqkms.getQ(i - 1); | 253 prevQ = wqkms.getQ(i - 1); |
249 } | 254 } |
250 double halveX = (prevX + wqkms.getKm(i)) / 2d; | 255 final double halveX = (prevX + wqkms.getKm(i)) / 2d; |
251 series.add(halveX, prevQ, false); | 256 series.add(halveX, prevQ, false); |
252 series.add(halveX, wqkms.getQ(i), false); | 257 series.add(halveX, wqkms.getQ(i), false); |
253 } | 258 } |
254 } | 259 } |
255 } | 260 } |
256 | 261 |
257 | |
258 /** | 262 /** |
259 * Add points to series (q to 1st dim, w to 2nd dim). | 263 * Add points to series (q to 1st dim, w to 2nd dim). |
260 * | 264 * |
261 * @param series Series to add points to. | 265 * @param series |
262 * @param wqkms WQKms to add to series. | 266 * Series to add points to. |
263 */ | 267 * @param wqkms |
264 public static void addPointsQW(XYSeries series, WQKms wqkms) { | 268 * WQKms to add to series. |
269 */ | |
270 public static void addPointsQW(final XYSeries series, final WQKms wqkms) { | |
265 if (wqkms == null) { | 271 if (wqkms == null) { |
266 return; | 272 return; |
267 } | 273 } |
268 | 274 |
269 int size = wqkms.size(); | 275 final int size = wqkms.size(); |
270 | 276 |
271 for (int i = 0; i < size; i++) { | 277 for (int i = 0; i < size; i++) { |
272 series.add(wqkms.getQ(i), wqkms.getW(i), false); | 278 series.add(wqkms.getQ(i), wqkms.getW(i), false); |
273 } | 279 } |
274 } | 280 } |
275 | 281 |
276 /** | 282 /** |
277 * Add points to series (q to 1st dim, w to 2nd dim), adding wTrans to the | 283 * Add points to series (q to 1st dim, w to 2nd dim), adding wTrans to the |
278 * W values and scaling it with wScale. | 284 * W values and scaling it with wScale. |
279 * | 285 * |
280 * @param series Series to add points to. | 286 * @param series |
281 * @param qws to add to series. | 287 * Series to add points to. |
282 * @param wAdd Value to add to each Q while adding to series. | 288 * @param qws |
283 * @param wScale multiply with | 289 * to add to series. |
284 */ | 290 * @param wAdd |
285 public static void addPointsQW( | 291 * Value to add to each Q while adding to series. |
286 XYSeries series, | 292 * @param wScale |
287 double[][] qws, | 293 * multiply with |
288 double wTrans, | 294 */ |
289 double wScale | 295 public static void addPointsQW(final XYSeries series, final double[][] qws, final double wTrans, final double wScale) { |
290 ) { | |
291 if (qws == null || qws.length == 0) { | 296 if (qws == null || qws.length == 0) { |
292 return; | 297 return; |
293 } | 298 } |
294 | 299 |
295 double x[] = qws[0]; | 300 final double x[] = qws[0]; |
296 double y[] = qws[1]; | 301 final double y[] = qws[1]; |
297 | 302 |
298 for (int i = 0; i < x.length; i++) { | 303 for (int i = 0; i < x.length; i++) { |
299 series.add(x[i], wScale * (y[i] + wTrans), false); | 304 series.add(x[i], wScale * (y[i] + wTrans), false); |
300 } | 305 } |
301 } | 306 } |
307 | |
302 /** | 308 /** |
303 * Add points to series (q to 1st dim, w to 2nd dim), adding wTrans to the | 309 * Add points to series (q to 1st dim, w to 2nd dim), adding wTrans to the |
304 * W values and scaling it with wScale. | 310 * W values and scaling it with wScale. |
305 * | 311 * |
306 * @param series Series to add points to. | 312 * @param series |
307 * @param wqkms WQKms to add to series. | 313 * Series to add points to. |
308 * @param wAdd Value to add to each Q while adding to series. | 314 * @param wqkms |
309 * @param wScale multiply with | 315 * WQKms to add to series. |
310 */ | 316 * @param wAdd |
311 public static void addPointsQW( | 317 * Value to add to each Q while adding to series. |
312 XYSeries series, | 318 * @param wScale |
313 WQKms wqkms, | 319 * multiply with |
314 double wTrans, | 320 */ |
315 double wScale | 321 public static void addPointsQW(final XYSeries series, final WQKms wqkms, final double wTrans, final double wScale) { |
316 ) { | |
317 if (wqkms == null) { | 322 if (wqkms == null) { |
318 return; | 323 return; |
319 } | 324 } |
320 | 325 |
321 int size = wqkms.size(); | 326 final int size = wqkms.size(); |
322 | 327 |
323 for (int i = 0; i < size; i++) { | 328 for (int i = 0; i < size; i++) { |
324 series.add(wqkms.getQ(i), wScale * (wqkms.getW(i) + wTrans), false); | 329 series.add(wqkms.getQ(i), wScale * (wqkms.getW(i) + wTrans), false); |
325 } | 330 } |
326 } | 331 } |
327 | 332 |
328 /** | 333 /** |
329 * Add points to series (q to 1st dim, w to 2nd dim). | 334 * Add points to series (q to 1st dim, w to 2nd dim). |
330 * | 335 * |
331 * @param series Series to add points to. | 336 * @param series |
332 * @param qs the Qs to add, assumed same length than ws. | 337 * Series to add points to. |
333 * @param ws the Ws to add, assumed same length than qs. | 338 * @param qs |
334 */ | 339 * the Qs to add, assumed same length than ws. |
335 public static void addPointsQW(XYSeries series, double[] qs, double ws[]) { | 340 * @param ws |
341 * the Ws to add, assumed same length than qs. | |
342 */ | |
343 public static void addPointsQW(final XYSeries series, final double[] qs, final double ws[]) { | |
336 if (ws == null || qs == null) { | 344 if (ws == null || qs == null) { |
337 return; | 345 return; |
338 } | 346 } |
339 | 347 |
340 int size = qs.length; | 348 final int size = qs.length; |
341 | 349 |
342 for (int i = 0; i < size; i++) { | 350 for (int i = 0; i < size; i++) { |
343 series.add(qs[i], ws[i], false); | 351 series.add(qs[i], ws[i], false); |
344 } | 352 } |
345 } | 353 } |
346 | 354 |
347 /** | 355 /** |
348 * Add points to series (q to 1st dim, w to 2nd dim), with | 356 * Add points to series (q to 1st dim, w to 2nd dim), with |
349 * scaling and translation. | 357 * scaling and translation. |
350 * | 358 * |
351 * @param series Series to add points to. | 359 * @param series |
352 * @param qs the Qs to add, assumed same length than ws. | 360 * Series to add points to. |
353 * @param ws the Ws to add, assumed same length than qs. | 361 * @param qs |
354 */ | 362 * the Qs to add, assumed same length than ws. |
355 public static void addPointsQW(XYSeries series, double[] qs, double ws[], | 363 * @param ws |
356 double wTrans, double wScale) { | 364 * the Ws to add, assumed same length than qs. |
365 */ | |
366 public static void addPointsQW(final XYSeries series, final double[] qs, final double ws[], final double wTrans, final double wScale) { | |
357 if (ws == null || qs == null) { | 367 if (ws == null || qs == null) { |
358 return; | 368 return; |
359 } | 369 } |
360 | 370 |
361 int size = qs.length; | 371 final int size = qs.length; |
362 | 372 |
363 for (int i = 0; i < size; i++) { | 373 for (int i = 0; i < size; i++) { |
364 series.add(qs[i], wScale * (ws[i]+wTrans), false); | 374 series.add(qs[i], wScale * (ws[i] + wTrans), false); |
365 } | 375 } |
366 } | 376 } |
367 | |
368 | |
369 | 377 |
370 /** | 378 /** |
371 * Add points to series (q to 1st dim, w to 2nd dim). | 379 * Add points to series (q to 1st dim, w to 2nd dim). |
372 * | 380 * |
373 * @param series Series to add points to. | 381 * @param series |
374 * @param wwqq WWQQ to add to series. | 382 * Series to add points to. |
375 */ | 383 * @param wwqq |
376 public static void addPoints(XYSeries series, WWQQ wwqq) { | 384 * WWQQ to add to series. |
385 */ | |
386 public static void addPoints(final XYSeries series, final WWQQ wwqq) { | |
377 if (wwqq == null) { | 387 if (wwqq == null) { |
378 return; | 388 return; |
379 } | 389 } |
380 | 390 |
381 int size = wwqq.size(); | 391 final int size = wwqq.size(); |
382 | 392 |
383 for (int i = 0; i < size; i++) { | 393 for (int i = 0; i < size; i++) { |
384 series.add(wwqq.getW1(i), wwqq.getW2(i), false); | 394 series.add(wwqq.getW1(i), wwqq.getW2(i), false); |
385 } | 395 } |
386 } | 396 } |
387 | |
388 | 397 |
389 /** | 398 /** |
390 * Create a Series such that an infinitely big area can be filled | 399 * Create a Series such that an infinitely big area can be filled |
391 * between the newly created and the given series. | 400 * between the newly created and the given series. |
392 */ | 401 */ |
393 public static XYSeries createGroundAtInfinity(XYSeries series) { | 402 public static XYSeries createGroundAtInfinity(final XYSeries series) { |
394 XYSeries ground = | 403 final XYSeries ground = new XYSeries(series.getKey() + /** TODO rand + */ |
395 new XYSeries(series.getKey() + /** TODO rand + */ "INF"); | 404 "INF"); |
396 ground.add(series.getMinX(), -BIG_DOUBLE_VALUE); | 405 ground.add(series.getMinX(), -BIG_DOUBLE_VALUE); |
397 ground.add(series.getMaxX(), -BIG_DOUBLE_VALUE); | 406 ground.add(series.getMaxX(), -BIG_DOUBLE_VALUE); |
398 return ground; | 407 return ground; |
399 } | 408 } |
400 | 409 |
401 | |
402 /** | 410 /** |
403 * Create a Series such that an infinitely big area can be filled | 411 * Create a Series such that an infinitely big area can be filled |
404 * between the newly created and the given series. | 412 * between the newly created and the given series. |
405 */ | 413 */ |
406 public static XYSeries createCeilingAtInfinity(XYSeries series) { | 414 public static XYSeries createCeilingAtInfinity(final XYSeries series) { |
407 XYSeries ground = | 415 final XYSeries ground = new XYSeries(series.getKey() + /** TODO rand + */ |
408 new XYSeries(series.getKey() + /** TODO rand + */ "INF"); | 416 "INF"); |
409 ground.add(series.getMinX(), BIG_DOUBLE_VALUE); | 417 ground.add(series.getMinX(), BIG_DOUBLE_VALUE); |
410 ground.add(series.getMaxX(), BIG_DOUBLE_VALUE); | 418 ground.add(series.getMaxX(), BIG_DOUBLE_VALUE); |
411 return ground; | 419 return ground; |
412 } | 420 } |
413 | 421 |
414 | 422 /** Checks if a given value is the BIG_DOUBLE_VALUE */ |
415 /** Checks if a given value is the BIG_DOUBLE_VALUE */ | 423 public static boolean isBigDoubleValue(final Number value) { |
416 public static boolean isBigDoubleValue(Number value) { | 424 if (value == null) |
417 if( value == null ) | |
418 return false; | 425 return false; |
419 | 426 |
420 return Math.abs( BIG_DOUBLE_VALUE - Math.abs(value.doubleValue()) ) < 0.1; | 427 return Math.abs(BIG_DOUBLE_VALUE - Math.abs(value.doubleValue())) < 0.1; |
421 } | 428 } |
422 } | 429 } |
423 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 430 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |