changeset 2663:33d61e2a49a2

Added and respect two new properties of waterlevels in cross-sections. flys-artifacts/trunk@4339 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 03 May 2012 08:56:19 +0000
parents bdc86e61428c
children 3c4ec3b50af7
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/themes.xml flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java
diffstat 4 files changed, 43 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu May 03 07:48:12 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu May 03 08:56:19 2012 +0000
@@ -1,3 +1,13 @@
+2012-05-03	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* doc/conf/themes.xml: Add two new options for waterlevel label in cs.
+
+	* src/main/java/de/intevation/flys/utils/ThemeUtil.java:
+	  Parse new theme properties.
+
+	* src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java:
+	  Adjust label according to chosen properties.
+
 2012-05-03	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/utils/ThemeUtil.java
--- a/flys-artifacts/doc/conf/themes.xml	Thu May 03 07:48:12 2012 +0000
+++ b/flys-artifacts/doc/conf/themes.xml	Thu May 03 08:56:19 2012 +0000
@@ -585,6 +585,8 @@
         <fields>
             <field name="linecolor" type="Color" display="Linienfarbe" default="0,0,153"/>
             <field name="linesize"  type="int"   display="Liniendicke" default="1" hints="h"/>
+            <field name="showwidth" type="boolean" display="Breite anzeigen" default="false"/>
+            <field name="showlevel" type="boolean" display="Wasserstand anzeigen" default="false"/>
         </fields>
     </theme>
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Thu May 03 07:48:12 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Thu May 03 08:56:19 2012 +0000
@@ -25,6 +25,8 @@
 
 import de.intevation.flys.geom.Lines;
 
+import de.intevation.flys.utils.ThemeUtil;
+
 
 /**
  * An OutGenerator that generates cross section graphs.
@@ -221,9 +223,20 @@
         Lines.LineData lines = (Lines.LineData) o;
         // DO NOT SORT DATA! This destroys the gaps indicated by NaNs
         StyledXYSeries series = new StyledXYSeries(seriesName, false, theme);
-        // TODO Label for line with infos if wished.
 
-        series.setLabel(series.getLabel() + lines.width);
+        // TODO i18n for all the label text and number format.
+        if (ThemeUtil.parseShowWidth(theme)) {
+            series.setLabel(series.getLabel() + ", b=" + lines.width + "m");
+        }
+        else {
+            // Do not modify.
+            //series.setLabel(series.getLabel());
+        }
+        if (ThemeUtil.parseShowLevel(theme) && lines.points.length >0 && lines.points[1].length > 0) {
+            series.setLabel(series.getLabel() + ", W=" + lines.points[1][0] + "NN+m");
+        }
+        // TODO Missing: "mittlere hoehe" (and area but this geos to
+        //                                 the area theme).
         
         StyledSeriesBuilder.addPoints(series, lines.points);
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Thu May 03 07:48:12 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Thu May 03 08:56:19 2012 +0000
@@ -73,6 +73,12 @@
     public final static String XPATH_LINE_LABEL_SHOWBG =
         "/theme/field[@name='linelabelshowbg']/@default";
 
+    public final static String XPATH_SHOW_WIDTH =
+        "/theme/field[@name='showwidth']/@default";
+
+    public final static String XPATH_SHOW_LEVEL =
+        "/theme/field[@name='showwidth']/@default";
+
     public final static String XPATH_TRANSPARENCY =
         "/theme/field[@name='transparent']/@default";
 
@@ -343,6 +349,16 @@
     }
 
 
+    public static boolean parseShowWidth(Document theme) {
+        String show = XMLUtils.xpathString(theme, XPATH_SHOW_WIDTH, null);
+        return parseBoolean(show, false);
+    }
+
+    public static boolean parseShowLevel(Document theme) {
+        String show = XMLUtils.xpathString(theme, XPATH_SHOW_LEVEL, null);
+        return parseBoolean(show, false);
+    }
+
     /**
      * Parses the textorientation, defaults to 'vertical'.
      * @param theme The theme.

http://dive4elements.wald.intevation.org