Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FlowDepthWaterlevelProcessor.java @ 9617:1d4262a68f1f
#12 Minuend/Subtrahend + MergeConflict #19 CollisionCalculation
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Thu, 10 Oct 2019 15:29:02 +0200 |
parents | |
children | 23702537fb4f |
comparison
equal
deleted
inserted
replaced
9616:cedcee24a21a | 9617:1d4262a68f1f |
---|---|
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 | |
11 package org.dive4elements.river.artifacts.sinfo.common; | |
12 | |
13 import java.util.HashSet; | |
14 import java.util.Set; | |
15 | |
16 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | |
17 import org.dive4elements.artifactdatabase.state.Facet; | |
18 import org.dive4elements.artifacts.CallContext; | |
19 import org.dive4elements.artifacts.CallMeta; | |
20 import org.dive4elements.river.artifacts.common.AbstractCalculationResult; | |
21 import org.dive4elements.river.artifacts.common.AbstractProcessor; | |
22 import org.dive4elements.river.artifacts.resources.Resources; | |
23 import org.dive4elements.river.exports.DiagramGenerator; | |
24 import org.dive4elements.river.themes.ThemeDocument; | |
25 | |
26 public final class FlowDepthWaterlevelProcessor extends AbstractProcessor { | |
27 | |
28 /* waterlevel */ | |
29 public static final String FACET_FLOW_DEPTH_BEDHEIGHT_MIN = "sinfo_facet_flow_depth_bedheight_min"; | |
30 public static final String FACET_FLOW_DEPTH_BEDHEIGHT_MAX = "sinfo_facet_flow_depth_bedheight_max"; | |
31 public static final String FACET_FLOW_DEPTH_BEDHEIGHT = "sinfo_facet_flow_depth_bedheight"; | |
32 public static final String FACET_FLOW_DEPTH_WATER_LEVEL = "sinfo_facet_flow_depth_waterlevel"; | |
33 public static final String FACET_FLOW_DEPTH_WATER_LEVEL_Y_AXIS_LABEL = "chart.longitudinal.section.yaxis.label"; | |
34 public static final String FACET_FLOW_DEPTH_WATER_LEVEL_DESCRIPTION = "facet.flow_depth.waterlevel"; | |
35 public static final String FACET_FLOW_DEPTH_BEDHEIGHT_DESCRIPTION = "facet.flow_depth.bedheight"; | |
36 public static final String FACET_FLOW_DEPTH_BEDHEIGHT_DESCRIPTION_MIN = "facet.flow_depth.bedheight.min"; | |
37 public static final String FACET_FLOW_DEPTH_BEDHEIGHT_DESCRIPTION_MAX = "facet.flow_depth.bedheight.max"; | |
38 | |
39 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); | |
40 | |
41 static { | |
42 HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_WATER_LEVEL); | |
43 HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_BEDHEIGHT); | |
44 HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_BEDHEIGHT_MIN); | |
45 HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_BEDHEIGHT_MAX); | |
46 } | |
47 | |
48 public FlowDepthWaterlevelProcessor() { | |
49 super(FACET_FLOW_DEPTH_WATER_LEVEL_Y_AXIS_LABEL, HANDLED_FACET_TYPES); | |
50 } | |
51 | |
52 protected SInfoResultType doGetType(final String facetName) { | |
53 | |
54 if (FACET_FLOW_DEPTH_WATER_LEVEL.contentEquals(facetName)) | |
55 return SInfoResultType.waterlevel; | |
56 if (FACET_FLOW_DEPTH_BEDHEIGHT.contentEquals(facetName)) | |
57 return SInfoResultType.meanBedHeight; | |
58 if (FACET_FLOW_DEPTH_BEDHEIGHT_MIN.contentEquals(facetName)) | |
59 return SInfoResultType.minBedHeight; | |
60 if (FACET_FLOW_DEPTH_BEDHEIGHT_MAX.contentEquals(facetName)) | |
61 return SInfoResultType.maxBedHeight; | |
62 | |
63 final String error = String.format("Unknown facet name: %s", facetName); | |
64 throw new UnsupportedOperationException(error); | |
65 } | |
66 | |
67 private static Facet createFlowDepthBedheightFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, | |
68 final int index, final String unit, final String facetLabel, final String facetName, final String description) { | |
69 final CallMeta meta = context.getMeta(); | |
70 final String yAxisLabel = Resources.getMsg(meta, FACET_FLOW_DEPTH_WATER_LEVEL_Y_AXIS_LABEL, FACET_FLOW_DEPTH_WATER_LEVEL_Y_AXIS_LABEL, unit); | |
71 | |
72 return AbstractProcessor.createFacet(context, hash, id, result, index, yAxisLabel, facetName, description, facetLabel); | |
73 } | |
74 | |
75 public static Facet createFlowDepthMeanBedheightFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, | |
76 final int index, final String unit, final String facetLabel) { | |
77 return FlowDepthWaterlevelProcessor.createFlowDepthBedheightFacet(context, hash, id, result, index, unit, facetLabel, FACET_FLOW_DEPTH_BEDHEIGHT, | |
78 FACET_FLOW_DEPTH_BEDHEIGHT_DESCRIPTION); | |
79 } | |
80 | |
81 public static Facet createFlowDepthMinBedheightFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, | |
82 final int index, final String unit, final String facetLabel) { | |
83 return FlowDepthWaterlevelProcessor.createFlowDepthBedheightFacet(context, hash, id, result, index, unit, facetLabel, FACET_FLOW_DEPTH_BEDHEIGHT_MIN, | |
84 FACET_FLOW_DEPTH_BEDHEIGHT_DESCRIPTION_MIN); | |
85 } | |
86 | |
87 public static Facet createFlowDepthMaxBedheightFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, | |
88 final int index, final String unit, final String facetLabel) { | |
89 return FlowDepthWaterlevelProcessor.createFlowDepthBedheightFacet(context, hash, id, result, index, unit, facetLabel, FACET_FLOW_DEPTH_BEDHEIGHT_MAX, | |
90 FACET_FLOW_DEPTH_BEDHEIGHT_DESCRIPTION_MAX); | |
91 } | |
92 | |
93 public static Facet createFlowDepthWaterlevelFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, | |
94 final int index, final String unit, final String wstLabel) { | |
95 final CallMeta meta = context.getMeta(); | |
96 final String yAxisLabel = Resources.getMsg(meta, FACET_FLOW_DEPTH_WATER_LEVEL_Y_AXIS_LABEL, FACET_FLOW_DEPTH_WATER_LEVEL_Y_AXIS_LABEL, unit); | |
97 return AbstractProcessor.createFacet(context, hash, id, result, index, yAxisLabel, FACET_FLOW_DEPTH_WATER_LEVEL, | |
98 FACET_FLOW_DEPTH_WATER_LEVEL_DESCRIPTION, wstLabel); | |
99 } | |
100 | |
101 @Override | |
102 protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { | |
103 | |
104 return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), GAP_DISTANCE); | |
105 } | |
106 } |