diff flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java @ 2656:f1dcd5f94ffa

Parse more theme properties for linelabels. flys-artifacts/trunk@4327 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 02 May 2012 15:09:04 +0000
parents 8aaa7f4ce06a
children 4d8959a4b49d
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Wed May 02 08:50:01 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Wed May 02 15:09:04 2012 +0000
@@ -55,6 +55,24 @@
     public final static String XPATH_SHOW_LINE_LABEL =
         "/theme/field[@name='showlinelabel']/@default";
 
+    public final static String XPATH_LINE_LABEL_FONT =
+        "/theme/field[@name='showlinelabelfont']/@default";
+
+    public final static String XPATH_LINE_LABEL_COLOR =
+        "/theme/field[@name='showlinelabelcolor']/@default";
+
+    public final static String XPATH_LINE_LABEL_SIZE =
+        "/theme/field[@name='showlinelabelsize']/@default";
+
+    public final static String XPATH_LINE_LABEL_STYLE =
+        "/theme/field[@name='showlinelabelstyle']/@default";
+
+    public final static String XPATH_LINE_LABEL_BGCOLOR =
+        "/theme/field[@name='showlinelabelbgcolor']/@default";
+
+    public final static String XPATH_LINE_LABEL_SHOWBG =
+        "/theme/field[@name='showlinelabelshowbg']/@default";
+
     public final static String XPATH_TRANSPARENCY =
         "/theme/field[@name='transparent']/@default";
 
@@ -187,8 +205,8 @@
      * Parses text size, defaulting to 10.
      * @param theme The theme.
      */
-    public static int parseTextSize(Document theme) {
-        String size = XMLUtils.xpathString(theme, XPATH_TEXT_SIZE, null);
+    public static int parseTextSize(Document theme, String path) {
+        String size = XMLUtils.xpathString(theme, path, null);
         if (size == null || size.length() == 0) {
             return 10;
         }
@@ -202,6 +220,16 @@
     }
 
 
+    public static int parseTextSize(Document theme) {
+        return parseTextSize(theme, XPATH_TEXT_SIZE);
+    }
+
+
+    public static int parseLineLabelSize(Document theme) {
+        return parseTextSize(theme, XPATH_LINE_LABEL_SIZE);
+    }
+
+
     /**
      * Parses the attribute 'showpoints', defaults to false.
      * @param theme The theme.
@@ -255,13 +283,27 @@
         return f;
     }
 
+    /** Parse font (name, size and style) for linelabels. */
+    public static Font parseLineLabelFont(Document theme) {
+        String font = XMLUtils.xpathString(theme, XPATH_LINE_LABEL_FONT, null);
+        if (font == null || font.length() == 0) {
+            return null;
+        }
+
+        int size = parseLineLabelSize(theme);
+        int style = parseLineLabelStyle(theme);
+
+        Font f = new Font (font, style, size);
+        return f;
+    }
+
 
     /**
      * Parses the text style, defaults to 'Font.PLAIN'.
      * @param theme The theme.
      */
-    public static int parseTextStyle(Document theme) {
-        String style = XMLUtils.xpathString(theme, XPATH_TEXT_STYLE, null);
+    public static int parseTextStyle(Document theme, String path) {
+        String style = XMLUtils.xpathString(theme, path, null);
         if (style == null || style.length() == 0) {
             return Font.PLAIN;
         }
@@ -278,6 +320,16 @@
     }
 
 
+    public static int parseTextStyle(Document theme) {
+        return parseTextStyle(theme, XPATH_TEXT_STYLE);
+    }
+
+
+    public static int parseLineLabelStyle(Document theme) {
+        return parseTextStyle(theme, XPATH_LINE_LABEL_STYLE);
+    }
+
+
     /**
      * Parses the textorientation, defaults to 'vertical'.
      * @param theme The theme.

http://dive4elements.wald.intevation.org