comparison flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeAccess.java @ 1754:8e6615ad60b8

Added some simple caching for themes. Only used in sticky annotations by now. flys-artifacts/trunk@3057 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 21 Oct 2011 15:19:49 +0000
parents
children 2336927cb096
comparison
equal deleted inserted replaced
1753:741ba9e34c7d 1754:8e6615ad60b8
1 package de.intevation.flys.utils;
2
3 import java.awt.Color;
4 import java.awt.Font;
5
6 import org.w3c.dom.Document;
7
8
9 public class ThemeAccess
10 {
11 protected Document theme;
12
13 protected Integer lineWidth;
14
15 protected Color lineColor;
16 protected Color textColor;
17 protected Font font;
18 protected String textOrientation;
19 protected Color textBackground;
20 protected Boolean showTextBackground;
21
22 public ThemeAccess(Document theme) {
23 this.theme = theme;
24 }
25
26 public int parseLineWidth() {
27 if (lineWidth == null) {
28 lineWidth = ThemeUtil.parseLineWidth(theme);
29 }
30 return lineWidth;
31 }
32
33 public Color parseLineColorField() {
34 if (lineColor == null) {
35 lineColor = ThemeUtil.parseLineColorField(theme);
36 if (lineColor == null) {
37 lineColor = Color.BLACK;
38 }
39 }
40 return lineColor;
41 }
42
43 public Color parseTextColor() {
44 if (textColor == null) {
45 textColor = ThemeUtil.parseTextColor(theme);
46 if (textColor == null) {
47 textColor = Color.BLACK;
48 }
49 }
50 return textColor;
51 }
52
53 public Font parseTextFont() {
54 if (font == null) {
55 font = ThemeUtil.parseTextFont(theme);
56 if (font == null) {
57 font = new Font("Arial", Font.BOLD, 10);
58 }
59 }
60 return font;
61 }
62
63 public String parseTextOrientation() {
64 if (textOrientation == null) {
65 textOrientation = ThemeUtil.parseTextOrientation(theme);
66 if (textOrientation == null) {
67 textOrientation = "horizontal";
68 }
69 }
70 return textOrientation;
71 }
72
73
74 public Color parseTextBackground() {
75 if (textBackground == null) {
76 textBackground = ThemeUtil.parseTextBackground(theme);
77 if (textBackground == null) {
78 textBackground = Color.WHITE;
79 }
80 }
81 return textBackground;
82 }
83
84 public boolean parseShowTextBackground() {
85 if (showTextBackground == null) {
86 showTextBackground = ThemeUtil.parseShowTextBackground(theme);
87 }
88 return showTextBackground;
89 }
90
91 /**
92 more of this
93 */
94
95 }
96 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org