view artifacts/src/main/java/org/dive4elements/river/themes/ThemeAccess.java @ 5863:4897a58c8746

River artifacts: Added new copyright headers.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 28 Apr 2013 14:40:59 +0200
parents 5aa05a7a34b7
children af13ceeba52a
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU AGPL (>=v3) 
 * and comes with ABSOLUTELY NO WARRANTY! Check out the
 * documentation coming with Dive4Elements River for details. 
 */

package org.dive4elements.river.themes;

import org.dive4elements.river.utils.ThemeUtil;

import java.awt.Color;
import java.awt.Font;

import org.w3c.dom.Document;


public class ThemeAccess
{
    protected Document theme;

    protected Integer lineWidth;

    protected Color   lineColor;
    protected Color   textColor;
    protected Font    font;
    protected String  textOrientation;
    protected Color   textBackground;
    protected Boolean showTextBackground;
    protected Color   pointColor;


    public ThemeAccess(Document theme) {
        this.theme = theme;
    }


    public int parseLineWidth() {
        if (lineWidth == null) {
            lineWidth = ThemeUtil.parseLineWidth(theme);
        }
        return lineWidth;
    }


    public Color parseLineColorField() {
        if (lineColor == null) {
            lineColor = ThemeUtil.parseLineColorField(theme);
            if (lineColor == null) {
                lineColor = Color.BLACK;
            }
        }
        return lineColor;
    }


    public Color parseTextColor() {
        if (textColor == null) {
            textColor = ThemeUtil.parseTextColor(theme);
            if (textColor == null) {
                textColor = Color.BLACK;
            }
        }
        return textColor;
    }


    public Font parseTextFont() {
        if (font == null) {
            font = ThemeUtil.parseTextFont(theme);
            if (font == null) {
                font = new Font("Arial", Font.BOLD, 10);
            }
        }
        return font;
    }


    public String parseTextOrientation() {
        if (textOrientation == null) {
            textOrientation = ThemeUtil.parseTextOrientation(theme);
        }
        return textOrientation;
    }


    public Color parseTextBackground() {
        if (textBackground == null) {
            textBackground = ThemeUtil.parseTextBackground(theme);
            if (textBackground == null) {
                textBackground = Color.WHITE;
            }
        }
        return textBackground;
    }

    public boolean parseLabelShowBackground() {
        if (showTextBackground == null) {
            showTextBackground = ThemeUtil.parseLabelShowBackground(theme);
        }
        return showTextBackground;
    }


    public Color parsePointColor() {
        if (pointColor == null) {
            pointColor = ThemeUtil.parsePointColor(theme);

            if (pointColor == null) {
                return parseLineColorField();
            }
        }

        return pointColor;
    }


    public LineStyle parseLineStyle() {
        return new LineStyle(parseLineColorField(), Integer.valueOf(parseLineWidth()));
    }

    public TextStyle parseTextStyle() {
        return new TextStyle(
            parseTextColor(),
            parseTextFont(),
            parseTextBackground(),
            parseLabelShowBackground(),
            !parseTextOrientation().equals("horizontal"));
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org