diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthProcessor.java @ 8886:cc86b0f9b3c3

SINFO-FlowDepth - work on tkh themes
author gernotbelger
date Wed, 14 Feb 2018 18:10:53 +0100
parents 7a8c12706834
children 90b7f45ff4ae
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthProcessor.java	Wed Feb 14 18:10:28 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthProcessor.java	Wed Feb 14 18:10:53 2018 +0100
@@ -11,8 +11,16 @@
 package org.dive4elements.river.artifacts.sinfo.flowdepth;
 
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.jfree.StyledXYSeries;
+import org.dive4elements.river.themes.ThemeDocument;
+
 public final class FlowDepthProcessor extends AbstractSInfoProcessor {
 
     /* Theme name, usually defined in 'FacetTypes', but that is soooo bad dependencies... */
@@ -35,9 +43,33 @@
         super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES);
     }
 
+    @Override
+    protected final String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) {
+
+        final CallContext context = generator.getCallContext();
+        final Map<String, String> metaData = bundle.getFacet().getMetaData();
+
+        final StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+        series.putMetaData(metaData, bundle.getArtifact(), context);
+
+        final String facetName = bundle.getFacetName();
+        final FlowDepthCalculationResult data = (FlowDepthCalculationResult) bundle.getData(context);
+        if (data == null) {
+            // Check has been here before so we keep it for security reasons
+            // this should never happen though.
+            throw new IllegalStateException("Data is null for facet: " + facetName);
+        }
+
+        final double[][] points = generatePoints(data, facetName);
+
+        StyledSeriesBuilder.addPoints(series, points, true);
+        generator.addAxisSeries(series, getAxisName(), visible);
+
+        return metaData.get("Y");
+    }
+
     // FIXME: do filtering
-    @Override
-    protected double[][] generatePoints(final FlowDepthCalculationResult data, final String facetName) {
+    private double[][] generatePoints(final FlowDepthCalculationResult data, final String facetName) {
 
         if (FACET_FLOW_DEPTH_FILTERED.contentEquals(facetName))
             return data.getFlowDepthPoints();
@@ -45,6 +77,7 @@
         if (FACET_FLOW_DEPTH_TKH_FILTERED.contentEquals(facetName))
             return data.getFlowDepthTkhPoints();
 
-        return super.generatePoints(data, facetName);
+        final String error = String.format("Unknown facet name: %s", facetName);
+        throw new UnsupportedOperationException(error);
     }
 }
\ No newline at end of file

http://dive4elements.wald.intevation.org