Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java @ 2601:9e8459c2e7d4
Fix flys/issue491 (areas over axis stop at zero).
flys-artifacts/trunk@4178 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 22 Mar 2012 10:56:20 +0000 |
parents | 63f44b8b41a3 |
children | 6fda6ec9e426 |
comparison
equal
deleted
inserted
replaced
2600:3f1cc396d253 | 2601:9e8459c2e7d4 |
---|---|
4 | 4 |
5 import org.jfree.data.xy.XYSeries; | 5 import org.jfree.data.xy.XYSeries; |
6 | 6 |
7 import de.intevation.flys.artifacts.model.WKms; | 7 import de.intevation.flys.artifacts.model.WKms; |
8 import de.intevation.flys.artifacts.model.WQKms; | 8 import de.intevation.flys.artifacts.model.WQKms; |
9 import de.intevation.flys.artifacts.model.WWQQ; | |
9 | 10 |
10 /** | 11 /** |
11 * Helper to create and modify StyledXYSeries. | 12 * Helper to create and modify StyledXYSeries. |
12 */ | 13 */ |
13 public class StyledSeriesBuilder { | 14 public class StyledSeriesBuilder { |
15 | |
16 /** | |
17 * JFreeChart and the area calculation will fail if we use Double.INFINITY | |
18 * or Double.MAX_VALUE (probably because these are really used in | |
19 * calculations). We define and use a more handy value instead. | |
20 */ | |
21 final static double BIG_DOUBLE_VALUE = 1234567d; | |
14 | 22 |
15 private static final Logger logger = Logger.getLogger | 23 private static final Logger logger = Logger.getLogger |
16 (StyledSeriesBuilder.class); | 24 (StyledSeriesBuilder.class); |
17 | 25 |
18 | 26 |
99 | 107 |
100 for (int i = 0; i < size; i++) { | 108 for (int i = 0; i < size; i++) { |
101 series.add(wqkms.getQ(i), wqkms.getW(i)); | 109 series.add(wqkms.getQ(i), wqkms.getW(i)); |
102 } | 110 } |
103 } | 111 } |
112 | |
113 | |
114 /** | |
115 * Add points to series (q to 1st dim, w to 2nd dim). | |
116 * | |
117 * @param series Series to add points to. | |
118 * @param points Points to add to series. | |
119 */ | |
120 public static void addPoints(XYSeries series, WWQQ wwqq) { | |
121 if (wwqq == null) { | |
122 return; | |
123 } | |
124 | |
125 int size = wwqq.size(); | |
126 | |
127 for (int i = 0; i < size; i++) { | |
128 series.add(wwqq.getW1(i), wwqq.getW2(i)); | |
129 } | |
130 } | |
131 | |
132 | |
133 /** | |
134 * Create a Series such that an infinitely big area can be filled | |
135 * between the newly created and the given series. | |
136 */ | |
137 public static XYSeries createGroundAtInfinity(XYSeries series) { | |
138 XYSeries ground = new XYSeries(series.getKey() + /** TODO rand + */ "INF"); | |
139 ground.add(series.getMinX(), -BIG_DOUBLE_VALUE); | |
140 ground.add(series.getMaxX(), -BIG_DOUBLE_VALUE); | |
141 return ground; | |
142 } | |
143 | |
144 | |
145 /** | |
146 * Create a Series such that an infinitely big area can be filled | |
147 * between the newly created and the given series. | |
148 */ | |
149 public static XYSeries createCeilingAtInfinity(XYSeries series) { | |
150 XYSeries ground = new XYSeries(series.getKey() + /** TODO rand + */ "INF"); | |
151 ground.add(series.getMinX(), BIG_DOUBLE_VALUE); | |
152 ground.add(series.getMaxX(), BIG_DOUBLE_VALUE); | |
153 return ground; | |
154 } | |
104 } | 155 } |
105 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 156 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |