[PATCH 2 of 2] Add MiddleBedHeightProcessor

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


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1380097510 -7200
# Node ID 05d442db4ca63b397dca6ccc80d434ae2427919b
# Parent  2237bb25a8f283c6908f899aa4283a392d8426bf
Add MiddleBedHeightProcessor

diff -r 2237bb25a8f2 -r 05d442db4ca6 artifacts/src/main/java/org/dive4elements/river/exports/process/MiddleBedHeightProcessor.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/MiddleBedHeightProcessor.java	Wed Sep 25 10:25:10 2013 +0200
@@ -0,0 +1,79 @@
+/* Copyright (C) 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 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.MiddleBedHeightData;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.themes.ThemeDocument;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.utils.RiverUtils;
+import org.dive4elements.river.jfree.StyledXYSeries;
+
+public class MiddleBedHeightProcessor extends DefaultProcessor {
+
+    /** Private logger. */
+    private static final Logger logger =
+            Logger.getLogger(WOutProcessor.class);
+
+    public static final String I18N_AXIS_LABEL =
+        "chart.bedheight_middle.section.yaxis.label";
+
+    public static final String I18N_AXIS_LABEL_DEFAULT =
+        "mittlere Sohlhöhen [müNN]";
+
+    @Override
+    public void doOut(
+            DiagramGenerator generator,
+            ArtifactAndFacet bundle,
+            ThemeDocument    theme,
+            boolean          visible) {
+        CallContext context = generator.getCallContext();
+        logger.debug("Processing: " + bundle.getFacetName());
+        MiddleBedHeightData data =
+            (MiddleBedHeightData) bundle.getData(context);
+
+        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
+                theme);
+
+        StyledSeriesBuilder.addPoints(series, data.getMiddleHeightsPoints(),
+                false, 0.110d);
+
+        generator.addAxisSeries(series, axisName, visible);
+    }
+
+    @Override
+    public String getAxisLabel(DiagramGenerator generator) {
+        D4EArtifact flys = (D4EArtifact) generator.getMaster();
+
+        String unit = RiverUtils.getRiver(flys).getWstUnit().getName();
+
+        return generator.msg(
+                I18N_AXIS_LABEL,
+                I18N_AXIS_LABEL_DEFAULT,
+                new Object[] { unit });
+    }
+
+    @Override
+    public boolean canHandle(String facetType) {
+        if (facetType == null) {
+            return false;
+        }
+        return facetType.equals(FacetTypes.MIDDLE_BED_HEIGHT_EPOCH) ||
+            facetType.equals(FacetTypes.MIDDLE_BED_HEIGHT_SINGLE);
+    }
+}


More information about the Dive4elements-commits mailing list