[PATCH] AbstractSInfoLineProcessor refactoring
Wald Commits
scm-commit at wald.intevation.org
Mon Jul 2 13:01:03 CEST 2018
# HG changeset patch
# User gernotbelger
# Date 1530529259 -7200
# Node ID 9831f6c60473e86cf6346b6e8c440e98c8880aae
# Parent b4402594213b48211adb270f75c7a6046b312e7b
AbstractSInfoLineProcessor refactoring
diff -r b4402594213b -r 9831f6c60473 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractSInfoLineProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractSInfoLineProcessor.java Mon Jul 02 07:33:53 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-/* 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.Map;
-import java.util.Set;
-
-import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
-import org.dive4elements.artifactdatabase.state.Facet;
-import org.dive4elements.artifacts.Artifact;
-import org.dive4elements.artifacts.CallContext;
-import org.dive4elements.river.artifacts.D4EArtifact;
-import org.dive4elements.river.artifacts.access.RiverAccess;
-import org.dive4elements.river.artifacts.common.AbstractCalculationResult;
-import org.dive4elements.river.artifacts.context.RiverContext;
-import org.dive4elements.river.artifacts.math.MovingAverage;
-import org.dive4elements.river.artifacts.model.ZoomScale;
-import org.dive4elements.river.artifacts.resources.Resources;
-import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
-import org.dive4elements.river.exports.DiagramGenerator;
-import org.dive4elements.river.exports.StyledSeriesBuilder;
-import org.dive4elements.river.jfree.StyledXYSeries;
-import org.dive4elements.river.themes.ThemeDocument;
-
-/**
- *
- * @author Domenico Nardi Tironi
- *
- * @deprecated Use
- * {@link AbstractSInfoProcessor#buildSeriesForType(DiagramGenerator, ArtifactAndFacet, ThemeDocument, boolean, org.dive4elements.river.artifacts.common.IResultType, Double)}
- * instead
- */
- at Deprecated
-abstract class AbstractSInfoLineProcessor<RESULT extends AbstractCalculationResult> extends AbstractSInfoProcessor {
-
- private static final double GAP_DISTANCE = 0.101;
-
- public AbstractSInfoLineProcessor(final String i18nAxisLabel, final Set<String> handledFacetType) {
- super(i18nAxisLabel, handledFacetType);
- }
-
- // FIXME:
- @Override
- protected final String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) {
-
- final CallContext context = generator.getContext();
- final Map<String, String> metaData = bundle.getFacet().getMetaData();
-
- final Artifact artifact = bundle.getArtifact();
-
- final StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
- series.putMetaData(metaData, artifact, context);
-
- final String facetName = bundle.getFacetName();
- @SuppressWarnings("unchecked")
- final RESULT data = (RESULT) 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(context, artifact, data, facetName);
-
- StyledSeriesBuilder.addPoints(series, points, true, GAP_DISTANCE);
- generator.addAxisSeries(series, getAxisName(), visible);
-
- return metaData.get("Y");
- }
-
- private Double findRadius(final CallContext context, final Artifact artifact) {
- final Double start = (Double) context.getContextValue("startkm");
- final Double end = (Double) context.getContextValue("endkm");
-
- if (start == null || end == null)
- return null;
-
- final RiverContext fc = (RiverContext) context.globalContext();
- final ZoomScale scales = (ZoomScale) fc.get("zoomscale");
- final RiverAccess access = new RiverAccess((D4EArtifact) artifact);
- final String river = access.getRiverName();
-
- return scales.getRadius(river, start, end);
- }
-
- private double[][] generatePoints(final CallContext context, final Artifact artifact, final RESULT data, final String facetName) {
-
- final double[][] points = doGetPoints(data, facetName);
- if (facetName.endsWith(".filtered")) {
- final Double radius = findRadius(context, artifact);
- return movingAverage(radius, points);
- }
-
- return points;
- }
-
- protected abstract double[][] doGetPoints(RESULT data, String facetName);
-
- private double[][] movingAverage(final Double radius, final double[][] points) {
-
- if (radius == null)
- return points;
-
- return MovingAverage.weighted(points, radius);
- }
-
- protected static final Facet createFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
- final int index, final String axisLabel, final String facetId, final String description) {
- final String facetFlowDepthFilteredDescription = Resources.getMsg(context.getMeta(), description, description, result.getLabel());
- return new SInfoResultFacet(index, facetId, facetFlowDepthFilteredDescription, axisLabel, ComputeType.ADVANCE, id, hash);
- }
-}
\ No newline at end of file
diff -r b4402594213b -r 9831f6c60473 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractSInfoProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractSInfoProcessor.java Mon Jul 02 07:33:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractSInfoProcessor.java Mon Jul 02 13:00:59 2018 +0200
@@ -15,6 +15,7 @@
import org.apache.log4j.Logger;
import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifactdatabase.state.Facet;
import org.dive4elements.artifacts.Artifact;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.river.artifacts.D4EArtifact;
@@ -24,6 +25,8 @@
import org.dive4elements.river.artifacts.context.RiverContext;
import org.dive4elements.river.artifacts.math.MovingAverage;
import org.dive4elements.river.artifacts.model.ZoomScale;
+import org.dive4elements.river.artifacts.resources.Resources;
+import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
import org.dive4elements.river.exports.DiagramGenerator;
import org.dive4elements.river.exports.StyledSeriesBuilder;
import org.dive4elements.river.exports.process.DefaultProcessor;
@@ -183,4 +186,12 @@
}
return generator.msg(this.i18n_axis_label, "MISSING");
}
+
+ // Moved from SInfoLineProcessor:
+ protected static final Facet createFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
+ final int index, final String axisLabel, final String facetId, final String description) {
+ final String facetFlowDepthFilteredDescription = Resources.getMsg(context.getMeta(), description, description, result.getLabel());
+ return new SInfoResultFacet(index, facetId, facetFlowDepthFilteredDescription, axisLabel, ComputeType.ADVANCE, id, hash);
+ }
+
}
\ No newline at end of file
diff -r b4402594213b -r 9831f6c60473 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/D50Processor.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/D50Processor.java Mon Jul 02 07:33:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/D50Processor.java Mon Jul 02 13:00:59 2018 +0200
@@ -52,7 +52,7 @@
}
public static Facet createD50Facet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_D50_YAXIS_LABEL, FACET_TKH_D50_FILTERED,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_D50_YAXIS_LABEL, FACET_TKH_D50_FILTERED,
I18N_FACET_TKH_D50_FILTERED_DESCRIPTION);
}
}
\ No newline at end of file
diff -r b4402594213b -r 9831f6c60473 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FloodDurationProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FloodDurationProcessor.java Mon Jul 02 07:33:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FloodDurationProcessor.java Mon Jul 02 13:00:59 2018 +0200
@@ -13,12 +13,15 @@
import java.util.HashSet;
import java.util.Set;
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
import org.dive4elements.artifactdatabase.state.Facet;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.river.artifacts.common.AbstractCalculationResult;
import org.dive4elements.river.artifacts.resources.Resources;
import org.dive4elements.river.artifacts.sinfo.flood_duration.FloodDurationCalculationResult;
import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.themes.ThemeDocument;
/**
* Processor to generate the facet and data series of infrastructure flood durations
@@ -26,7 +29,7 @@
* @author Matthias Schäfer
*
*/
-public final class FloodDurationProcessor extends AbstractSInfoLineProcessor<AbstractCalculationResult> {
+public final class FloodDurationProcessor extends AbstractSInfoProcessor {
public static final String FACET_FLOOD_DURATION = "sinfo_facet_flood_duration";
@@ -55,35 +58,52 @@
super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES);
}
+ // @Override TODO: REMOVE (has been replaced by doGetType
+ // protected double[][] doGetPoints(final AbstractCalculationResult data, final String facetName) {
+ //
+ // if (FACET_FLOOD_DURATION.contentEquals(facetName))
+ // return ((FloodDurationCalculationResult) data).fetchInfrastructurePoints(SInfoResultType.floodDuration);
+ //
+ // if (FACET_MAIN_VALUE_1_DURATION.contentEquals(facetName))
+ // return ((FloodDurationCalculationResult) data).fetchMainValuePoints(SInfoResultType.mainValue1Duration);
+ //
+ // if (FACET_MAIN_VALUE_2_DURATION.contentEquals(facetName))
+ // return ((FloodDurationCalculationResult) data).fetchMainValuePoints(SInfoResultType.mainValue2Duration);
+ //
+ // if (FACET_MAIN_VALUE_3_DURATION.contentEquals(facetName))
+ // return ((FloodDurationCalculationResult) data).fetchMainValuePoints(SInfoResultType.mainValue3Duration);
+ //
+ // final String error = String.format("Unknown facet name: %s", facetName);
+ // throw new UnsupportedOperationException(error);
+ // }
- @Override
- protected double[][] doGetPoints(final AbstractCalculationResult data, final String facetName) {
+ public static Facet createFloodDurationFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
+ final int index) {
+
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, I18N_AXIS_LABEL, FACET_FLOOD_DURATION, FACET_FLOOD_DURATION_DESCRIPTION);
+ }
+
+ private SInfoResultType doGetType(final String facetName) {
if (FACET_FLOOD_DURATION.contentEquals(facetName))
- return ((FloodDurationCalculationResult) data).fetchInfrastructurePoints(SInfoResultType.floodDuration);
+ return SInfoResultType.floodDuration;
if (FACET_MAIN_VALUE_1_DURATION.contentEquals(facetName))
- return ((FloodDurationCalculationResult) data).fetchMainValuePoints(SInfoResultType.mainValue1Duration);
+ return SInfoResultType.mainValue1Duration;
if (FACET_MAIN_VALUE_2_DURATION.contentEquals(facetName))
- return ((FloodDurationCalculationResult) data).fetchMainValuePoints(SInfoResultType.mainValue2Duration);
+ return SInfoResultType.mainValue2Duration;
if (FACET_MAIN_VALUE_3_DURATION.contentEquals(facetName))
- return ((FloodDurationCalculationResult) data).fetchMainValuePoints(SInfoResultType.mainValue3Duration);
+ return SInfoResultType.mainValue3Duration;
final String error = String.format("Unknown facet name: %s", facetName);
throw new UnsupportedOperationException(error);
+
}
- public static Facet createFloodDurationFacet(final CallContext context, final String hash, final String id,
- final AbstractCalculationResult result, final int index) {
-
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, I18N_AXIS_LABEL,
- FACET_FLOOD_DURATION, FACET_FLOOD_DURATION_DESCRIPTION);
- }
-
- public static Facet createMainValueDurationFacet(final CallContext context, final String hash, final String id,
- final FloodDurationCalculationResult result, final int index) {
+ public static Facet createMainValueDurationFacet(final CallContext context, final String hash, final String id, final FloodDurationCalculationResult result,
+ final int index) {
final String description = Resources.getMsg(context.getMeta(), FACET_MAIN_VALUE_DURATION_DESCRIPTION, FACET_MAIN_VALUE_DURATION_DESCRIPTION,
result.getMainValueLabel(index));
@@ -91,4 +111,10 @@
final String facetName = new String[] { FACET_MAIN_VALUE_1_DURATION, FACET_MAIN_VALUE_2_DURATION, FACET_MAIN_VALUE_3_DURATION }[index];
return new SInfoResultFacet(0, facetName, description, I18N_AXIS_LABEL, ComputeType.ADVANCE, id, hash);
}
+
+ @Override
+ protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) {
+
+ return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), GAP_DISTANCE);
+ }
}
\ No newline at end of file
diff -r b4402594213b -r 9831f6c60473 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FloodHeightProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FloodHeightProcessor.java Mon Jul 02 07:33:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FloodHeightProcessor.java Mon Jul 02 13:00:59 2018 +0200
@@ -13,13 +13,16 @@
import java.util.HashSet;
import java.util.Set;
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
import org.dive4elements.artifactdatabase.state.Facet;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.river.artifacts.common.AbstractCalculationResult;
import org.dive4elements.river.artifacts.resources.Resources;
import org.dive4elements.river.artifacts.sinfo.flood_duration.FloodDurationCalculationResult;
import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
+import org.dive4elements.river.exports.DiagramGenerator;
import org.dive4elements.river.exports.LongitudinalSectionGenerator;
+import org.dive4elements.river.themes.ThemeDocument;
/**
* Processor to generate the facet and data series of infrastructure flood heights
@@ -27,7 +30,7 @@
* @author Matthias Schäfer
*
*/
-public final class FloodHeightProcessor extends AbstractSInfoLineProcessor<AbstractCalculationResult> {
+public final class FloodHeightProcessor extends AbstractSInfoProcessor {
public static final String FACET_FLOOD_HEIGHT = "sinfo_facet_flood_height";
@@ -56,37 +59,40 @@
super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES);
}
-
- @Override
- protected double[][] doGetPoints(final AbstractCalculationResult data, final String facetName) {
+ protected SInfoResultType doGetType(final String facetName) {
if (FACET_FLOOD_HEIGHT.contentEquals(facetName))
- return ((FloodDurationCalculationResult) data).fetchInfrastructurePoints(SInfoResultType.infrastructureHeight);
+ return SInfoResultType.infrastructureHeight;
if (FACET_MAIN_VALUE_1_HEIGHT.contentEquals(facetName))
- return ((FloodDurationCalculationResult) data).fetchMainValuePoints(SInfoResultType.waterlevel1);
+ return SInfoResultType.waterlevel1;
if (FACET_MAIN_VALUE_2_HEIGHT.contentEquals(facetName))
- return ((FloodDurationCalculationResult) data).fetchMainValuePoints(SInfoResultType.waterlevel2);
+ return SInfoResultType.waterlevel2;
if (FACET_MAIN_VALUE_3_HEIGHT.contentEquals(facetName))
- return ((FloodDurationCalculationResult) data).fetchMainValuePoints(SInfoResultType.waterlevel3);
+ return SInfoResultType.waterlevel3;
final String error = String.format("Unknown facet name: %s", facetName);
throw new UnsupportedOperationException(error);
}
- public static Facet createFloodHeightFacet(final CallContext context, final String hash, final String id,
- final AbstractCalculationResult result, final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, I18N_AXIS_LABEL,
- FACET_FLOOD_HEIGHT, FACET_FLOOD_HEIGHT_DESCRIPTION);
+ public static Facet createFloodHeightFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
+ final int index) {
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, I18N_AXIS_LABEL, FACET_FLOOD_HEIGHT, FACET_FLOOD_HEIGHT_DESCRIPTION);
}
- public static Facet createMainValueHeightFacet(final CallContext context, final String hash, final String id,
- final FloodDurationCalculationResult result, final int index) {
+ public static Facet createMainValueHeightFacet(final CallContext context, final String hash, final String id, final FloodDurationCalculationResult result,
+ final int index) {
final String description = Resources.getMsg(context.getMeta(), FACET_MAIN_VALUE_HEIGHT_DESCRIPTION, FACET_MAIN_VALUE_HEIGHT_DESCRIPTION,
result.getMainValueLabel(index));
assert ((index >= 0) && (index <= 2));
final String facetName = new String[] { FACET_MAIN_VALUE_1_HEIGHT, FACET_MAIN_VALUE_2_HEIGHT, FACET_MAIN_VALUE_3_HEIGHT }[index];
return new SInfoResultFacet(0, facetName, description, I18N_AXIS_LABEL, ComputeType.ADVANCE, id, hash);
}
+
+ @Override
+ protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) {
+
+ return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), null);
+ }
}
\ No newline at end of file
diff -r b4402594213b -r 9831f6c60473 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthDevelopmentPerYearProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthDevelopmentPerYearProcessor.java Mon Jul 02 07:33:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthDevelopmentPerYearProcessor.java Mon Jul 02 13:00:59 2018 +0200
@@ -13,11 +13,14 @@
import java.util.HashSet;
import java.util.Set;
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
import org.dive4elements.artifactdatabase.state.Facet;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.river.artifacts.common.AbstractCalculationResult;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.themes.ThemeDocument;
-public final class FlowDepthDevelopmentPerYearProcessor extends AbstractSInfoLineProcessor<AbstractCalculationResult> {
+public final class FlowDepthDevelopmentPerYearProcessor extends AbstractSInfoProcessor {
private static final String I18N_AXIS_LABEL = "sinfo.chart.flow_depth_development_per_year.section.yaxis.label";
@@ -47,13 +50,12 @@
super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES);
}
- @Override
- protected double[][] doGetPoints(final AbstractCalculationResult data, final String facetName) {
+ protected SInfoResultType doGetType(final String facetName) {
if (FACET_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_FILTERED.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepthDevelopmentPerYear);
+ return SInfoResultType.flowdepthDevelopmentPerYear;
if (FACET_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_RAW.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepthDevelopmentPerYear);
+ return SInfoResultType.flowdepthDevelopmentPerYear;
final String error = String.format("Unknown facet name: %s", facetName);
throw new UnsupportedOperationException(error);
@@ -61,13 +63,19 @@
public static Facet createFlowDepthDevelopmentFilteredFacet(final CallContext context, final String hash, final String id,
final AbstractCalculationResult result, final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_YAXIS_LABEL,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_YAXIS_LABEL,
FACET_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_FILTERED, FACET_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_FILTERED_DESCRIPTION);
}
public static Facet createFlowDepthDevelopmentRawFacet(final CallContext context, final String hash, final String id,
final AbstractCalculationResult result, final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_YAXIS_LABEL,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_YAXIS_LABEL,
FACET_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_RAW, FACET_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_RAW_DESCRIPTION);
}
+
+ @Override
+ protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) {
+
+ return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), GAP_DISTANCE);
+ }
}
\ No newline at end of file
diff -r b4402594213b -r 9831f6c60473 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthDevelopmentProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthDevelopmentProcessor.java Mon Jul 02 07:33:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthDevelopmentProcessor.java Mon Jul 02 13:00:59 2018 +0200
@@ -13,13 +13,16 @@
import java.util.HashSet;
import java.util.Set;
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
import org.dive4elements.artifactdatabase.state.Facet;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.river.artifacts.common.AbstractCalculationResult;
import org.dive4elements.river.artifacts.resources.Resources;
import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.themes.ThemeDocument;
-public final class FlowDepthDevelopmentProcessor extends AbstractSInfoLineProcessor<AbstractCalculationResult> {
+public final class FlowDepthDevelopmentProcessor extends AbstractSInfoProcessor {
private static final String I18N_AXIS_LABEL = "sinfo.chart.flow_depth_development.section.yaxis.label";
@@ -57,19 +60,18 @@
super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES);
}
- @Override
- protected double[][] doGetPoints(final AbstractCalculationResult data, final String facetName) {
+ protected SInfoResultType doGetType(final String facetName) {
if (FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepthDevelopment);
+ return SInfoResultType.flowdepthDevelopment;
if (FACET_FLOW_DEPTH_DEVELOPMENT_RAW.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepthDevelopment);
+ return SInfoResultType.flowdepthDevelopment;
if (FACET_WATERLEVEL_DIFFERENCE_FILTERED.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.waterlevelDifference);
+ return SInfoResultType.waterlevelDifference;
if (FACET_BEDHEIGHT_DIFFERENCE_FILTERED.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.bedHeightDifference);
+ return SInfoResultType.bedHeightDifference;
final String error = String.format("Unknown facet name: %s", facetName);
throw new UnsupportedOperationException(error);
@@ -77,13 +79,13 @@
public static Facet createFlowDepthDevelopmentFilteredFacet(final CallContext context, final String hash, final String id,
final AbstractCalculationResult result, final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_YAXIS_LABEL,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_YAXIS_LABEL,
FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED, FACET_FLOW_DEPTH_DEVELOPMENT_FILTERED_DESCRIPTION);
}
public static Facet createFlowDepthDevelopmentRawFacet(final CallContext context, final String hash, final String id,
final AbstractCalculationResult result, final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_YAXIS_LABEL,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_YAXIS_LABEL,
FACET_FLOW_DEPTH_DEVELOPMENT_RAW, FACET_FLOW_DEPTH_DEVELOPMENT_RAW_DESCRIPTION);
}
@@ -103,4 +105,10 @@
return new SInfoResultFacet(index, FACET_BEDHEIGHT_DIFFERENCE_FILTERED, facetFlowDepthFilteredDescription,
SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_YAXIS_LABEL, ComputeType.ADVANCE, id, hash);
}
+
+ @Override
+ protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) {
+
+ return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), null);
+ }
}
\ No newline at end of file
diff -r b4402594213b -r 9831f6c60473 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthProcessor.java Mon Jul 02 07:33:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthProcessor.java Mon Jul 02 13:00:59 2018 +0200
@@ -13,11 +13,14 @@
import java.util.HashSet;
import java.util.Set;
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
import org.dive4elements.artifactdatabase.state.Facet;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.river.artifacts.common.AbstractCalculationResult;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.themes.ThemeDocument;
-public final class FlowDepthProcessor extends AbstractSInfoLineProcessor<AbstractCalculationResult> {
+public final class FlowDepthProcessor extends AbstractSInfoProcessor {
private static final String AXIS_LABEL = "sinfo.chart.flow_depth.section.yaxis.label";
@@ -102,38 +105,37 @@
super(AXIS_LABEL, HANDLED_FACET_TYPES);
}
- @Override
- protected double[][] doGetPoints(final AbstractCalculationResult data, final String facetName) {
+ protected SInfoResultType doGetType(final String facetName) {
if (FACET_FLOW_DEPTH_FILTERED.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepth);
+ return SInfoResultType.flowdepth;
if (FACET_FLOW_DEPTH_RAW.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepth);
+ return SInfoResultType.flowdepth;
if (FACET_FLOW_DEPTH_TKH_FILTERED.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepthtkh);
+ return SInfoResultType.flowdepthtkh;
if (FACET_FLOW_DEPTH_TKH_RAW.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepthtkh);
+ return SInfoResultType.flowdepthtkh;
if (FACET_FLOW_DEPTH_MIN_FILTERED.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepthmin);
+ return SInfoResultType.flowdepthmin;
if (FACET_FLOW_DEPTH_MIN_RAW.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepthmin);
+ return SInfoResultType.flowdepthmin;
if (FACET_FLOW_DEPTH_MAX_FILTERED.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepthmax);
+ return SInfoResultType.flowdepthmax;
if (FACET_FLOW_DEPTH_MAX_RAW.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepthmax);
+ return SInfoResultType.flowdepthmax;
if (FACET_FLOW_DEPTH_CURRENT_FILTERED.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepthCurrent);
+ return SInfoResultType.flowdepthCurrent;
if (FACET_FLOW_DEPTH_CURRENT_RAW.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepthCurrent);
+ return SInfoResultType.flowdepthCurrent;
if (FACET_FLOW_DEPTH_HISTORICAL_FILTERED.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepthHistorical);
+ return SInfoResultType.flowdepthHistorical;
if (FACET_FLOW_DEPTH_HISTORICAL_RAW.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.flowdepthHistorical);
+ return SInfoResultType.flowdepthHistorical;
final String error = String.format("Unknown facet name: %s", facetName);
throw new UnsupportedOperationException(error);
@@ -141,73 +143,79 @@
public static Facet createFlowDepthFilteredFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_FILTERED,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_FILTERED,
FACET_FLOW_DEPTH_FILTERED_DESCRIPTION);
}
public static Facet createFlowDepthRawFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_RAW,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_RAW,
FACET_FLOW_DEPTH_RAW_DESCRIPTION);
}
public static Facet createFlowDepthTkhFilteredFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_TKH_FILTERED,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_TKH_FILTERED,
FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION);
}
public static Facet createFlowDepthTkhRawFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_TKH_RAW,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_TKH_RAW,
FACET_FLOW_DEPTH_TKH_RAW_DESCRIPTION);
}
public static Facet createFlowDepthMinFilteredFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_MIN_FILTERED,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_MIN_FILTERED,
FACET_FLOW_DEPTH_MIN_FILTERED_DESCRIPTION);
}
public static Facet createFlowDepthMinRawFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_MIN_RAW,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_MIN_RAW,
FACET_FLOW_DEPTH_MIN_RAW_DESCRIPTION);
}
public static Facet createFlowDepthMaxFilteredFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_MAX_FILTERED,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_MAX_FILTERED,
FACET_FLOW_DEPTH_MAX_FILTERED_DESCRIPTION);
}
public static Facet createFlowDepthMaxRawFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_MAX_RAW,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_MAX_RAW,
FACET_FLOW_DEPTH_MAX_RAW_DESCRIPTION);
}
public static Facet createFlowDepthCurrentFilteredFacet(final CallContext context, final String hash, final String id,
final AbstractCalculationResult result, final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_CURRENT_FILTERED,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_CURRENT_FILTERED,
FACET_FLOW_DEPTH_CURRENT_FILTERED_DESCRIPTION);
}
public static Facet createFlowDepthCurrentRawFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_CURRENT_RAW,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_CURRENT_RAW,
FACET_FLOW_DEPTH_CURRENT_RAW_DESCRIPTION);
}
public static Facet createFlowDepthHistoricalFilteredFacet(final CallContext context, final String hash, final String id,
final AbstractCalculationResult result, final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL,
- FACET_FLOW_DEPTH_HISTORICAL_FILTERED, FACET_FLOW_DEPTH_HISTORICAL_FILTERED_DESCRIPTION);
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_HISTORICAL_FILTERED,
+ FACET_FLOW_DEPTH_HISTORICAL_FILTERED_DESCRIPTION);
}
public static Facet createFlowDepthHistoricalRawFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_HISTORICAL_RAW,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, FACET_FLOW_DEPTH_HISTORICAL_RAW,
FACET_FLOW_DEPTH_HISTORICAL_RAW_DESCRIPTION);
}
+
+ @Override
+ protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) {
+
+ return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), GAP_DISTANCE);
+ }
}
\ No newline at end of file
diff -r b4402594213b -r 9831f6c60473 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/TauProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/TauProcessor.java Mon Jul 02 07:33:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/TauProcessor.java Mon Jul 02 13:00:59 2018 +0200
@@ -13,11 +13,14 @@
import java.util.HashSet;
import java.util.Set;
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
import org.dive4elements.artifactdatabase.state.Facet;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.river.artifacts.common.AbstractCalculationResult;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.themes.ThemeDocument;
-public final class TauProcessor extends AbstractSInfoLineProcessor<AbstractTkhCalculationResult> {
+public final class TauProcessor extends AbstractSInfoProcessor {
public static final String FACET_TKH_TAU_FILTERED = "sinfo_facet_tau";
@@ -37,18 +40,22 @@
super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES);
}
- @Override
- protected double[][] doGetPoints(final AbstractTkhCalculationResult data, final String facetName) {
+ protected SInfoResultType doGetType(final String facetName) {
if (FACET_TKH_TAU_FILTERED.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.tau);
+ return SInfoResultType.tau;
final String error = String.format("Unknown facet name: %s", facetName);
throw new UnsupportedOperationException(error);
}
public static Facet createTauFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_TAU_YAXIS_LABEL, FACET_TKH_TAU_FILTERED,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_TAU_YAXIS_LABEL, FACET_TKH_TAU_FILTERED,
I18N_FACET_TKH_TAU_FILTERED_DESCRIPTION);
}
+
+ @Override
+ protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) {
+ return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), GAP_DISTANCE);
+ }
}
\ No newline at end of file
diff -r b4402594213b -r 9831f6c60473 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/VelocityProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/VelocityProcessor.java Mon Jul 02 07:33:53 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/VelocityProcessor.java Mon Jul 02 13:00:59 2018 +0200
@@ -13,11 +13,14 @@
import java.util.HashSet;
import java.util.Set;
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
import org.dive4elements.artifactdatabase.state.Facet;
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.river.artifacts.common.AbstractCalculationResult;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.themes.ThemeDocument;
-public final class VelocityProcessor extends AbstractSInfoLineProcessor<AbstractTkhCalculationResult> {
+public final class VelocityProcessor extends AbstractSInfoProcessor {
public static final String FACET_TKH_VELOCITY_FILTERED = "sinfo_facet_velocity";
@@ -37,11 +40,10 @@
super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES);
}
- @Override
- protected double[][] doGetPoints(final AbstractTkhCalculationResult data, final String facetName) {
+ protected SInfoResultType doGetType(final String facetName) {
if (FACET_TKH_VELOCITY_FILTERED.contentEquals(facetName))
- return data.getStationPoints(SInfoResultType.velocity);
+ return SInfoResultType.velocity;
final String error = String.format("Unknown facet name: %s", facetName);
throw new UnsupportedOperationException(error);
@@ -49,7 +51,13 @@
public static Facet createVelocityFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result,
final int index) {
- return AbstractSInfoLineProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_VELOCITY_YAXIS_LABEL, FACET_TKH_VELOCITY_FILTERED,
+ return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, SINFO_CHART_VELOCITY_YAXIS_LABEL, FACET_TKH_VELOCITY_FILTERED,
I18N_FACET_TKH_VELOCITY_FILTERED_DESCRIPTION);
}
+
+ @Override
+ protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) {
+ // TODO Auto-generated method stub
+ return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), GAP_DISTANCE);
+ }
}
\ No newline at end of file
More information about the Dive4Elements-commits
mailing list