[PATCH 2 of 4] Add BedWidthProcessor to handle width facets

Wald Commits scm-commit at wald.intevation.org
Wed Sep 25 15:08:52 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1380114461 -7200
# Node ID 432047ee5b4b532788b5755a5bc06a52b7a23b99
# Parent  b6595716f5f0083a75d321bdf08aa1638737346f
Add BedWidthProcessor to handle width facets

    This can probably be combined with the BedHeightSoundingProcessor
    but currently they should also both write to differently labled
    axes.

diff -r b6595716f5f0 -r 432047ee5b4b artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java	Wed Sep 25 15:07:41 2013 +0200
@@ -0,0 +1,73 @@
+/* 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.BedHeightSingle;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.jfree.StyledXYSeries;
+import org.dive4elements.river.model.BedHeightSingleValue;
+import org.dive4elements.river.themes.ThemeDocument;
+
+import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult;
+import org.dive4elements.river.artifacts.model.minfo.MorphologicWidth;
+
+public class BedWidthProcessor extends DefaultProcessor {
+
+    private final static Logger logger =
+            Logger.getLogger(BedWidthProcessor.class);
+
+    public static final String I18N_AXIS_LABEL_DEFAULT =
+        "Breite [m]";
+    public static final String I18N_AXIS_LABEL =
+        "chart.beddifference.yaxis.label.morph";
+
+    @Override
+    public void doOut(
+            DiagramGenerator generator,
+            ArtifactAndFacet bundle,
+            ThemeDocument    theme,
+            boolean          visible) {
+        CallContext context = generator.getCallContext();
+        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
+                theme);
+        Object data = bundle.getData(context);
+
+        if (data instanceof BedDiffYearResult) {
+            BedDiffYearResult bData = (BedDiffYearResult) data;
+            StyledSeriesBuilder.addPoints(series, bData.getMorphWidthData(), true);
+        } else if (data instanceof MorphologicWidth) {
+            MorphologicWidth bData = (MorphologicWidth) data;
+            StyledSeriesBuilder.addPoints(series, bData.getAsArray(), true);
+        }
+
+        generator.addAxisSeries(series, axisName, visible);
+    }
+
+    @Override
+    public boolean canHandle(String facettype) {
+        return facettype.equals(FacetTypes.BED_DIFFERENCE_MORPH_WIDTH) ||
+            facettype.equals(FacetTypes.MORPHOLOGIC_WIDTH);
+    }
+
+    @Override
+    public String getAxisLabel(DiagramGenerator generator) {
+        return generator.msg(
+                I18N_AXIS_LABEL,
+                I18N_AXIS_LABEL_DEFAULT);
+    }
+}


More information about the Dive4elements-commits mailing list