Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineState.java @ 9429:bd5f5d2220fa
Work on salix cross sections; waterlevels work now with different colors
Colors and i10n for all themes.
author | gernotbelger |
---|---|
date | Fri, 17 Aug 2018 17:48:01 +0200 |
parents | b6e595f1696f |
children | ee6508687e3f |
rev | line source |
---|---|
8996 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8996
diff
changeset
|
2 * Software engineering by |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8996
diff
changeset
|
3 * Björnsen Beratende Ingenieure GmbH |
8996 | 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 package org.dive4elements.river.artifacts.uinfo.salix; | |
11 | |
12 import java.util.List; | |
13 | |
14 import org.dive4elements.artifactdatabase.state.Facet; | |
15 import org.dive4elements.artifacts.CallContext; | |
16 import org.dive4elements.river.artifacts.ChartArtifact; | |
17 import org.dive4elements.river.artifacts.D4EArtifact; | |
18 import org.dive4elements.river.artifacts.model.Calculation; | |
19 import org.dive4elements.river.artifacts.model.CalculationResult; | |
20 import org.dive4elements.river.artifacts.model.DataFacet; | |
21 import org.dive4elements.river.artifacts.model.EmptyFacet; | |
22 import org.dive4elements.river.artifacts.model.FacetTypes; | |
23 import org.dive4elements.river.artifacts.model.ReportFacet; | |
9316
72b3270e1568
U-Info salix line with regional and supraregional scenario calculation and chart display
mschaefer
parents:
9295
diff
changeset
|
24 import org.dive4elements.river.artifacts.resources.Resources; |
8996 | 25 import org.dive4elements.river.artifacts.states.DefaultState; |
26 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; | |
9429
bd5f5d2220fa
Work on salix cross sections; waterlevels work now with different colors
gernotbelger
parents:
9426
diff
changeset
|
27 import org.dive4elements.river.artifacts.uinfo.salix.SalixLineCrossSectionIndexData.SalixWaterlevel; |
8996 | 28 |
29 /** | |
30 * @author Domenico Nardi Tironi | |
31 */ | |
32 public class SalixLineState extends DefaultState { | |
33 | |
34 private static final long serialVersionUID = 1L; | |
35 | |
36 /** | |
37 * From this state can only be continued trivially. | |
38 */ | |
39 @Override | |
40 protected String getUIProvider() { | |
41 return "continue"; | |
42 } | |
43 | |
44 @Override | |
45 public Object computeFeed(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { | |
46 // FIXME: why is this necessary? | |
47 if (artifact instanceof ChartArtifact) { | |
48 facets.add(new EmptyFacet()); | |
49 return null; | |
50 } | |
51 | |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
52 return compute((UINFOArtifact) artifact, context, ComputeType.FEED, hash, facets, old); |
8996 | 53 } |
54 | |
55 @Override | |
56 public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { | |
57 if (artifact instanceof ChartArtifact) { | |
58 facets.add(new EmptyFacet()); | |
59 return null; | |
60 } | |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
61 return compute((UINFOArtifact) artifact, context, ComputeType.ADVANCE, hash, facets, old); |
8996 | 62 } |
63 | |
64 /** | |
65 * Compute result or returned object from cache, create facets. | |
66 * | |
67 * @param old | |
68 * Object that was cached. | |
69 */ | |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
70 private Object compute(final UINFOArtifact uinfo, final CallContext context, final ComputeType type, final String hash, final List<Facet> facets, |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
71 final Object old) { |
8996 | 72 |
9316
72b3270e1568
U-Info salix line with regional and supraregional scenario calculation and chart display
mschaefer
parents:
9295
diff
changeset
|
73 final CalculationResult res = doCompute(uinfo, context, old); |
8996 | 74 |
75 if (facets == null) | |
76 return res; | |
77 | |
78 final SalixLineCalculationResults results = (SalixLineCalculationResults) res.getData(); | |
79 | |
9361
2aec052d4088
Refactoring on SalixLineCalculationResult etc., calculation using MQ etc., scenario (regional+supra) csv columns and meta data added
mschaefer
parents:
9347
diff
changeset
|
80 final List<SalixLineCalculationResult> resultList = results.getResults(); |
8996 | 81 |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
82 final String stateId = getID(); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
83 |
9347 | 84 int facetIndex = 0; |
85 | |
8996 | 86 if (!resultList.isEmpty()) { |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
87 facets.add(SalixLineProcessor.createSalixLineFilteredFacet(context, hash, stateId, facetIndex++, 0)); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
88 facets.add(SalixLineProcessor.createSalixLineRawFacet(context, hash, stateId, facetIndex++, 0)); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
89 facets.add(SalixLineProcessor.createSalixMnwMwFilteredFacet(context, hash, stateId, facetIndex++, 0)); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
90 facets.add(SalixLineProcessor.createSalixMnwMwRawFacet(context, hash, stateId, facetIndex++, 0)); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
91 facets.add(SalixLineProcessor.createSalixRankFacet(context, hash, stateId, facetIndex++, 0)); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
92 |
9429
bd5f5d2220fa
Work on salix cross sections; waterlevels work now with different colors
gernotbelger
parents:
9426
diff
changeset
|
93 facets.add(SalixLineProcessor.createSalixCrossSectionFacet(context, type, hash, stateId, facetIndex++)); |
9347 | 94 |
9361
2aec052d4088
Refactoring on SalixLineCalculationResult etc., calculation using MQ etc., scenario (regional+supra) csv columns and meta data added
mschaefer
parents:
9347
diff
changeset
|
95 final SalixLineCalculationResult result = resultList.get(0); |
9347 | 96 |
9361
2aec052d4088
Refactoring on SalixLineCalculationResult etc., calculation using MQ etc., scenario (regional+supra) csv columns and meta data added
mschaefer
parents:
9347
diff
changeset
|
97 for (int i = 0; i <= result.getScenarioCount() - 1; i++) { |
9429
bd5f5d2220fa
Work on salix cross sections; waterlevels work now with different colors
gernotbelger
parents:
9426
diff
changeset
|
98 final String scenarioLabel = result.getScenarioLabel(i); |
bd5f5d2220fa
Work on salix cross sections; waterlevels work now with different colors
gernotbelger
parents:
9426
diff
changeset
|
99 |
bd5f5d2220fa
Work on salix cross sections; waterlevels work now with different colors
gernotbelger
parents:
9426
diff
changeset
|
100 final String sublabel = Resources.getMsg(context.getMeta(), "uinfo_salix_scenario_deltaw", "uinfo_salix_scenario_deltaw", scenarioLabel); |
9361
2aec052d4088
Refactoring on SalixLineCalculationResult etc., calculation using MQ etc., scenario (regional+supra) csv columns and meta data added
mschaefer
parents:
9347
diff
changeset
|
101 // REMARK: using data index as facetIndex, as we know there is only one result of this type. Else we should just |
2aec052d4088
Refactoring on SalixLineCalculationResult etc., calculation using MQ etc., scenario (regional+supra) csv columns and meta data added
mschaefer
parents:
9347
diff
changeset
|
102 // increment |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
103 facets.add(SalixLineProcessor.createSalixScenarioFilteredFacet(context, hash, stateId, i, 0, facetIndex++, sublabel)); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
104 facets.add(SalixLineProcessor.createSalixScenarioRawFacet(context, hash, stateId, i, 0, facetIndex++, sublabel)); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
105 |
9429
bd5f5d2220fa
Work on salix cross sections; waterlevels work now with different colors
gernotbelger
parents:
9426
diff
changeset
|
106 facets.add(SalixLineProcessor.createSalixScenarioCrossSectionFacet(context, type, hash, stateId, i, facetIndex++, sublabel)); |
9316
72b3270e1568
U-Info salix line with regional and supraregional scenario calculation and chart display
mschaefer
parents:
9295
diff
changeset
|
107 } |
9295
385b52ccde23
Work on U-Info salix line calculation and chart (no scenario case)
mschaefer
parents:
9243
diff
changeset
|
108 |
9429
bd5f5d2220fa
Work on salix cross sections; waterlevels work now with different colors
gernotbelger
parents:
9426
diff
changeset
|
109 for (final SalixWaterlevel knownWaterlevel : SalixLineCrossSectionIndexData.SalixWaterlevel.values()) |
bd5f5d2220fa
Work on salix cross sections; waterlevels work now with different colors
gernotbelger
parents:
9426
diff
changeset
|
110 facets.add(SalixLineProcessor.createSalixWaterlevelCrossSectionFacet(context, type, hash, stateId, knownWaterlevel, facetIndex++)); |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
111 |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
112 final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, stateId); |
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
113 final Facet pdf = new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, stateId); |
8996 | 114 |
115 facets.add(csv); | |
116 facets.add(pdf); | |
117 } | |
118 | |
119 final Calculation report = res.getReport(); | |
120 | |
121 if (report.hasProblems()) | |
9426
b6e595f1696f
Activated cross section output mode for salix line and implemented some themes preliminary.
gernotbelger
parents:
9368
diff
changeset
|
122 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, stateId)); |
8996 | 123 |
124 return res; | |
125 } | |
126 | |
9295
385b52ccde23
Work on U-Info salix line calculation and chart (no scenario case)
mschaefer
parents:
9243
diff
changeset
|
127 private CalculationResult doCompute(final UINFOArtifact uinfo, final CallContext context, final Object old) { |
8996 | 128 if (old instanceof CalculationResult) |
129 return (CalculationResult) old; | |
130 | |
9295
385b52ccde23
Work on U-Info salix line calculation and chart (no scenario case)
mschaefer
parents:
9243
diff
changeset
|
131 return new SalixLineCalculation(context).calculate(uinfo); |
8996 | 132 } |
133 } |