changeset 7582:8ebca831486b

issue1606: Added methods to parse omitted theme properties.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 19 Nov 2013 10:19:25 +0100
parents b2d750a6df9f
children 4b67eb1a3a68
files artifacts/src/main/java/org/dive4elements/river/themes/ThemeDocument.java
diffstat 1 files changed, 49 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/themes/ThemeDocument.java	Tue Nov 19 10:17:59 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/themes/ThemeDocument.java	Tue Nov 19 10:19:25 2013 +0100
@@ -85,6 +85,12 @@
 
     public final static String LABEL_FONT_STYLE = "labelfontstyle";
 
+    public final static String FONT = "font";
+
+    public final static String TEXT_SIZE = "textsize";
+
+    public final static String TEXT_STYLE = "textstyle";
+
     public final static String TEXT_ORIENTATION = "textorientation";
 
     public final static String LABEL_BGCOLOR = "labelbgcolor";
@@ -250,6 +256,19 @@
         return parseBoolean(show, false);
     }
 
+    public Font parseFont() {
+        String font = getValue(FONT);
+        logger.debug(" font is " + font);
+        if (font == null) {
+            return null;
+        }
+
+        int size = parseFontSize();
+        int style = parseFontStyle();
+        Font f = new Font(font, style, size);
+        return f;
+    }
+
     public Font parseTextFont() {
         String font = getValue(LABEL_FONT_FACE);
         if (font == null) {
@@ -342,6 +361,21 @@
         return parseBoolean(show, true);
     }
 
+    public int parseFontStyle() {
+        String style = getValue(TEXT_STYLE);
+        if (style == null) {
+            return Font.PLAIN;
+        }
+
+        if (style.equals("italic")) {
+            return Font.ITALIC;
+        }
+        if (style.equals("bold")) {
+            return Font.BOLD;
+        }
+        return Font.PLAIN;
+    }
+
     public int parseTextStyle() {
         String style = getValue(LABEL_FONT_STYLE);
         if (style == null) {
@@ -443,6 +477,21 @@
             : null;
     }
 
+    public int parseFontSize() {
+        String size = getValue(TEXT_SIZE);
+        if (size == null) {
+            return 10;
+        }
+
+        try {
+            return Integer.parseInt(size);
+        }
+        catch (NumberFormatException nfe) {
+            // Do nothing
+        }
+        return 10;
+    }
+
     public int parseTextSize() {
         String size = getValue(LABEL_FONT_SIZE);
         if (size == null) {

http://dive4elements.wald.intevation.org