diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/VelocityProcessor.java @ 8940:82998242ba84

Preparing for additional outputs of SINFO-Tkh
author gernotbelger
date Tue, 06 Mar 2018 18:51:18 +0100
parents
children a9950a3a71e5
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/VelocityProcessor.java	Tue Mar 06 18:51:18 2018 +0100
@@ -0,0 +1,60 @@
+/* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
+ * Software engineering by
+ *  Björnsen Beratende Ingenieure GmbH
+ *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
+ *
+ * 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.artifacts.sinfo.common;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.dive4elements.artifactdatabase.state.Facet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.resources.Resources;
+import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
+
+public final class VelocityProcessor extends AbstractSInfoLineProcessor {
+
+    // FIXME: translate!
+    private static final String I18N_AXIS_LABEL = "sinfo.chart.velocity.section.yaxis.label";
+
+    private static final String SINFO_CHART_VELOCITY_YAXIS_LABEL = "sinfo.chart.velocity.yaxis.label";
+
+    // FIXME: check: filtered or not?
+    private static final String FACET_TKH_VELOCITY_FILTERED = "sinfo_tkh_velocity.filtered";
+
+    private static final String I18N_FACET_TKH_VELOCITY_FILTERED_DESCRIPTION = "sinfo.facet.tkh_velocity.filtered.description";
+
+    private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>();
+
+    static {
+        HANDLED_FACET_TYPES.add(FACET_TKH_VELOCITY_FILTERED);
+    }
+
+    public VelocityProcessor() {
+        super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES);
+    }
+
+    @Override
+    protected double[][] doGetPoints(final AbstractSInfoCalculationResult<?> data, final String facetName) {
+
+        if (FACET_TKH_VELOCITY_FILTERED.contentEquals(facetName))
+            return data.getVelocityPoints();
+
+        final String error = String.format("Unknown facet name: %s", facetName);
+        throw new UnsupportedOperationException(error);
+    }
+
+    public static Facet createVelocityFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult<?> result,
+            final int index) {
+        final String facetFlowDepthFilteredDescription = Resources.getMsg(context.getMeta(), I18N_FACET_TKH_VELOCITY_FILTERED_DESCRIPTION,
+                I18N_FACET_TKH_VELOCITY_FILTERED_DESCRIPTION, result.getLabel());
+        return new SInfoResultFacet(index, VelocityProcessor.FACET_TKH_VELOCITY_FILTERED, facetFlowDepthFilteredDescription, SINFO_CHART_VELOCITY_YAXIS_LABEL,
+                ComputeType.ADVANCE, id, hash);
+    }
+}
\ No newline at end of file

http://dive4elements.wald.intevation.org