changeset 4577:1c6c2ddac3d6

Work on dynamic color classes for floodmap (work in progress, not yet functional).
author Christian Lins <christian.lins@intevation.de>
date Tue, 27 Nov 2012 15:51:28 +0100 (2012-11-27)
parents 32a4651eef93
children 8304f982984f
files flys-artifacts/doc/conf/default-themes.xml flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties flys-client/src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java
diffstat 8 files changed, 103 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/default-themes.xml	Tue Nov 27 14:20:46 2012 +0100
+++ b/flys-artifacts/doc/conf/default-themes.xml	Tue Nov 27 15:51:28 2012 +0100
@@ -156,7 +156,7 @@
             <field name="showpoints" type="boolean" display="Datenpunkte anzeigen"
                 default="false" hidden="true" />
             <field name="pointsize" type="int" display="Punktdicke"
-                default="5" hidden="true" />   
+                default="5" hidden="true" />
             <field name="showlinelabel" type="boolean"
                 display="Beschriftung anzeigen" default="false" hidden="true" />
             <field name="labelfontface" type="Font"
@@ -186,7 +186,7 @@
             <field name="bandwidth" type="double" display="Bandbreite"
                 default="0"/>
             <field name="fillcolor" type="Color" display="Bandbreitenfarbe"
-                default="104, 104, 104"/> 
+                default="104, 104, 104"/>
     	    <field name="transparency" type="int" default="20" display="Transparenz"/>
             <field name="linecolor" type="Color" display="Linienfarbe"
                 default="204, 204, 204" />
@@ -1132,6 +1132,14 @@
         <inherits>
             <inherit from="WSPLGENS" />
         </inherits>
+        <fields>
+            <field name="startcolor" type="Color"
+                display="Farbverlauf Startfarbe" default="178, 201, 215" />
+            <field name="endcolor" type="Color"
+                display="Farbverlauf Endfarbe" default="2, 27, 42" />
+            <field name="numclasses" type="int" display="Anzahl Klassen"
+                default="5" />
+        </fields>
     </theme>
 
     <theme name="RiverAxis">
@@ -1224,7 +1232,7 @@
                 default="0, 0, 102" />
         </fields>
     </theme>
-    
+
     <!-- Bed Quality -->
     <theme name="PorosityTopLayer">
     	<inherits>
@@ -1236,7 +1244,7 @@
                 default="0, 0, 0" />
         </fields>
     </theme>
-    
+
     <theme name="PorositySubLayer">
     	<inherits>
     		<inherit from="HiddenColorLines" />
@@ -1247,7 +1255,7 @@
                 default="0, 0, 0" />
         </fields>
     </theme>
-    
+
     <theme name="DensityTopLayer">
     	<inherits>
     		<inherit from="HiddenColorLines" />
@@ -1258,7 +1266,7 @@
                 default="#996366" />
         </fields>
     </theme>
-    
+
     <theme name="DensitySubLayer">
     	<inherits>
     		<inherit from="HiddenColorLines" />
@@ -1269,7 +1277,7 @@
                 default="#996366" />
         </fields>
     </theme>
-    
+
     <theme name="BedDiameterTopLayer">
     	<inherits>
     		<inherit from="HiddenColorLines" />
@@ -1280,7 +1288,7 @@
                 default="#FF0000" />
         </fields>
     </theme>
-    
+
     <theme name="BedDiameterSubLayer">
     	<inherits>
     		<inherit from="HiddenColorLines" />
@@ -1291,7 +1299,7 @@
                 default="#FF0000" />
         </fields>
     </theme>
-    
+
     <theme name="BedLoadDiameter">
     	<inherits>
     		<inherit from="HiddenColorLines" />
@@ -1762,7 +1770,7 @@
             <field name="backgroundcolor" type="Color" default="255, 0, 0" display="Füllfarbe" />
     	</fields>
     </theme>
-    
+
     <theme name="FixingReferencePeriod">
         <inherits>
     		<inherit from="Areas"/>
@@ -1823,7 +1831,7 @@
                 display="Beschriftung anzeigen" default="false" hints="h" />
         </fields>
     </theme>
- 
+
     <theme name="SedimentLoadSuspSand">
         <inherits>
             <inherit from="HiddenColorLines" />
@@ -1874,6 +1882,6 @@
                 display="Beschriftung anzeigen" default="false" hints="h" />
         </fields>
     </theme>
- 
-    
+
+
 </themegroup>
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java	Tue Nov 27 14:20:46 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java	Tue Nov 27 15:51:28 2012 +0100
@@ -108,7 +108,6 @@
 
             if (FLOODMAP_WSPLGEN.equals(name)) {
                 setInitialExtent(extent);
-                logger.debug("MapGenerator.doOut(): attr = " + XMLUtils.toString(attr));
                 createWSPLGENLayer(flys, wms, attr);
             }
             else if (FLOODMAP_BARRIERS.equals(name)) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Tue Nov 27 14:20:46 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Tue Nov 27 15:51:28 2012 +0100
@@ -117,6 +117,15 @@
     public final static String XPATH_WSPLGEN_FIELDS =
             "/theme[@name='WSPLGEN']/field";
 
+    public final static String XPATH_WSPLGEN_STARTCOLOR =
+            "/theme/field[@name='startcolor'/@default";
+
+    public final static String XPATH_WSPLGEN_ENDCOLOR =
+            "/theme/field[@name='endcolor'/@default";
+
+    public final static String XPATH_WSPLGEN_NUMCLASSES =
+            "/theme/field[@name='numclasses'/@default";
+
     /** XPATH to bandwidth field. */
     public final static String XPATH_BANDWIDTH =
             "/theme/field[@name='bandwidth']/@default";
@@ -619,6 +628,45 @@
 
 
     public static String createWSPLGENStyle(Document theme) {
+        MapserverStyle ms = new MapserverStyle();
+
+        Color startColor = parseColor(
+                XMLUtils.xpathString(theme, XPATH_WSPLGEN_STARTCOLOR, null));
+        Color endColor = parseColor(
+                XMLUtils.xpathString(theme, XPATH_WSPLGEN_ENDCOLOR, null));
+        int numClasses = Integer.parseInt(
+                XMLUtils.xpathString(theme, XPATH_WSPLGEN_NUMCLASSES, null));
+
+        if (numClasses < 5) {
+            numClasses = 5;
+        }
+        else if (numClasses > 20) {
+            numClasses = 20;
+        }
+
+        int rd = (startColor.getRed()   - endColor.getRed())   / numClasses;
+        int gd = (startColor.getGreen() - endColor.getGreen()) / numClasses;
+        int bd = (startColor.getBlue()  - endColor.getBlue())  / numClasses;
+
+        for (int n = 0; n < numClasses; n++) {
+            StringBuilder newColor = new StringBuilder();
+            newColor.append(startColor.getRed()   + n * rd);
+            newColor.append(' ');
+            newColor.append(startColor.getGreen() + n * gd);
+            newColor.append(' ');
+            newColor.append(startColor.getBlue()  + n * bd);
+
+            Clazz c = new Clazz("Klasse " + n + " (FIXME)");
+            Style s = new Style();
+            s.setColor(newColor.toString());
+            s.setSize(5);
+
+            c.addItem(new Expression("Klasse " + n));
+            c.addItem(s);
+
+            ms.addClazz(c);
+        }
+
         NodeList categories = (NodeList) XMLUtils.xpath(
                 theme,
                 XPATH_WSPLGEN_FIELDS,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Tue Nov 27 14:20:46 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Tue Nov 27 15:51:28 2012 +0100
@@ -1098,5 +1098,11 @@
 
     String projectlist_close();
 
+    String startcolor();
+
+    String endcolor();
+
+    String numclasses();
+
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Tue Nov 27 14:20:46 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Tue Nov 27 15:51:28 2012 +0100
@@ -442,6 +442,10 @@
 bedheights = Bedheights
 datacage = Datacage
 
+startcolor = Colorrange start color
+endcolor = Colorrange end color
+numclasses = Number of classes
+
 # capabilities information panel
 addwmsInputTitle = Base URL of WMS service
 addwmsInfoTitle = Information about WMS service
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Tue Nov 27 14:20:46 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Tue Nov 27 15:51:28 2012 +0100
@@ -443,6 +443,10 @@
 bedheights = Sohlh\u00f6hen
 datacage = Datenkorb
 
+startcolor = Farbverlauf Startfarbe
+endcolor = Farbverlauf Endfarbe
+numclasses = Anzahl Klassen
+
 # capabilities information panel
 addwmsInputTitle = Basis URL des WMS Dienstes
 addwmsInfoTitle = Informationen des WMS Dienstes
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Tue Nov 27 14:20:46 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Tue Nov 27 15:51:28 2012 +0100
@@ -443,6 +443,10 @@
 bedheights = Bedheights
 datacage = Datacage
 
+startcolor = Colorrange start color
+endcolor = Colorrange end color
+numclasses = Number of classes
+
 # capabilities information panel
 addwmsInputTitle = Base URL of WMS service
 addwmsInfoTitle = Information about WMS service
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java	Tue Nov 27 14:20:46 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java	Tue Nov 27 15:51:28 2012 +0100
@@ -410,6 +410,22 @@
                 f.setValueMap(valueMap);
                 f.setValue(value);
             }
+            else if (name.equals("numclasses")) {
+                LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
+                valueMap.put("5", "5");
+                valueMap.put("6", "6");
+                valueMap.put("7", "7");
+                valueMap.put("8", "8");
+                valueMap.put("9", "9");
+                valueMap.put("10", "10");
+                valueMap.put("12", "12");
+                valueMap.put("14", "14");
+                valueMap.put("16", "16");
+                valueMap.put("18", "18");
+                valueMap.put("20", "20");
+                f.setValueMap(valueMap);
+                f.setValue(value);
+            }
             else if (name.equals("transparency")) {
                 LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
                 for (int n = 10; n < 100; n += 10) {

http://dive4elements.wald.intevation.org