[Dive4elements-commits] [PATCH 3 of 5] Fixed and improved theme handling for areas

Wald Commits scm-commit at wald.intevation.org
Mon Dec 17 15:54:55 CET 2012


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1355754773 -3600
# Node ID 85876e3a53465814caa938fc85712ca9dc20c1f2
# Parent  ffe273af84fb2e5b144fb33f0877637b257ff8ac
Fixed and improved theme handling for areas.

diff -r ffe273af84fb -r 85876e3a5346 flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledAreaSeriesCollection.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledAreaSeriesCollection.java	Mon Dec 17 15:31:07 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledAreaSeriesCollection.java	Mon Dec 17 15:32:53 2012 +0100
@@ -84,9 +84,9 @@
 
     protected void applyFillColor(StableXYDifferenceRenderer renderer) {
         Color paint = ThemeUtil.parseColor(
-                ThemeUtil.getBackgroundColorString(theme));
+                ThemeUtil.getAreaBackgroundColorString(theme));
 
-        int transparency = ThemeUtil.parseTransparency(theme);
+        int transparency = ThemeUtil.parseAreaTransparency(theme);
         if (transparency > 0 && paint != null) {
             paint = new Color(
                         paint.getRed(),
@@ -113,7 +113,7 @@
 
 
     protected void applyShowShape(StableXYDifferenceRenderer renderer) {
-        boolean show = ThemeUtil.parseShowBorder(theme);
+        boolean show = ThemeUtil.parseAreaShowBorder(theme);
         renderer.setDrawOutline(show);
     }
 
diff -r ffe273af84fb -r 85876e3a5346 flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledDomainMarker.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledDomainMarker.java	Mon Dec 17 15:31:07 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledDomainMarker.java	Mon Dec 17 15:32:53 2012 +0100
@@ -16,19 +16,21 @@
 
     private static final long serialVersionUID = -4369417661339512342L;
 
-    private final Color fillColor, backgroundColor;
+    private final Color backgroundColor, backgroundColor2;
 
     public StyledDomainMarker(double start, double end, Document theme) {
         super(start, end);
 
         backgroundColor = ThemeUtil.parseColor(
-                ThemeUtil.getBackgroundColorString(theme));
-        fillColor = ThemeUtil.parseColor(
-                ThemeUtil.getFillColorString(theme));
+                ThemeUtil.getAreaBackgroundColorString(theme));
+        backgroundColor2 = new Color(
+            255 - backgroundColor.getRed(),
+            255 - backgroundColor.getGreen(),
+            255 - backgroundColor.getBlue());
         useSecondColor(false);
 
         int alpha = 100 - ThemeUtil.parseInteger(
-                ThemeUtil.getTransparencyString(theme), 50);
+                ThemeUtil.getAreaTransparencyString(theme), 50);
         setAlpha(alpha / 100.0f);
     }
 
@@ -38,13 +40,13 @@
      * @param secondColor
      */
     public void useSecondColor(boolean secondColor) {
-        if(secondColor) {
+        if(!secondColor) {
             if(backgroundColor != null)
                 setPaint(backgroundColor);
         }
         else {
-            if(fillColor != null)
-                setPaint(fillColor);
+            if(backgroundColor2 != null)
+                setPaint(backgroundColor2);
         }
     }
 }
diff -r ffe273af84fb -r 85876e3a5346 flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledValueMarker.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledValueMarker.java	Mon Dec 17 15:31:07 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledValueMarker.java	Mon Dec 17 15:32:53 2012 +0100
@@ -19,7 +19,7 @@
     public StyledValueMarker(double value, Document theme) {
         super(value);
 
-        Color color = ThemeUtil.parseLineColorField(theme);
+        Color color = ThemeUtil.parseAreaBackgroundColor(theme);
         if(color == null) {
             color = Color.BLACK;
         }
diff -r ffe273af84fb -r 85876e3a5346 flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Mon Dec 17 15:31:07 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Mon Dec 17 15:32:53 2012 +0100
@@ -29,6 +29,9 @@
     public final static String XPATH_LINE_COLOR =
             "/theme/field[@name='linecolor']/@default";
 
+    public final static String XPATH_AREA_LINE_COLOR =
+            "/theme/field[@name='areabordercolor']/@default";
+
     public static final String XPATH_LINE_SIZE =
             "/theme/field[@name='linesize']/@default";
 
@@ -44,6 +47,9 @@
     public final static String XPATH_SHOW_BORDER =
             "/theme/field[@name='showborder']/@default";
 
+    public final static String XPATH_AREA_SHOW_BORDER =
+            "/theme/field[@name='showborder']/@default";
+
     public final static String XPATH_SHOW_POINTS =
             "/theme/field[@name='showpoints']/@default";
 
@@ -71,6 +77,9 @@
     public final static String XPATH_TRANSPARENCY =
             "/theme/field[@name='transparency']/@default";
 
+    public final static String XPATH_AREA_TRANSPARENCY =
+            "/theme/field[@name='areatransparency']/@default";
+
     public final static String XPATH_SHOW_AREA =
             "/theme/field[@name='showarea']/@default";
 
@@ -101,6 +110,9 @@
     public final static String XPATH_BACKGROUND_COLOR =
             "/theme/field[@name='backgroundcolor']/@default";
 
+    public final static String XPATH_AREA_BACKGROUND_COLOR =
+            "/theme/field[@name='areabgcolor']/@default";
+
     public final static String XPATH_SYMBOL =
             "/theme/field[@name='symbol']/@default";
 
@@ -570,6 +582,11 @@
     }
 
 
+    public static String getAreaTransparencyString(Document theme) {
+        return XMLUtils.xpathString(theme, XPATH_AREA_TRANSPARENCY, null);
+    }
+
+
     public static String getShowMinimum(Document theme) {
         return XMLUtils.xpathString(theme, XPATH_SHOW_MINIMUM, null);
     }
@@ -613,6 +630,19 @@
     }
 
 
+    public static Color parseAreaLineColorField(Document theme) {
+        String lineColorStr = getAreaLineColorString(theme);
+        logger.debug("parseLineColorField: lineColorStr = " +
+                (lineColorStr == null ? "null" : lineColorStr));
+        return parseColor(lineColorStr);
+    }
+
+
+    private static String getAreaLineColorString(Document theme) {
+        return XMLUtils.xpathString(theme, XPATH_AREA_LINE_COLOR, null);
+    }
+
+
     public static boolean parseShowMinimum(Document theme) {
         return parseBoolean(getShowMinimum(theme), false);
     }
@@ -723,5 +753,30 @@
 
         return ms.toString();
     }
+
+
+    public static String getAreaBackgroundColorString(Document theme) {
+        return XMLUtils.xpathString(theme, XPATH_AREA_BACKGROUND_COLOR, null);
+    }
+
+
+    public static Color parseAreaBackgroundColor(Document theme) {
+        return parseColor(getAreaBackgroundColorString(theme));
+    }
+
+
+    public static int parseAreaTransparency(Document theme) {
+        return parseInteger(getAreaTransparencyString(theme), 50);
+    }
+
+
+    public static boolean parseAreaShowBorder(Document theme) {
+        return parseBoolean(getAreaShowBorderString(theme), false);
+    }
+
+
+    private static String getAreaShowBorderString(Document theme) {
+        return XMLUtils.xpathString(theme, XPATH_AREA_SHOW_BORDER, null);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :


More information about the Dive4elements-commits mailing list