diff flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java @ 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 469528551b78
children 756bd8f0b97c
line wrap: on
line diff
--- 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;
     }
 
 

http://dive4elements.wald.intevation.org