Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodQProcessor.java @ 9631:6ecd1a28017f
Nachtrag Pos. 20: Q theme for height chart added, calculator corrected (rows for km without any infrastructure)
author | mschaefer |
---|---|
date | Tue, 15 Oct 2019 12:26:13 +0200 |
parents | |
children | 9c07a33c2d62 |
comparison
equal
deleted
inserted
replaced
9630:8da911b5169c | 9631:6ecd1a28017f |
---|---|
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.ArtifactAndFacet; | |
17 import org.dive4elements.artifactdatabase.state.Facet; | |
18 import org.dive4elements.artifacts.CallContext; | |
19 import org.dive4elements.river.artifacts.common.AbstractCalculationResult; | |
20 import org.dive4elements.river.artifacts.common.AbstractProcessor; | |
21 import org.dive4elements.river.artifacts.resources.Resources; | |
22 import org.dive4elements.river.artifacts.sinfo.flood_duration.FloodDurationCalculationResult.ValueGetter; | |
23 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | |
24 import org.dive4elements.river.exports.DiagramGenerator; | |
25 import org.dive4elements.river.exports.process.QOutProcessor; | |
26 import org.dive4elements.river.themes.ThemeDocument; | |
27 | |
28 /** | |
29 * Processor to generate the facet and data series of mainvalue discharges | |
30 * | |
31 * @author Matthias Schäfer | |
32 * | |
33 */ | |
34 public final class FloodQProcessor extends AbstractProcessor { | |
35 | |
36 private static final String FACET_MAIN_VALUE_Q_DESCRIPTION = "mainvalue.q.description"; | |
37 | |
38 public static final String FACET_MAIN_VALUE_Q = "mainvalue.q"; | |
39 | |
40 private static final String I18N_AXIS_LABEL = QOutProcessor.I18N_LONGITUDINAL_LABEL; | |
41 | |
42 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); | |
43 | |
44 static { | |
45 HANDLED_FACET_TYPES.add(FACET_MAIN_VALUE_Q); | |
46 } | |
47 | |
48 public FloodQProcessor() { | |
49 super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES); | |
50 } | |
51 | |
52 public static Facet createMainValueQFacet(final CallContext context, final String hash, final String id, final FloodDurationCalculationResult result, | |
53 final int facetIndex, final int resultIndex, final int dataIndex) { | |
54 final String description = Resources.getMsg(context.getMeta(), FACET_MAIN_VALUE_Q_DESCRIPTION, FACET_MAIN_VALUE_Q_DESCRIPTION, | |
55 result.getWaterlevelLabel(dataIndex)); | |
56 | |
57 return new FloodDurationFacet(facetIndex, resultIndex, dataIndex, FACET_MAIN_VALUE_Q, description, ComputeType.ADVANCE, I18N_AXIS_LABEL, hash, id); | |
58 } | |
59 | |
60 @Override | |
61 protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { | |
62 | |
63 final String facetName = bundle.getFacetName(); | |
64 if (FACET_MAIN_VALUE_Q.contentEquals(facetName)) { | |
65 | |
66 final AbstractCalculationResult data = getResult(generator, bundle); | |
67 | |
68 final FloodDurationFacet facet = (FloodDurationFacet) bundle.getFacet(); | |
69 final int index = facet.getWaterlevelIndex(); | |
70 | |
71 if (data instanceof FloodDurationCalculationResult) { | |
72 final FloodDurationCalculationResult.ValueGetter valuegetter = new ValueGetter() { | |
73 @Override | |
74 public double getValue(final DurationWaterlevel waterlevel) { | |
75 return waterlevel.getDischarge(); | |
76 } | |
77 }; | |
78 final double[][] points = ((FloodDurationCalculationResult) data).getMainValueDurationPoints(valuegetter, index); | |
79 return buildSeriesForPoints(points, generator, bundle, theme, visible, null); | |
80 } | |
81 } | |
82 | |
83 final String error = String.format("Unknown facet name: %s", facetName); | |
84 throw new UnsupportedOperationException(error); | |
85 } | |
86 } |