Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthState.java @ 8884:7a8c12706834
Work on SINFO-FlowDepth
author | gernotbelger |
---|---|
date | Tue, 13 Feb 2018 14:53:23 +0100 |
parents | 64ca63f79f6f |
children | e3519c3e7a0a |
comparison
equal
deleted
inserted
replaced
8883:a536e1aacf0f | 8884:7a8c12706834 |
---|---|
23 import org.dive4elements.river.artifacts.resources.Resources; | 23 import org.dive4elements.river.artifacts.resources.Resources; |
24 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; | 24 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; |
25 import org.dive4elements.river.artifacts.states.DefaultState; | 25 import org.dive4elements.river.artifacts.states.DefaultState; |
26 | 26 |
27 /** State in which a waterlevel has been calculated. */ | 27 /** State in which a waterlevel has been calculated. */ |
28 public class FlowDepthState | 28 public class FlowDepthState extends DefaultState { |
29 extends DefaultState | 29 |
30 { | |
31 /// ** The log that is used in this state. */ | 30 /// ** The log that is used in this state. */ |
32 // private static Logger log = Logger.getLogger(FlowDepthState.class); | 31 // private static Logger log = Logger.getLogger(FlowDepthState.class); |
33 | 32 |
34 private static final long serialVersionUID = 1L; | 33 private static final long serialVersionUID = 1L; |
35 | 34 |
36 private static final String I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth.filtered.description"; | 35 private static final String I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth.filtered.description"; |
36 | |
37 private static final String I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth.tkh.filtered.description"; | |
38 | |
39 private static final String I18N_FACET_TKH_DESCRIPTION = "sinfo.facet.tkh.description"; | |
40 | |
41 private static final String SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL = "sinfo.chart.flow_depth.yaxis.label"; | |
42 | |
43 private static final String SINFO_CHART_TKX_YAXIS_LABEL = "sinfo.chart.tkh.yaxis.label"; | |
37 | 44 |
38 /** | 45 /** |
39 * From this state can only be continued trivially. | 46 * From this state can only be continued trivially. |
40 */ | 47 */ |
41 @Override | 48 @Override |
42 protected String getUIProvider() { | 49 protected String getUIProvider() { |
43 return "continue"; | 50 return "continue"; |
44 } | 51 } |
45 | 52 |
46 @Override | 53 @Override |
47 public Object computeFeed( | 54 public Object computeFeed(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { |
48 final D4EArtifact artifact, | |
49 final String hash, | |
50 final CallContext context, | |
51 final List<Facet> facets, | |
52 final Object old | |
53 ) { | |
54 // FIXME: why is this necessary? | 55 // FIXME: why is this necessary? |
55 if (artifact instanceof ChartArtifact) { | 56 if (artifact instanceof ChartArtifact) { |
56 facets.add(new EmptyFacet()); | 57 facets.add(new EmptyFacet()); |
57 return null; | 58 return null; |
58 } | 59 } |
59 | 60 |
60 return compute((SINFOArtifact) artifact, context, hash, facets, old); | 61 return compute((SINFOArtifact) artifact, context, hash, facets, old); |
61 } | 62 } |
62 | 63 |
63 @Override | 64 @Override |
64 public Object computeAdvance( | 65 public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { |
65 final D4EArtifact artifact, | |
66 final String hash, | |
67 final CallContext context, | |
68 final List<Facet> facets, | |
69 final Object old | |
70 ) { | |
71 if (artifact instanceof ChartArtifact) { | 66 if (artifact instanceof ChartArtifact) { |
72 facets.add(new EmptyFacet()); | 67 facets.add(new EmptyFacet()); |
73 return null; | 68 return null; |
74 } | 69 } |
75 return compute((SINFOArtifact) artifact, context, hash, facets, old); | 70 return compute((SINFOArtifact) artifact, context, hash, facets, old); |
76 } | 71 } |
77 | 72 |
78 /** | 73 /** |
79 * Compute result or returned object from cache, create facets. | 74 * Compute result or returned object from cache, create facets. |
80 * @param old Object that was cached. | 75 * |
76 * @param old | |
77 * Object that was cached. | |
81 */ | 78 */ |
82 private Object compute( | 79 private Object compute(final SINFOArtifact sinfo, final CallContext context, final String hash, final List<Facet> facets, final Object old) { |
83 final SINFOArtifact sinfo, | |
84 final CallContext context, | |
85 final String hash, | |
86 final List<Facet> facets, | |
87 final Object old | |
88 ) { | |
89 | 80 |
90 final CalculationResult res; | 81 final CalculationResult res; |
91 if (old instanceof CalculationResult) | 82 if (old instanceof CalculationResult) |
92 res = (CalculationResult) old; | 83 res = (CalculationResult) old; |
93 else | 84 else |
95 | 86 |
96 if (facets == null) { | 87 if (facets == null) { |
97 return res; | 88 return res; |
98 } | 89 } |
99 | 90 |
100 final FlowDepthCalculationResults results = (FlowDepthCalculationResults) res.getData(); | 91 final FlowDepthCalculationResults results = (FlowDepthCalculationResults) res.getData(); |
101 | 92 |
102 /* add themes for chart, for each result */ | 93 /* add themes for chart, for each result */ |
103 final List<FlowDepthCalculationResult> resultList = results.getResults(); | 94 final List<FlowDepthCalculationResult> resultList = results.getResults(); |
104 for (int index = 0; index < resultList.size(); index++) { | 95 for (int index = 0; index < resultList.size(); index++) { |
105 | 96 |
106 final FlowDepthCalculationResult result = resultList.get(index); | 97 final FlowDepthCalculationResult result = resultList.get(index); |
107 | 98 |
108 /* filtered (zoom dependent mean) flow depth */ | 99 /* filtered (zoom dependent mean) flow depth */ |
109 final String facetFlowDepthFilteredDescription = Resources.getMsg( context.getMeta(), I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, result.getLabel() ); | 100 final String facetFlowDepthFilteredDescription = Resources.getMsg(context.getMeta(), I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, |
110 facets.add(new FlowDepthFilterFacet( | 101 I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, result.getLabel()); |
111 index, | 102 facets.add(new FlowDepthFacet(index, FlowDepthProcessor.FACET_FLOW_DEPTH_FILTERED, facetFlowDepthFilteredDescription, |
112 FlowDepthProcessor.FACET_FLOW_DEPTH_FILTERED, | 103 SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, ComputeType.ADVANCE, this.id, hash)); |
113 facetFlowDepthFilteredDescription, | |
114 ComputeType.ADVANCE, | |
115 this.id, | |
116 hash | |
117 )); | |
118 | 104 |
119 // FIXME: add other themes | 105 if (results.isUseTkh()) { |
106 /* filtered (zoom dependent mean) flow depth including tkh */ | |
107 final String facetFlowDepthTkhFilteredDescription = Resources.getMsg(context.getMeta(), I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION, | |
108 I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION, result.getLabel()); | |
109 facets.add(new FlowDepthFacet(index, FlowDepthProcessor.FACET_FLOW_DEPTH_TKH_FILTERED, facetFlowDepthTkhFilteredDescription, | |
110 SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, ComputeType.ADVANCE, this.id, hash)); | |
111 | |
112 // FIXME: add other themes | |
113 // - Streckenfavoriten | |
114 | |
115 // FIXME: | |
116 // - Gemittelte Linie der Fließtiefe mitsamt TKH | |
117 // - Transportkörperhöhen (oben/unten/schraffur) | |
118 final String facetTkhDescription = Resources.getMsg(context.getMeta(), I18N_FACET_TKH_DESCRIPTION, I18N_FACET_TKH_DESCRIPTION, | |
119 result.getLabel()); | |
120 facets.add(new FlowDepthFacet(index, TkhProcessor.FACET_TKH, facetTkhDescription, SINFO_CHART_TKX_YAXIS_LABEL, ComputeType.ADVANCE, this.id, | |
121 hash)); | |
122 } | |
123 | |
124 // FIXME: Datenkorbkonfiguration | |
120 } | 125 } |
121 | 126 |
122 if (!resultList.isEmpty() ) { | 127 if (!resultList.isEmpty()) { |
123 final Facet csv = new DataFacet( | 128 final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id); |
124 FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id); | 129 final Facet pdf = new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id); |
125 final Facet pdf = new DataFacet( | |
126 FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id); | |
127 | 130 |
128 facets.add(csv); | 131 facets.add(csv); |
129 facets.add(pdf); | 132 facets.add(pdf); |
130 } | 133 } |
131 | 134 |