Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java Tue Mar 20 15:08:01 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java Thu Mar 22 10:56:20 2012 +0000 @@ -6,12 +6,20 @@ import de.intevation.flys.artifacts.model.WKms; import de.intevation.flys.artifacts.model.WQKms; +import de.intevation.flys.artifacts.model.WWQQ; /** * Helper to create and modify StyledXYSeries. */ public class StyledSeriesBuilder { + /** + * JFreeChart and the area calculation will fail if we use Double.INFINITY + * or Double.MAX_VALUE (probably because these are really used in + * calculations). We define and use a more handy value instead. + */ + final static double BIG_DOUBLE_VALUE = 1234567d; + private static final Logger logger = Logger.getLogger (StyledSeriesBuilder.class); @@ -101,5 +109,48 @@ series.add(wqkms.getQ(i), wqkms.getW(i)); } } + + + /** + * Add points to series (q to 1st dim, w to 2nd dim). + * + * @param series Series to add points to. + * @param points Points to add to series. + */ + public static void addPoints(XYSeries series, WWQQ wwqq) { + if (wwqq == null) { + return; + } + + int size = wwqq.size(); + + for (int i = 0; i < size; i++) { + series.add(wwqq.getW1(i), wwqq.getW2(i)); + } + } + + + /** + * Create a Series such that an infinitely big area can be filled + * between the newly created and the given series. + */ + public static XYSeries createGroundAtInfinity(XYSeries series) { + XYSeries ground = new XYSeries(series.getKey() + /** TODO rand + */ "INF"); + ground.add(series.getMinX(), -BIG_DOUBLE_VALUE); + ground.add(series.getMaxX(), -BIG_DOUBLE_VALUE); + return ground; + } + + + /** + * Create a Series such that an infinitely big area can be filled + * between the newly created and the given series. + */ + public static XYSeries createCeilingAtInfinity(XYSeries series) { + XYSeries ground = new XYSeries(series.getKey() + /** TODO rand + */ "INF"); + ground.add(series.getMinX(), BIG_DOUBLE_VALUE); + ground.add(series.getMaxX(), BIG_DOUBLE_VALUE); + return ground; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :