Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java @ 2792:fe987587ebc9
Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
file:///home/clients/bsh/bsh-generischer-viewer/Material/SVN/flys-artifacts/trunk
........
r4539 | teichmann | 2012-05-27 20:02:13 +0200 (So, 27 Mai 2012) | 1 line
FixA: Added forgotten csv/report facets/generators to conf.
........
r4540 | teichmann | 2012-05-27 20:11:31 +0200 (So, 27 Mai 2012) | 1 line
FixA: Fixed class cast bug in report facet.
........
r4543 | teichmann | 2012-05-28 20:35:01 +0200 (Mo, 28 Mai 2012) | 1 line
FixA: Added facet to return delta w/t as CSV
........
r4545 | teichmann | 2012-05-28 22:59:27 +0200 (Mo, 28 Mai 2012) | 1 line
FixA: Made Delta W/t calculation finally work
........
r4546 | teichmann | 2012-05-28 23:34:24 +0200 (Mo, 28 Mai 2012) | 1 line
FixA: corrected fitting (Q->W instead W->Q).
........
flys-artifacts/tags/2.7@4547 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 29 May 2012 04:58:29 +0000 |
parents | 6fda6ec9e426 |
children | 5642a83420f2 |
line wrap: on
line source
package de.intevation.flys.exports; import org.apache.log4j.Logger; import org.jfree.data.xy.XYSeries; 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); /** * Trivial, hidden constructor. */ private StyledSeriesBuilder() { } /** * Add points to series. * * @param series Series to add points to. * @param points Points to add to series, points[0] to 1st dim, points[1] * to 2nd dim. * @param skipNANs if true, skip NAN values in points parameter. */ public static void addPoints(XYSeries series, double[][] points, boolean skipNANs) { if (points == null || points.length <= 1) { return; } double [] xPoints = points[0]; double [] yPoints = points[1]; for (int i = 0; i < xPoints.length; i++) { if (skipNANs && (Double.isNaN(xPoints[i]) || Double.isNaN(yPoints[i]))) { logger.warn ("Skipping NaN in StyledSeriesBuilder."); continue; } series.add(xPoints[i], yPoints[i], false); } } /** * Add points to series (km 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, WKms wkms) { if (wkms == null) { return; } int size = wkms.size(); for (int i = 0; i < size; i++) { series.add(wkms.getKm(i), wkms.getW(i), false); } } /** * Add points to series (km to 1st dim, q to 2nd dim). * * @param series Series to add points to. * @param points Points to add to series. */ public static void addPointsKmQ(XYSeries series, WQKms wqkms) { if (wqkms == null) { return; } int size = wqkms.size(); for (int i = 0; i < size; i++) { series.add(wqkms.getKm(i), wqkms.getQ(i), false); } } /** * 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 addPointsQW(XYSeries series, WQKms wqkms) { if (wqkms == null) { return; } int size = wqkms.size(); for (int i = 0; i < size; i++) { 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 :