diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/MinMaxState.java @ 2205:a22e0cb6eace

Format the timerange (static ui) inserted in the 'historical discharge curves' calculation. flys-artifacts/trunk@3829 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 30 Jan 2012 13:29:07 +0000
parents d1660809daab
children ee5310134463
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/MinMaxState.java	Mon Jan 30 13:23:40 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/MinMaxState.java	Mon Jan 30 13:29:07 2012 +0000
@@ -57,6 +57,46 @@
 
 
     /**
+     * @param cc
+     * @param name
+     * @param value
+     * @param type
+     *
+     * @return
+     */
+    @Override
+    protected String getLabelFor(
+        CallContext cc,
+        String      name,
+        String      value,
+        String      type
+    ) {
+        if (type.indexOf("range") > 0) {
+            String[] minmax = extractRangeAsString(value);
+
+            if (minmax != null) {
+                return minmax[0] + " - " + minmax[1];
+            }
+        }
+
+        return super.getLabelFor(cc, name, value, type);
+    }
+
+
+    /**
+     * Returns a string array with [min,max] from <i>rawValue</i>.
+     * <i>rawValue</i> should be a string like "1999;2001".
+     *
+     * @param rawValue A string with min and max separated by a ';'.
+     *
+     * @return the min and max as string array ([min,max]).
+     */
+    protected String[] extractRangeAsString(String rawValue) {
+        return rawValue.split(";");
+    }
+
+
+    /**
      * This method returns the default values for min and max. If the static
      * field DefaultState.USE_DEFAULTS is set, the minimum and maximum inserted
      * by the user is returned as string. Otherwise, the absolute minimum and
@@ -100,7 +140,7 @@
 
         logger.debug("Raw value for '" + name + "' = " + rawValue);
 
-        return rawValue.split(";");
+        return extractRangeAsString(rawValue);
     }
 
 

http://dive4elements.wald.intevation.org