comparison flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeAccess.java @ 2152:2336927cb096

Add basic (text) styling for HYKS. flys-artifacts/trunk@3734 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 20 Jan 2012 08:38:50 +0000
parents 8e6615ad60b8
children c68f4f227c09
comparison
equal deleted inserted replaced
2151:eb1a676c0d6e 2152:2336927cb096
3 import java.awt.Color; 3 import java.awt.Color;
4 import java.awt.Font; 4 import java.awt.Font;
5 5
6 import org.w3c.dom.Document; 6 import org.w3c.dom.Document;
7 7
8 import org.jfree.chart.annotations.XYTextAnnotation;
8 9
10
11 /** Undocumented. */
9 public class ThemeAccess 12 public class ThemeAccess
10 { 13 {
11 protected Document theme; 14 protected Document theme;
12 15
13 protected Integer lineWidth; 16 protected Integer lineWidth;
17 protected Font font; 20 protected Font font;
18 protected String textOrientation; 21 protected String textOrientation;
19 protected Color textBackground; 22 protected Color textBackground;
20 protected Boolean showTextBackground; 23 protected Boolean showTextBackground;
21 24
25
22 public ThemeAccess(Document theme) { 26 public ThemeAccess(Document theme) {
23 this.theme = theme; 27 this.theme = theme;
24 } 28 }
29
25 30
26 public int parseLineWidth() { 31 public int parseLineWidth() {
27 if (lineWidth == null) { 32 if (lineWidth == null) {
28 lineWidth = ThemeUtil.parseLineWidth(theme); 33 lineWidth = ThemeUtil.parseLineWidth(theme);
29 } 34 }
30 return lineWidth; 35 return lineWidth;
31 } 36 }
37
32 38
33 public Color parseLineColorField() { 39 public Color parseLineColorField() {
34 if (lineColor == null) { 40 if (lineColor == null) {
35 lineColor = ThemeUtil.parseLineColorField(theme); 41 lineColor = ThemeUtil.parseLineColorField(theme);
36 if (lineColor == null) { 42 if (lineColor == null) {
38 } 44 }
39 } 45 }
40 return lineColor; 46 return lineColor;
41 } 47 }
42 48
49
43 public Color parseTextColor() { 50 public Color parseTextColor() {
44 if (textColor == null) { 51 if (textColor == null) {
45 textColor = ThemeUtil.parseTextColor(theme); 52 textColor = ThemeUtil.parseTextColor(theme);
46 if (textColor == null) { 53 if (textColor == null) {
47 textColor = Color.BLACK; 54 textColor = Color.BLACK;
48 } 55 }
49 } 56 }
50 return textColor; 57 return textColor;
51 } 58 }
52 59
60
53 public Font parseTextFont() { 61 public Font parseTextFont() {
54 if (font == null) { 62 if (font == null) {
55 font = ThemeUtil.parseTextFont(theme); 63 font = ThemeUtil.parseTextFont(theme);
56 if (font == null) { 64 if (font == null) {
57 font = new Font("Arial", Font.BOLD, 10); 65 font = new Font("Arial", Font.BOLD, 10);
58 } 66 }
59 } 67 }
60 return font; 68 return font;
61 } 69 }
70
62 71
63 public String parseTextOrientation() { 72 public String parseTextOrientation() {
64 if (textOrientation == null) { 73 if (textOrientation == null) {
65 textOrientation = ThemeUtil.parseTextOrientation(theme); 74 textOrientation = ThemeUtil.parseTextOrientation(theme);
66 if (textOrientation == null) { 75 if (textOrientation == null) {
90 99
91 /** 100 /**
92 more of this 101 more of this
93 */ 102 */
94 103
104 public TextStyle parseTextStyle() {
105 return new TextStyle(parseTextColor(), parseTextFont(),
106 parseTextBackground(), false);
107 }
108
109 public static class TextStyle {
110 protected Color textColor;
111 protected Font font;
112 protected Color bgColor;
113 protected boolean showBg;
114
115 public TextStyle(Color fgColor, Font font, Color bgColor,
116 boolean showBg
117 ) {
118 this.textColor = fgColor;
119 this.font = font;
120 this.bgColor = bgColor;
121 this.showBg = showBg;
122 }
123
124 public void apply(XYTextAnnotation ta) {
125 ta.setPaint(textColor);
126 ta.setFont(font);
127 }
128 }
95 } 129 }
96 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 130 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org