changeset 7145:432047ee5b4b

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.
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 25 Sep 2013 15:07:41 +0200
parents b6595716f5f0
children 414794d0a50d
files artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java
diffstat 1 files changed, 73 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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);
+    }
+}

http://dive4elements.wald.intevation.org