changeset 571:6ebe845a9d37

#117 Improved double value parsing in DoubleArrayPanel and DoubleRangePanel. flys-client/trunk@2121 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 15 Jun 2011 08:28:54 +0000
parents 85d7cc0f2bab
children 830e4720caad
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleRangePanel.java
diffstat 3 files changed, 27 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue Jun 14 16:43:09 2011 +0000
+++ b/flys-client/ChangeLog	Wed Jun 15 08:28:54 2011 +0000
@@ -1,3 +1,13 @@
+2011-06-15  Ingo Weinzierl <ingo@intevation.de>
+
+	  flys/issue117 (W-INFO: Wasserspiegellagenberechnung / Q-Eingabe)
+
+	* src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java:
+	  This panel will return a list of unique values.
+
+	* src/main/java/de/intevation/flys/client/client/ui/DoubleRangePanel.java:
+	  Improved parsing of double values.
+
 2011-06-14	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	  flys/issue88 (WINFO/Wasserspiegellage: Namensänderung im Eingabebereich
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java	Tue Jun 14 16:43:09 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java	Wed Jun 15 08:28:54 2011 +0000
@@ -192,21 +192,30 @@
             return null;
         }
 
-        double[] values = new double[parts.length];
-
         NumberFormat f = NumberFormat.getDecimalFormat();
 
+        double[] values = new double[parts.length];
+
         int i = 0;
-        for (String part: parts) {
+        OUTER: for (String part: parts) {
             try {
-                values[i++] = f.parse(part);
+                double x = f.parse(part);
+                for (int j = 0; j < i; ++j) {
+                    if (values[j] == x) {
+                        continue OUTER;
+                    }
+                }
+                values[i++] = x;
             }
             catch (NumberFormatException nfe) {
                 // do nothing
             }
         }
 
-        return values;
+        double [] out = new double[i];
+        System.arraycopy(values, 0, out, 0, i);
+
+        return out;
     }
 
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleRangePanel.java	Tue Jun 14 16:43:09 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleRangePanel.java	Wed Jun 15 08:28:54 2011 +0000
@@ -178,7 +178,9 @@
     protected double getDouble(String value) {
         NumberFormat f = NumberFormat.getDecimalFormat();
 
-        return f.parse(value);
+        String[] splitted = value.split(" ");
+
+        return f.parse(splitted[0]);
     }
 
 

http://dive4elements.wald.intevation.org