Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationSelect.java @ 3967:0f67a915bfd9
dummy merge for repo head
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:15:32 +0200 |
parents | d9af29a4bb85 |
children |
rev | line source |
---|---|
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import gnu.trove.TDoubleArrayList; |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
679
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
7 import org.w3c.dom.Element; |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
8 |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifacts.Artifact; |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifacts.CallContext; |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
679
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
12 import de.intevation.artifacts.common.utils.XMLUtils; |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
13 |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.artifactdatabase.data.StateData; |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
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:
385
diff
changeset
|
16 import de.intevation.flys.artifacts.FLYSArtifact; |
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:
385
diff
changeset
|
17 |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 /** |
3284
d9af29a4bb85
Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2235
diff
changeset
|
20 * This state is used to realize the input of multiple locations as string. |
d9af29a4bb85
Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2235
diff
changeset
|
21 * |
d9af29a4bb85
Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2235
diff
changeset
|
22 * The string should be a whitespace separated list of double values where each |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 * double value represents a location. |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 * |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 */ |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 public class LocationSelect extends LocationDistanceSelect { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 /** The logger used in this class.*/ |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 private static Logger logger = Logger.getLogger(LocationSelect.class); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 public LocationSelect() { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 |
3284
d9af29a4bb85
Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2235
diff
changeset
|
37 /** UI Provider (which input method should the client provide to user. */ |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 @Override |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 protected String getUIProvider() { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 return "location_panel"; |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 @Override |
679
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
45 protected Element[] createItems( |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
46 XMLUtils.ElementCreator cr, |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
47 Artifact artifact, |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
48 String name, |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
49 CallContext context) |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
50 { |
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:
679
diff
changeset
|
51 double[] minmax = getMinMax(artifact); |
679
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
52 |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
53 double minVal = Double.MIN_VALUE; |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
54 double maxVal = Double.MAX_VALUE; |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
55 |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
56 if (minmax != null) { |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
57 minVal = minmax[0]; |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
58 maxVal = minmax[1]; |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
59 } |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
60 else { |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
61 logger.warn("Could not read min/max distance values!"); |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
62 } |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
63 |
2235
ee5310134463
Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2223
diff
changeset
|
64 if (name.equals(LOCATIONS)) { |
679
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
65 Element min = createItem( |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
66 cr, |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
67 new String[] {"min", new Double(minVal).toString()}); |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
68 |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
69 Element max = createItem( |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
70 cr, |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
71 new String[] {"max", new Double(maxVal).toString()}); |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
72 |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
73 return new Element[] { min, max }; |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
74 } |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
75 |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
76 return null; |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
77 } |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
78 |
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
79 |
3284
d9af29a4bb85
Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2235
diff
changeset
|
80 /** Validates data from artifact. */ |
679
9a035ef7b595
The state that is used to enter locations writes the river's range into the DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
81 @Override |
1050
eccf966fb677
State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
921
diff
changeset
|
82 public boolean validate(Artifact artifact) |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 throws IllegalArgumentException |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 logger.debug("LocationSelect.validate"); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 |
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:
385
diff
changeset
|
87 FLYSArtifact flys = (FLYSArtifact) artifact; |
2235
ee5310134463
Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2223
diff
changeset
|
88 StateData data = getData(flys, LOCATIONS); |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 |
2223
6e67b5dd8c4c
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1838
diff
changeset
|
90 String locationStr = data != null |
6e67b5dd8c4c
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1838
diff
changeset
|
91 ? (String) data.getValue() |
6e67b5dd8c4c
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1838
diff
changeset
|
92 : null; |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 if (locationStr == null || locationStr.length() == 0) { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 logger.error("No locations given."); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 throw new IllegalArgumentException("error_empty_state"); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 |
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:
679
diff
changeset
|
99 double[] minmax = getMinMax(artifact); |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 double[] mm = extractLocations(locationStr); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 logger.debug("Inserted min location: " + mm[0]); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 logger.debug("Inserted max location: " + mm[mm.length-1]); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
383
diff
changeset
|
105 return validateBounds(minmax[0], minmax[1], mm[0], mm[mm.length-1], 0d); |
383
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 /** |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 * This method takes a string that consist of whitespace separated double |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 * values and returns the double values as array. |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 * |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 * @param locationStr The locations inserted in this state. |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 * |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 * @return the locations as array. |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 */ |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 protected double[] extractLocations(String locationStr) { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 String[] tmp = locationStr.split(" "); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 TDoubleArrayList locations = new TDoubleArrayList(); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 for (String l: tmp) { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 try { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 locations.add(Double.parseDouble(l)); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 catch (NumberFormatException nfe) { |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 logger.warn(nfe, nfe); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 locations.sort(); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 return locations.toNativeArray(); |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 } |
dcc3cd962c0e
Enhanced the transition model to reach a state that creates duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |