annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java @ 1664:71d5abde92f2

Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets. flys-artifacts/trunk@2869 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 30 Sep 2011 08:02:21 +0000
parents fbe18ad4caff
children 0ebce697adcc
rev   line source
688
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
1664
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
3 import java.text.NumberFormat;
688
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.util.List;
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import org.apache.log4j.Logger;
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import de.intevation.artifacts.CallContext;
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import de.intevation.artifactdatabase.state.Facet;
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import de.intevation.flys.artifacts.FLYSArtifact;
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import de.intevation.flys.artifacts.WINFOArtifact;
1664
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
14 import de.intevation.flys.artifacts.model.DataFacet;
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
15 import de.intevation.flys.artifacts.model.CrossSectionFacet;
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
16 import de.intevation.flys.artifacts.model.CrossSectionWaterLineFacet;
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
17 import de.intevation.flys.artifacts.model.CalculationResult;
692
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
18 import de.intevation.flys.artifacts.model.FacetTypes;
711
69c8541edcc7 Generate report facets if there are problems with the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
19 import de.intevation.flys.artifacts.model.ReportFacet;
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 693
diff changeset
20 import de.intevation.flys.artifacts.model.WaterlevelFacet;
692
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
21 import de.intevation.flys.artifacts.model.WQKms;
1664
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
22 import de.intevation.flys.utils.Formatter;
703
af3b5d9e91a4 Generate data facets for the computed states.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 697
diff changeset
23
688
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
692
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
25 public class WaterlevelState
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
26 extends DefaultState
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
27 implements FacetTypes
22e4bffbe240 Generated facets for each output aspect.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
28 {
1111
b96ce07ba56c Added dummy sceleton for Cross Sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1051
diff changeset
29 /** The logger that is used in this state. */
688
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 private static Logger logger = Logger.getLogger(WaterlevelState.class);
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 @Override
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
34 protected String getUIProvider() {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
35 return "continue";
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
36 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
37
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
38
1140
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
39 protected Object compute(
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
40 WINFOArtifact winfo,
1664
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
41 CallContext cc,
1140
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
42 String hash,
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
43 List<Facet> facets,
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
44 Object old
1138
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
45 ) {
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
46 String id = getID();
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
47
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
48 CalculationResult res = old instanceof CalculationResult
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
49 ? (CalculationResult)old
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
50 : winfo.getWaterlevelData();
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
51
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
52 if (facets == null) {
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
53 return res;
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
54 }
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
55
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
56 WQKms [] wqkms = (WQKms [])res.getData();
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
57
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
58 for (int i = 0; i < wqkms.length; i++) {
1664
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
59 String name = wqkms[i].getName();
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
60 boolean isQ = winfo.isQ();
1138
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
61
1664
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
62 String nameW = createWTitle(cc, name, isQ);
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
63 String nameQ = createQTitle(cc, name, isQ);
1138
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
64
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
65 logger.debug("Create facet: " + nameW);
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
66 logger.debug("Create facet: " + nameQ);
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
67
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
68 Facet w = new WaterlevelFacet(
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
69 i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, id, hash);
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
70 Facet q = new WaterlevelFacet(
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
71 i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, id, hash);
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
72
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
73 facets.add(w);
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
74 facets.add(q);
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
75 }
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
76
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
77 if (wqkms.length > 0) {
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
78 Facet wst = new DataFacet(
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
79 WST, "WST data", ComputeType.ADVANCE, hash, id);
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
80 Facet csv = new DataFacet(
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
81 CSV, "CSV data", ComputeType.ADVANCE, hash, id);
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
82
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
83 facets.add(wst);
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
84 facets.add(csv);
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
85 }
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
86
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
87 if (res.getReport().hasProblems()) {
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
88 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id));
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
89 }
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
90
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
91 // Also register the CrossSectionFacet (added to respective out).
1141
bcba246d9c03 Fix various issues like i18n in cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1140
diff changeset
92 facets.add(new CrossSectionFacet(winfo.getCrossSectionName()));
bcba246d9c03 Fix various issues like i18n in cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1140
diff changeset
93 // Assume to be in wq_single mode.
bcba246d9c03 Fix various issues like i18n in cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1140
diff changeset
94 facets.add(new CrossSectionWaterLineFacet("Q=" + winfo.getDataAsString("wq_single")));
1138
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
95 return res;
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
96 }
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
97
d90f5bfa3ddf Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1122
diff changeset
98
1664
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
99 public static String createWTitle(CallContext cc, String name, boolean isQ) {
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
100 String[] parts = name.split("=");
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
101
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
102 NumberFormat nf = Formatter.getWaterlevelW(cc);
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
103
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
104 double v;
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
105
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
106 try {
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
107 v = Double.valueOf(parts[1]);
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
108 }
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
109 catch (NumberFormatException nfe) {
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
110 logger.warn("Cannot parse Double of: '" + parts[1] + "'");
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
111 return name;
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
112 }
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
113
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
114 String prefix = null;
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
115
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
116 if (isQ) {
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
117 prefix = "Q=";
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
118 }
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
119
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
120 return prefix == null
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
121 ? "W(" + nf.format(v) + ")"
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
122 : "W(" + prefix + nf.format(v) + ")";
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
123 }
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
124
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
125
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
126 public static String createQTitle(CallContext cc, String name, boolean isQ) {
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
127 String[] parts = name.split("=");
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
128
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
129 NumberFormat nf = Formatter.getWaterlevelQ(cc);
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
130
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
131 double v;
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
132
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
133 try {
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
134 v = Double.valueOf(parts[1]);
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
135 }
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
136 catch (NumberFormatException nfe) {
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
137 logger.warn("Cannot parse Double of: '" + parts[1] + "'");
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
138 return name;
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
139 }
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
140
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
141 String prefix = null;
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
142
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
143 if (!isQ) {
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
144 prefix = "W=";
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
145 }
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
146
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
147 return prefix == null
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
148 ? "Q(" + nf.format(v) + ")"
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
149 : "Q(" + prefix + nf.format(v) + ")";
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
150 }
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
151
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
152
1140
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
153 /**
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
154 * @param context Ignored.
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
155 */
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
156 @Override
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
157 public Object computeFeed(
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
158 FLYSArtifact artifact,
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
159 String hash,
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
160 CallContext context,
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
161 List<Facet> facets,
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
162 Object old
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
163 ) {
1664
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
164 return compute((WINFOArtifact) artifact, context, hash, facets, old);
1140
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
165
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
166 }
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
167
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
168
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
169 /**
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
170 * @param context Ignored.
96d7842e80ee Cosmetics, refactored, resolved todo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
171 */
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
172 @Override
697
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 696
diff changeset
173 public Object computeAdvance(
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 696
diff changeset
174 FLYSArtifact artifact,
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 696
diff changeset
175 String hash,
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 696
diff changeset
176 CallContext context,
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 711
diff changeset
177 List<Facet> facets,
697
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 696
diff changeset
178 Object old
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 696
diff changeset
179 ) {
1664
71d5abde92f2 Bugfix: #176 and #349 Create proper titles for W and Q waterlevel facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1158
diff changeset
180 return compute((WINFOArtifact) artifact, context, hash, facets, old);
688
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181 }
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 }
dc3613c4daf6 Moved Waterlevel state into the correct package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org