Mercurial > dive4elements > river
changeset 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 | 3f1cc396d253 |
children | 538820485945 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java |
diffstat | 3 files changed, 66 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Tue Mar 20 15:08:01 2012 +0000 +++ b/flys-artifacts/ChangeLog Thu Mar 22 10:56:20 2012 +0000 @@ -1,3 +1,16 @@ +2012-03-22 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + Fix flys/issue491, if area fill between curve and axis, draw not only + to zero. + + * src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java + (doArea): Add an artificial dataset to set lower bounds for area. + + * src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java + (addPoints): New convenience method to be used in future. + (createGroundAtInfinity, createCeilingAtInfinity): Create artificial + datasets for better areas. + 2012-03-20 Raimund Renkert <raimund.renkert@intevation.de> Issue 506.
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Tue Mar 20 15:08:01 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Thu Mar 22 10:56:20 2012 +0000 @@ -1,6 +1,5 @@ package de.intevation.flys.exports; - import org.apache.log4j.Logger; import org.jfree.chart.JFreeChart; @@ -634,10 +633,12 @@ area.setMode(StyledAreaSeriesCollection.FILL_MODE.ABOVE); down.setKey(seriesName); area.addSeries(down); + area.addSeries(StyledSeriesBuilder.createGroundAtInfinity(down)); } else if (up != null && down == null) { area.setMode(StyledAreaSeriesCollection.FILL_MODE.UNDER); area.addSeries(up); + area.addSeries(StyledSeriesBuilder.createGroundAtInfinity(up)); } else if (up != null && down != null) { if (data.doPaintBetween()) {
--- 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 :