[PATCH] (issue1225) Unify "Width" processor

Wald Commits scm-commit at wald.intevation.org
Fri Dec 13 15:39:09 CET 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1386945545 -3600
# Node ID 4374a8d26706350c8b8a50e3eaa5ec1edf0c5748
# Parent  9509359c8db8500113d22d747bf8fc4c4255ce88
(issue1225) Unify "Width" processor

diff -r 9509359c8db8 -r 4374a8d26706 artifacts/doc/conf/longitudinal-diagram-defaults.xml
--- a/artifacts/doc/conf/longitudinal-diagram-defaults.xml	Thu Dec 12 16:26:21 2013 +0100
+++ b/artifacts/doc/conf/longitudinal-diagram-defaults.xml	Fri Dec 13 15:39:05 2013 +0100
@@ -5,7 +5,6 @@
     <axis name="deltaW"/>
     <axis name="diffBed"/>
     <axis name="diffBed/Y"/>
-    <axis name="SoundingWidth"/>
     <axis name="Width"/>
     <axis name="Diameter"/>
     <axis name="Density"/>
@@ -26,7 +25,6 @@
     <processor class="org.dive4elements.river.exports.process.WDiffProcessor" axis="diffW"/>
     <processor class="org.dive4elements.river.exports.process.WOutProcessor"  axis="W"/>
     <processor class="org.dive4elements.river.exports.process.QOutProcessor"  axis="Q"/>
-    <processor class="org.dive4elements.river.exports.process.BedHeightSoundingProcessor"  axis="SoundingWidth"/>
     <processor class="org.dive4elements.river.exports.process.BedWidthProcessor"           axis="Width"/>
     <processor class="org.dive4elements.river.exports.process.FixDeltaWProcessor"          axis="diffBed"/>
     <processor class="org.dive4elements.river.exports.process.BedDiffYearProcessor"        axis="diffBed"/>
diff -r 9509359c8db8 -r 4374a8d26706 artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightSoundingProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightSoundingProcessor.java	Thu Dec 12 16:26:21 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU AGPL (>=v3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out the
- * documentation coming with Dive4Elements River for details.
- */
-
-package org.dive4elements.river.exports.process;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.jfree.data.xy.XYSeries;
-
-import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
-import org.dive4elements.artifacts.CallContext;
-import org.dive4elements.river.artifacts.model.minfo.BedHeightSingleData;
-import org.dive4elements.river.artifacts.model.FacetTypes;
-import org.dive4elements.river.exports.XYChartGenerator;
-import org.dive4elements.river.exports.DiagramGenerator;
-import org.dive4elements.river.jfree.StyledXYSeries;
-import org.dive4elements.river.model.BedHeightSingleValue;
-import org.dive4elements.river.themes.ThemeDocument;
-
-public class BedHeightSoundingProcessor extends DefaultProcessor {
-
-    private final static Logger logger =
-            Logger.getLogger(BedHeightSoundingProcessor.class);
-
-    public static final String I18N_AXIS_LABEL_DEFAULT
-        = "Gepeilte Breite [m]";
-    public static final String I18N_AXIS_LABEL =
-        "chart.bedheight_middle.sounding.yaxis.label";
-
-    @Override
-    public void doOut(
-            DiagramGenerator generator,
-            ArtifactAndFacet bundle,
-            ThemeDocument    theme,
-            boolean          visible) {
-        XYSeries series = prepareSeries(bundle, theme, generator.getCallContext());
-        generator.addAxisSeries(series, axisName, visible);
-    }
-
-    @Override
-    public void doOut(
-            XYChartGenerator generator,
-            ArtifactAndFacet bundle,
-            ThemeDocument theme,
-            boolean visible,
-            int index
-    ) {
-        XYSeries series = prepareSeries(bundle, theme, generator.getCallContext());
-        generator.addAxisSeries(series, index, visible);
-    }
-
-    /** Prepare an series, independent of axis. */
-    private XYSeries prepareSeries(ArtifactAndFacet bundle,
-        ThemeDocument theme, CallContext context) {
-        Object data = bundle.getData(context);
-        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
-                theme);
-        if (data instanceof BedHeightSingleData) {
-            BedHeightSingleData bData = (BedHeightSingleData)data;
-            double[] width = bData.getMorphWidths();
-            double[] stations = bData.getStations().toNativeArray();
-
-            logger.debug("doBedheightSingleOut");
-
-            for (int i = 0; i < width.length; i++) {
-                series.add(stations[i], width[i], false);
-            }
-        } else if (data instanceof List<?>) {
-            List<BedHeightSingleValue> bData = (List<BedHeightSingleValue>)data;
-
-            logger.debug("doBedheightSingleValueOut");
-
-            for(BedHeightSingleValue bvalue: bData) {
-                series.add(bvalue.getStation(), bvalue.getSoundingWidth());
-            }
-        }
-        else {
-            logger.error("Unknown data type " + data.getClass());
-        }
-        return series;
-    }
-
-
-    @Override
-    public boolean canHandle(String facettype) {
-        return FacetTypes.BEDHEIGHT_SOUNDING_WIDTH.equals(facettype);
-    }
-
-    @Override
-    public String getAxisLabel(DiagramGenerator generator) {
-        return generator.msg(
-                I18N_AXIS_LABEL,
-                I18N_AXIS_LABEL_DEFAULT);
-    }
-}
diff -r 9509359c8db8 -r 4374a8d26706 artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java	Thu Dec 12 16:26:21 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java	Fri Dec 13 15:39:05 2013 +0100
@@ -11,6 +11,8 @@
 import org.apache.log4j.Logger;
 import org.jfree.data.xy.XYSeries;
 
+import java.util.List;
+
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifacts.CallContext;
 import org.dive4elements.river.artifacts.model.FacetTypes;
@@ -20,6 +22,9 @@
 import org.dive4elements.river.themes.ThemeDocument;
 
 import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult;
+import org.dive4elements.river.model.BedHeightSingleValue;
+import org.dive4elements.river.artifacts.model.minfo.BedHeightSingleData;
+
 import org.dive4elements.river.artifacts.model.minfo.MorphologicWidth;
 
 public class BedWidthProcessor extends DefaultProcessor {
@@ -49,6 +54,20 @@
         } else if (data instanceof MorphologicWidth) {
             MorphologicWidth bData = (MorphologicWidth) data;
             StyledSeriesBuilder.addPoints(series, bData.getAsArray(), true);
+        } else if (data instanceof BedHeightSingleData) {
+            BedHeightSingleData bData = (BedHeightSingleData)data;
+            double[] width = bData.getMorphWidths();
+            double[] stations = bData.getStations().toNativeArray();
+
+            for (int i = 0; i < width.length; i++) {
+                series.add(stations[i], width[i], false);
+            }
+        } else if (data instanceof List<?>) {
+            List<BedHeightSingleValue> bData = (List<BedHeightSingleValue>)data;
+
+            for(BedHeightSingleValue bvalue: bData) {
+                series.add(bvalue.getStation(), bvalue.getSoundingWidth());
+            }
         } else {
             logger.error("Unknown data for facet: " + bundle.getFacetName());
         }
@@ -59,7 +78,8 @@
     @Override
     public boolean canHandle(String facettype) {
         return facettype.equals(FacetTypes.BED_DIFFERENCE_MORPH_WIDTH) ||
-            facettype.equals(FacetTypes.MORPHOLOGIC_WIDTH);
+            facettype.equals(FacetTypes.MORPHOLOGIC_WIDTH) ||
+            facettype.equals(FacetTypes.BEDHEIGHT_SOUNDING_WIDTH);
     }
 
     @Override


More information about the Dive4elements-commits mailing list