Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java @ 1748:d56b94325bec
Added methods to extract further attributes from theme.
flys-artifacts/trunk@3048 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 20 Oct 2011 14:26:22 +0000 |
parents | 6cdc7a77d3d4 |
children | 415ec0223dff |
comparison
equal
deleted
inserted
replaced
1747:d2a17e990c70 | 1748:d56b94325bec |
---|---|
22 "/theme/field[@name='linecolor']/@default"; | 22 "/theme/field[@name='linecolor']/@default"; |
23 | 23 |
24 public static final String XPATH_LINE_SIZE = | 24 public static final String XPATH_LINE_SIZE = |
25 "/theme/field[@name='linesize']/@default"; | 25 "/theme/field[@name='linesize']/@default"; |
26 | 26 |
27 public final static String XPATH_SHOW_POINTS = | |
28 "/theme/field[@name='showpoints']/@default"; | |
29 | |
27 public final static String XPATH_TEXT_COLOR = | 30 public final static String XPATH_TEXT_COLOR = |
28 "/theme/field[@name='textcolor']/@default"; | 31 "/theme/field[@name='textcolor']/@default"; |
29 | 32 |
30 public final static String XPATH_TEXT_SIZE = | 33 public final static String XPATH_TEXT_SIZE = |
31 "/theme/field[@name='textsize']/@default"; | 34 "/theme/field[@name='textsize']/@default"; |
32 | 35 |
33 public final static String XPATH_TEXT_FONT = | 36 public final static String XPATH_TEXT_FONT = |
34 "/theme/field[@name='font']/@default"; | 37 "/theme/field[@name='font']/@default"; |
38 | |
39 public final static String XPATH_TEXT_STYLE = | |
40 "/theme/field[@name='textstyle']/@default"; | |
41 | |
42 public final static String XPATH_TEXT_ORIENTATION = | |
43 "/theme/field[@name='textorientation']/@default"; | |
44 | |
45 public final static String XPATH_TEXT_BACKGROUND = | |
46 "/theme/field[@name='textbackground']/@default"; | |
47 | |
48 public final static String XPATH_SHOW_BACKGROUND = | |
49 "/theme/field[@name='showbackground']/@default"; | |
35 | 50 |
36 /** | 51 /** |
37 * Parses line width, defaulting to 0. | 52 * Parses line width, defaulting to 0. |
38 * @param theme the theme | 53 * @param theme the theme |
39 */ | 54 */ |
71 return 10; | 86 return 10; |
72 } | 87 } |
73 | 88 |
74 | 89 |
75 /** | 90 /** |
91 * Parses the attribute 'showpoints', defaults to false. | |
92 * @param theme The theme. | |
93 */ | |
94 public static boolean parseShowPoints(Document theme) { | |
95 String show = XMLUtils.xpathString(theme, XPATH_SHOW_POINTS, null); | |
96 if (show == null || show.length() == 0) { | |
97 return false; | |
98 } | |
99 if (show.equals("true")) { | |
100 return true; | |
101 } | |
102 else { | |
103 return false; | |
104 } | |
105 } | |
106 | |
107 | |
108 /** | |
76 * Parses text color. | 109 * Parses text color. |
77 * @param theme The theme. | 110 * @param theme The theme. |
78 */ | 111 */ |
79 public static Color parseTextColor(Document theme) { | 112 public static Color parseTextColor(Document theme) { |
80 String color = XMLUtils.xpathString(theme, XPATH_TEXT_COLOR, null); | 113 String color = XMLUtils.xpathString(theme, XPATH_TEXT_COLOR, null); |
93 } | 126 } |
94 | 127 |
95 int size = parseTextSize(theme); | 128 int size = parseTextSize(theme); |
96 Font f = new Font (font, 0, size); | 129 Font f = new Font (font, 0, size); |
97 return f; | 130 return f; |
131 } | |
132 | |
133 | |
134 /** | |
135 * Parses the text style, defaults to 'Font.PLAIN'. | |
136 * @param theme The theme. | |
137 */ | |
138 public static int parseTextStyle(Document theme) { | |
139 String style = XMLUtils.xpathString(theme, XPATH_TEXT_STYLE, null); | |
140 if (style == null || style.length() == 0) { | |
141 return Font.PLAIN; | |
142 } | |
143 | |
144 if (style.equals("italic")) { | |
145 return Font.ITALIC; | |
146 } | |
147 else if (style.equals("bold")) { | |
148 return Font.BOLD; | |
149 } | |
150 else { | |
151 return Font.PLAIN; | |
152 } | |
153 } | |
154 | |
155 | |
156 /** | |
157 * Parses the textorientation, defaults to 'vertical'. | |
158 * @param theme The theme. | |
159 */ | |
160 public static String parseTextOrientation(Document theme) { | |
161 String o = XMLUtils.xpathString(theme, XPATH_TEXT_ORIENTATION, null); | |
162 if (o == null || o.length() == 0) { | |
163 return "vertical"; | |
164 } | |
165 return o; | |
166 } | |
167 | |
168 | |
169 /** | |
170 * Parses the text background color, defaults to white. | |
171 * @param theme The theme. | |
172 */ | |
173 public static Color parseTextBackground(Document theme) { | |
174 String color = XMLUtils.xpathString(theme, XPATH_TEXT_BACKGROUND, null); | |
175 if (color == null || color.length() == 0) { | |
176 return Color.WHITE; | |
177 } | |
178 return parseRGB(color); | |
179 } | |
180 | |
181 | |
182 /** | |
183 * Parses the attribute whether to show background or not, defaults to | |
184 * false. | |
185 * @param theme The theme. | |
186 */ | |
187 public static boolean parseShowTextBackground(Document theme) { | |
188 String show = XMLUtils.xpathString(theme, XPATH_SHOW_BACKGROUND, null); | |
189 if(show == null || show.length() == 0) { | |
190 return false; | |
191 } | |
192 | |
193 if(show.equals("true")) { | |
194 return true; | |
195 } | |
196 else { | |
197 return false; | |
198 } | |
98 } | 199 } |
99 | 200 |
100 | 201 |
101 /** | 202 /** |
102 * Parse a string like "103, 100, 0" and return a corresping color. | 203 * Parse a string like "103, 100, 0" and return a corresping color. |
120 c = null; | 221 c = null; |
121 } | 222 } |
122 return c; | 223 return c; |
123 } | 224 } |
124 | 225 |
226 | |
125 /** | 227 /** |
126 * Gets color from color field. | 228 * Gets color from color field. |
127 * @param theme the theme document. | 229 * @param theme the theme document. |
128 * @return color. | 230 * @return color. |
129 */ | 231 */ |