changeset 1878:84cf67a2a19e

Added support for fillcolors of polygons in floodmaps. flys-artifacts/trunk@3237 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 11 Nov 2011 11:28:15 +0000
parents 1a6018d5f0b7
children d7369f395a80
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/themes.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MapserverStyle.java flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java
diffstat 4 files changed, 45 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Nov 11 11:00:31 2011 +0000
+++ b/flys-artifacts/ChangeLog	Fri Nov 11 11:28:15 2011 +0000
@@ -1,3 +1,15 @@
+2011-11-11  Ingo Weinzierl <ingo@intevation.de>
+
+	* doc/conf/themes.xml: Modified some floodmap styles and added a
+	  backgroundcolor attribute to polygon themes.
+
+	* src/main/java/de/intevation/flys/artifacts/model/MapserverStyle.java:
+	  Added support for backgroundcolor.
+
+	* src/main/java/de/intevation/flys/utils/ThemeUtil.java: Parse
+	  backgroundcolor from theme document. If a value is given, the
+	  backgroundcolor is set on the Mapserver style.
+
 2011-11-11  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/MapserverStyle.java:
--- a/flys-artifacts/doc/conf/themes.xml	Fri Nov 11 11:00:31 2011 +0000
+++ b/flys-artifacts/doc/conf/themes.xml	Fri Nov 11 11:28:15 2011 +0000
@@ -719,7 +719,7 @@
     <theme name="RiverAxis">
         <fields>
             <field name="linecolor" type="Color" display="Linienfarbe" default="0, 0, 205"/>
-            <field name="linesize"  type="int"   display="Liniendicke" default="5" hints="h"/>
+            <field name="linesize"  type="int"   display="Liniendicke" default="3" hints="h"/>
         </fields>
     </theme>
 
@@ -736,7 +736,7 @@
     <theme name="Fixpoints">
         <fields>
             <field name="linecolor" type="Color" display="Linienfarbe" default="255, 0, 0"/>
-            <field name="linesize"  type="int"   display="Liniendicke" default="5" hints="h"/>
+            <field name="linesize"  type="int"   display="Liniendicke" default="3" hints="h"/>
             <field name="symbol"    type="Symbol" display="Symbol"     default="point"/>
         </fields>
     </theme>
@@ -744,35 +744,37 @@
     <theme name="Qps">
         <fields>
             <field name="linecolor" type="Color" display="Linienfarbe" default="0, 0, 255"/>
-            <field name="linesize"  type="int"   display="Liniendicke" default="5" hints="h"/>
+            <field name="linesize"  type="int"   display="Liniendicke" default="3" hints="h"/>
         </fields>
     </theme>
 
     <theme name="Hws">
         <fields>
             <field name="linecolor" type="Color" display="Linienfarbe" default="255, 0, 0"/>
-            <field name="linesize"  type="int"   display="Liniendicke" default="5" hints="h"/>
+            <field name="linesize"  type="int"   display="Liniendicke" default="3" hints="h"/>
         </fields>
     </theme>
 
     <theme name="Catchment">
         <fields>
-            <field name="linecolor" type="Color" display="Linienfarbe" default="255, 0, 0"/>
-            <field name="linesize"  type="int"   display="Liniendicke" default="5" hints="h"/>
+            <field name="linecolor" type="Color" display="Linienfarbe" default="0, 0, 0"/>
+            <field name="linesize"  type="int"   display="Liniendicke" default="1" hints="h"/>
+            <field name="backgroundcolor" type="Color" display="Hintergrund" default="140, 200, 130"/>
         </fields>
     </theme>
 
     <theme name="Floodplain">
         <fields>
-            <field name="linecolor" type="Color" display="Linienfarbe" default="140, 200, 130"/>
-            <field name="linesize"  type="int"   display="Liniendicke" default="5" hints="h"/>
+            <field name="linecolor" type="Color" display="Linienfarbe" default="0, 0, 0"/>
+            <field name="linesize"  type="int"   display="Liniendicke" default="1" hints="h"/>
+            <field name="backgroundcolor" type="Color" display="Hintergrund" default="140, 200, 130"/>
         </fields>
     </theme>
 
     <theme name="Lines">
         <fields>
             <field name="linecolor" type="Color" display="Linienfarbe" default="140, 200, 130"/>
-            <field name="linesize"  type="int"   display="Liniendicke" default="5" hints="h"/>
+            <field name="linesize"  type="int"   display="Liniendicke" default="3" hints="h"/>
         </fields>
     </theme>
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MapserverStyle.java	Fri Nov 11 11:00:31 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MapserverStyle.java	Fri Nov 11 11:28:15 2011 +0000
@@ -42,10 +42,15 @@
     }
 
     public static class Style implements ClazzItem {
+        protected String color;
         protected String outlinecolor;
         protected String symbol;
         protected int    size;
 
+        public void setColor(String color) {
+            this.color = color;
+        }
+
         public void setOutlineColor(String outlinecolor) {
             this.outlinecolor = outlinecolor;
         }
@@ -65,6 +70,10 @@
             sb.append("WIDTH " + String.valueOf(size) + "\n");
             sb.append("OUTLINECOLOR " + outlinecolor + "\n");
 
+            if (color != null) {
+                sb.append("COLOR " + color + "\n");
+            }
+
             if (symbol != null) {
                 sb.append("SYMBOL '" + symbol + "'\n");
             }
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Fri Nov 11 11:00:31 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Fri Nov 11 11:28:15 2011 +0000
@@ -239,7 +239,7 @@
      * @param theme The theme.
      */
     public static Color parseTextBackground(Document theme) {
-        String color = XMLUtils.xpathString(theme, XPATH_TEXT_BACKGROUND, null);
+        String color = getBackgroundColorString(theme);
         if (color == null || color.length() == 0) {
             return Color.WHITE;
         }
@@ -296,6 +296,11 @@
     }
 
 
+    public static String getBackgroundColorString(Document theme) {
+        return XMLUtils.xpathString(theme, XPATH_TEXT_BACKGROUND, null);
+    }
+
+
     public static String getTextColorString(Document theme) {
         return XMLUtils.xpathString(theme, XPATH_TEXT_COLOR, null);
     }
@@ -318,8 +323,8 @@
 
     public static String createMapserverStyle(Document theme) {
         String symbol    = getSymbol(theme);
+        String backcolor = getBackgroundColorString(theme);
         String linecolor = getLineColorString(theme);
-        linecolor        = linecolor.replace(",", "");
 
         int linewidth = parseLineWidth(theme);
 
@@ -328,7 +333,12 @@
         Clazz c = new Clazz(" ");
 
         Style s = new Style();
-        s.setOutlineColor(linecolor);
+        s.setOutlineColor(linecolor.replace(",", ""));
+
+        if (backcolor != null && backcolor.length() > 0) {
+            s.setColor(backcolor.replace(",", ""));
+        }
+
         s.setSize(linewidth);
         s.setSymbol(symbol);
         c.addItem(s);

http://dive4elements.wald.intevation.org