annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java @ 141:7f909429ccc8

Added some more calculation types (to the DESCRIBE in the calculation select state). flys-artifacts/trunk@1524 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 21 Mar 2011 09:16:17 +0000
parents 21d791e21aca
children b5c99532f898
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
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 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
8 import de.intevation.artifacts.CallMeta;
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 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
11
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import de.intevation.artifactdatabase.ProtocolUtils;
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
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
14 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
15
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 /**
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 * @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
18 */
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 public class CalculationSelect extends DefaultState {
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 /** 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
22 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
23
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
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
25 /** Constant value for the reference line 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
26 public static final String CALCULATION_REFERENCE_LINE =
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
27 "calc.reference.line";
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
28
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 /** Constant value for the differences 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
30 public static final String CALCULATION_DIFFERENCES =
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
31 "calc.differences";
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
32
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 /** 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
34 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
35 "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
36
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 /** Constant value for the profile 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
38 public static final String CALCULATION_PROFILE =
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
39 "calc.profile";
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
40
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 /** Constant value for the state discharge curve 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
42 public static final String CALCULATION_STATE_DISCHARGE_CURVE =
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
43 "calc.state.discharge.curve";
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
44
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 /** 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
46 public static final String[] 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
47 CALCULATION_REFERENCE_LINE,
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
48 CALCULATION_DIFFERENCES,
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,
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
50 CALCULATION_PROFILE,
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
51 CALCULATION_STATE_DISCHARGE_CURVE };
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
52
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
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 protected Element[] createItems(
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 XMLUtils.ElementCreator cr,
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 String name,
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 CallContext context)
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 {
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
59 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
60 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
61
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
62 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
63
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 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
65 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
66 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
67 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
68 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
69 });
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 }
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 return calcs;
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 }
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74
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 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
77 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
78 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
79 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
80
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 String[] arr = (String[]) obj;
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 label.setTextContent(arr[0]);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 value.setTextContent(arr[1]);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 item.appendChild(label);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 item.appendChild(value);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 return item;
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 }
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org