[PATCH 2 of 3] issue1606: Added methods to parse omitted theme properties

Wald Commits scm-commit at wald.intevation.org
Tue Nov 19 10:20:06 CET 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1384852765 -3600
# Node ID 8ebca831486b3ebe7209ff8d188e4302e8371909
# Parent  b2d750a6df9f9fbe68fb2aec50d78cc8249fc558
issue1606: Added methods to parse omitted theme properties.

diff -r b2d750a6df9f -r 8ebca831486b artifacts/src/main/java/org/dive4elements/river/themes/ThemeDocument.java
--- 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) {


More information about the Dive4elements-commits mailing list