[Dive4elements-commits] [PATCH 2 of 3] Added processor for new factes in bed difference chart generators

Wald Commits scm-commit at wald.intevation.org
Fri Apr 12 14:51:38 CEST 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1365771018 -7200
# Node ID aa06e25528aed57e26074f22359e1af8c465dfa8
# Parent  8cb8b03a423defc2e01587241cb153b70a2b766b
Added processor for new factes in bed difference chart generators.

diff -r 8cb8b03a423d -r aa06e25528ae flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedDifferenceEpochGenerator.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedDifferenceEpochGenerator.java	Fri Apr 12 14:49:04 2013 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedDifferenceEpochGenerator.java	Fri Apr 12 14:50:18 2013 +0200
@@ -9,15 +9,18 @@
 import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.access.FlowVelocityAccess;
 import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.WKms;
 import de.intevation.flys.artifacts.model.minfo.BedDiffEpochResult;
 import de.intevation.flys.exports.StyledSeriesBuilder;
 import de.intevation.flys.exports.fixings.FixChartGenerator;
 import de.intevation.flys.exports.process.KMIndexProcessor;
 import de.intevation.flys.exports.process.Processor;
+import de.intevation.flys.exports.process.WOutProcessor;
 import de.intevation.flys.jfree.Bounds;
 import de.intevation.flys.jfree.DoubleBounds;
 import de.intevation.flys.jfree.FLYSAnnotation;
 import de.intevation.flys.jfree.StyledXYSeries;
+import de.intevation.flys.utils.DataUtil;
 
 
 public class BedDifferenceEpochGenerator
@@ -25,7 +28,7 @@
 implements FacetTypes
 {
     public enum YAXIS {
-        D(0), H(1), dW(2);
+        D(0), H(1), dW(2), W(3);
 
         protected int idx;
 
@@ -51,6 +54,10 @@
     public static final String I18N_DW_YAXIS_LABEL =
             "chart.fixings.longitudinalsection.yaxis.label";
 
+    private static final String I18N_W_YAXIS_LABEL =
+        "chart.longitudinal.section.yaxis.label";
+    private static final String I18N_W_YAXIS_LABEL_DEFAULT = "W [NN + m]";
+
 
     @Override
     protected YAxisWalker getYAxisWalker() {
@@ -112,6 +119,7 @@
             context.putContextValue("endkm", bounds.getUpper());
         }
         Processor processor = new KMIndexProcessor();
+        Processor woutp = new WOutProcessor();
         if (name.equals(BED_DIFFERENCE_EPOCH)) {
             doBedDifferenceEpochOut(
                 (BedDiffEpochResult) bundle.getData(context),
@@ -141,6 +149,16 @@
         else if (processor.canHandle(name)) {
             processor.doOut(this, bundle, attr, visible, YAXIS.dW.idx);
         }
+        else if (woutp.canHandle(name)) {
+            woutp.doOut(this, bundle, attr, visible, YAXIS.W.idx);
+        }
+        else if (name.equals(W_DIFFERENCES)) {
+            doWDifferencesOut(
+                (WKms) bundle.getData(context),
+                bundle,
+                attr,
+                visible);
+        }
         else if (name.equals(LONGITUDINAL_ANNOTATION)) {
             doAnnotations(
                 (FLYSAnnotation) bundle.getData(context),
@@ -175,7 +193,9 @@
         else if (pos == YAXIS.dW.idx) {
             return msg(I18N_DW_YAXIS_LABEL, I18N_DW_YAXIS_LABEL_DEFAULT);
         }
-
+        else if (pos == YAXIS.W.idx) {
+            return msg(I18N_W_YAXIS_LABEL, I18N_W_YAXIS_LABEL_DEFAULT);
+        }
         return label;
     }
 
@@ -206,4 +226,24 @@
 
         addAxisSeries(series, YAXIS.H.idx, visible);
     }
+
+    protected void doWDifferencesOut(
+        WKms       wkms,
+        ArtifactAndFacet aandf,
+        Document   theme,
+        boolean    visible
+    ) {
+        if (wkms == null) {
+            logger.warn("No data to add to WDifferencesChart.");
+            return;
+         }
+
+        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
+        StyledSeriesBuilder.addPoints(series, wkms);
+
+        addAxisSeries(series, YAXIS.D.idx, visible);
+        if (DataUtil.guessWaterIncreasing(wkms.allWs())) {
+            setInverted(true);
+        }
+    }
 }
diff -r 8cb8b03a423d -r aa06e25528ae flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedDifferenceYearGenerator.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedDifferenceYearGenerator.java	Fri Apr 12 14:49:04 2013 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedDifferenceYearGenerator.java	Fri Apr 12 14:50:18 2013 +0200
@@ -7,16 +7,19 @@
 import de.intevation.artifactdatabase.state.ArtifactAndFacet;
 import de.intevation.artifactdatabase.state.Facet;
 import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.WKms;
 import de.intevation.flys.artifacts.model.minfo.BedDiffYearResult;
 import de.intevation.flys.artifacts.model.minfo.BedDifferencesResult;
 import de.intevation.flys.exports.StyledSeriesBuilder;
 import de.intevation.flys.exports.fixings.FixChartGenerator;
 import de.intevation.flys.exports.process.KMIndexProcessor;
 import de.intevation.flys.exports.process.Processor;
+import de.intevation.flys.exports.process.WOutProcessor;
 import de.intevation.flys.jfree.Bounds;
 import de.intevation.flys.jfree.DoubleBounds;
 import de.intevation.flys.jfree.FLYSAnnotation;
 import de.intevation.flys.jfree.StyledXYSeries;
+import de.intevation.flys.utils.DataUtil;
 
 
 public class BedDifferenceYearGenerator
@@ -24,7 +27,7 @@
 implements FacetTypes
 {
     public enum YAXIS {
-        D(0), M(1), H(2),  dW(3);
+        D(0), M(1), H(2),  dW(3), W(4);
 
         protected int idx;
 
@@ -51,6 +54,9 @@
             "delta W [cm]";
     public static final String I18N_DW_YAXIS_LABEL =
             "chart.fixings.longitudinalsection.yaxis.label";
+    private static final String I18N_W_YAXIS_LABEL =
+        "chart.longitudinal.section.yaxis.label";
+    private static final String I18N_W_YAXIS_LABEL_DEFAULT = "W [NN + m]";
 
     @Override
     protected YAxisWalker getYAxisWalker() {
@@ -110,6 +116,7 @@
             context.putContextValue("endkm", bounds.getUpper());
         }
         Processor processor = new KMIndexProcessor();
+        Processor woutp = new WOutProcessor();
         if (name.equals(BED_DIFFERENCE_YEAR)) {
             doBedDifferenceYearOut(
                 (BedDiffYearResult) bundle.getData(context),
@@ -155,8 +162,15 @@
                  attr,
                  visible);
         }
-        else if (processor.canHandle(name)) {
-            processor.doOut(this, bundle, attr, visible, YAXIS.dW.idx);
+        else if (woutp.canHandle(name)) {
+            woutp.doOut(this, bundle, attr, visible, YAXIS.W.idx);
+        }
+        else if (name.equals(W_DIFFERENCES)) {
+            doWDifferencesOut(
+                (WKms) bundle.getData(context),
+                bundle,
+                attr,
+                visible);
         }
         else {
             logger.warn("Unknown facet name " + name);
@@ -207,6 +221,10 @@
         else if (pos == YAXIS.dW.idx) {
             label = msg(I18N_DW_YAXIS_LABEL, I18N_DW_YAXIS_LABEL_DEFAULT);
         }
+        else if (pos == YAXIS.W.idx) {
+            return msg(I18N_W_YAXIS_LABEL, I18N_W_YAXIS_LABEL_DEFAULT);
+        }
+
         return label;
     }
 
@@ -229,4 +247,24 @@
 
         addAxisSeries(series, YAXIS.M.idx, visible);
     }
-}
+
+    protected void doWDifferencesOut(
+        WKms       wkms,
+        ArtifactAndFacet aandf,
+        Document   theme,
+        boolean    visible
+    ) {
+        if (wkms == null) {
+            logger.warn("No data to add to WDifferencesChart.");
+            return;
+         }
+
+        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
+        StyledSeriesBuilder.addPoints(series, wkms);
+
+        addAxisSeries(series, YAXIS.D.idx, visible);
+        if (DataUtil.guessWaterIncreasing(wkms.allWs())) {
+            setInverted(true);
+        }
+    }
+}
\ No newline at end of file


More information about the Dive4elements-commits mailing list