changeset 7390:45e3bb00ce1a

Stub for new BedHeightProcessor.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 17 Oct 2013 11:12:14 +0200
parents 2c3031b6a831
children 9513d1af7d58
files artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightProcessor.java
diffstat 1 files changed, 102 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/BedHeightProcessor.java	Thu Oct 17 11:12:14 2013 +0200
@@ -0,0 +1,102 @@
+/* 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.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 BedHeightProcessor extends DefaultProcessor {
+
+    private final static Logger logger =
+            Logger.getLogger(BedHeightProcessor.class);
+
+    private final static String BEDHEIGHT = "bedheight";
+
+    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 BedHeightSingle) {
+            BedHeightSingle bData = (BedHeightSingle)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 BEDHEIGHT.equals(facettype);
+    }
+
+    @Override
+    public String getAxisLabel(DiagramGenerator generator) {
+        return generator.msg(
+                I18N_AXIS_LABEL,
+                I18N_AXIS_LABEL_DEFAULT);
+    }
+}

http://dive4elements.wald.intevation.org