Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/shared/DoubleUtils.java @ 1542:3e2ef8e0a0dc
Issue 265.
Deactivate measure control and scale line if the map output tab is not
selected.
flys-client/trunk@3761 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 25 Jan 2012 08:50:06 +0000 |
parents | af6ad7522351 |
children | ff8312688cd5 |
rev | line source |
---|---|
1279
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.shared; |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 public final class DoubleUtils { |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 public static final String DEFAULT_DELIM = " "; |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 private DoubleUtils() { |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 } |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 public static Double getDouble(String value) { |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 try { |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 return Double.valueOf(value); |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 } |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 catch (NumberFormatException nfe) { |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 // do nothing |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 } |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 return null; |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 } |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 public static double[] getMinMax(String value) { |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 return getMinMax(value, DEFAULT_DELIM); |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 } |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 public static double[] getMinMax(String value, String delim) { |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 if (value == null) { |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 return null; |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 } |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 String[] values = value.split(delim); |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 int len = values != null ? values.length : 0; |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 double[] mm = new double[] { Double.MAX_VALUE, -Double.MAX_VALUE }; |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 for (int i = 0; i < len; i++) { |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 Double d = getDouble(values[i]); |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 if (d != null) { |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 mm[0] = mm[0] < d ? mm[0] : d; |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 mm[1] = mm[1] > d ? mm[1] : d; |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 } |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 } |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 return mm[0] != Double.MAX_VALUE && mm[1] != -Double.MAX_VALUE |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 ? mm |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 : null; |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 } |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 } |
af6ad7522351
Bugfix: #336 Improved determination of min/max KM values - code moved to ArtifactDescription.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |