[PATCH 04 of 13] Stub for new BedHeightProcessor
Wald Commits
scm-commit at wald.intevation.org
Mon Oct 21 11:29:38 CEST 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1382001134 -7200
# Node ID 45e3bb00ce1a055c4e9f1230d03f768ac9f6f81e
# Parent 2c3031b6a831f69f5e860345e34e7129ad679e72
Stub for new BedHeightProcessor.
diff -r 2c3031b6a831 -r 45e3bb00ce1a artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightProcessor.java
--- /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);
+ }
+}
More information about the Dive4elements-commits
mailing list