Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DistanceOnlySelect.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 | cafd8af6734a |
children | 1358d0c8481c |
rev | line source |
---|---|
1625
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
1630
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
5 import de.intevation.artifacts.Artifact; |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
6 |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
7 import de.intevation.artifactdatabase.data.StateData; |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
8 |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
9 import de.intevation.flys.artifacts.FLYSArtifact; |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
10 |
1625
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 public class DistanceOnlySelect extends DistanceSelect { |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 private static Logger logger = Logger.getLogger(DistanceOnlySelect.class); |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 @Override |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 protected String getUIProvider() { |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 return "distance_only_panel"; |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 } |
1630
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
20 |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
21 |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
22 @Override |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
23 public boolean validate(Artifact artifact) |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
24 throws IllegalArgumentException |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
25 { |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
26 FLYSArtifact flys = (FLYSArtifact) artifact; |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
27 |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
28 StateData dFrom = getData(flys, getLowerField()); |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
29 StateData dTo = getData(flys, getUpperField()); |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
30 |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
31 String fromStr = dFrom != null ? (String) dFrom.getValue() : null; |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
32 String toStr = dTo != null ? (String) dTo.getValue() : null; |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
33 |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
34 if (fromStr == null || toStr == null) { |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
35 throw new IllegalArgumentException("error_empty_state"); |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
36 } |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
37 |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
38 try { |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
39 double from = Double.parseDouble(fromStr); |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
40 double to = Double.parseDouble(toStr); |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
41 |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
42 double[] minmax = getMinMax(flys); |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
43 |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
44 return validateBounds(minmax[0], minmax[1], from, to); |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
45 } |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
46 catch (NumberFormatException nfe) { |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
47 throw new IllegalArgumentException("error_invalid_double_value"); |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
48 } |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
49 } |
1625
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 } |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |