diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthState.java @ 8879:64ca63f79f6f

Further work on SINFO-FlowDepth
author gernotbelger
date Fri, 09 Feb 2018 13:27:10 +0100
parents 9f7a285b0ee3
children 7a8c12706834
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthState.java	Fri Feb 09 13:20:16 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthState.java	Fri Feb 09 13:27:10 2018 +0100
@@ -45,13 +45,29 @@
 
     @Override
     public Object computeFeed(
-        final D4EArtifact artifact,
-        final String       hash,
-        final CallContext  context,
-        final List<Facet>  facets,
-        final Object       old
-    ) {
-    	// FIXME: why is this necessary?
+            final D4EArtifact artifact,
+            final String       hash,
+            final CallContext  context,
+            final List<Facet>  facets,
+            final Object       old
+            ) {
+        // FIXME: why is this necessary?
+        if (artifact instanceof ChartArtifact) {
+            facets.add(new EmptyFacet());
+            return null;
+        }
+
+        return compute((SINFOArtifact) artifact, context, hash, facets, old);
+    }
+
+    @Override
+    public Object computeAdvance(
+            final D4EArtifact artifact,
+            final String       hash,
+            final CallContext  context,
+            final List<Facet>  facets,
+            final Object       old
+            ) {
         if (artifact instanceof ChartArtifact) {
             facets.add(new EmptyFacet());
             return null;
@@ -59,37 +75,23 @@
         return compute((SINFOArtifact) artifact, context, hash, facets, old);
     }
 
-    @Override
-    public Object computeAdvance(
-    	final D4EArtifact artifact,
-    	final String       hash,
-    	final CallContext  context,
-    	final List<Facet>  facets,
-    	final Object       old
-    ) {
-        if (artifact instanceof ChartArtifact) {
-            facets.add(new EmptyFacet());
-            return null;
-        }
-        return compute((SINFOArtifact) artifact, context, hash, facets, old);
-    }
-    
     /**
      * Compute result or returned object from cache, create facets.
      * @param old Object that was cached.
      */
     private Object compute(
-    	final SINFOArtifact sinfo,
-        final CallContext   context,
-        final String        hash,
-        final List<Facet>   facets,
-        final Object        old
-    ) {
+            final SINFOArtifact sinfo,
+            final CallContext   context,
+            final String        hash,
+            final List<Facet>   facets,
+            final Object        old
+            ) {
+
         final CalculationResult res;
-		if (old instanceof CalculationResult)
-			res = (CalculationResult) old;
-		else
-			res = new FlowDepthCalculation(context).calculate(sinfo);
+        if (old instanceof CalculationResult)
+            res = (CalculationResult) old;
+        else
+            res = new FlowDepthCalculation(context).calculate(sinfo);
 
         if (facets == null) {
             return res;
@@ -101,27 +103,27 @@
         final List<FlowDepthCalculationResult> resultList = results.getResults();
         for (int index = 0; index < resultList.size(); index++) {
 
-			final FlowDepthCalculationResult result = resultList.get(index);
-			
-			/* filtered (zoom dependent mean) flow depth */
-			final String facetFlowDepthFilteredDescription = Resources.getMsg( context.getMeta(), I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, result.getLabel() );
-			facets.add(new FlowDepthFilterFacet(
-			        index,
-			        FlowDepthProcessor.FACET_FLOW_DEPTH_FILTERED,
-			        facetFlowDepthFilteredDescription,
-			        ComputeType.ADVANCE,
-			        id,
-			        hash
-			    ));
-			
-			// FIXME: add other themes
-		}
+            final FlowDepthCalculationResult result = resultList.get(index);
+
+            /* filtered (zoom dependent mean) flow depth */
+            final String facetFlowDepthFilteredDescription = Resources.getMsg( context.getMeta(), I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, result.getLabel() );
+            facets.add(new FlowDepthFilterFacet(
+                    index,
+                    FlowDepthProcessor.FACET_FLOW_DEPTH_FILTERED,
+                    facetFlowDepthFilteredDescription,
+                    ComputeType.ADVANCE,
+                    this.id,
+                    hash
+                    ));
+
+            // FIXME: add other themes
+        }
 
         if (!resultList.isEmpty() ) {
-            Facet csv = new DataFacet(
-                FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, id);
-            Facet pdf = new DataFacet(
-            		FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, id);
+            final Facet csv = new DataFacet(
+                    FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id);
+            final Facet pdf = new DataFacet(
+                    FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id);
 
             facets.add(csv);
             facets.add(pdf);
@@ -130,7 +132,7 @@
         final Calculation report = res.getReport();
 
         if (report.hasProblems()) {
-            facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id));
+            facets.add(new ReportFacet(ComputeType.ADVANCE, hash, this.id));
         }
 
         return res;

http://dive4elements.wald.intevation.org