ingo@3227: package de.intevation.flys.themes;
sascha@1754: 
christian@3286: import de.intevation.flys.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 :