Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodHeightProcessor.java @ 9612:f8308db94634
#20 UI, Diagramme
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Wed, 09 Oct 2019 16:17:16 +0200 |
parents | 08f46ccd37ba |
children | 26e113e8224f |
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 |
9215 | 11 package org.dive4elements.river.artifacts.sinfo.flood_duration; |
9202
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; |
9347 | 20 import org.dive4elements.river.artifacts.common.AbstractProcessor; |
9202
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.resources.Resources; |
9215 | 22 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
9612 | 23 import org.dive4elements.river.artifacts.sinfo.flood_duration.FloodDurationCalculationResult.Infrastructure; |
9208 | 24 import org.dive4elements.river.artifacts.sinfo.flood_duration.FloodDurationCalculationResult.ValueGetter; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
25 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
9203 | 26 import org.dive4elements.river.exports.DiagramGenerator; |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
27 import org.dive4elements.river.model.Attribute.AttributeKey; |
9203 | 28 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
|
29 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
30 /** |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
31 * 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
|
32 * |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
33 * @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
|
34 * |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
35 */ |
9347 | 36 public final class FloodHeightProcessor extends AbstractProcessor { |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
37 |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
38 private static final String FACET_FLOOD_HEIGHT_LEFT = "sinfo_facet_flood_height.left"; |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
39 |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
40 private static final String FACET_FLOOD_HEIGHT_RIGHT = "sinfo_facet_flood_height.right"; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
41 |
9612 | 42 private static final String FACET_MAIN_VALUE_HEIGHT_DESCRIPTION = "mainvalue.w.description"; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
43 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9203
diff
changeset
|
44 private static final String FACET_MAIN_VALUE_HEIGHT = "mainvalue.w"; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
45 |
9297
7100a555607c
Small fixes of the S-Info flood duration outputs
mschaefer
parents:
9285
diff
changeset
|
46 private static final String I18N_AXIS_LABEL = "sinfo.chart.flood_duration.height.section.yaxis.label"; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
47 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
48 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
|
49 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
50 static { |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
51 HANDLED_FACET_TYPES.add(FACET_FLOOD_HEIGHT_LEFT); |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
52 HANDLED_FACET_TYPES.add(FACET_FLOOD_HEIGHT_RIGHT); |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9203
diff
changeset
|
53 HANDLED_FACET_TYPES.add(FACET_MAIN_VALUE_HEIGHT); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
54 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
55 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
56 public FloodHeightProcessor() { |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
57 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
|
58 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
59 |
9203 | 60 public static Facet createFloodHeightFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, |
9612 | 61 final int facetIndex, final int resultIndex, final Infrastructure infrastructure) { |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
62 |
9612 | 63 final String facetName = infrastructure.getRiverside().equals(AttributeKey.LEFT) ? FACET_FLOOD_HEIGHT_LEFT : FACET_FLOOD_HEIGHT_RIGHT; |
64 final String description = infrastructure.getFloodHeightLabel(context); | |
65 return new InfrastructureResultFacet(facetIndex, resultIndex, facetName, description, I18N_AXIS_LABEL, id, hash, infrastructure); | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
66 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
67 |
9203 | 68 public static Facet createMainValueHeightFacet(final CallContext context, final String hash, final String id, final FloodDurationCalculationResult result, |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9203
diff
changeset
|
69 final int facetIndex, final int resultIndex, final int dataIndex) { |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
70 final String description = Resources.getMsg(context.getMeta(), FACET_MAIN_VALUE_HEIGHT_DESCRIPTION, FACET_MAIN_VALUE_HEIGHT_DESCRIPTION, |
9285 | 71 result.getWaterlevelLabel(dataIndex)); |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9203
diff
changeset
|
72 |
9215 | 73 return new FloodDurationFacet(facetIndex, resultIndex, dataIndex, FACET_MAIN_VALUE_HEIGHT, description, ComputeType.ADVANCE, I18N_AXIS_LABEL, hash, id); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
74 } |
9203 | 75 |
76 @Override | |
77 protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { | |
78 | |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9203
diff
changeset
|
79 final String facetName = bundle.getFacetName(); |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9203
diff
changeset
|
80 |
9612 | 81 if (FACET_FLOOD_HEIGHT_LEFT.contentEquals(facetName) || FACET_FLOOD_HEIGHT_RIGHT.contentEquals(facetName)) |
82 return buildInfrastructureSeries(generator, bundle, theme, visible); | |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9203
diff
changeset
|
83 |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9203
diff
changeset
|
84 if (FACET_MAIN_VALUE_HEIGHT.contentEquals(facetName)) { |
9208 | 85 |
86 final AbstractCalculationResult data = getResult(generator, bundle); | |
87 | |
9215 | 88 final FloodDurationFacet facet = (FloodDurationFacet) bundle.getFacet(); |
89 final int index = facet.getWaterlevelIndex(); | |
90 | |
9208 | 91 if (data instanceof FloodDurationCalculationResult) { |
92 final FloodDurationCalculationResult.ValueGetter valuegetter = new ValueGetter() { | |
93 @Override | |
94 public double getValue(final DurationWaterlevel waterlevel) { | |
95 return waterlevel.getWaterlevel(); | |
96 } | |
97 }; | |
9265 | 98 final double[][] points = ((FloodDurationCalculationResult) data).getMainValueDurationPoints(valuegetter, index); |
9347 | 99 return buildSeriesForPoints(points, generator, bundle, theme, visible, null); |
9208 | 100 } |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9203
diff
changeset
|
101 } |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9203
diff
changeset
|
102 |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9203
diff
changeset
|
103 final String error = String.format("Unknown facet name: %s", facetName); |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9203
diff
changeset
|
104 throw new UnsupportedOperationException(error); |
9203 | 105 } |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
106 |
9612 | 107 private String buildInfrastructureSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, |
108 final boolean visible) { | |
109 | |
110 final InfrastructureResultFacet infFacet = (InfrastructureResultFacet) bundle.getFacet(); | |
111 final Infrastructure infrastructure = infFacet.getInfrastructure(); | |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
112 |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
113 final FloodDurationCalculationResult data = (FloodDurationCalculationResult) getResult(generator, bundle); |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
114 |
9612 | 115 final double[][] points = data.getInfrastructurePoints(SInfoResultType.infrastructureHeight, infrastructure); |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
116 |
9347 | 117 return buildSeriesForPoints(points, generator, bundle, theme, visible, null); |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
118 } |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
diff
changeset
|
119 } |