changeset 2029:131842fc6581

Enable basicst area rendering in longitudinal section diagrams. flys-artifacts/trunk@3491 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 20 Dec 2011 11:30:00 +0000
parents f834a6961bb7
children 355495661a1c
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java
diffstat 2 files changed, 79 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Dec 20 11:28:13 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Dec 20 11:30:00 2011 +0000
@@ -1,3 +1,9 @@
+2011-12-20	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java
+	  (doOut, doArea): Added handling for areafacets. Code yet mostly
+			   copied from CrossSectionGenerator.
+
 2011-12-20	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/CrossSectionWaterLineFacet.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Tue Dec 20 11:28:13 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Tue Dec 20 11:30:00 2011 +0000
@@ -330,6 +330,13 @@
                 attr,
                 visible);
         }
+        else if (FacetTypes.IS.AREA(name)) {
+            doArea(artifactAndFacet.getData(context),
+                artifactAndFacet.getFacetDescription(),
+                attr,
+                visible);
+        
+        }
         else {
             logger.warn("Unknown facet name: " + name);
             return;
@@ -477,5 +484,71 @@
             ? prefix + "(" + name +")"
             : name;
     }
+
+
+    /**
+     * Do Area out.
+     */
+    protected void doArea(
+        Object     o,
+        String     seriesName,
+        Document   theme,
+        boolean    visible
+    ) {
+        logger.debug("LongitudinalSectionGenerator.doArea");
+        StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme);
+
+        // TODO make this more stable.
+        Object[] doubles = (Object[]) o;
+        XYSeries up   = null;
+        XYSeries down = null;
+
+        if (doubles[1] != null) {
+            up = new StyledXYSeries(seriesName, false, theme);
+            if (doubles[1] instanceof WQKms) {
+                StyledSeriesBuilder.addPoints(up, (WQKms) doubles[1]);
+            }
+            else if (doubles[1] instanceof double[][]) {
+                StyledSeriesBuilder.addPoints(up, (double [][]) doubles[1]);
+            }
+            else {
+                logger.error("Do not know how to deal with (up) area info from: "
+                    + doubles[1]);
+            }
+        }
+
+        if (doubles[0] != null) {
+            // TODO: Sort this out: when the two series have the same name,
+            // the renderer (or anything in between) will not work correctly.
+            down = new StyledXYSeries(seriesName + " ", false, theme);
+            if (doubles[0] instanceof WQKms) {
+                StyledSeriesBuilder.addPoints(down, (WQKms) doubles[0]);
+            }
+            else if (doubles[0] instanceof double[][]) {
+                StyledSeriesBuilder.addPoints(down, (double[][]) doubles[0]);
+            }
+            else {
+                logger.error("Do not know how to deal with (down) area info from: "
+                    + doubles[0]);
+            }
+
+        }
+
+        if (up == null && down != null) {
+            area.setMode(StyledAreaSeriesCollection.FILL_MODE.ABOVE);
+            down.setKey(seriesName);
+            area.addSeries(down);
+        }
+        else if (up != null && down == null) {
+            area.setMode(StyledAreaSeriesCollection.FILL_MODE.UNDER);
+            area.addSeries(up);
+        }
+        else if (up != null && down != null) {
+            area.setMode(StyledAreaSeriesCollection.FILL_MODE.BETWEEN);
+            area.addSeries(up);
+            area.addSeries(down);
+        }
+        addAreaSeries(area, 0, visible);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org