Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCurveProcessor.java @ 9612:f8308db94634
#20 UI, Diagramme
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Wed, 09 Oct 2019 16:17:16 +0200 |
parents | f318359b81a2 |
children | 26e113e8224f |
rev | line source |
---|---|
9252 | 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.flood_duration; | |
12 | |
13 import java.util.HashSet; | |
14 import java.util.Set; | |
15 | |
16 import org.dive4elements.artifactdatabase.state.Facet; | |
17 import org.dive4elements.artifacts.CallContext; | |
18 import org.dive4elements.river.artifacts.common.AbstractCalculationResult; | |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
19 import org.dive4elements.river.artifacts.model.FacetTypes; |
9612 | 20 import org.dive4elements.river.artifacts.resources.Resources; |
21 import org.dive4elements.river.artifacts.sinfo.flood_duration.FloodDurationCalculationResult.Infrastructure; | |
9252 | 22 import org.dive4elements.river.exports.DiagramGenerator; |
23 import org.dive4elements.river.exports.DurationCurveGenerator; | |
24 import org.dive4elements.river.exports.process.DefaultProcessor; | |
9376
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
25 import org.dive4elements.river.model.Attribute.AttributeKey; |
9252 | 26 |
27 /** | |
28 * Processor to generate the facet and data series of a flood duration curve | |
29 * | |
30 * @author Matthias Schäfer | |
31 * | |
32 */ | |
33 public final class FloodDurationCurveProcessor extends DefaultProcessor { | |
34 | |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
35 private static final String FACET_FLOOD_DURATION_W = FacetTypes.DURATION_W; // "duration_curve.w"; |
9252 | 36 |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
37 private static final String FACET_FLOOD_DURATION_Q = FacetTypes.DURATION_Q; // "duration_curve.q"; |
9252 | 38 |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
39 public static final String FACET_FLOOD_DURATION_MAINVALUES_W = "sinfo.mainvalues.w"; |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
40 |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
41 public static final String FACET_FLOOD_DURATION_MAINVALUES_Q = "sinfo.mainvalues.q"; |
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
42 |
9376
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
43 public static final String FACET_FLOOD_DURATION_INFRASTRUCTURE_W_LEFT = "infrastructure.w.left"; |
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
44 |
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
45 public static final String FACET_FLOOD_DURATION_INFRASTRUCTURE_W_RIGHT = "infrastructure.w.right"; |
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
46 |
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
47 public static final String FACET_FLOOD_DURATION_INFRASTRUCTURE_Q_LEFT = "infrastructure.q.left"; |
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
48 |
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
49 public static final String FACET_FLOOD_DURATION_INFRASTRUCTURE_Q_RIGHT = "infrastructure.q.right"; |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
50 |
9252 | 51 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); |
52 | |
53 static { | |
54 HANDLED_FACET_TYPES.add(FACET_FLOOD_DURATION_W); | |
55 HANDLED_FACET_TYPES.add(FACET_FLOOD_DURATION_Q); | |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
56 HANDLED_FACET_TYPES.add(FACET_FLOOD_DURATION_MAINVALUES_W); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
57 HANDLED_FACET_TYPES.add(FACET_FLOOD_DURATION_MAINVALUES_Q); |
9376
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
58 HANDLED_FACET_TYPES.add(FACET_FLOOD_DURATION_INFRASTRUCTURE_W_LEFT); |
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
59 HANDLED_FACET_TYPES.add(FACET_FLOOD_DURATION_INFRASTRUCTURE_W_RIGHT); |
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
60 HANDLED_FACET_TYPES.add(FACET_FLOOD_DURATION_INFRASTRUCTURE_Q_LEFT); |
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
61 HANDLED_FACET_TYPES.add(FACET_FLOOD_DURATION_INFRASTRUCTURE_Q_RIGHT); |
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
62 } |
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
63 |
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
64 public static boolean isInfrastructureFacet(final String name) { |
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
65 return name.equals(FACET_FLOOD_DURATION_INFRASTRUCTURE_W_LEFT) || name.equals(FACET_FLOOD_DURATION_INFRASTRUCTURE_W_RIGHT) |
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
66 || name.equals(FACET_FLOOD_DURATION_INFRASTRUCTURE_Q_LEFT) || name.equals(FACET_FLOOD_DURATION_INFRASTRUCTURE_Q_RIGHT); |
9252 | 67 } |
68 | |
69 public static Facet createFloodDurationWCurveFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, | |
70 final int facetIndex, final int resultIndex, final String description) { | |
71 | |
72 return new FloodDurationCurveFacet(FACET_FLOOD_DURATION_W, description); | |
73 } | |
74 | |
75 public static Facet createFloodDurationQCurveFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, | |
76 final int facetIndex, final int resultIndex, final String description) { | |
77 | |
78 return new FloodDurationCurveFacet(FACET_FLOOD_DURATION_Q, description); | |
79 } | |
80 | |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
81 public static Facet createMainValuesWFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
82 final int facetIndex, final int resultIndex, final String description) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
83 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
84 return new FloodDurationMainValuesWFacet(FACET_FLOOD_DURATION_MAINVALUES_W, description); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
85 } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
86 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
87 public static Facet createMainValuesQFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, |
9612 | 88 final int facetIndex, final int resultIndex, final String description, final Infrastructure infrastructure) { |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
89 |
9612 | 90 return new FloodDurationMainValuesQFacet(FACET_FLOOD_DURATION_MAINVALUES_Q, description, facetIndex, infrastructure); |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
91 } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
92 |
9376
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
93 public static Facet createInfrastructureFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, |
9612 | 94 final int facetIndex, final int resultIndex, final boolean isW, final AttributeKey riverside) { |
9252 | 95 |
9612 | 96 final String description = getLabel(context, isW, riverside); |
97 final String facetName = getFacetName(riverside, isW); | |
98 | |
99 return new FloodDurationInfrastructureFacet(facetName, isW, resultIndex, riverside, facetIndex, description); | |
100 } | |
101 | |
102 private static String getFacetName(final AttributeKey riverside, final boolean isW) { | |
103 switch (riverside) { | |
104 case LEFT: | |
9376
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
105 if (isW) |
9612 | 106 return FACET_FLOOD_DURATION_INFRASTRUCTURE_W_LEFT; |
9376
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
107 else |
9612 | 108 return FACET_FLOOD_DURATION_INFRASTRUCTURE_Q_LEFT; |
109 | |
110 case RIGHT: | |
111 if (isW) | |
112 return FACET_FLOOD_DURATION_INFRASTRUCTURE_W_RIGHT; | |
113 else | |
114 return FACET_FLOOD_DURATION_INFRASTRUCTURE_Q_RIGHT; | |
115 default: | |
116 throw new IllegalStateException(); | |
9376
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
117 } |
9612 | 118 } |
119 | |
120 private static String getLabel(final CallContext context, final boolean isW, final AttributeKey riverside) { | |
121 switch (riverside) { | |
122 case LEFT: | |
9376
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
123 if (isW) |
9612 | 124 return Resources.getMsg(context.getMeta(), "sinfo_facet_flood_duration_curve.infra.w.left.description"); |
9376
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
125 else |
9612 | 126 return Resources.getMsg(context.getMeta(), "sinfo_facet_flood_duration_curve.infra.q.left.description"); |
127 case RIGHT: | |
128 if (isW) | |
129 return Resources.getMsg(context.getMeta(), "sinfo_facet_flood_duration_curve.infra.w.right.description"); | |
130 else | |
131 return Resources.getMsg(context.getMeta(), "sinfo_facet_flood_duration_curve.infra.q.right.description"); | |
132 | |
133 default: | |
134 throw new IllegalStateException(); | |
9376
f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents:
9259
diff
changeset
|
135 } |
9252 | 136 } |
137 | |
138 @Override | |
139 public final String getAxisLabel(final DiagramGenerator generator) { | |
140 return generator.msg(DurationCurveGenerator.I18N_YAXIS_LABEL_W); | |
141 } | |
142 | |
143 @Override | |
144 public final boolean canHandle(final String facettype) { | |
145 return HANDLED_FACET_TYPES.contains(facettype); | |
146 } | |
147 } |