Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java @ 674:d5f9ba1d055f
Added calculation base class to collect the problems during the calculations. Adjusted calculation 4 to use the mechanism.
flys-artifacts/trunk@2098 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 10 Jun 2011 09:19:27 +0000 |
parents | 627be3ca1ab6 |
children | 06689035024c |
rev | line source |
---|---|
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.w3c.dom.Element; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
628
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
7 import gnu.trove.TDoubleArrayList; |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
8 |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
9 import de.intevation.artifacts.Artifact; |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifacts.CallContext; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.common.utils.XMLUtils; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.artifactdatabase.ProtocolUtils; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.artifactdatabase.data.StateData; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
17 import de.intevation.flys.model.River; |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
18 |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
19 import de.intevation.flys.artifacts.FLYSArtifact; |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
20 import de.intevation.flys.artifacts.model.RiverFactory; |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.flys.artifacts.resources.Resources; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 /** |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 */ |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
26 public class LocationDistanceSelect extends RangeState { |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 /** The logger used in this class.*/ |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 private static Logger logger = Logger.getLogger(LocationDistanceSelect.class); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 /** The default step width.*/ |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 public static final String DEFAULT_STEP = "100"; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
627
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
35 /** The name of the 'mode' field. */ |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
36 public static final String MODE = "ld_mode"; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
37 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
38 /** The name of the 'locations' field.*/ |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
39 public static final String LOCATIONS = "ld_locations"; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
40 |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
41 /** 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:
313
diff
changeset
|
42 public static final String FROM = "ld_from"; |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
43 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
44 /** 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:
313
diff
changeset
|
45 public static final String TO = "ld_to"; |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
46 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
47 /** 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:
313
diff
changeset
|
48 public static final String STEP = "ld_step"; |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
49 |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 /** |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 * The default constructor that initializes an empty State object. |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 */ |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 public LocationDistanceSelect() { |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 } |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 protected Element createData( |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 XMLUtils.ElementCreator cr, |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
58 Artifact artifact, |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 StateData data, |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 CallContext context) |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 { |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 Element select = ProtocolUtils.createArtNode( |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 cr, "select", null, null); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 cr.addAttr(select, "name", data.getName(), true); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 Element label = ProtocolUtils.createArtNode( |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 cr, "label", null, null); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 Element choices = ProtocolUtils.createArtNode( |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 cr, "choices", null, null); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 label.setTextContent(Resources.getMsg( |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 context.getMeta(), |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 data.getName(), |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 data.getName())); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 select.appendChild(label); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 return select; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 } |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
629
diff
changeset
|
84 @Override |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 protected Element[] createItems( |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 XMLUtils.ElementCreator cr, |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
87 Artifact artifact, |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 String name, |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 CallContext context) |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 { |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
91 double[] minmax = getMinMaxDistance(artifact); |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
92 |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
93 double minVal = Double.MIN_VALUE; |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
94 double maxVal = Double.MAX_VALUE; |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
95 |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
96 if (minmax != null) { |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
97 minVal = minmax[0]; |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
98 maxVal = minmax[1]; |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
99 } |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
100 else { |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
101 logger.warn("Could not read min/max distance values!"); |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
102 } |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 if (name.equals("ld_from")) { |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
105 Element min = createItem( |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
106 cr, |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
107 new String[] {"min", new Double(minVal).toString()}); |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
108 |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 return new Element[] { min }; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 } |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 else if (name.equals("ld_to")) { |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
112 Element max = createItem( |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
113 cr, |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
114 new String[] {"max", new Double(maxVal).toString()}); |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
115 |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 return new Element[] { max }; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 } |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 else { |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 Element step = createItem(cr, new String[] {"step", DEFAULT_STEP}); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 return new Element[] { step }; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 } |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 } |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 Element item = ProtocolUtils.createArtNode(cr, "item", null, null); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 Element label = ProtocolUtils.createArtNode(cr, "label", null, null); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 Element value = ProtocolUtils.createArtNode(cr, "value", null, null); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 String[] arr = (String[]) obj; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 label.setTextContent(arr[0]); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 value.setTextContent(arr[1]); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 item.appendChild(label); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
137 item.appendChild(value); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 return item; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 } |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
629
diff
changeset
|
143 @Override |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 protected String getUIProvider() { |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 return "location_distance_panel"; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 } |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
147 |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
148 |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
149 protected double[] getMinMaxDistance(Artifact artifact) { |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
150 FLYSArtifact flysArtifact = (FLYSArtifact) 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
|
151 StateData data = getData(flysArtifact, "river"); |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
152 |
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
|
153 String name = data != null ? (String) data.getValue() : ""; |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
154 |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
155 logger.debug("Search for the min/max distances of '" + name + "'"); |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
156 |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
157 River river = RiverFactory.getRiver(name); |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
158 |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
159 return river != null ? river.determineMinMaxDistance() : null; |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
160 } |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
161 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
162 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
163 @Override |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
164 public boolean validate(Artifact artifact, CallContext context) |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
165 throws IllegalArgumentException |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
166 { |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
167 logger.debug("LocationDistanceSelect.validate"); |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
168 |
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
|
169 FLYSArtifact flys = (FLYSArtifact) artifact; |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
170 |
627
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
171 if (flys.isRange()) { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
172 return validateRange(flys, context); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
173 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
174 else { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
175 return validateLocations(flys, context); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
176 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
177 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
178 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
179 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
180 protected boolean validateLocations(FLYSArtifact flys, CallContext context) |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
181 throws IllegalArgumentException |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
182 { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
183 StateData dValues = getData(flys, LOCATIONS); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
184 String values = dValues != null ? (String)dValues.getValue() : null; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
185 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
186 if (values == null || values.length() == 0) { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
187 throw new IllegalArgumentException("error_empty_state"); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
188 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
189 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
190 double[] absMinMax = getMinMaxDistance(flys); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
191 double[] relMinMax = getMinMaxFromString(values); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
192 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
193 if (relMinMax[0] < absMinMax[0] || relMinMax[0] > absMinMax[1]) { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
194 throw new IllegalArgumentException("error_feed_from_out_of_range"); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
195 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
196 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
197 if (relMinMax[1] > absMinMax[1] || relMinMax[1] < absMinMax[0]) { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
198 throw new IllegalArgumentException("error_feed_to_out_of_range"); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
199 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
200 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
201 return true; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
202 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
203 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
204 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
205 protected boolean validateRange(FLYSArtifact flys, CallContext context) |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
206 throws IllegalArgumentException |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
207 { |
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
|
208 StateData dFrom = getData(flys, FROM); |
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
|
209 StateData dTo = getData(flys, TO); |
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
|
210 StateData dStep = getData(flys, STEP); |
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
|
211 |
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
|
212 String fromStr = dFrom != null ? (String) dFrom.getValue() : null; |
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
|
213 String toStr = dTo != null ? (String) dTo.getValue() : null; |
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
|
214 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:
313
diff
changeset
|
215 |
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
|
216 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
|
217 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
|
218 } |
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
|
219 |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
220 try { |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
221 double from = Double.parseDouble(fromStr); |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
222 double to = Double.parseDouble(toStr); |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
223 double step = Double.parseDouble(stepStr); |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
224 |
627
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
225 double[] minmaxDist = getMinMaxDistance(flys); |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
226 |
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
|
227 return validateBounds(minmaxDist[0], minmaxDist[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:
313
diff
changeset
|
228 } |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
229 catch (NumberFormatException nfe) { |
627
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
230 throw new IllegalArgumentException("error_invalid_double_value"); |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
231 } |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
232 } |
627
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
233 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
234 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
235 /** |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
236 * Extracts the min/max values from String <i>s</i>. An |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
237 * IllegalArgumentException is thrown if there is a value that throws a |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
238 * NumberFormatException. |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
239 * |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
240 * @param s String that contains whitespace separated double values. |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
241 * |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
242 * @return a 2dmin array [min,max]. |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
243 */ |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
244 public static double[] getMinMaxFromString(String s) |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
245 throws IllegalArgumentException |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
246 { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
247 String[] values = s.split(" "); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
248 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
249 double[] minmax = new double[] { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
250 Double.MAX_VALUE, |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
251 -Double.MAX_VALUE }; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
252 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
253 for (String v: values) { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
254 try { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
255 double value = Double.valueOf(v); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
256 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
257 minmax[0] = minmax[0] < value ? minmax[0] : value; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
258 minmax[1] = minmax[1] > value ? minmax[1] : value; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
259 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
260 catch (NumberFormatException nfe) { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
261 throw new IllegalArgumentException( |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
262 "error_invalid_double_value"); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
263 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
264 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
265 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
266 return minmax; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
267 } |
628
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
268 |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
269 |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
270 public static double[] getLocations(FLYSArtifact flys) { |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
271 StateData data = flys.getData("ld_locations"); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
272 String value = data != null ? (String) data.getValue() : null; |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
273 |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
274 if (value == null || value.length() == 0) { |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
275 logger.warn("No location data given."); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
276 return null; |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
277 } |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
278 |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
279 String[] splitted = value.split(" "); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
280 TDoubleArrayList values = new TDoubleArrayList(); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
281 |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
282 for (String split: splitted) { |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
283 try { |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
284 values.add(Double.valueOf(split)); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
285 } |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
286 catch (NumberFormatException nfe) { |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
287 logger.warn(nfe, nfe); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
288 } |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
289 } |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
290 |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
291 return values.toNativeArray(); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
292 } |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
293 } |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
294 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |