comparison artifacts/src/main/java/org/dive4elements/river/themes/ThemeDocument.java @ 6908:819481cc9195

Artifacts: ThemeDocument. The bloody part: Removal of the XPaths. Now the theme XML document is scanned once(!) at construction time for field values and the resulting key/value pairs are store in a map.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 23 Aug 2013 11:07:11 +0200
parents 7a9cbb3a3d5a
children 835e07ee769d
comparison
equal deleted inserted replaced
6907:dbad1f442f3e 6908:819481cc9195
8 8
9 package org.dive4elements.river.themes; 9 package org.dive4elements.river.themes;
10 10
11 import java.awt.Color; 11 import java.awt.Color;
12 import java.awt.Font; 12 import java.awt.Font;
13 import java.util.HashMap;
14 import java.util.Map;
13 15
14 import org.apache.log4j.Logger; 16 import org.apache.log4j.Logger;
15 import org.dive4elements.artifacts.CallMeta; 17 import org.dive4elements.artifacts.CallMeta;
16 import org.dive4elements.artifacts.common.utils.XMLUtils;
17 import org.dive4elements.river.artifacts.model.MapserverStyle; 18 import org.dive4elements.river.artifacts.model.MapserverStyle;
18 import org.dive4elements.river.artifacts.model.MapserverStyle.Clazz; 19 import org.dive4elements.river.artifacts.model.MapserverStyle.Clazz;
19 import org.dive4elements.river.artifacts.model.MapserverStyle.Expression; 20 import org.dive4elements.river.artifacts.model.MapserverStyle.Expression;
20 import org.dive4elements.river.artifacts.model.MapserverStyle.Label; 21 import org.dive4elements.river.artifacts.model.MapserverStyle.Label;
21 import org.dive4elements.river.artifacts.model.MapserverStyle.Style; 22 import org.dive4elements.river.artifacts.model.MapserverStyle.Style;
22 import org.dive4elements.river.artifacts.resources.Resources; 23 import org.dive4elements.river.artifacts.resources.Resources;
23 import org.w3c.dom.Document; 24 import org.w3c.dom.Document;
25 import org.w3c.dom.Element;
26 import org.w3c.dom.NodeList;
24 27
25 public class ThemeDocument 28 public class ThemeDocument
26 { 29 {
27 private static Logger logger = Logger.getLogger(ThemeDocument.class); 30 private static Logger logger = Logger.getLogger(ThemeDocument.class);
28 31
29 private static final String MSG_ISOBATH_CLASS = "floodmap.isobath.class"; 32 private static final String MSG_ISOBATH_CLASS = "floodmap.isobath.class";
30 33
31 private static final String MSG_ISOBATH_LASTCLASS = "floodmap.isobath.lastclass"; 34 private static final String MSG_ISOBATH_LASTCLASS = "floodmap.isobath.lastclass";
32 35
33 public final static String XPATH_FILL_COLOR = 36 public final static String FILL_COLOR = "fillcolor";
34 "/theme/field[@name='fillcolor']/@default"; 37
35 38 public final static String LINE_COLOR = "linecolor";
36 public final static String XPATH_LINE_COLOR = 39
37 "/theme/field[@name='linecolor']/@default"; 40 public final static String AREA_LINE_COLOR = "areabordercolor";
38 41
39 public final static String XPATH_AREA_LINE_COLOR = 42 public static final String LINE_SIZE = "linesize";
40 "/theme/field[@name='areabordercolor']/@default"; 43
41 44 public static final String LINE_STYLE = "linetype";
42 public static final String XPATH_LINE_SIZE = 45
43 "/theme/field[@name='linesize']/@default"; 46 public static final String POINT_SIZE = "pointsize";
44 47
45 public static final String XPATH_LINE_STYLE = 48 public static final String POINT_COLOR = "pointcolor";
46 "/theme/field[@name='linetype']/@default"; 49
47 50 public final static String SHOW_BORDER = "showborder";
48 public static final String XPATH_POINT_SIZE = 51
49 "/theme/field[@name='pointsize']/@default"; 52 public final static String AREA_SHOW_BORDER = "showborder";
50 53
51 public static final String XPATH_POINT_COLOR = 54 public final static String SHOW_POINTS = "showpoints";
52 "/theme/field[@name='pointcolor']/@default"; 55
53 56 public final static String SHOW_LINE = "showlines";
54 public final static String XPATH_SHOW_BORDER = 57
55 "/theme/field[@name='showborder']/@default"; 58 public final static String SHOW_VERTICAL_LINE = "showverticalline";
56 59
57 public final static String XPATH_AREA_SHOW_BORDER = 60 public final static String SHOW_HORIZONTAL_LINE = "showhorizontalline";
58 "/theme/field[@name='showborder']/@default"; 61
59 62 public final static String SHOW_LINE_LABEL = "showlinelabel";
60 public final static String XPATH_SHOW_POINTS = 63
61 "/theme/field[@name='showpoints']/@default"; 64 public final static String SHOW_POINT_LABEL = "showpointlabel";
62 65
63 public final static String XPATH_SHOW_LINE = 66 public final static String SHOW_WIDTH = "showwidth";
64 "/theme/field[@name='showlines']/@default"; 67
65 68 public final static String SHOW_LEVEL = "showlevel";
66 public final static String XPATH_SHOW_VERTICAL_LINE = 69
67 "/theme/field[@name='showverticalline']/@default"; 70 public final static String TRANSPARENCY = "transparency";
68 71
69 public final static String XPATH_SHOW_HORIZONTAL_LINE = 72 public final static String AREA_TRANSPARENCY = "areatransparency";
70 "/theme/field[@name='showhorizontalline']/@default"; 73
71 74 public final static String SHOW_AREA = "showarea";
72 public final static String XPATH_SHOW_LINE_LABEL = 75
73 "/theme/field[@name='showlinelabel']/@default"; 76 public final static String SHOW_MIDDLE_HEIGHT = "showmiddleheight";
74 77
75 public final static String XPATH_SHOW_POINT_LABEL = 78 public final static String LABEL_FONT_COLOR = "labelfontcolor";
76 "/theme/field[@name='showpointlabel']/@default"; 79
77 80 public final static String LABEL_FONT_SIZE = "labelfontsize";
78 public final static String XPATH_SHOW_WIDTH = 81
79 "/theme/field[@name='showwidth']/@default"; 82 public final static String LABEL_FONT_FACE = "labelfontface";
80 83
81 public final static String XPATH_SHOW_LEVEL = 84 public final static String LABEL_FONT_STYLE = "labelfontstyle";
82 "/theme/field[@name='showlevel']/@default"; 85
83 86 public final static String TEXT_ORIENTATION = "textorientation";
84 public final static String XPATH_TRANSPARENCY = 87
85 "/theme/field[@name='transparency']/@default"; 88 public final static String LABEL_BGCOLOR = "labelbgcolor";
86 89
87 public final static String XPATH_AREA_TRANSPARENCY = 90 public final static String LABEL_SHOW_BACKGROUND = "labelshowbg";
88 "/theme/field[@name='areatransparency']/@default"; 91
89 92 public final static String BACKGROUND_COLOR = "backgroundcolor";
90 public final static String XPATH_SHOW_AREA = 93
91 "/theme/field[@name='showarea']/@default"; 94 public final static String AREA_BACKGROUND_COLOR = "areabgcolor";
92 95
93 public final static String XPATH_SHOW_MIDDLE_HEIGHT = 96 public final static String SYMBOL = "symbol";
94 "/theme/field[@name='showmiddleheight']/@default"; 97
95 98 public final static String SHOW_MINIMUM = "showminimum";
96 public final static String XPATH_LABEL_FONT_COLOR = 99
97 "/theme/field[@name='labelfontcolor']/@default"; 100 public final static String SHOW_MAXIMUM = "showmaximum";
98 101
99 public final static String XPATH_LABEL_FONT_SIZE = 102 public final static String WSPLGEN_FIELDS = "/theme[@name='WSPLGEN']/field";
100 "/theme/field[@name='labelfontsize']/@default"; 103
101 104 public final static String WSPLGEN_STARTCOLOR = "startcolor";
102 public final static String XPATH_LABEL_FONT_FACE = 105
103 "/theme/field[@name='labelfontface']/@default"; 106 public final static String WSPLGEN_ENDCOLOR = "endcolor";
104 107
105 public final static String XPATH_LABEL_FONT_STYLE = 108 public final static String WSPLGEN_NUMCLASSES = "numclasses";
106 "/theme/field[@name='labelfontstyle']/@default"; 109
107 110 public final static String BANDWIDTH = "bandwidth";
108 public final static String XPATH_TEXT_ORIENTATION = 111
109 "/theme/field[@name='textorientation']/@default"; 112 public final static String SHOWEXTRAMARK = "showextramark";
110 113
111 public final static String XPATH_LABEL_BGCOLOR =
112 "/theme/field[@name='labelbgcolor']/@default";
113
114 public final static String XPATH_LABEL_SHOW_BACKGROUND =
115 "/theme/field[@name='labelshowbg']/@default";
116
117 public final static String XPATH_BACKGROUND_COLOR =
118 "/theme/field[@name='backgroundcolor']/@default";
119
120 public final static String XPATH_AREA_BACKGROUND_COLOR =
121 "/theme/field[@name='areabgcolor']/@default";
122
123 public final static String XPATH_SYMBOL =
124 "/theme/field[@name='symbol']/@default";
125
126 public final static String XPATH_SHOW_MINIMUM =
127 "/theme/field[@name='showminimum']/@default";
128
129 public final static String XPATH_SHOW_MAXIMUM =
130 "/theme/field[@name='showmaximum']/@default";
131
132 public final static String XPATH_WSPLGEN_FIELDS =
133 "/theme[@name='WSPLGEN']/field";
134
135 public final static String XPATH_WSPLGEN_STARTCOLOR =
136 "/theme/field[@name='startcolor']/@default";
137
138 public final static String XPATH_WSPLGEN_ENDCOLOR =
139 "/theme/field[@name='endcolor']/@default";
140
141 public final static String XPATH_WSPLGEN_NUMCLASSES =
142 "/theme/field[@name='numclasses']/@default";
143
144 /** XPATH to bandwidth field. */
145 public final static String XPATH_BANDWIDTH =
146 "/theme/field[@name='bandwidth']/@default";
147
148 /** XPATH to find showextramark field. */
149 public final static String XPATH_SHOWEXTRAMARK =
150 "/theme/field[@name='showextramark']/@default";
151 114
152 private Document document; 115 private Document document;
116
117 private Map<String, String> values;
153 118
154 public ThemeDocument() { 119 public ThemeDocument() {
155 } 120 }
156 121
157 public ThemeDocument(Document document) { 122 public ThemeDocument(Document document) {
158 this.document = document; 123 this.document = document;
124 values = extractValues(document);
159 } 125 }
160 126
161 public Document getDocument() { 127 public Document getDocument() {
162 return document; 128 return document;
163 } 129 }
164 130
131 private String getValue(String key) {
132 return values.get(key);
133 }
134
135 private static Map<String, String> extractValues(Document document) {
136 Map<String, String> values = new HashMap<String, String>();
137 NodeList fields = document.getElementsByTagName("field");
138 for (int i = 0, N = fields.getLength(); i < N; ++i) {
139 Element field = (Element)fields.item(i);
140 String name = field.getAttribute("name");
141 String value = field.getAttribute("default");
142 if (!name.isEmpty() && !value.isEmpty()) {
143 values.put(name, value);
144 }
145 }
146 return values;
147 }
148
165 /** Parse string to be boolean with default if empty or unrecognized. */ 149 /** Parse string to be boolean with default if empty or unrecognized. */
166 public static boolean parseBoolean(String value, boolean defaultsTo) { 150 private static boolean parseBoolean(String value, boolean defaultsTo) {
167 if (value == null || value.length() == 0) { 151 if (value == null || value.length() == 0) {
168 return defaultsTo; 152 return defaultsTo;
169 } 153 }
170 if (value.equals("false")) { 154 if (value.equals("false")) {
171 return false; 155 return false;
172 } 156 }
173 else if (value.equals("true")) { 157 if (value.equals("true")) {
174 return true; 158 return true;
175 } 159 }
176 else { 160 return defaultsTo;
177 return defaultsTo;
178 }
179 } 161 }
180 162
181 163
182 /** 164 /**
183 * Attempt converting \param value to an integer, in failing cases, 165 * Attempt converting \param value to an integer, in failing cases,
184 * return \param defaultsTo. 166 * return \param defaultsTo.
185 * @param value String to be converted to integer. 167 * @param value String to be converted to integer.
186 * @param defaultsTo Default to return if conversion failed. 168 * @param defaultsTo Default to return if conversion failed.
187 * @return \param value as integer or defaultsto if conversion failed. 169 * @return \param value as integer or defaultsto if conversion failed.
188 */ 170 */
189 public static int parseInteger(String value, int defaultsTo) { 171 private static int parseInteger(String value, int defaultsTo) {
190 if (value == null || value.length() == 0) { 172 if (value == null || value.length() == 0) {
191 return defaultsTo; 173 return defaultsTo;
192 } 174 }
193 175
194 try { 176 try {
207 * return \param defaultsTo. 189 * return \param defaultsTo.
208 * @param value String to be converted to double. 190 * @param value String to be converted to double.
209 * @param defaultsTo Default to return if conversion failed. 191 * @param defaultsTo Default to return if conversion failed.
210 * @return \param value as integer or defaultsto if conversion failed. 192 * @return \param value as integer or defaultsto if conversion failed.
211 */ 193 */
212 public static double parseDouble(String value, double defaultsTo) { 194 private static double parseDouble(String value, double defaultsTo) {
213 if (value == null || value.length() == 0) { 195 if (value == null || value.length() == 0) {
214 return defaultsTo; 196 return defaultsTo;
215 } 197 }
216 198
217 try { 199 try {
223 205
224 return defaultsTo; 206 return defaultsTo;
225 } 207 }
226 208
227 public boolean parseShowLineLabel() { 209 public boolean parseShowLineLabel() {
228 String show = XMLUtils.xpathString(document, XPATH_SHOW_LINE_LABEL, null); 210 String show = getValue(SHOW_LINE_LABEL);
229 return parseBoolean(show, false); 211 return parseBoolean(show, false);
230 } 212 }
231 213
232 public boolean parseShowWidth() { 214 public boolean parseShowWidth() {
233 String show = XMLUtils.xpathString(document, XPATH_SHOW_WIDTH, null); 215 String show = getValue(SHOW_WIDTH);
234 return parseBoolean(show, false); 216 return parseBoolean(show, false);
235 } 217 }
236 218
237 public boolean parseShowLevel() { 219 public boolean parseShowLevel() {
238 String show = XMLUtils.xpathString(document, XPATH_SHOW_LEVEL, null); 220 String show = getValue(SHOW_LEVEL);
239 return parseBoolean(show, false); 221 return parseBoolean(show, false);
240 } 222 }
241 223
242 public String parseTextOrientation() { 224 public String parseTextOrientation() {
243 String o = XMLUtils.xpathString(document, XPATH_TEXT_ORIENTATION, null); 225 String o = getValue(TEXT_ORIENTATION);
244 if ("true".equals(o)) { 226
245 return "horizontal"; 227 return o != null && "true".equals(o)
246 } 228 ? "horizontal"
247 else { 229 : "vertical";
248 return "vertical";
249 }
250 } 230 }
251 231
252 public boolean parseShowMiddleHeight() { 232 public boolean parseShowMiddleHeight() {
253 String show = XMLUtils.xpathString(document, XPATH_SHOW_MIDDLE_HEIGHT, null); 233 String show = getValue(SHOW_MIDDLE_HEIGHT);
254 return parseBoolean(show, false); 234 return parseBoolean(show, false);
255 } 235 }
256 236
257 public boolean parseLabelShowBackground() { 237 public boolean parseLabelShowBackground() {
258 String show = XMLUtils.xpathString(document, XPATH_LABEL_SHOW_BACKGROUND, null); 238 String show = getValue(LABEL_SHOW_BACKGROUND);
259 return parseBoolean(show, false); 239 return parseBoolean(show, false);
260 } 240 }
261 241
262 public Font parseTextFont() { 242 public Font parseTextFont() {
263 String font = XMLUtils.xpathString(document, XPATH_LABEL_FONT_FACE, null); 243 String font = getValue(LABEL_FONT_FACE);
264 if (font == null || font.length() == 0) { 244 if (font == null || font.length() == 0) {
265 return null; 245 return null;
266 } 246 }
267 247
268 int size = parseTextSize(); 248 int size = parseTextSize();
274 public Color parseTextColor() { 254 public Color parseTextColor() {
275 return parseRGB(getTextColorString()); 255 return parseRGB(getTextColorString());
276 } 256 }
277 257
278 public String getTextColorString() { 258 public String getTextColorString() {
279 String textColor = XMLUtils.xpathString(document, XPATH_LABEL_FONT_COLOR, null); 259 String textColor = getValue(LABEL_FONT_COLOR);
280 return textColor; 260 return textColor;
281 } 261 }
282 262
283 public Color parseTextBackground() { 263 public Color parseTextBackground() {
284 String color = getLabelBackgroundColorString(); 264 String color = getLabelBackgroundColorString();
286 return Color.WHITE; 266 return Color.WHITE;
287 } 267 }
288 return parseRGB(color); 268 return parseRGB(color);
289 } 269 }
290 270
291 public String getLabelBackgroundColorString() { 271 private String getLabelBackgroundColorString() {
292 return XMLUtils.xpathString(document, XPATH_LABEL_BGCOLOR, null); 272 return getValue(LABEL_BGCOLOR);
293 } 273 }
294 274
295 275
296 public int parseLineWidth() { 276 public int parseLineWidth() {
297 String size = XMLUtils.xpathString(document, XPATH_LINE_SIZE, null); 277 String size = getValue(LINE_SIZE);
298 if (size == null || size.length() == 0) { 278 if (size == null || size.length() == 0) {
299 return 0; 279 return 0;
300 } 280 }
301 281
302 try { 282 try {
307 } 287 }
308 return 0; 288 return 0;
309 } 289 }
310 290
311 public float [] parseLineStyle() { 291 public float [] parseLineStyle() {
312 String dash = XMLUtils.xpathString(document, XPATH_LINE_STYLE, null); 292 String dash = getValue(LINE_STYLE);
313 293
314 float[] def = {10}; 294 float[] def = {10};
315 if (dash == null || dash.length() == 0) { 295 if (dash == null || dash.length() == 0) {
316 return def; 296 return def;
317 } 297 }
326 for (int i = 0; i < pattern.length; i++) { 306 for (int i = 0; i < pattern.length; i++) {
327 dashes[i] = Float.parseFloat(pattern[i]); 307 dashes[i] = Float.parseFloat(pattern[i]);
328 } 308 }
329 return dashes; 309 return dashes;
330 } 310 }
331 catch(NumberFormatException nfe) { 311 catch (NumberFormatException nfe) {
332 logger.warn("Unable to set dash from string: '" + dash + "'"); 312 logger.warn("Unable to set dash from string: '" + dash + "'");
333 return def; 313 return def;
334 } 314 }
335 } 315 }
336 316
337 public int parsePointWidth() { 317 public int parsePointWidth() {
338 String width = XMLUtils.xpathString(document, XPATH_POINT_SIZE, null); 318 String width = getValue(POINT_SIZE);
339
340 return parseInteger(width, 3); 319 return parseInteger(width, 3);
341 } 320 }
342 321
343 public Color parsePointColor() { 322 public Color parsePointColor() {
344 String color = XMLUtils.xpathString(document, XPATH_POINT_COLOR, null); 323 String color = getValue(POINT_COLOR);
345 logger.debug("parsePointColor(): color = " + color);
346 return parseColor(color); 324 return parseColor(color);
347 } 325 }
348 326
349 public boolean parseShowPoints() { 327 public boolean parseShowPoints() {
350 String show = XMLUtils.xpathString(document, XPATH_SHOW_POINTS, null); 328 String show = getValue(SHOW_POINTS);
351 return parseBoolean(show, false); 329 return parseBoolean(show, false);
352 } 330 }
353 331
354 public boolean parseShowLine() { 332 public boolean parseShowLine() {
355 String show = XMLUtils.xpathString(document, XPATH_SHOW_LINE, null); 333 String show = getValue(SHOW_LINE);
356 return parseBoolean(show, true); 334 return parseBoolean(show, true);
357 } 335 }
358 336
359 public int parseTextStyle() { 337 public int parseTextStyle() {
360 return parseTextStyle(XPATH_LABEL_FONT_STYLE); 338 String style = getValue(LABEL_FONT_STYLE);
361 }
362
363 public int parseTextStyle(String path) {
364 String style = XMLUtils.xpathString(document, path, null);
365 if (style == null || style.length() == 0) { 339 if (style == null || style.length() == 0) {
366 return Font.PLAIN; 340 return Font.PLAIN;
367 } 341 }
368 342
369 if (style.equals("italic")) { 343 if (style.equals("italic")) {
370 return Font.ITALIC; 344 return Font.ITALIC;
371 } 345 }
372 else if (style.equals("bold")) { 346 if (style.equals("bold")) {
373 return Font.BOLD; 347 return Font.BOLD;
374 } 348 }
375 else { 349 return Font.PLAIN;
376 return Font.PLAIN;
377 }
378 } 350 }
379 351
380 public TextStyle parseComplexTextStyle() { 352 public TextStyle parseComplexTextStyle() {
381 return new TextStyle( 353 return new TextStyle(
382 parseTextColor(), 354 parseTextColor(),
390 return new LineStyle( 362 return new LineStyle(
391 parseLineColorField(), 363 parseLineColorField(),
392 Integer.valueOf(parseLineWidth())); 364 Integer.valueOf(parseLineWidth()));
393 } 365 }
394 366
395 public Color parseComplexLineColorField() {
396 return null;
397 }
398
399 public boolean parseShowVerticalLine() { 367 public boolean parseShowVerticalLine() {
400 String show = XMLUtils.xpathString(document, XPATH_SHOW_VERTICAL_LINE, null); 368 String show = getValue(SHOW_VERTICAL_LINE);
401 return parseBoolean(show, true); 369 return parseBoolean(show, true);
402 } 370 }
403 371
404 public boolean parseShowHorizontalLine() { 372 public boolean parseShowHorizontalLine() {
405 String show = XMLUtils.xpathString(document, XPATH_SHOW_HORIZONTAL_LINE, null); 373 String show = getValue(SHOW_HORIZONTAL_LINE);
406 return parseBoolean(show, true); 374 return parseBoolean(show, true);
407 } 375 }
408 376
409 public double parseBandWidth() { 377 public double parseBandWidth() {
410 String bandWidth = XMLUtils.xpathString(document, XPATH_BANDWIDTH, null); 378 String bandWidth = getValue(BANDWIDTH);
411 return parseDouble(bandWidth, 0); 379 return parseDouble(bandWidth, 0);
412 } 380 }
413 381
414 public static Color parseColor(String colorString) { 382 public static Color parseColor(String colorString) {
415 if (colorString == null || colorString.length() == 0) { 383 if (colorString == null || colorString.length() == 0) {
441 return Color.decode(hex); 409 return Color.decode(hex);
442 } 410 }
443 411
444 412
445 public boolean parseShowArea() { 413 public boolean parseShowArea() {
446 String show = XMLUtils.xpathString(document, XPATH_SHOW_AREA, null); 414 String show = getValue(SHOW_AREA);
447 return parseBoolean(show, false); 415 return parseBoolean(show, false);
448 } 416 }
449 417
450 public boolean parseShowPointLabel() { 418 public boolean parseShowPointLabel() {
451 String show = XMLUtils.xpathString(document, XPATH_SHOW_POINT_LABEL, null); 419 String show = getValue(SHOW_POINT_LABEL);
452 return parseBoolean(show, false); 420 return parseBoolean(show, false);
453 } 421 }
454 422
455 public boolean parseShowExtraMark() { 423 public boolean parseShowExtraMark() {
456 String show = XMLUtils.xpathString(document, XPATH_SHOWEXTRAMARK, null); 424 String show = getValue(SHOWEXTRAMARK);
457 return parseBoolean(show, false); 425 return parseBoolean(show, false);
458 } 426 }
459 427
460 public int parseTextSize() { 428 public int parseTextSize() {
461 return parseTextSize(XPATH_LABEL_FONT_SIZE); 429 String size = getValue(LABEL_FONT_SIZE);
462 }
463
464 public int parseTextSize(String path) {
465 String size = XMLUtils.xpathString(document, path, null);
466 if (size == null || size.length() == 0) { 430 if (size == null || size.length() == 0) {
467 return 10; 431 return 10;
468 } 432 }
469 433
470 try { 434 try {
497 } 461 }
498 return c; 462 return c;
499 } 463 }
500 464
501 public String getLineColorString() { 465 public String getLineColorString() {
502 return XMLUtils.xpathString(document, XPATH_LINE_COLOR, null); 466 return getValue(LINE_COLOR);
503 } 467 }
504 468
505 469
506 /** Get show border as string. */ 470 /** Get show border as string. */
507 public String getShowBorderString() { 471 public String getShowBorderString() {
508 return XMLUtils.xpathString(document, XPATH_SHOW_BORDER, null); 472 return getValue(SHOW_BORDER);
509 } 473 }
510 474
511 475
512 /** Get fill color as string. */ 476 /** Get fill color as string. */
513 public String getFillColorString() { 477 private String getFillColorString() {
514 return XMLUtils.xpathString(document, XPATH_FILL_COLOR, null); 478 return getValue(FILL_COLOR);
515 }
516
517
518 public String getBackgroundColorString() {
519 return XMLUtils.xpathString(document, XPATH_BACKGROUND_COLOR, null);
520 } 479 }
521 480
522 public String getSymbol() { 481 public String getSymbol() {
523 return XMLUtils.xpathString(document, XPATH_SYMBOL, null); 482 return getValue(SYMBOL);
524 } 483 }
525 484
526 485
527 public String getTransparencyString() { 486 private String getTransparencyString() {
528 return XMLUtils.xpathString(document, XPATH_TRANSPARENCY, null); 487 return getValue(TRANSPARENCY);
529 } 488 }
530 489
531 490
532 public String getAreaTransparencyString() { 491 public String getAreaTransparencyString() {
533 return XMLUtils.xpathString(document, XPATH_AREA_TRANSPARENCY, null); 492 return getValue(AREA_TRANSPARENCY);
534 } 493 }
535 494
536 495
537 public String getShowMinimum() { 496 public String getShowMinimum() {
538 return XMLUtils.xpathString(document, XPATH_SHOW_MINIMUM, null); 497 return getValue(SHOW_MINIMUM);
539 } 498 }
540 499
541 500
542 public String getShowMaximum() { 501 public String getShowMaximum() {
543 return XMLUtils.xpathString(document, XPATH_SHOW_MAXIMUM, null); 502 return getValue(SHOW_MAXIMUM);
544 } 503 }
545 504
546 505
547 /** 506 /**
548 * Gets color from color field. 507 * Gets color from color field.
584 return parseColor(lineColorStr); 543 return parseColor(lineColorStr);
585 } 544 }
586 545
587 546
588 private String getAreaLineColorString() { 547 private String getAreaLineColorString() {
589 return XMLUtils.xpathString(document, XPATH_AREA_LINE_COLOR, null); 548 return getValue(AREA_LINE_COLOR);
590 } 549 }
591 550
592 551
593 public boolean parseShowMinimum() { 552 public boolean parseShowMinimum() {
594 return parseBoolean(getShowMinimum(), false); 553 return parseBoolean(getShowMinimum(), false);
610 public String createDynamicMapserverStyle( 569 public String createDynamicMapserverStyle(
611 float from, float to, float step, CallMeta meta) 570 float from, float to, float step, CallMeta meta)
612 { 571 {
613 MapserverStyle ms = new MapserverStyle(); 572 MapserverStyle ms = new MapserverStyle();
614 573
615 String strStartColor = XMLUtils.xpathString(document, XPATH_WSPLGEN_STARTCOLOR, null); 574 String strStartColor = getValue(WSPLGEN_STARTCOLOR);
616 Color startColor = strStartColor != null ? parseColor(strStartColor) : new Color(178, 201, 215); 575 Color startColor = strStartColor != null ? parseColor(strStartColor) : new Color(178, 201, 215);
617 String strEndColor = XMLUtils.xpathString(document, XPATH_WSPLGEN_ENDCOLOR, null); 576 String strEndColor = getValue(WSPLGEN_ENDCOLOR);
618 Color endColor = strEndColor != null? parseColor(strEndColor) : new Color(2, 27, 42); 577 Color endColor = strEndColor != null? parseColor(strEndColor) : new Color(2, 27, 42);
619 578
620 to = to != 0 ? to : 9999; 579 to = to != 0 ? to : 9999;
621 step = step != 0 ? step : to; 580 step = step != 0 ? step : to;
622 581
731 690
732 return ms.toString(); 691 return ms.toString();
733 } 692 }
734 693
735 694
736 public String getAreaBackgroundColorString() { 695 private String getAreaBackgroundColorString() {
737 return XMLUtils.xpathString(document, XPATH_AREA_BACKGROUND_COLOR, null); 696 return getValue(AREA_BACKGROUND_COLOR);
738 } 697 }
739 698
740 699
741 public Color parseAreaBackgroundColor() { 700 public Color parseAreaBackgroundColor() {
742 return parseColor(getAreaBackgroundColorString()); 701 return parseColor(getAreaBackgroundColorString());
743 } 702 }
744 703
745 704
746 public int parseAreaTransparency() { 705 public int parseAreaTransparency() {
747 return parseInteger(getAreaTransparencyString(), 50); 706 return parseAreaTransparency(50);
707 }
708
709 public int parseAreaTransparency(int alpha) {
710 return parseInteger(getAreaTransparencyString(), alpha);
748 } 711 }
749 712
750 713
751 public boolean parseAreaShowBorder() { 714 public boolean parseAreaShowBorder() {
752 return parseBoolean(getAreaShowBorderString(), false); 715 return parseBoolean(getAreaShowBorderString(), false);
753 } 716 }
754 717
755 718
756 private String getAreaShowBorderString() { 719 private String getAreaShowBorderString() {
757 return XMLUtils.xpathString(document, XPATH_AREA_SHOW_BORDER, null); 720 return getValue(AREA_SHOW_BORDER);
758 } 721 }
759 } 722 }
760 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 723 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org