changeset 3399:e08a6352fe24

Change bandwidth theme attribute type to double (but bugged). flys-artifacts/trunk@5035 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 18 Jul 2012 10:02:37 +0000
parents 7f9fe694f8d1
children 2eea676ba48f
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/default-themes.xml flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java
diffstat 4 files changed, 42 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Jul 18 09:54:46 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Jul 18 10:02:37 2012 +0000
@@ -1,3 +1,11 @@
+2012-07-18	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* doc/conf/default-themes.xml,
+	  src/main/java/de/intevation/flys/utils/ThemeUtil.java,
+	  src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java:
+	  Change bandwidth type to double (still bugged, round integers still
+	  work, though).
+
 2012-07-18	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/fixings/DeltaWtExporter.java:
--- a/flys-artifacts/doc/conf/default-themes.xml	Wed Jul 18 09:54:46 2012 +0000
+++ b/flys-artifacts/doc/conf/default-themes.xml	Wed Jul 18 10:02:37 2012 +0000
@@ -48,7 +48,7 @@
             <inherit from="MinMaxPoints" />
         </inherits>
         <fields>
-            <field name="bandwidth" type="int" display="Bandbreite"
+            <field name="bandwidth" type="double" display="Bandbreite"
                 default="0"/> 
             <field name="linecolor" type="Color" display="Linienfarbe"
                 default="204, 204, 204" />
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Wed Jul 18 09:54:46 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Wed Jul 18 10:02:37 2012 +0000
@@ -433,7 +433,7 @@
         addAxisSeries(series, YAXIS.W.idx, visible);
 
         // If a "band around the curve shall be drawn, add according area.
-        int bandWidth = ThemeUtil.parseBandWidth(theme);
+        double bandWidth = ThemeUtil.parseBandWidth(theme);
         if (bandWidth > 0 ) {
             XYSeries seriesDown = new StyledXYSeries(
                 "band " + aandf.getFacetDescription(), false, theme);
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Wed Jul 18 09:54:46 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Wed Jul 18 10:02:37 2012 +0000
@@ -156,6 +156,13 @@
     }
 
 
+    /**
+     * Attempt converting \param value to an integer, in failing cases,
+     * return \param defaultsTo.
+     * @param value String to be converted to integer.
+     * @param defaultsTo Default to return if conversion failed.
+     * @return \param value as integer or defaultsto if conversion failed.
+     */
     public static int parseInteger(String value, int defaultsTo) {
         if (value == null || value.length() == 0) {
             return defaultsTo;
@@ -173,6 +180,29 @@
 
 
     /**
+     * Attempt converting \param value to a double, in failing cases,
+     * return \param defaultsTo.
+     * @param value String to be converted to double.
+     * @param defaultsTo Default to return if conversion failed.
+     * @return \param value as integer or defaultsto if conversion failed.
+     */
+    public static double parseDouble(String value, double defaultsTo) {
+        if (value == null || value.length() == 0) {
+            return defaultsTo;
+        }
+
+        try {
+            return Double.valueOf(value);
+        }
+        catch (NumberFormatException nfe) {
+            // do nothing
+        }
+
+        return defaultsTo;
+    }
+
+
+    /**
      * Parses line width, defaulting to 0.
      * @param theme the theme
      */
@@ -196,10 +226,10 @@
      * Parse band width, defaulting to 0.
      * @param theme the theme.
      */
-    public static int parseBandWidth(Document theme) {
+    public static double parseBandWidth(Document theme) {
         String bandWidth = XMLUtils.xpathString(theme, XPATH_BANDWIDTH, null);
 
-        return parseInteger(bandWidth, 0);
+        return parseDouble(bandWidth, 0);
     }
 
 

http://dive4elements.wald.intevation.org