Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java @ 154:03362976fa0f
DischargeTables: Cache the scale, too. Otherwise two calls to getValues() with different arguments will result in the same output.
flys-artifacts/trunk@1591 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 28 Mar 2011 15:21:27 +0000 |
parents | 7f839b81cdde |
children | 89bd0417418f |
rev | line source |
---|---|
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.w3c.dom.Element; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.CallContext; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifacts.common.utils.XMLUtils; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifactdatabase.ProtocolUtils; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifactdatabase.data.StateData; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.flys.artifacts.resources.Resources; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 /** |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 */ |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 public class WQSelect extends DefaultState { |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 /** The logger used in this class.*/ |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 private static Logger logger = Logger.getLogger(WQSelect.class); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 /** The default step width for Qs.*/ |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 public static final String DEFAULT_STEP_Q = "50"; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 /** The default step width for Qs.*/ |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 public static final String DEFAULT_STEP_W = "30"; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 /** |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 * The default constructor that initializes an empty State object. |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 */ |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 public WQSelect() { |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 protected Element createData( |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 XMLUtils.ElementCreator cr, |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 StateData data, |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 CallContext context) |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 { |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 Element select = ProtocolUtils.createArtNode( |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 cr, "select", null, null); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 cr.addAttr(select, "name", data.getName(), true); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 Element label = ProtocolUtils.createArtNode( |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 cr, "label", null, null); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 Element choices = ProtocolUtils.createArtNode( |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 cr, "choices", null, null); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 label.setTextContent(Resources.getMsg( |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 context.getMeta(), |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 data.getName(), |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 data.getName())); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 select.appendChild(label); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 return select; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 protected Element[] createItems( |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 XMLUtils.ElementCreator cr, |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 String name, |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 CallContext context) |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 { |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 // TODO Insert correct min/max values! |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 if (name.equals("wq_from")) { |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 Element minW = createItem(cr, new String[] {"minW", "250"}); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 Element minQ = createItem(cr, new String[] {"minQ", "5.5"}); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 return new Element[] { minW, minQ }; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 else if (name.equals("wq_to")) { |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 Element maxW = createItem(cr, new String[] {"maxW", "850"}); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 Element maxQ = createItem(cr, new String[] {"maxQ", "1530"}); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 return new Element[] { maxW, maxQ }; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 else { |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 Element stepW = createItem(cr, new String[] {"stepW", DEFAULT_STEP_W}); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 Element stepQ = createItem(cr, new String[] {"stepQ", DEFAULT_STEP_Q}); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 return new Element[] { stepW, stepQ }; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 Element item = ProtocolUtils.createArtNode(cr, "item", null, null); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 Element label = ProtocolUtils.createArtNode(cr, "label", null, null); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 Element value = ProtocolUtils.createArtNode(cr, "value", null, null); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 String[] arr = (String[]) obj; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 label.setTextContent(arr[0]); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 value.setTextContent(arr[1]); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 item.appendChild(label); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 item.appendChild(value); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 return item; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 protected String getUIProvider() { |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 return "wq_panel"; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |