sascha@1754: package de.intevation.flys.utils; sascha@1754: sascha@1754: import java.awt.Color; sascha@1754: import java.awt.Font; sascha@1754: sascha@1754: import org.w3c.dom.Document; sascha@1754: felix@2666: import de.intevation.flys.jfree.StableXYDifferenceRenderer; felix@2666: felix@2152: import org.jfree.chart.annotations.XYTextAnnotation; sascha@1754: felix@2152: felix@2152: /** Undocumented. */ 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: sascha@1754: public boolean parseShowTextBackground() { sascha@1754: if (showTextBackground == null) { sascha@1754: showTextBackground = ThemeUtil.parseShowTextBackground(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@2161: public static class LineStyle { felix@2161: protected Color lineColor; felix@2161: protected int lineWidth; felix@2161: felix@2161: public LineStyle(Color color, int width) { felix@2161: this.lineColor = color; felix@2161: this.lineWidth = width; felix@2161: } felix@2161: felix@2161: public int getWidth() { felix@2161: return lineWidth; felix@2161: } felix@2161: felix@2161: public Color getColor() { felix@2161: return lineColor; felix@2161: } felix@2161: } felix@2161: felix@2412: felix@2152: public TextStyle parseTextStyle() { christian@3205: return new TextStyle( christian@3205: parseTextColor(), christian@3205: parseTextFont(), christian@3205: parseTextBackground(), christian@3205: parseShowTextBackground(), felix@2416: !parseTextOrientation().equals("horizontal")); felix@2152: } felix@2152: felix@2412: felix@2152: public static class TextStyle { felix@2152: protected Color textColor; felix@2152: protected Font font; felix@2152: protected Color bgColor; felix@2152: protected boolean showBg; felix@2416: protected boolean isVertical; felix@2152: felix@2152: public TextStyle(Color fgColor, Font font, Color bgColor, felix@2416: boolean showBg, boolean isVertical felix@2152: ) { felix@2416: this.textColor = fgColor; felix@2416: this.font = font; felix@2416: this.bgColor = bgColor; felix@2416: this.showBg = showBg; felix@2416: this.isVertical = isVertical; felix@2152: } felix@2152: felix@2152: public void apply(XYTextAnnotation ta) { felix@2152: ta.setPaint(textColor); felix@2152: ta.setFont(font); felix@2412: if (this.showBg) { felix@2412: ta.setBackgroundPaint(bgColor); felix@2412: } felix@2416: if (this.isVertical) { felix@2416: ta.setRotationAngle(270f*Math.PI/180f); felix@2416: } felix@2416: else { christian@3205: ta.setRotationAngle(0); felix@2416: } felix@2152: } felix@2666: felix@2666: public void apply(StableXYDifferenceRenderer renderer) { felix@2666: renderer.setLabelColor(textColor); felix@2666: renderer.setLabelFont(font); felix@2667: if (this.showBg) { felix@2667: renderer.setLabelBGColor(bgColor); felix@2667: } felix@2666: } felix@2152: } sascha@1754: } sascha@1754: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :