Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/states/DistanceOnlySelect.java @ 7646:f603a53e45dc
issue1020: Cosmetics.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 05 Dec 2013 15:35:53 +0100 |
parents | a0078e5e3b39 |
children | e4606eae8ea5 |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4949
diff
changeset
|
9 package org.dive4elements.river.artifacts.states; |
1625
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 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
|
12 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4949
diff
changeset
|
13 import org.dive4elements.artifacts.Artifact; |
1630
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
14 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4949
diff
changeset
|
15 import org.dive4elements.river.artifacts.access.RangeAccess; |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
16 import org.dive4elements.river.artifacts.D4EArtifact; |
1630
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
17 |
1625
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 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
|
20 |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 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
|
22 |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 @Override |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 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
|
25 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
|
26 } |
1630
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 |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
29 @Override |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
30 public boolean validate(Artifact artifact) |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
31 throws IllegalArgumentException |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
32 { |
4865
1358d0c8481c
RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1630
diff
changeset
|
33 // TODO think about better hierarchy wrt RangeState#validate. |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
34 D4EArtifact flys = (D4EArtifact) artifact; |
1630
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
35 |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
36 try { |
6101
a0078e5e3b39
Removed unused context from RangeAccess and subclasses leading to some dead code removal.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
37 RangeAccess rangeAccess = new RangeAccess(flys); |
4865
1358d0c8481c
RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1630
diff
changeset
|
38 double from = rangeAccess.getFrom(); |
1358d0c8481c
RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1630
diff
changeset
|
39 double to = rangeAccess.getTo(); |
1630
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
40 |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
41 double[] minmax = getMinMax(flys); |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
42 |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
43 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
|
44 } |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
45 catch (NumberFormatException nfe) { |
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
46 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
|
47 } |
4865
1358d0c8481c
RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1630
diff
changeset
|
48 catch (NullPointerException npe) { |
1358d0c8481c
RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1630
diff
changeset
|
49 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
|
50 } |
1630
cafd8af6734a
Improved bounds validation for distance only states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1625
diff
changeset
|
51 } |
1625
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 } |
c45e8d6b99a2
#315 Added new state for entering a kilometer range without step width.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |