annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DistanceOnlySelect.java @ 5074:90b9b80ffbbf dami

Fix example run script to work with the new packaging
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 20 Feb 2013 18:50:13 +0100
parents 1358d0c8481c
children 53be73133104
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
4865
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1630
diff changeset
9 import de.intevation.flys.artifacts.access.RangeAccess;
1630
cafd8af6734a Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1625
diff changeset
10 import de.intevation.flys.artifacts.FLYSArtifact;
cafd8af6734a Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1625
diff changeset
11
1625
c45e8d6b99a2 #315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
c45e8d6b99a2 #315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 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
14
c45e8d6b99a2 #315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 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
16
c45e8d6b99a2 #315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 @Override
c45e8d6b99a2 #315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 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
19 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
20 }
1630
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
cafd8af6734a Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1625
diff changeset
23 @Override
cafd8af6734a Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1625
diff changeset
24 public boolean validate(Artifact artifact)
cafd8af6734a Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1625
diff changeset
25 throws IllegalArgumentException
cafd8af6734a Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1625
diff changeset
26 {
4865
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1630
diff changeset
27 // TODO think about better hierarchy wrt RangeState#validate.
1630
cafd8af6734a Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1625
diff changeset
28 FLYSArtifact flys = (FLYSArtifact) artifact;
cafd8af6734a Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1625
diff changeset
29
cafd8af6734a Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1625
diff changeset
30 try {
4865
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1630
diff changeset
31 RangeAccess rangeAccess = new RangeAccess(flys, null);
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1630
diff changeset
32 double from = rangeAccess.getFrom();
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1630
diff changeset
33 double to = rangeAccess.getTo();
1630
cafd8af6734a Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1625
diff changeset
34
cafd8af6734a Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1625
diff changeset
35 double[] minmax = getMinMax(flys);
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 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
38 }
cafd8af6734a Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1625
diff changeset
39 catch (NumberFormatException nfe) {
cafd8af6734a Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1625
diff changeset
40 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
41 }
4865
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1630
diff changeset
42 catch (NullPointerException npe) {
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1630
diff changeset
43 throw new IllegalArgumentException("error_empty_state");
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1630
diff changeset
44 }
1630
cafd8af6734a Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1625
diff changeset
45 }
1625
c45e8d6b99a2 #315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 }
c45e8d6b99a2 #315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org