changeset 1769:bbe12d77710d

Prepare rendering of added other (static) WKms and Differences in LongitudinalSection Diagrams. flys-artifacts/trunk@3090 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 26 Oct 2011 12:54:22 +0000
parents 41ba2276d785
children e8a98eee816d
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java
diffstat 2 files changed, 72 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Oct 26 12:47:37 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Oct 26 12:54:22 2011 +0000
@@ -1,3 +1,9 @@
+2011-10-26	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java:
+	  Prepare rendering of "other/static wkms" (functional) and
+	  w-differences (not yet fully functional).
+
 2011-10-26  Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/states/DefaultState.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Wed Oct 26 12:47:37 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Wed Oct 26 12:54:22 2011 +0000
@@ -21,6 +21,7 @@
 import de.intevation.flys.artifacts.FLYSArtifact;
 
 import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.WKms;
 import de.intevation.flys.artifacts.model.WQKms;
 
 import de.intevation.flys.jfree.FLYSAnnotation;
@@ -204,7 +205,10 @@
      * @return range with 0 included.
      */
     protected Range createSecondAxisRange(Range range) {
-       return new Range(0d, range.getUpperBound());
+        if (range == null) {
+            return null;
+        }
+        return new Range(0d, range.getUpperBound());
     }
 
 
@@ -239,6 +243,11 @@
     }
 
 
+    /**
+     * Produce output.
+     * @param facet current facet.
+     * @param attr  theme for facet
+     */
     public void doOut(
         Artifact artifact,
         Facet    facet,
@@ -270,6 +279,17 @@
         else if (name.equals(LONGITUDINAL_ANNOTATION)) {
             doAnnotationsOut(f.getData(artifact, context), facet, attr, visible);
         }
+        // TODO -> type, and merge with WDifferencesCurveGenerator
+        else if (name.equals("other.wkms")) {
+            doWOut((WKms) f.getData(artifact, context), facet, attr, visible);
+        }
+        else if (name.equals(W_DIFFERENCES)) {
+            doWDifferencesOut(
+                (WKms) f.getData(artifact, context),
+                facet,
+                attr,
+                visible);
+        }
         else {
             logger.warn("Unknown facet name: " + name);
             return;
@@ -315,7 +335,7 @@
      * @param visible The visibility of the curve.
      */
     protected void doWOut(
-        WQKms    wqkms,
+        WKms     wkms,
         Facet    facet,
         Document theme,
         boolean  visible
@@ -324,20 +344,61 @@
 
         XYSeries series = new StyledXYSeries(facet.getDescription(), theme);
 
-        int size = wqkms.size();
+        int size = wkms.size();
 
         for (int i = 0; i < size; i++) {
-            series.add(wqkms.getKm(i), wqkms.getW(i), false);
+            series.add(wkms.getKm(i), wkms.getW(i), false);
         }
 
         addFirstAxisSeries(series, visible);
 
-        if (needInvertAxis(wqkms)) {
+        if (wkms instanceof WQKms) {
+            if (needInvertAxis((WQKms) wkms)) {
+                setInverted(true);
+            }
+        }
+    }
+
+
+    /**
+     * Add items to dataseries which describes the differences.
+     */
+    protected void doWDifferencesOut(
+        WKms       wkms,
+        Facet      facet,
+        Document   theme,
+        boolean    visible
+    ) {
+        logger.debug("WDifferencesCurveGenerator.doWDifferencesOut");
+        if (wkms == null) {
+            logger.warn("No data to add to WDifferencesChart.");
+            return;
+         }
+
+        int size = wkms.size();
+        XYSeries series = new StyledXYSeries(facet.getDescription(), theme);
+
+        if (logger.isDebugEnabled()) {
+            if (wkms.size() > 0) {
+                logger.debug("Generate series: " + series.getKey());
+                logger.debug("Start km: " + wkms.getKm(0));
+                logger.debug("End   km: " + wkms.getKm(size-1));
+                logger.debug("Values  : " + size);
+            }
+        }
+
+        for (int i = 0; i < size; i++) {
+            series.add(wkms.getKm(i), wkms.getW(i));
+        }
+
+        addSecondAxisSeries(series, visible);
+        if (DataUtil.guessWaterIncreasing(wkms.allWs())) {
             setInverted(true);
         }
     }
 
 
+
     /**
      * Process the output for Q facets in a longitudinal section curve.
      *

http://dive4elements.wald.intevation.org