[Dive4elements-commits] [PATCH 12 of 13] Use new WOutProcessor for generating charts

Wald Commits scm-commit at wald.intevation.org
Wed Nov 7 15:58:46 CET 2012


# HG changeset patch
# User Björn Ricks <bjoern.ricks at intevation.de>
# Date 1352300188 -3600
# Node ID 9425b7c51b737e9086d46852e095a554f3bc31e6
# Parent  a5993b69439bcae04f40c064fab3e7213bf0fa6f
Use new WOutProcessor for generating charts

Use WOutProcessor in DischargeLongitudinalSectionGenerator and
LongitudinalSectionGenerator.

diff -r a5993b69439b -r 9425b7c51b73 flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java	Wed Nov 07 15:52:25 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java	Wed Nov 07 15:56:28 2012 +0100
@@ -12,7 +12,8 @@
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.WQCKms;
 import de.intevation.flys.artifacts.model.WQKms;
-import de.intevation.flys.artifacts.model.WKms;
+import de.intevation.flys.exports.process.Processor;
+import de.intevation.flys.exports.process.WOutProcessor;
 
 import de.intevation.flys.jfree.FLYSAnnotation;
 import de.intevation.flys.jfree.StyledXYSeries;
@@ -53,14 +54,7 @@
 
         Facet facet = artifactFacet.getFacet();
 
-        if (IS.WQ_KM(name)) {
-            doWOut(
-                (WQKms) artifactFacet.getData(context),
-                artifactFacet,
-                attr,
-                visible);
-        }
-        else if (name.equals(DISCHARGE_LONGITUDINAL_Q)) {
+        if (name.equals(DISCHARGE_LONGITUDINAL_Q)) {
             doQOut(
                 (WQKms) artifactFacet.getData(context),
                 artifactFacet,
@@ -74,12 +68,6 @@
                 attr,
                 visible);
         }
-        else if (IS.W_KM(name)) {
-            doWOut(
-                (WKms) artifactFacet.getData(context),
-                artifactFacet,
-                attr, visible);
-        }
         else if (name.equals(LONGITUDINAL_ANNOTATION)) {
             doAnnotations((FLYSAnnotation) artifactFacet.getData(context),
                  artifactFacet, attr, visible);
@@ -90,7 +78,13 @@
                 attr, visible, YAXIS.W.idx);
         }
         else {
-            logger.warn("Unknown facet name: " + name);
+            Processor processor = new WOutProcessor();
+            if (processor.canHandle(name)) {
+                processor.doOut(this, artifactFacet, attr, visible, YAXIS.W.idx);
+            }
+            else {
+                logger.warn("Unknown facet name: " + name);
+            }
         }
     }
 
diff -r a5993b69439b -r 9425b7c51b73 flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Wed Nov 07 15:52:25 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Wed Nov 07 15:56:28 2012 +0100
@@ -8,13 +8,12 @@
 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.exports.process.WOutProcessor;
 import de.intevation.flys.jfree.FLYSAnnotation;
 import de.intevation.flys.jfree.StyledAreaSeriesCollection;
 import de.intevation.flys.jfree.StyledXYSeries;
 import de.intevation.flys.utils.DataUtil;
 import de.intevation.flys.utils.FLYSUtils;
-import de.intevation.flys.utils.ThemeUtil;
-
 import org.apache.log4j.Logger;
 import org.jfree.chart.axis.NumberAxis;
 import org.jfree.chart.axis.ValueAxis;
@@ -326,12 +325,9 @@
             return;
         }
 
-        if (name.equals(LONGITUDINAL_W)) {
-            doWOut(
-                (WQKms) artifactAndFacet.getData(context),
-                artifactAndFacet,
-                attr,
-                visible);
+        WOutProcessor processor = new WOutProcessor();
+        if (processor.canHandle(name)) {
+            processor.doOut(this, artifactAndFacet, attr, visible, YAXIS.W.idx);
         }
         else if (name.equals(LONGITUDINAL_Q)) {
             doQOut(
@@ -347,22 +343,6 @@
                  attr,
                  visible);
         }
-        else if (name.equals(STATIC_WKMS)
-                || name.equals(HEIGHTMARKS_POINTS)
-                || name.equals(STATIC_WQKMS)) {
-            doWOut(
-                (WKms) artifactAndFacet.getData(context),
-                artifactAndFacet,
-                attr,
-                visible);
-        }
-        else if (name.equals(STATIC_WQKMS_W)) {
-            doWOut(
-                (WQKms) artifactAndFacet.getData(context),
-                artifactAndFacet,
-                attr,
-                visible);
-        }
         else if (name.equals(STATIC_WQKMS_Q)) {
             doQOut(
                 (WQKms) artifactAndFacet.getData(context),
@@ -398,53 +378,6 @@
         }
     }
 
-
-    /**
-     * Process the output for W facets in a longitudinal section curve.
-     *
-     * @param wkms WKms data.
-     * @param aandf The artifact and facet. This facet does NOT support any data objects. Use
-     * FLYSArtifact.getNativeFacet() instead to retrieve a Facet which supports
-     * data.
-     * @param theme The theme that contains styling information.
-     * @param visible The visibility of the curve.
-     */
-    protected void doWOut(
-        WKms             wkms,
-        ArtifactAndFacet aandf,
-        Document         theme,
-        boolean          visible
-    ) {
-        logger.debug("LongitudinalSectionGenerator.doWOut");
-
-        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
-
-        StyledSeriesBuilder.addPoints(series, wkms);
-        addAxisSeries(series, YAXIS.W.idx, visible);
-
-        // If a "band around the curve shall be drawn, add according area.
-        double bandWidth = ThemeUtil.parseBandWidth(theme);
-        if (bandWidth > 0 ) {
-            XYSeries seriesDown = new StyledXYSeries(
-                "band " + aandf.getFacetDescription(), false, theme);
-            XYSeries seriesUp = new StyledXYSeries(
-                aandf.getFacetDescription()+"+/-"+bandWidth, false, theme);
-            StyledSeriesBuilder.addUpperBand(seriesUp, wkms, bandWidth);
-            StyledSeriesBuilder.addLowerBand(seriesDown, wkms, bandWidth);
-
-            StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme);
-            area.addSeries(seriesUp);
-            area.addSeries(seriesDown);
-            area.setMode(StyledAreaSeriesCollection.FILL_MODE.BETWEEN);
-            addAreaSeries(area, YAXIS.W.idx, visible);
-        }
-
-        if (needInvertAxis(wkms)) {
-            setInverted(true);
-        }
-    }
-
-
     /**
      * Add items to dataseries which describes the differences.
      */


More information about the Dive4elements-commits mailing list