Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/StyledSeriesBuilder.java @ 6778:cbe9ac4380a5
issue1439: Show line segments for points that have gaps on both sides. Small refac.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 08 Aug 2013 10:38:36 +0200 |
parents | 334db91c96dc |
children | 590d420ed382 |
comparison
equal
deleted
inserted
replaced
6777:48f6780c372d | 6778:cbe9ac4380a5 |
---|---|
47 * to 2nd dim. | 47 * to 2nd dim. |
48 * @param skipNANs if true, skip NAN values in points parameter. Otherwise, | 48 * @param skipNANs if true, skip NAN values in points parameter. Otherwise, |
49 * the NaNs lead to gaps in graph. | 49 * the NaNs lead to gaps in graph. |
50 * @param distance if two consecutive entries in points[0] are more | 50 * @param distance if two consecutive entries in points[0] are more |
51 * than distance apart, create a NaN value to skip in display. | 51 * than distance apart, create a NaN value to skip in display. |
52 * Still, create a line segment. | |
52 */ | 53 */ |
53 public static void addPoints(XYSeries series, double[][] points, boolean skipNANs, double distance) { | 54 public static void addPoints(XYSeries series, double[][] points, boolean skipNANs, double distance) { |
54 if (points == null || points.length <= 1) { | 55 if (points == null || points.length <= 1) { |
55 return; | 56 return; |
56 } | 57 } |
62 logger.warn ("Skipping NaN in StyledSeriesBuilder."); | 63 logger.warn ("Skipping NaN in StyledSeriesBuilder."); |
63 continue; | 64 continue; |
64 } | 65 } |
65 // Create gap if distance >= distance. | 66 // Create gap if distance >= distance. |
66 if (i != 0 && Math.abs(xPoints[i-1] - xPoints[i]) >= distance) { | 67 if (i != 0 && Math.abs(xPoints[i-1] - xPoints[i]) >= distance) { |
68 // Create at least a small segment for last point. | |
69 if (!Double.isNaN(yPoints[i-1])) { | |
70 series.add(xPoints[i-1]+0.99d*(distance)/2.d, yPoints[i-1], false); | |
71 } | |
72 | |
67 if (!Double.isNaN(yPoints[i-1]) && !Double.isNaN(yPoints[i])) { | 73 if (!Double.isNaN(yPoints[i-1]) && !Double.isNaN(yPoints[i])) { |
68 series.add((xPoints[i-1]+xPoints[i])/2.d, Double.NaN, false); | 74 series.add((xPoints[i-1]+xPoints[i])/2.d, Double.NaN, false); |
69 } | 75 } |
70 } | 76 } |
71 series.add(xPoints[i], yPoints[i], false); | 77 series.add(xPoints[i], yPoints[i], false); |