8956
|
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 FlowDepthDevelopmentPerYearProcessor extends AbstractSInfoLineProcessor<AbstractSInfoCalculationResult> { |
|
22 |
|
23 private static final String I18N_AXIS_LABEL = "sinfo.chart.flow_depth_development_per_year.section.yaxis.label"; |
|
24 |
|
25 private static final String SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_YAXIS_LABEL = "sinfo.chart.flow_depth_development_per_year.yaxis.label"; |
|
26 |
|
27 /* Theme name, usually defined in 'FacetTypes', but that is soooo bad dependencies... */ |
|
28 // REMARK: these mustend with 'filtered' so extra handling happens in chart: point are always recalculated, because data |
|
29 // changes depending on zoom state |
|
30 public static final String FACET_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_FILTERED = "sinfo_facet_flow_depth_development_per_year.filtered"; |
|
31 |
|
32 private static final String I18N_FACET_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth_development_per_year.filtered.description"; |
|
33 |
|
34 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); |
|
35 |
|
36 static { |
|
37 HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_FILTERED); |
|
38 } |
|
39 |
|
40 public FlowDepthDevelopmentPerYearProcessor() { |
|
41 super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES); |
|
42 } |
|
43 |
|
44 @Override |
|
45 protected double[][] doGetPoints(final AbstractSInfoCalculationResult data, final String facetName) { |
|
46 |
|
47 if (FACET_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_FILTERED.contentEquals(facetName)) |
|
48 return data.getStationPoints(SInfoResultType.flowdepthDevelopmentPerYear); |
|
49 |
|
50 final String error = String.format("Unknown facet name: %s", facetName); |
|
51 throw new UnsupportedOperationException(error); |
|
52 } |
|
53 |
|
54 public static Facet createFlowDepthDevelopmentFacet(final CallContext context, final String hash, final String id, |
|
55 final AbstractSInfoCalculationResult result, final int index) { |
|
56 final String facetFlowDepthFilteredDescription = Resources.getMsg(context.getMeta(), I18N_FACET_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_FILTERED_DESCRIPTION, |
|
57 I18N_FACET_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_FILTERED_DESCRIPTION, result.getLabel()); |
|
58 return new SInfoResultFacet(index, FACET_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_FILTERED, facetFlowDepthFilteredDescription, |
|
59 SINFO_CHART_FLOW_DEPTH_DEVELOPMENT_PER_YEAR_YAXIS_LABEL, ComputeType.ADVANCE, id, hash); |
|
60 } |
|
61 } |