teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.themes; sascha@1754: teichmann@5831: import org.dive4elements.river.utils.ThemeUtil; christian@3286: sascha@1754: import java.awt.Color; sascha@1754: import java.awt.Font; sascha@1754: sascha@1754: import org.w3c.dom.Document; sascha@1754: felix@2152: sascha@1754: public class ThemeAccess sascha@1754: { sascha@1754: protected Document theme; sascha@1754: sascha@1754: protected Integer lineWidth; sascha@1754: sascha@1754: protected Color lineColor; sascha@1754: protected Color textColor; sascha@1754: protected Font font; sascha@1754: protected String textOrientation; sascha@1754: protected Color textBackground; sascha@1754: protected Boolean showTextBackground; ingo@3090: protected Color pointColor; sascha@1754: felix@2152: sascha@1754: public ThemeAccess(Document theme) { sascha@1754: this.theme = theme; sascha@1754: } sascha@1754: felix@2152: sascha@1754: public int parseLineWidth() { sascha@1754: if (lineWidth == null) { sascha@1754: lineWidth = ThemeUtil.parseLineWidth(theme); sascha@1754: } sascha@1754: return lineWidth; sascha@1754: } sascha@1754: felix@2152: sascha@1754: public Color parseLineColorField() { sascha@1754: if (lineColor == null) { sascha@1754: lineColor = ThemeUtil.parseLineColorField(theme); sascha@1754: if (lineColor == null) { sascha@1754: lineColor = Color.BLACK; sascha@1754: } sascha@1754: } sascha@1754: return lineColor; sascha@1754: } sascha@1754: sascha@3076: sascha@1754: public Color parseTextColor() { sascha@1754: if (textColor == null) { sascha@1754: textColor = ThemeUtil.parseTextColor(theme); sascha@1754: if (textColor == null) { sascha@1754: textColor = Color.BLACK; sascha@1754: } sascha@1754: } sascha@1754: return textColor; sascha@1754: } sascha@1754: felix@2152: sascha@1754: public Font parseTextFont() { sascha@1754: if (font == null) { sascha@1754: font = ThemeUtil.parseTextFont(theme); sascha@1754: if (font == null) { sascha@1754: font = new Font("Arial", Font.BOLD, 10); sascha@1754: } sascha@1754: } sascha@1754: return font; sascha@1754: } sascha@1754: felix@2152: sascha@1754: public String parseTextOrientation() { sascha@1754: if (textOrientation == null) { sascha@1754: textOrientation = ThemeUtil.parseTextOrientation(theme); sascha@1754: } sascha@1754: return textOrientation; sascha@1754: } sascha@1754: sascha@1754: sascha@1754: public Color parseTextBackground() { sascha@1754: if (textBackground == null) { sascha@1754: textBackground = ThemeUtil.parseTextBackground(theme); sascha@1754: if (textBackground == null) { sascha@1754: textBackground = Color.WHITE; sascha@1754: } sascha@1754: } sascha@1754: return textBackground; sascha@1754: } sascha@1754: christian@3464: public boolean parseLabelShowBackground() { sascha@1754: if (showTextBackground == null) { christian@3464: showTextBackground = ThemeUtil.parseLabelShowBackground(theme); sascha@1754: } sascha@1754: return showTextBackground; sascha@1754: } sascha@1754: sascha@1754: ingo@3090: public Color parsePointColor() { ingo@3090: if (pointColor == null) { ingo@3090: pointColor = ThemeUtil.parsePointColor(theme); ingo@3090: ingo@3090: if (pointColor == null) { ingo@3090: return parseLineColorField(); ingo@3090: } ingo@3090: } ingo@3090: ingo@3090: return pointColor; ingo@3090: } ingo@3090: ingo@3090: felix@2161: public LineStyle parseLineStyle() { felix@2161: return new LineStyle(parseLineColorField(), Integer.valueOf(parseLineWidth())); felix@2161: } felix@2161: felix@2152: public TextStyle parseTextStyle() { christian@3205: return new TextStyle( christian@3205: parseTextColor(), christian@3205: parseTextFont(), christian@3205: parseTextBackground(), christian@3464: parseLabelShowBackground(), felix@2416: !parseTextOrientation().equals("horizontal")); felix@2152: } sascha@1754: } sascha@1754: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :