8940
|
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.Facet; |
|
17 import org.dive4elements.artifacts.CallContext; |
|
18 import org.dive4elements.river.artifacts.resources.Resources; |
|
19 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
|
20 |
|
21 public final class VelocityProcessor extends AbstractSInfoLineProcessor { |
|
22 |
|
23 // FIXME: translate! |
|
24 private static final String I18N_AXIS_LABEL = "sinfo.chart.velocity.section.yaxis.label"; |
|
25 |
|
26 private static final String SINFO_CHART_VELOCITY_YAXIS_LABEL = "sinfo.chart.velocity.yaxis.label"; |
|
27 |
|
28 // FIXME: check: filtered or not? |
|
29 private static final String FACET_TKH_VELOCITY_FILTERED = "sinfo_tkh_velocity.filtered"; |
|
30 |
|
31 private static final String I18N_FACET_TKH_VELOCITY_FILTERED_DESCRIPTION = "sinfo.facet.tkh_velocity.filtered.description"; |
|
32 |
|
33 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); |
|
34 |
|
35 static { |
|
36 HANDLED_FACET_TYPES.add(FACET_TKH_VELOCITY_FILTERED); |
|
37 } |
|
38 |
|
39 public VelocityProcessor() { |
|
40 super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES); |
|
41 } |
|
42 |
|
43 @Override |
|
44 protected double[][] doGetPoints(final AbstractSInfoCalculationResult<?> data, final String facetName) { |
|
45 |
|
46 if (FACET_TKH_VELOCITY_FILTERED.contentEquals(facetName)) |
|
47 return data.getVelocityPoints(); |
|
48 |
|
49 final String error = String.format("Unknown facet name: %s", facetName); |
|
50 throw new UnsupportedOperationException(error); |
|
51 } |
|
52 |
|
53 public static Facet createVelocityFacet(final CallContext context, final String hash, final String id, final AbstractSInfoCalculationResult<?> result, |
|
54 final int index) { |
|
55 final String facetFlowDepthFilteredDescription = Resources.getMsg(context.getMeta(), I18N_FACET_TKH_VELOCITY_FILTERED_DESCRIPTION, |
|
56 I18N_FACET_TKH_VELOCITY_FILTERED_DESCRIPTION, result.getLabel()); |
|
57 return new SInfoResultFacet(index, VelocityProcessor.FACET_TKH_VELOCITY_FILTERED, facetFlowDepthFilteredDescription, SINFO_CHART_VELOCITY_YAXIS_LABEL, |
|
58 ComputeType.ADVANCE, id, hash); |
|
59 } |
|
60 } |