annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java @ 313:89bd0417418f

The location/distance state now writes default values into DESCRIBE. flys-artifacts/trunk@1697 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 14 Apr 2011 13:36:06 +0000
parents b5c99532f898
children b33ba2cd4a3e
rev   line source
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import org.apache.log4j.Logger;
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import org.w3c.dom.Element;
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
7 import de.intevation.artifacts.Artifact;
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import de.intevation.artifacts.CallContext;
141
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
9 import de.intevation.artifacts.CallMeta;
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import de.intevation.artifacts.common.utils.XMLUtils;
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import de.intevation.artifactdatabase.ProtocolUtils;
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
141
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
15 import de.intevation.flys.artifacts.resources.Resources;
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
16
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 /**
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 */
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 public class CalculationSelect extends DefaultState {
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 /** The logger that is used in this class.*/
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 private static Logger logger = Logger.getLogger(CalculationSelect.class);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
141
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
26 /** Constant value for the reference line calculation.*/
157
b5c99532f898 Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 141
diff changeset
27 public static final String CALCULATION_SURFACE_CURVE =
b5c99532f898 Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 141
diff changeset
28 "calc.surface.curve";
141
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
29
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
30 /** Constant value for the differences calculation.*/
157
b5c99532f898 Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 141
diff changeset
31 public static final String CALCULATION_DURATION_CURVE =
b5c99532f898 Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 141
diff changeset
32 "calc.duration.curve";
141
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
33
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
34 /** Constant value for the flood map calculation.*/
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
35 public static final String CALCULATION_FLOOD_MAP =
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
36 "calc.flood.map";
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
37
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
38 /** Constant value for the profile calculation.*/
157
b5c99532f898 Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 141
diff changeset
39 public static final String CALCULATION_DISCHARGE_LONGITUDINAL_CURVE =
b5c99532f898 Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 141
diff changeset
40 "calc.discharge.longitudinal.section";
141
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
41
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
42 /** Constant value for the state discharge curve calculation.*/
157
b5c99532f898 Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 141
diff changeset
43 public static final String CALCULATION_DISCHARGE_CURVE =
b5c99532f898 Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 141
diff changeset
44 "calc.discharge.curve";
141
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
45
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
46 /** An array that holds all available calculation modes.*/
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
47 public static final String[] CALCULATIONS = {
157
b5c99532f898 Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 141
diff changeset
48 CALCULATION_SURFACE_CURVE,
141
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
49 CALCULATION_FLOOD_MAP,
157
b5c99532f898 Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 141
diff changeset
50 CALCULATION_DISCHARGE_CURVE,
b5c99532f898 Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 141
diff changeset
51 CALCULATION_DURATION_CURVE,
b5c99532f898 Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 141
diff changeset
52 CALCULATION_DISCHARGE_LONGITUDINAL_CURVE };
141
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
53
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
54
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 protected Element[] createItems(
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 XMLUtils.ElementCreator cr,
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
57 Artifact artifact,
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 String name,
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 CallContext context)
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 {
141
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
61 CallMeta meta = context.getMeta();
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
62 Element[] calcs = new Element[CALCULATIONS.length];
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63
141
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
64 int i = 0;
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
65
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
66 for (String calc: CALCULATIONS) {
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
67 calcs[i++] = createItem(
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
68 cr, new String[] {
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
69 Resources.getMsg(meta, calc, calc),
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
70 calc
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
71 });
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
72 }
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
73
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
74 return calcs;
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 }
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 String[] arr = (String[]) obj;
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 label.setTextContent(arr[0]);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 value.setTextContent(arr[1]);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 item.appendChild(label);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 item.appendChild(value);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 return item;
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 }
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 }
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org