annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java @ 5240:9c024718bffb

WaterlevelParser: Use Wst-structures directly (instead of Waterlevel*).
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 12 Mar 2013 10:55:14 +0100
parents 8e66293c5369
children
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
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
3 import java.text.NumberFormat;
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
4
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
5 import gnu.trove.TDoubleArrayList;
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
6
137
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 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
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 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
10
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 137
diff changeset
11 import de.intevation.artifacts.Artifact;
137
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.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
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.artifacts.common.utils.XMLUtils;
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
15 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
137
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 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
18 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
19
319
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
20 import de.intevation.flys.model.Gauge;
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
21 import de.intevation.flys.model.River;
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
22 import de.intevation.flys.model.Wst;
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
23
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
24 import de.intevation.flys.artifacts.FLYSArtifact;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
25 import de.intevation.flys.artifacts.WINFOArtifact;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
26
319
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
27 import de.intevation.flys.artifacts.model.WstFactory;
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
28 import de.intevation.flys.artifacts.model.WstValueTable;
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 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
30
1103
e0243627ba62 Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1055
diff changeset
31 import de.intevation.flys.utils.FLYSUtils;
e0243627ba62 Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1055
diff changeset
32
e0243627ba62 Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1055
diff changeset
33
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 /**
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 * @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
36 */
921
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
37 public class WQSelect extends DefaultState {
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
1691
17648043429f Cosmetics, docs, annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1103
diff changeset
39 /** The logger used in this class. */
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 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
41
1691
17648043429f Cosmetics, docs, annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1103
diff changeset
42 /** The default step width for Qs. */
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 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
44
1691
17648043429f Cosmetics, docs, annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1103
diff changeset
45 /** The default step width for Qs. */
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 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
47
2059
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
48 /** The max number of steps for Qs and Ws. */
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
49 public static final int MAX_STEPS = 30;
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
50
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
51 /** The name of the 'mode' field. */
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
52 public static final String WQ_MODE = "wq_isq";
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
53
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
54 /** Them name fo the 'free' field. */
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
55 public static final String WQ_FREE = "wq_isfree";
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
56
1691
17648043429f Cosmetics, docs, annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1103
diff changeset
57 /** The name of the 'selection' field. */
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
58 public static final String WQ_SELECTION = "wq_isrange";
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
59
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
60 /** The name of the 'from' field. */
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
61 public static final String WQ_FROM = "wq_from";
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
62
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
63 /** The name of the 'to' field. */
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
64 public static final String WQ_TO = "wq_to";
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
65
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
66 /** The name of the 'step' field. */
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
67 public static final String WQ_STEP = "wq_step";
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
68
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
69 /** The name of the 'single' field. */
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
70 public static final String WQ_SINGLE = "wq_single";
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
71
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
72
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 /**
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 * 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
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 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
77 }
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
79
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
80 @Override
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
81 protected Element createStaticData(
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
82 FLYSArtifact flys,
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
83 ElementCreator creator,
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
84 CallContext cc,
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
85 String name,
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
86 String value,
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
87 String type
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
88 ) {
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
89 if (!name.equals(WQ_SINGLE)) {
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
90 return super.createStaticData(flys, creator, cc, name, value, type);
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
91 }
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
92
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
93 Boolean isQ = flys.getDataAsBoolean(WQ_MODE);
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
94 Boolean isFree = flys.getDataAsBoolean(WQ_FREE);
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
95
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
96 WINFOArtifact winfo = (WINFOArtifact) flys;
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
97
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
98 Element dataElement = creator.create("data");
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
99 creator.addAttr(dataElement, "name", name, true);
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
100 creator.addAttr(dataElement, "type", type, true);
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
101
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
102 Element itemElement = creator.create("item");
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
103 creator.addAttr(itemElement, "value", value, true);
2025
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
104
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
105 String label;
2025
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
106
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2260
diff changeset
107 if (!isQ || isFree) {
2025
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
108 label = getLabel(winfo, cc, value);
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
109 }
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
110 else {
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
111 label = getSpecialLabel(winfo, cc, value);
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
112 }
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
113
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
114 creator.addAttr(itemElement, "label", label, true);
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
115
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
116 dataElement.appendChild(itemElement);
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
117
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
118 return dataElement;
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
119 }
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
120
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
121
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
122 protected static String getLabel(
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
123 WINFOArtifact winfo,
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
124 CallContext cc,
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
125 String raw
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
126 ) {
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
127 String[] values = raw.split(" ");
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
128
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
129 if (values.length < 1) {
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
130 return null;
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
131 }
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
132
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
133 StringBuilder label = new StringBuilder();
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
134
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
135 NumberFormat nf = NumberFormat.getInstance(
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
136 Resources.getLocale(cc.getMeta()));
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
137
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
138 for (String value: values) {
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
139 try {
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
140 double v = Double.parseDouble(value.trim());
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
141
2025
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
142 String formatted = nf.format(v);
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
143
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
144 if (label.length() > 0) {
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
145 label.append(';');
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
146 }
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
147 label.append(formatted);
2025
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
148 }
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
149 catch (NumberFormatException nfe) {
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
150 // do nothing here
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
151 }
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
152 }
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
153
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
154 return label.toString();
2025
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
155 }
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
156
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
157
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
158 protected static String getSpecialLabel(
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
159 WINFOArtifact winfo,
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
160 CallContext cc,
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
161 String raw
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
162 ) {
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
163 String[] values = raw.split(" ");
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
165 if (values.length < 1) {
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
166 return null;
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
167 }
2025
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
168
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
169 NumberFormat nf = NumberFormat.getInstance(
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
170 Resources.getLocale(cc.getMeta()));
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
171
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
172 Gauge gauge = winfo.getGauge();
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
173
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
174 boolean debug = logger.isDebugEnabled();
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
175
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
176 StringBuilder label = new StringBuilder();
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
177
2025
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
178 for (String value: values) {
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
179 try {
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
180 double v = Double.parseDouble(value.trim());
2025
6762f54b23b1 Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1743
diff changeset
181
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
182 String tmp = nf.format(v);
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
183 String mv = FLYSUtils.getNamedMainValue(gauge, v);
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
184
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
185 if (mv != null && mv.length() > 0) {
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
186 tmp = mv + ": " + tmp;
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
187 if (debug) {
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
188 logger.debug("Add main value: '" + mv + "'");
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
189 }
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
190 }
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
191 if (label.length() > 0) {
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
192 label.append(';');
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
193 }
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
194 label.append(tmp);
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
195 }
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
196 catch (NumberFormatException nfe) {
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
197 // do nothing here
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
198 }
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
199 }
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
200
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2070
diff changeset
201 return label.toString();
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
202 }
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
203
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
204
1691
17648043429f Cosmetics, docs, annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1103
diff changeset
205 @Override
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 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
207 XMLUtils.ElementCreator cr,
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 137
diff changeset
208 Artifact artifact,
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 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
210 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
211 {
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 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
213 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
214
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215 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
216
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 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
218 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
219
4049
8e66293c5369 Removed dead code
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2623
diff changeset
220 // XXX: DEAD CODE
8e66293c5369 Removed dead code
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2623
diff changeset
221 /*
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
222 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
223 cr, "choices", null, null);
4049
8e66293c5369 Removed dead code
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2623
diff changeset
224 */
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
226 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
227 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
228 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
229 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
230
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
231 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
232
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
233 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
234 }
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
235
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
236
660
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 631
diff changeset
237 @Override
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
238 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
239 XMLUtils.ElementCreator cr,
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 137
diff changeset
240 Artifact artifact,
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
241 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
242 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
243 {
2062
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
244 double[] minmaxW = determineMinMaxW(artifact);
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
245 double[] minmaxWFree = determineMinMaxWFree(artifact);
2062
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
246 double[] minmaxQ = determineMinMaxQAtGauge(artifact);
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
247 double[] minmaxQFree = determineMinMaxQ(artifact);
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
248
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
249 if (name.equals("wq_from")) {
2062
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
250 Element minW = createItem(cr, new String[] {
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
251 "minW",
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
252 String.valueOf(minmaxW[0])});
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
253
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
254 Element minQ = createItem(cr, new String[] {
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
255 "minQ",
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
256 String.valueOf(minmaxQ[0])});
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
257
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
258 Element minQFree = createItem(cr, new String[] {
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
259 "minQFree",
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
260 String.valueOf(minmaxQFree[0])});
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
261
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
262 Element minWFree = createItem(cr, new String[] {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
263 "minWFree",
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
264 String.valueOf(minmaxWFree[0])});
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
265
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
266 return new Element[] { minW, minQ, minQFree, minWFree };
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
267 }
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
268 else if (name.equals("wq_to")) {
2062
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
269 Element maxW = createItem(cr, new String[] {
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
270 "maxW",
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
271 String.valueOf(minmaxW[1])});
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
272
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
273 Element maxQ = createItem(cr, new String[] {
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
274 "maxQ",
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
275 String.valueOf(minmaxQ[1])});
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
276
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
277 Element maxQFree = createItem(cr, new String[] {
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
278 "maxQFree",
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
279 String.valueOf(minmaxQFree[1])});
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
280
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
281 Element maxWFree = createItem(cr, new String[] {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
282 "maxWFree",
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
283 String.valueOf(minmaxWFree[1])});
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
284
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
285 return new Element[] { maxW, maxQ, maxQFree, maxWFree };
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
286 }
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
287 else {
660
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 631
diff changeset
288 Element stepW = createItem(
2059
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
289 cr, new String[] {
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
290 "stepW",
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
291 String.valueOf(getStepsW(minmaxW[0], minmaxW[1]))});
660
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 631
diff changeset
292 Element stepQ = createItem(
2059
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
293 cr, new String[] {
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
294 "stepQ",
2062
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
295 String.valueOf(getStepsQ(minmaxQ[0], minmaxQ[1]))});
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
296 Element stepQFree = createItem(
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
297 cr, new String[] {
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
298 "stepQFree",
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
299 String.valueOf(getStepsQ(minmaxQFree[0], minmaxQFree[1]))});
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
300 Element stepWFree = createItem(
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
301 cr, new String[] {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
302 "stepWFree",
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
303 String.valueOf(getStepsW(minmaxWFree[0], minmaxWFree[1]))});
2062
ed6c6d437875 Added min/max values for free Qs to the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2061
diff changeset
304
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
305 return new Element[] { stepW, stepQ, stepQFree, stepWFree };
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
306 }
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
307 }
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
308
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
309
2059
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
310 protected static double getStepsW(double min, double max) {
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
311 double diff = min < max ? max - min : min - max;
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
312 double step = diff / MAX_STEPS;
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
313
2061
87f9153bb7ca Fixed order to determine correct step width of Qs and Ws.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2060
diff changeset
314 if (step < 10) {
87f9153bb7ca Fixed order to determine correct step width of Qs and Ws.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2060
diff changeset
315 return getSteps(step, 1);
2059
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
316 }
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
317 else if (step < 100) {
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
318 return getSteps(step, 10);
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
319 }
2061
87f9153bb7ca Fixed order to determine correct step width of Qs and Ws.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2060
diff changeset
320 else if (step < 1000) {
87f9153bb7ca Fixed order to determine correct step width of Qs and Ws.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2060
diff changeset
321 return getSteps(step, 100);
2059
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
322 }
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
323 else {
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
324 return step;
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
325 }
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
326 }
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
327
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
328
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
329 protected static double getStepsQ(double min, double max) {
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
330 double diff = min < max ? max - min : min - max;
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
331 double step = diff / MAX_STEPS;
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
332
2061
87f9153bb7ca Fixed order to determine correct step width of Qs and Ws.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2060
diff changeset
333 if (step < 10) {
87f9153bb7ca Fixed order to determine correct step width of Qs and Ws.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2060
diff changeset
334 return getSteps(step, 1);
2059
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
335 }
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
336 else if (step < 100) {
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
337 return getSteps(step, 10);
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
338 }
2061
87f9153bb7ca Fixed order to determine correct step width of Qs and Ws.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2060
diff changeset
339 else if (step < 1000) {
87f9153bb7ca Fixed order to determine correct step width of Qs and Ws.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2060
diff changeset
340 return getSteps(step, 100);
2059
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
341 }
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
342 else {
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
343 return step;
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
344 }
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
345 }
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
346
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
347
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
348 protected static double getSteps(double steps, double factor) {
2623
c4591312f3d3 Fixed step calculation in W/Q range input mode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2618
diff changeset
349 int fac = (int) (steps / factor);
c4591312f3d3 Fixed step calculation in W/Q range input mode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2618
diff changeset
350 double diff = steps - fac * factor;
2059
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
351
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
352 if (diff == 0) {
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
353 return steps;
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
354 }
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
355
2623
c4591312f3d3 Fixed step calculation in W/Q range input mode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2618
diff changeset
356 return factor * (fac + 1);
2059
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
357 }
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
358
522826b41ffa Compute better step width for W/Q input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2030
diff changeset
359
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
360 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
361 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
362 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
363 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
364
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
365 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
366
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
367 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
368 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
369
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
370 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
371 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
372
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
373 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
374 }
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
375
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
376
660
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 631
diff changeset
377 @Override
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
378 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
379 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
380 }
319
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
381
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
382
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
383 /**
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
384 * Determines the min and max W value for the current gauge. If no min and
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
385 * max values could be determined, this method will return
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
386 * [Double.MIN_VALUE, Double.MAX_VALUE].
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
387 *
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
388 * @param artifact The FLYSArtifact.
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
389 *
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
390 * @return the min and max W values for the current gauge.
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
391 */
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
392 protected double[] determineMinMaxW(Artifact artifact) {
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
393 logger.debug("WQSelect.determineCurrentGauge");
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
394
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
395 Gauge gauge = ((WINFOArtifact) artifact).getGauge();
320
a8e7c351bdf1 The getGauge() method of the FLYSArtifact returns the first gauge based on the given stationing now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 319
diff changeset
396 double[] minmaxW = gauge != null ? gauge.determineMinMaxW() : null;
319
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
397
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
398 double minW = minmaxW != null ? minmaxW[0] : Double.MIN_VALUE;
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
399 double maxW = minmaxW != null ? minmaxW[1] : Double.MAX_VALUE;
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
400
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
401 return new double[] { minW, maxW };
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
402 }
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
403
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
404
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
405 /**
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
406 * Determines the min and max W value. If no min and
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
407 * max values could be determined, this method will return
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
408 * [Double.MIN_VALUE, Double.MAX_VALUE].
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
409 *
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
410 * @param artifact The FLYSArtifact.
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
411 *
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
412 * @return the min and max W values.
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
413 */
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
414 protected double[] determineMinMaxWFree(Artifact artifact) {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
415 logger.debug("WQSelect.determineMinMaxWFree");
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
416
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
417 WINFOArtifact winfo = (WINFOArtifact) artifact;
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
418 WstValueTable valueTable = winfo.getWstValueTable();
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
419
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
420 double[] minmaxW = null;
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
421 if(valueTable != null) {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
422 double[] km = null;
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
423 if(winfo.isRange()) {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
424 km = winfo.getFromToStep();
2618
3a93bbbe2ec7 Fix for 'W free' validation and theme names.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2617
diff changeset
425 // Use the start km to determine the min max values.
3a93bbbe2ec7 Fix for 'W free' validation and theme names.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2617
diff changeset
426 minmaxW = valueTable.getMinMaxW(km[0]);
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
427 }
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
428 else {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
429 km = winfo.getKms();
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
430 minmaxW = valueTable.getMinMaxW(km[0]);
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
431 }
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
432 }
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
433 return minmaxW != null
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
434 ? minmaxW
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
435 : new double[] { Double.MIN_VALUE, Double.MAX_VALUE };
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
436 }
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
437
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
438
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
439 /**
319
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
440 * Determines the min and max Q value for the current gauge. If no min and
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
441 * max values could be determined, this method will return
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
442 * [Double.MIN_VALUE, Double.MAX_VALUE].
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
443 *
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
444 * @param artifact The FLYSArtifact.
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
445 *
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
446 * @return the min and max Q values for the current gauge.
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
447 */
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
448 protected double[] determineMinMaxQAtGauge(Artifact artifact) {
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
449 logger.debug("WQSelect.determineMinMaxQAtGauge");
319
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
450
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
451 WINFOArtifact flysArtifact = (WINFOArtifact) artifact;
319
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
452
1103
e0243627ba62 Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1055
diff changeset
453 River river = FLYSUtils.getRiver(flysArtifact);
e0243627ba62 Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1055
diff changeset
454 Gauge gauge = flysArtifact.getGauge();
e0243627ba62 Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1055
diff changeset
455 Wst wst = WstFactory.getWst(river);
319
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
456
320
a8e7c351bdf1 The getGauge() method of the FLYSArtifact returns the first gauge based on the given stationing now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 319
diff changeset
457 double[] minmaxQ = gauge != null
a8e7c351bdf1 The getGauge() method of the FLYSArtifact returns the first gauge based on the given stationing now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 319
diff changeset
458 ? wst.determineMinMaxQ(gauge.getRange())
a8e7c351bdf1 The getGauge() method of the FLYSArtifact returns the first gauge based on the given stationing now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 319
diff changeset
459 : null;
319
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
460
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
461 double minQ = minmaxQ != null ? minmaxQ[0] : Double.MIN_VALUE;
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
462 double maxQ = minmaxQ != null ? minmaxQ[1] : Double.MAX_VALUE;
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
463
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
464 return new double[] { minQ, maxQ };
d8558dd64152 The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
465 }
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
466
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
467
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
468 /**
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
469 * Determines the min and max Q value for the current kilometer range. If no
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
470 * min and max values could be determined, this method will return
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
471 *
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
472 * @param artifact The FLYSArtifact.
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
473 *
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
474 * @return the min and max Q values for the current kilometer range.
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
475 */
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
476 protected double[] determineMinMaxQ(Artifact artifact) {
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
477 logger.debug("WQSelect.determineMinMaxQ");
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
478
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
479 WINFOArtifact winfo = (WINFOArtifact) artifact;
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
480 WstValueTable valueTable = winfo.getWstValueTable();
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
481
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
482 double[] minmaxQ = null;
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
483 if(valueTable != null) {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
484 double[] km = null;
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
485 if(winfo.isRange()) {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
486 km = winfo.getFromToStep();
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
487 minmaxQ = valueTable.getMinMaxQ(km[0], km[1], km[2]);
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
488 }
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
489 else {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
490 km = winfo.getKms();
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
491 minmaxQ = valueTable.getMinMaxQ(km[0]);
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
492 for (int i = 1; i < km.length; i++) {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
493 double[] tmp = valueTable.getMinMaxQ(km[i]);
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
494 if(tmp[0] < minmaxQ[0]) {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
495 minmaxQ[0] = tmp[0];
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
496 }
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
497 if(tmp[1] > minmaxQ[1]) {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
498 minmaxQ[1] = tmp[1];
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
499 }
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
500 }
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
501 }
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
502 }
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
503 return minmaxQ != null
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
504 ? minmaxQ
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
505 : new double[] { Double.MIN_VALUE, Double.MAX_VALUE };
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
506 }
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
507
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
508
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
509 @Override
1050
eccf966fb677 State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 921
diff changeset
510 public boolean validate(Artifact artifact)
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
511 throws IllegalArgumentException
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
512 {
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
513 logger.debug("WQSelect.validate");
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
514
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
515 WINFOArtifact flys = (WINFOArtifact) artifact;
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
516
624
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
517 StateData data = getData(flys, WQ_SELECTION);
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
518 boolean isRange = data != null
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2260
diff changeset
519 ? Boolean.valueOf((String) data.getValue())
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2260
diff changeset
520 : false;
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
521
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
522
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
523
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2260
diff changeset
524 if (!isRange) {
1050
eccf966fb677 State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 921
diff changeset
525 return validateSingle(artifact);
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
526 }
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
527 else {
1050
eccf966fb677 State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 921
diff changeset
528 return validateRange(artifact);
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
529 }
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
530 }
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
531
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
532
921
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
533 protected boolean validateBounds(
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
534 double fromValid, double toValid,
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
535 double from, double to, double step)
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
536 throws IllegalArgumentException
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
537 {
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
538 logger.debug("RangeState.validateRange");
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
539
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
540 if (from < fromValid) {
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
541 logger.error(
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
542 "Invalid 'from'. " + from + " is smaller than " + fromValid);
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
543 throw new IllegalArgumentException("error_feed_from_out_of_range");
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
544 }
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
545 else if (to > toValid) {
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
546 logger.error(
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
547 "Invalid 'to'. " + to + " is bigger than " + toValid);
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
548 throw new IllegalArgumentException("error_feed_to_out_of_range");
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
549 }
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
550
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
551 return true;
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
552 }
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
553
610d0e0f4f85 #159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
554
1050
eccf966fb677 State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 921
diff changeset
555 protected boolean validateSingle(Artifact artifact)
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
556 throws IllegalArgumentException
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
557 {
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
558 logger.debug("WQSelect.validateSingle");
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
559
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
560 WINFOArtifact flys = (WINFOArtifact) artifact;
624
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
561 StateData data = getData(flys, WQ_SINGLE);
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
562
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
563 String tmp = data != null ? (String) data.getValue() : null;
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
564
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
565 if (tmp == null || tmp.length() == 0) {
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
566 throw new IllegalArgumentException("error_empty_state");
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
567 }
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
568
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
569 String[] strValues = tmp.split(" ");
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
570 TDoubleArrayList all = new TDoubleArrayList();
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
571
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
572 for (String strValue: strValues) {
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
573 try {
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
574 all.add(Double.parseDouble(strValue));
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
575 }
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
576 catch (NumberFormatException nfe) {
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
577 logger.warn(nfe, nfe);
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
578 }
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
579 }
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
580
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
581 all.sort();
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
582
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
583 FLYSUtils.WQ_MODE mode = FLYSUtils.getWQMode(flys);
624
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
584
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
585 logger.debug("WQ Mode: " + mode);
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
586
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
587 double[] minmax = null;
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
588
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
589 if (mode == FLYSUtils.WQ_MODE.WGAUGE) {
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
590 minmax = determineMinMaxW(artifact);
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
591 }
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
592 else if (mode == FLYSUtils.WQ_MODE.QGAUGE) {
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
593 minmax = determineMinMaxQAtGauge(artifact);
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
594 }
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
595 else if (mode == FLYSUtils.WQ_MODE.QFREE) {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
596 minmax = determineMinMaxQ(artifact);
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
597 }
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
598 else {
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
599 minmax = determineMinMaxWFree(artifact);
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
600 }
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
601
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
602 double min = all.get(0);
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
603 double max = all.get(all.size()-1);
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
604
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
605 logger.debug("Inserted min value = " + min);
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
606 logger.debug("Inserted max value = " + max);
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
607
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
608 return validateBounds(minmax[0], minmax[1], min, max, 0d);
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
609 }
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
610
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
611
1050
eccf966fb677 State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 921
diff changeset
612 protected boolean validateRange(Artifact artifact)
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
613 throws IllegalArgumentException
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
614 {
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
615 logger.debug("WQSelect.validateRange");
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
616
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
617 WINFOArtifact flys = (WINFOArtifact) artifact;
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
618 FLYSUtils.WQ_MODE mode = FLYSUtils.getWQMode(flys);
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
619
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
620 if (mode == null) {
631
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
621 throw new IllegalArgumentException("error_feed_invalid_wq_mode");
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
622 }
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
623
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
624 StateData dFrom = flys.getData(WQ_FROM);
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
625 StateData dTo = flys.getData(WQ_TO);
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
626 StateData dStep = flys.getData(WQ_STEP);
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
627
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
628 String fromStr = dFrom != null ? (String) dFrom.getValue() : null;
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
629 String toStr = dTo != null ? (String) dTo.getValue() : null;
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
630 String stepStr = dStep != null ? (String) dStep.getValue() : null;
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
631
352
ed3325a0232a Throw an illegal argument exception in LocationDistanceSelect.validate() and WQSelect.validate() if no data has been inserted so far.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 322
diff changeset
632 if (fromStr == null || toStr == null || stepStr == null) {
ed3325a0232a Throw an illegal argument exception in LocationDistanceSelect.validate() and WQSelect.validate() if no data has been inserted so far.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 322
diff changeset
633 throw new IllegalArgumentException("error_empty_state");
ed3325a0232a Throw an illegal argument exception in LocationDistanceSelect.validate() and WQSelect.validate() if no data has been inserted so far.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 322
diff changeset
634 }
ed3325a0232a Throw an illegal argument exception in LocationDistanceSelect.validate() and WQSelect.validate() if no data has been inserted so far.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 322
diff changeset
635
631
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
636 try {
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
637 double from = Double.parseDouble(fromStr);
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
638 double to = Double.parseDouble(toStr);
a9af60c84dca Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
639 double step = Double.parseDouble(stepStr);
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
640
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
641 if (mode == FLYSUtils.WQ_MODE.WGAUGE) {
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
642 return validateGaugeW(artifact, from, to, step);
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
643 }
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
644 else if (mode == FLYSUtils.WQ_MODE.QGAUGE) {
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
645 return validateGaugeQ(artifact, from, to, step);
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
646 }
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
647 else if (mode == FLYSUtils.WQ_MODE.QFREE) {
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
648 return validateFreeQ(artifact, from, to, step);
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
649 }
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
650 else if (mode == FLYSUtils.WQ_MODE.WFREE) {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
651 return validateFreeW(artifact, from, to, step);
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
652 }
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
653 else {
660
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 631
diff changeset
654 throw new IllegalArgumentException(
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 631
diff changeset
655 "error_feed_invalid_wq_mode");
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
656 }
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
657 }
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
658 catch (NumberFormatException nfe) {
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
659 throw new IllegalArgumentException("error_feed_number_format");
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
660 }
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
661 }
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
662
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
663
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
664 /**
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
665 * Validates the inserted W values.
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
666 *
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
667 * @param artifact The owner artifact.
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
668 * @param from The lower value of the W range.
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
669 * @param to The upper value of the W range.
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
670 * @param step The step width.
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
671 *
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
672 * @return true, if everything was fine, otherwise an exception is thrown.
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
673 */
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
674 protected boolean validateGaugeW(
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
675 Artifact artifact,
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
676 double from,
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
677 double to,
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
678 double step)
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
679 throws IllegalArgumentException
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
680 {
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
681 logger.debug("WQSelect.validateGaugeW");
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
682
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
683 double[] minmaxW = determineMinMaxW(artifact);
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
684
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
685 return validateBounds(minmaxW[0], minmaxW[1], from, to, step);
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
686 }
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
687
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
688
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
689 /**
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
690 * Validates the inserted Q values based on the Q range for the current
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
691 * gauge.
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
692 *
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
693 * @param artifact The owner artifact.
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
694 * @param from The lower value of the Q range.
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
695 * @param to The upper value of the Q range.
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
696 * @param step The step width.
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
697 *
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
698 * @return true, if everything was fine, otherwise an exception is thrown.
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
699 */
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
700 protected boolean validateGaugeQ(
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
701 Artifact artifact,
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
702 double from,
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
703 double to,
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
704 double step)
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
705 throws IllegalArgumentException
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
706 {
2060
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
707 logger.debug("WQSelect.validateGaugeQ");
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
708
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
709 double[] minmaxQ = determineMinMaxQAtGauge(artifact);
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
710
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
711 return validateBounds(minmaxQ[0], minmaxQ[1], from, to, step);
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
712 }
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
713
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
714
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
715 /**
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
716 * Validates the inserted Q values based on the Q range for the current
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
717 * kilometer range.
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
718 *
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
719 * @param artifact The owner artifact.
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
720 * @param from The lower value of the Q range.
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
721 * @param to The upper value of the Q range.
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
722 * @param step The step width.
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
723 *
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
724 * @return true, if everything was fine, otherwise an exception is thrown.
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
725 */
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
726 protected boolean validateFreeQ(
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
727 Artifact artifact,
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
728 double from,
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
729 double to,
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
730 double step)
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
731 throws IllegalArgumentException
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
732 {
3ffb7195173f Validate user defined Qs based on the start kilometer ('Q free').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2059
diff changeset
733 logger.debug("WQSelect.validateFreeQ");
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
734
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
735 double[] minmaxQ = determineMinMaxQ(artifact);
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
736
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
737 return validateBounds(minmaxQ[0], minmaxQ[1], from, to, step);
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 320
diff changeset
738 }
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
739
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
740
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
741 /**
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
742 * Validates the inserted W values based on the W range for the current
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
743 * kilometer range.
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
744 *
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
745 * @param artifact The owner artifact.
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
746 * @param from The lower value of the W range.
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
747 * @param to The upper value of the W range.
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
748 * @param step The step width.
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
749 *
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
750 * @return true, if everything was fine, otherwise an exception is thrown.
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
751 */
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
752 protected boolean validateFreeW(
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
753 Artifact artifact,
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
754 double from,
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
755 double to,
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
756 double step)
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
757 throws IllegalArgumentException
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
758 {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
759 logger.debug("WQSelect.validateFreeW");
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
760
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
761 double[] minmaxW = determineMinMaxWFree(artifact);
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
762
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
763 return validateBounds(minmaxW[0], minmaxW[1], from, to, step);
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
764 }
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2423
diff changeset
765
137
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
766 }
7f839b81cdde Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
767 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org