comparison artifacts/src/main/java/org/dive4elements/river/exports/StyledSeriesBuilder.java @ 8696:5dea205ea3e7

(issue1670) Remove 99-percent copy-paste method, which had been used only once.
author Tom Gottfried <tom@intevation.de>
date Mon, 20 Apr 2015 12:58:52 +0200
parents a7eaf3e13bbe
children 527e0f4c28c1
comparison
equal deleted inserted replaced
8695:5abbccb13e45 8696:5dea205ea3e7
34 34
35 /** 35 /**
36 * Trivial, hidden constructor. 36 * Trivial, hidden constructor.
37 */ 37 */
38 private StyledSeriesBuilder() { 38 private StyledSeriesBuilder() {
39 }
40
41
42 /**
43 * Add points to series, create gaps if certain distance between
44 * points is met and scale the Y value.
45 *
46 * @param series Series to add points to.
47 * @param points Points to add to series, points[0] to 1st dim, points[1]
48 * to 2nd dim.
49 * @param skipNANs if true, skip NAN values in points parameter. Otherwise,
50 * the NaNs lead to gaps in graph.
51 * @param distance if two consecutive entries in points[0] are more
52 * than distance apart, create a NaN value to skip in display.
53 * Still, create a line segment.
54 * @param factor Factor by which to scale the y value (points[1]).
55 */
56 public static void addPointsFactorY(XYSeries series,
57 double[][] points,
58 boolean skipNANs,
59 double distance,
60 double factor
61 ) {
62 if (points == null || points.length <= 1) {
63 return;
64 }
65 double [] xPoints = points[0];
66 double [] yPoints = points[1];
67 for (int i = 0; i < xPoints.length; i++) {
68 if (skipNANs &&
69 (Double.isNaN(xPoints[i]) || Double.isNaN(yPoints[i]))) {
70 continue;
71 }
72 // Create gap if distance >= distance.
73 if (i != 0 && Math.abs(xPoints[i-1] - xPoints[i]) >= distance) {
74 // Create at least a small segment for last point.
75 if (!Double.isNaN(yPoints[i-1])) {
76 series.add(xPoints[i-1]+0.99d*(distance)/2.d, yPoints[i-1]*factor, false);
77 }
78
79 if (!Double.isNaN(yPoints[i-1]) && !Double.isNaN(yPoints[i])) {
80 series.add((xPoints[i-1]+xPoints[i])/2.d, Double.NaN, false);
81 }
82 }
83 series.add(xPoints[i], yPoints[i]*factor, false);
84 }
85 } 39 }
86 40
87 41
88 /** 42 /**
89 * Add points to series, create gaps if certain distance between points is met. 43 * Add points to series, create gaps if certain distance between points is met.

http://dive4elements.wald.intevation.org