Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/FloodHeightProcessor.java @ 9203:9831f6c60473
AbstractSInfoLineProcessor refactoring
author | gernotbelger |
---|---|
date | Mon, 02 Jul 2018 13:00:59 +0200 |
parents | b4402594213b |
children | 3dae6b78e1da |
rev | line source |
---|---|
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
2 * Software engineering by |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
3 * Björnsen Beratende Ingenieure GmbH |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
5 * |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
6 * This file is Free Software under the GNU AGPL (>=v3) |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
8 * documentation coming with Dive4Elements River for details. |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
9 */ |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
10 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
11 package org.dive4elements.river.artifacts.sinfo.common; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
12 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
13 import java.util.HashSet; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
14 import java.util.Set; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
15 |
9203 | 16 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
17 import org.dive4elements.artifactdatabase.state.Facet; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
18 import org.dive4elements.artifacts.CallContext; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
19 import org.dive4elements.river.artifacts.common.AbstractCalculationResult; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
20 import org.dive4elements.river.artifacts.resources.Resources; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
21 import org.dive4elements.river.artifacts.sinfo.flood_duration.FloodDurationCalculationResult; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
22 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
9203 | 23 import org.dive4elements.river.exports.DiagramGenerator; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
24 import org.dive4elements.river.exports.LongitudinalSectionGenerator; |
9203 | 25 import org.dive4elements.river.themes.ThemeDocument; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
26 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
27 /** |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
28 * Processor to generate the facet and data series of infrastructure flood heights |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
29 * |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
30 * @author Matthias Schäfer |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
31 * |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
32 */ |
9203 | 33 public final class FloodHeightProcessor extends AbstractSInfoProcessor { |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
34 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
35 public static final String FACET_FLOOD_HEIGHT = "sinfo_facet_flood_height"; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
36 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
37 public static final String FACET_FLOOD_HEIGHT_DESCRIPTION = "sinfo_facet_flood_height.description"; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
38 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
39 public static final String FACET_MAIN_VALUE_1_HEIGHT = "mainvalue.1.w"; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
40 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
41 public static final String FACET_MAIN_VALUE_2_HEIGHT = "mainvalue.2.w"; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
42 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
43 public static final String FACET_MAIN_VALUE_3_HEIGHT = "mainvalue.3.w"; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
44 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
45 public static final String FACET_MAIN_VALUE_HEIGHT_DESCRIPTION = "mainvalue.w.description"; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
46 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
47 private static final String I18N_AXIS_LABEL = LongitudinalSectionGenerator.I18N_YAXIS_LABEL; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
48 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
49 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
50 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
51 static { |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
52 HANDLED_FACET_TYPES.add(FACET_FLOOD_HEIGHT); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
53 HANDLED_FACET_TYPES.add(FACET_MAIN_VALUE_1_HEIGHT); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
54 HANDLED_FACET_TYPES.add(FACET_MAIN_VALUE_2_HEIGHT); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
55 HANDLED_FACET_TYPES.add(FACET_MAIN_VALUE_3_HEIGHT); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
56 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
57 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
58 public FloodHeightProcessor() { |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
59 super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
60 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
61 |
9203 | 62 protected SInfoResultType doGetType(final String facetName) { |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
63 if (FACET_FLOOD_HEIGHT.contentEquals(facetName)) |
9203 | 64 return SInfoResultType.infrastructureHeight; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
65 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
66 if (FACET_MAIN_VALUE_1_HEIGHT.contentEquals(facetName)) |
9203 | 67 return SInfoResultType.waterlevel1; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
68 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
69 if (FACET_MAIN_VALUE_2_HEIGHT.contentEquals(facetName)) |
9203 | 70 return SInfoResultType.waterlevel2; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
71 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
72 if (FACET_MAIN_VALUE_3_HEIGHT.contentEquals(facetName)) |
9203 | 73 return SInfoResultType.waterlevel3; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
74 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
75 final String error = String.format("Unknown facet name: %s", facetName); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
76 throw new UnsupportedOperationException(error); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
77 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
78 |
9203 | 79 public static Facet createFloodHeightFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, |
80 final int index) { | |
81 return AbstractSInfoProcessor.createFacet(context, hash, id, result, index, I18N_AXIS_LABEL, FACET_FLOOD_HEIGHT, FACET_FLOOD_HEIGHT_DESCRIPTION); | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
82 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
83 |
9203 | 84 public static Facet createMainValueHeightFacet(final CallContext context, final String hash, final String id, final FloodDurationCalculationResult result, |
85 final int index) { | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
86 final String description = Resources.getMsg(context.getMeta(), FACET_MAIN_VALUE_HEIGHT_DESCRIPTION, FACET_MAIN_VALUE_HEIGHT_DESCRIPTION, |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
87 result.getMainValueLabel(index)); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
88 assert ((index >= 0) && (index <= 2)); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
89 final String facetName = new String[] { FACET_MAIN_VALUE_1_HEIGHT, FACET_MAIN_VALUE_2_HEIGHT, FACET_MAIN_VALUE_3_HEIGHT }[index]; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
90 return new SInfoResultFacet(0, facetName, description, I18N_AXIS_LABEL, ComputeType.ADVANCE, id, hash); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
91 } |
9203 | 92 |
93 @Override | |
94 protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { | |
95 | |
96 return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), null); | |
97 } | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
98 } |