comparison artifacts/src/main/java/org/dive4elements/river/utils/ThemeUtil.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-artifacts/src/main/java/org/dive4elements/river/utils/ThemeUtil.java@bd047b71ab37
children 4897a58c8746
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.utils;
2
3 import org.dive4elements.artifacts.common.utils.XMLUtils;
4 import org.dive4elements.river.artifacts.model.MapserverStyle;
5 import org.dive4elements.river.artifacts.model.MapserverStyle.Clazz;
6 import org.dive4elements.river.artifacts.model.MapserverStyle.Expression;
7 import org.dive4elements.river.artifacts.model.MapserverStyle.Label;
8 import org.dive4elements.river.artifacts.model.MapserverStyle.Style;
9
10 import java.awt.Color;
11 import java.awt.Font;
12
13 import org.apache.log4j.Logger;
14 import org.w3c.dom.Document;
15
16
17 /**
18 * Utility to deal with themes and their representations.
19 */
20 public class ThemeUtil {
21
22 /** Private logger. */
23 private static Logger logger =
24 Logger.getLogger(ThemeUtil.class);
25
26 public final static String XPATH_FILL_COLOR =
27 "/theme/field[@name='fillcolor']/@default";
28
29 public final static String XPATH_LINE_COLOR =
30 "/theme/field[@name='linecolor']/@default";
31
32 public final static String XPATH_AREA_LINE_COLOR =
33 "/theme/field[@name='areabordercolor']/@default";
34
35 public static final String XPATH_LINE_SIZE =
36 "/theme/field[@name='linesize']/@default";
37
38 public static final String XPATH_LINE_STYLE =
39 "/theme/field[@name='linetype']/@default";
40
41 public static final String XPATH_POINT_SIZE =
42 "/theme/field[@name='pointsize']/@default";
43
44 public static final String XPATH_POINT_COLOR =
45 "/theme/field[@name='pointcolor']/@default";
46
47 public final static String XPATH_SHOW_BORDER =
48 "/theme/field[@name='showborder']/@default";
49
50 public final static String XPATH_AREA_SHOW_BORDER =
51 "/theme/field[@name='showborder']/@default";
52
53 public final static String XPATH_SHOW_POINTS =
54 "/theme/field[@name='showpoints']/@default";
55
56 public final static String XPATH_SHOW_LINE =
57 "/theme/field[@name='showlines']/@default";
58
59 public final static String XPATH_SHOW_VERTICAL_LINE =
60 "/theme/field[@name='showverticalline']/@default";
61
62 public final static String XPATH_SHOW_HORIZONTAL_LINE =
63 "/theme/field[@name='showhorizontalline']/@default";
64
65 public final static String XPATH_SHOW_LINE_LABEL =
66 "/theme/field[@name='showlinelabel']/@default";
67
68 public final static String XPATH_SHOW_POINT_LABEL =
69 "/theme/field[@name='showpointlabel']/@default";
70
71 public final static String XPATH_SHOW_WIDTH =
72 "/theme/field[@name='showwidth']/@default";
73
74 public final static String XPATH_SHOW_LEVEL =
75 "/theme/field[@name='showlevel']/@default";
76
77 public final static String XPATH_TRANSPARENCY =
78 "/theme/field[@name='transparency']/@default";
79
80 public final static String XPATH_AREA_TRANSPARENCY =
81 "/theme/field[@name='areatransparency']/@default";
82
83 public final static String XPATH_SHOW_AREA =
84 "/theme/field[@name='showarea']/@default";
85
86 public final static String XPATH_SHOW_MIDDLE_HEIGHT =
87 "/theme/field[@name='showmiddleheight']/@default";
88
89 public final static String XPATH_LABEL_FONT_COLOR =
90 "/theme/field[@name='labelfontcolor']/@default";
91
92 public final static String XPATH_LABEL_FONT_SIZE =
93 "/theme/field[@name='labelfontsize']/@default";
94
95 public final static String XPATH_LABEL_FONT_FACE =
96 "/theme/field[@name='labelfontface']/@default";
97
98 public final static String XPATH_LABEL_FONT_STYLE =
99 "/theme/field[@name='labelfontstyle']/@default";
100
101 public final static String XPATH_TEXT_ORIENTATION =
102 "/theme/field[@name='textorientation']/@default";
103
104 public final static String XPATH_LABEL_BGCOLOR =
105 "/theme/field[@name='labelbgcolor']/@default";
106
107 public final static String XPATH_LABEL_SHOW_BACKGROUND =
108 "/theme/field[@name='labelshowbg']/@default";
109
110 public final static String XPATH_BACKGROUND_COLOR =
111 "/theme/field[@name='backgroundcolor']/@default";
112
113 public final static String XPATH_AREA_BACKGROUND_COLOR =
114 "/theme/field[@name='areabgcolor']/@default";
115
116 public final static String XPATH_SYMBOL =
117 "/theme/field[@name='symbol']/@default";
118
119 public final static String XPATH_SHOW_MINIMUM =
120 "/theme/field[@name='showminimum']/@default";
121
122 public final static String XPATH_SHOW_MAXIMUM =
123 "/theme/field[@name='showmaximum']/@default";
124
125 public final static String XPATH_WSPLGEN_FIELDS =
126 "/theme[@name='WSPLGEN']/field";
127
128 public final static String XPATH_WSPLGEN_STARTCOLOR =
129 "/theme/field[@name='startcolor']/@default";
130
131 public final static String XPATH_WSPLGEN_ENDCOLOR =
132 "/theme/field[@name='endcolor']/@default";
133
134 public final static String XPATH_WSPLGEN_NUMCLASSES =
135 "/theme/field[@name='numclasses']/@default";
136
137 /** XPATH to bandwidth field. */
138 public final static String XPATH_BANDWIDTH =
139 "/theme/field[@name='bandwidth']/@default";
140
141 /** XPATH to find showextramark field. */
142 public final static String XPATH_SHOWEXTRAMARK =
143 "/theme/field[@name='showextramark']/@default";
144
145 /** Parse string to be boolean with default if empty or unrecognized. */
146 public static boolean parseBoolean(String value, boolean defaultsTo) {
147 if (value == null || value.length() == 0) {
148 return defaultsTo;
149 }
150 if (value.equals("false")) {
151 return false;
152 }
153 else if (value.equals("true")) {
154 return true;
155 }
156 else {
157 return defaultsTo;
158 }
159 }
160
161
162 /**
163 * Attempt converting \param value to an integer, in failing cases,
164 * return \param defaultsTo.
165 * @param value String to be converted to integer.
166 * @param defaultsTo Default to return if conversion failed.
167 * @return \param value as integer or defaultsto if conversion failed.
168 */
169 public static int parseInteger(String value, int defaultsTo) {
170 if (value == null || value.length() == 0) {
171 return defaultsTo;
172 }
173
174 try {
175 return Integer.parseInt(value);
176 }
177 catch (NumberFormatException nfe) {
178 // do nothing
179 }
180
181 return defaultsTo;
182 }
183
184
185 /**
186 * Attempt converting \param value to a double, in failing cases,
187 * return \param defaultsTo.
188 * @param value String to be converted to double.
189 * @param defaultsTo Default to return if conversion failed.
190 * @return \param value as integer or defaultsto if conversion failed.
191 */
192 public static double parseDouble(String value, double defaultsTo) {
193 if (value == null || value.length() == 0) {
194 return defaultsTo;
195 }
196
197 try {
198 return Double.parseDouble(value);
199 }
200 catch (NumberFormatException nfe) {
201 // do nothing
202 }
203
204 return defaultsTo;
205 }
206
207
208 /**
209 * Parses line width, defaulting to 0.
210 * @param theme the theme
211 */
212 public static int parseLineWidth(Document theme) {
213 String size = XMLUtils.xpathString(theme, XPATH_LINE_SIZE, null);
214 if (size == null || size.length() == 0) {
215 return 0;
216 }
217
218 try {
219 return Integer.parseInt(size);
220 }
221 catch (NumberFormatException nfe) {
222 logger.warn("Unable to set line size from string: '" + size + "'");
223 }
224 return 0;
225 }
226
227
228 /**
229 * Parse band width, defaulting to 0.
230 * @param theme the theme.
231 */
232 public static double parseBandWidth(Document theme) {
233 String bandWidth = XMLUtils.xpathString(theme, XPATH_BANDWIDTH, null);
234
235 return parseDouble(bandWidth, 0);
236 }
237
238
239 public static int parsePointWidth(Document theme) {
240 String width = XMLUtils.xpathString(theme, XPATH_POINT_SIZE, null);
241
242 return parseInteger(width, 3);
243 }
244
245
246 public static Color parsePointColor(Document theme) {
247 String color = XMLUtils.xpathString(theme, XPATH_POINT_COLOR, null);
248 logger.debug("parsePointColor(): color = " + color);
249 return parseColor(color);
250 }
251
252
253 /**
254 * Parses the line style, defaulting to '10'.
255 * @param theme The theme.
256 */
257 public static float[] parseLineStyle(Document theme) {
258 String dash = XMLUtils.xpathString(theme, XPATH_LINE_STYLE, null);
259
260 float[] def = {10};
261 if (dash == null || dash.length() == 0) {
262 return def;
263 }
264
265 String[] pattern = dash.split(",");
266 if(pattern.length == 1) {
267 return def;
268 }
269
270 try {
271 float[] dashes = new float[pattern.length];
272 for (int i = 0; i < pattern.length; i++) {
273 dashes[i] = Float.parseFloat(pattern[i]);
274 }
275 return dashes;
276 }
277 catch(NumberFormatException nfe) {
278 logger.warn("Unable to set dash from string: '" + dash + "'");
279 return def;
280 }
281 }
282
283
284 /**
285 * Parses text size, defaulting to 10.
286 * @param theme The theme.
287 */
288 public static int parseTextSize(Document theme, String path) {
289 String size = XMLUtils.xpathString(theme, path, null);
290 if (size == null || size.length() == 0) {
291 return 10;
292 }
293
294 try {
295 return Integer.parseInt(size);
296 }
297 catch (NumberFormatException nfe) {
298 }
299 return 10;
300 }
301
302
303 public static int parseTextSize(Document theme) {
304 return parseTextSize(theme, XPATH_LABEL_FONT_SIZE);
305 }
306
307
308 /**
309 * Parses the attribute 'showextramark', defaults to false.
310 * @param theme The theme.
311 */
312 public static boolean parseShowExtraMark(Document theme) {
313 String show = XMLUtils.xpathString(theme, XPATH_SHOWEXTRAMARK, null);
314 return parseBoolean(show, false);
315 }
316
317 /**
318 * Parses the attribute 'showpoints', defaults to false.
319 * @param theme The theme.
320 */
321 public static boolean parseShowPoints(Document theme) {
322 String show = XMLUtils.xpathString(theme, XPATH_SHOW_POINTS, null);
323 return parseBoolean(show, false);
324 }
325
326 /**
327 * Parses the attribute 'showmiddleheight', defaults to false.
328 * @param theme The theme.
329 */
330 public static boolean parseShowMiddleHeight(Document theme) {
331 String show = XMLUtils.xpathString(theme, XPATH_SHOW_MIDDLE_HEIGHT, null);
332 return parseBoolean(show, false);
333 }
334
335 /**
336 * Parses the attribute 'showarea', defaults to false.
337 * @param theme The theme.
338 */
339 public static boolean parseShowArea(Document theme) {
340 String show = XMLUtils.xpathString(theme, XPATH_SHOW_AREA, null);
341 return parseBoolean(show, false);
342 }
343
344 /**
345 * Parses the attribute 'showverticalline', defaults to true.
346 * @param theme The theme.
347 */
348 public static boolean parseShowVerticalLine(Document theme) {
349 String show = XMLUtils.xpathString(theme, XPATH_SHOW_VERTICAL_LINE, null);
350 return parseBoolean(show, true);
351 }
352
353 /**
354 * Parses the attribute 'showhorizontalline', defaults to true.
355 * @param theme The theme.
356 */
357 public static boolean parseShowHorizontalLine(Document theme) {
358 String show = XMLUtils.xpathString(theme, XPATH_SHOW_HORIZONTAL_LINE, null);
359 return parseBoolean(show, true);
360 }
361
362 /**
363 * Parses the attribute 'showlines', defaults to true.
364 * @param theme The theme.
365 */
366 public static boolean parseShowLine(Document theme) {
367 String show = XMLUtils.xpathString(theme, XPATH_SHOW_LINE, null);
368 return parseBoolean(show, true);
369 }
370
371 /**
372 * Parses the attribute 'showlinelabel', defaults to true.
373 * @param theme The theme.
374 */
375 public static boolean parseShowLineLabel(Document theme) {
376 String show = XMLUtils.xpathString(theme, XPATH_SHOW_LINE_LABEL, null);
377 return parseBoolean(show, false);
378 }
379
380 public static boolean parseShowPointLabel(Document theme) {
381 String show = XMLUtils.xpathString(theme, XPATH_SHOW_POINT_LABEL, null);
382 return parseBoolean(show, false);
383 }
384
385 /**
386 * Parses text color.
387 * @param theme The theme.
388 */
389 public static Color parseTextColor(Document theme) {
390 return parseRGB(getTextColorString(theme));
391 }
392
393
394 /**
395 * Parses the font.
396 * @param theme The theme.
397 */
398 public static Font parseTextFont(Document theme) {
399 String font = XMLUtils.xpathString(theme, XPATH_LABEL_FONT_FACE, null);
400 if (font == null || font.length() == 0) {
401 return null;
402 }
403
404 int size = parseTextSize(theme);
405 int style = parseTextStyle(theme);
406 Font f = new Font (font, style, size);
407 return f;
408 }
409
410
411 /**
412 * Parses the text style, defaults to 'Font.PLAIN'.
413 * @param theme The theme.
414 */
415 public static int parseTextStyle(Document theme, String path) {
416 String style = XMLUtils.xpathString(theme, path, null);
417 if (style == null || style.length() == 0) {
418 return Font.PLAIN;
419 }
420
421 if (style.equals("italic")) {
422 return Font.ITALIC;
423 }
424 else if (style.equals("bold")) {
425 return Font.BOLD;
426 }
427 else {
428 return Font.PLAIN;
429 }
430 }
431
432
433 public static int parseTextStyle(Document theme) {
434 return parseTextStyle(theme, XPATH_LABEL_FONT_STYLE);
435 }
436
437
438 public static boolean parseShowWidth(Document theme) {
439 String show = XMLUtils.xpathString(theme, XPATH_SHOW_WIDTH, null);
440 return parseBoolean(show, false);
441 }
442
443
444 public static boolean parseShowLevel(Document theme) {
445 String show = XMLUtils.xpathString(theme, XPATH_SHOW_LEVEL, null);
446 return parseBoolean(show, false);
447 }
448
449 /**
450 * Parses the textorientation, defaults to 'vertical'.
451 * @param theme The theme.
452 */
453 public static String parseTextOrientation(Document theme) {
454 String o = XMLUtils.xpathString(theme, XPATH_TEXT_ORIENTATION, null);
455 if ("true".equals(o)) {
456 return "horizontal";
457 }
458 else {
459 return "vertical";
460 }
461 }
462
463
464 /**
465 * Parses the text background color, defaults to white.
466 * @param theme The theme.
467 */
468 public static Color parseTextBackground(Document theme) {
469 String color = getLabelBackgroundColorString(theme);
470 if (color == null || color.length() == 0) {
471 return Color.WHITE;
472 }
473 return parseRGB(color);
474 }
475
476
477 /**
478 * Parses the attribute whether to show background or not, defaults to
479 * false.
480 * @param theme The theme.
481 */
482 public static boolean parseLabelShowBackground(Document theme) {
483 String show = XMLUtils.xpathString(theme, XPATH_LABEL_SHOW_BACKGROUND, null);
484 return parseBoolean(show, false);
485 }
486
487
488 public static Color parseColor(String colorString) {
489 if (colorString == null || colorString.length() == 0) {
490 return null;
491 }
492 else if (colorString.indexOf("#") == 0) {
493 return parseHexColor(colorString);
494 }
495 else if (colorString.indexOf(",") >= 0) {
496 return parseRGB(colorString);
497 }
498
499 return null;
500 }
501
502
503 /**
504 * Parse a string like "#00CC22" and return the corresponding color.
505 *
506 * @param hex The hex color value.
507 *
508 * @return a Color or null, if <i>hex</i> is empty.
509 */
510 public static Color parseHexColor(String hex) {
511 if (hex == null) {
512 return null;
513 }
514
515 return Color.decode(hex);
516 }
517
518 /**
519 * Parse a string like "103, 100, 0" and return a corresping color.
520 * @param rgbtext Color as string representation, e.g. "255,0,20".
521 * @return Color, null in case of issues.
522 */
523 public static Color parseRGB(String rgbtext) {
524 if (rgbtext == null) {
525 return null;
526 }
527 String rgb[] = rgbtext.split(",");
528 Color c = null;
529 try {
530 c = new Color(
531 Integer.parseInt(rgb[0].trim()),
532 Integer.parseInt(rgb[1].trim()),
533 Integer.parseInt(rgb[2].trim()));
534 }
535 catch (NumberFormatException nfe) {
536 c = null;
537 }
538 return c;
539 }
540
541
542 public static String getLineColorString(Document theme) {
543 return XMLUtils.xpathString(theme, XPATH_LINE_COLOR, null);
544 }
545
546
547 /** Get show border as string. */
548 public static String getShowBorderString(Document theme) {
549 return XMLUtils.xpathString(theme, XPATH_SHOW_BORDER, null);
550 }
551
552
553 /** Get fill color as string. */
554 public static String getFillColorString(Document theme) {
555 return XMLUtils.xpathString(theme, XPATH_FILL_COLOR, null);
556 }
557
558
559 public static String getLabelBackgroundColorString(Document theme) {
560 return XMLUtils.xpathString(theme, XPATH_LABEL_BGCOLOR, null);
561 }
562
563
564 public static String getBackgroundColorString(Document theme) {
565 return XMLUtils.xpathString(theme, XPATH_BACKGROUND_COLOR, null);
566 }
567
568
569 public static String getTextColorString(Document theme) {
570 String textColor = XMLUtils.xpathString(theme, XPATH_LABEL_FONT_COLOR, null);
571 return textColor;
572 }
573
574
575 public static String getSymbol(Document theme) {
576 return XMLUtils.xpathString(theme, XPATH_SYMBOL, null);
577 }
578
579
580 public static String getTransparencyString(Document theme) {
581 return XMLUtils.xpathString(theme, XPATH_TRANSPARENCY, null);
582 }
583
584
585 public static String getAreaTransparencyString(Document theme) {
586 return XMLUtils.xpathString(theme, XPATH_AREA_TRANSPARENCY, null);
587 }
588
589
590 public static String getShowMinimum(Document theme) {
591 return XMLUtils.xpathString(theme, XPATH_SHOW_MINIMUM, null);
592 }
593
594
595 public static String getShowMaximum(Document theme) {
596 return XMLUtils.xpathString(theme, XPATH_SHOW_MAXIMUM, null);
597 }
598
599
600 /**
601 * Gets color from color field.
602 * @param theme the theme document.
603 * @return color.
604 */
605 public static Color parseFillColorField(Document theme) {
606 return parseRGB(getFillColorString(theme));
607 }
608
609
610 public static boolean parseShowBorder(Document theme) {
611 return parseBoolean(getShowBorderString(theme), false);
612 }
613
614
615 public static int parseTransparency(Document theme) {
616 return parseInteger(getTransparencyString(theme), 50);
617 }
618
619
620 /**
621 * Gets color from color field.
622 * @param theme the theme document.
623 * @return color.
624 */
625 public static Color parseLineColorField(Document theme) {
626 String lineColorStr = getLineColorString(theme);
627 logger.debug("parseLineColorField: lineColorStr = " +
628 (lineColorStr == null ? "null" : lineColorStr));
629 return parseColor(lineColorStr);
630 }
631
632
633 public static Color parseAreaLineColorField(Document theme) {
634 String lineColorStr = getAreaLineColorString(theme);
635 logger.debug("parseLineColorField: lineColorStr = " +
636 (lineColorStr == null ? "null" : lineColorStr));
637 return parseColor(lineColorStr);
638 }
639
640
641 private static String getAreaLineColorString(Document theme) {
642 return XMLUtils.xpathString(theme, XPATH_AREA_LINE_COLOR, null);
643 }
644
645
646 public static boolean parseShowMinimum(Document theme) {
647 return parseBoolean(getShowMinimum(theme), false);
648 }
649
650
651 public static boolean parseShowMaximum(Document theme) {
652 return parseBoolean(getShowMaximum(theme), false);
653 }
654
655
656 /**
657 * Creates a MapserverStyle from the given XML theme.
658 * This method uses a start- and endcolor to interpolate a
659 * given number of color classes for the MapserverStyle.
660 * @param theme
661 * @return String representation of the MapserverStyle
662 */
663 public static String createDynamicMapserverStyle(Document theme,
664 float from, float to, float step)
665 {
666 MapserverStyle ms = new MapserverStyle();
667
668 String strStartColor = XMLUtils.xpathString(theme, XPATH_WSPLGEN_STARTCOLOR, null);
669 Color startColor = strStartColor != null ? parseColor(strStartColor) : new Color(178, 201, 215);
670 String strEndColor = XMLUtils.xpathString(theme, XPATH_WSPLGEN_ENDCOLOR, null);
671 Color endColor = strEndColor != null? parseColor(strEndColor) : new Color(2, 27, 42);
672 /*
673 String strNumClasses = XMLUtils.xpathString(theme, XPATH_WSPLGEN_NUMCLASSES, null);
674 int numClasses;
675 if (strNumClasses != null) {
676 numClasses = Integer.parseInt(strNumClasses);
677 }
678 else {
679 numClasses = 5;
680 logger.warn("createDynamicMapserverStyle(): strNumClasses is null");
681 }
682
683 if (numClasses < 5) {
684 numClasses = 5;
685 }
686 else if (numClasses > 20) {
687 numClasses = 20;
688 }*/
689
690
691 int numClasses = (int)((to - from) / step);
692
693 float rd = (endColor.getRed() - startColor.getRed()) / (float)numClasses;
694 float gd = (endColor.getGreen() - startColor.getGreen()) / (float)numClasses;
695 float bd = (endColor.getBlue() - startColor.getBlue()) / (float)numClasses;
696
697 for (int n = 0; n < numClasses; n++) {
698 StringBuilder newColor = new StringBuilder();
699 newColor.append(startColor.getRed() + Math.round(n * rd));
700 newColor.append(' ');
701 newColor.append(startColor.getGreen() + Math.round(n * gd));
702 newColor.append(' ');
703 newColor.append(startColor.getBlue() + Math.round(n * bd));
704
705 String expr = createWSPLGENExpression(from + n * step, step, n + 1, numClasses);
706
707 Clazz c = new Clazz(expr);
708 Style s = new Style();
709 s.setColor(newColor.toString());
710 s.setSize(5);
711
712 c.addItem(new Expression("(" + expr + ")"));
713 c.addItem(s);
714
715 ms.addClazz(c);
716 }
717
718 return ms.toString();
719 }
720
721
722 protected static String createWSPLGENExpression(float val, float step, int idx, int maxIdx) {
723 if (idx < maxIdx) {
724 return "[DIFF] >= " + val + " AND [DIFF] < " + (val + step);
725 }
726 else {
727 return "[DIFF] >= " + val;
728 }
729 }
730
731
732 public static String createMapserverStyle(Document theme) {
733 String symbol = getSymbol(theme);
734 String backcolor = getLabelBackgroundColorString(theme);
735 String linecolor = getLineColorString(theme);
736 if (linecolor == null || "".equals(linecolor)) {
737 logger.warn("createMapserverStyle: linecolor String is empty");
738 linecolor = "0,128,255";
739 }
740
741 int linewidth = parseLineWidth(theme);
742
743 MapserverStyle ms = new MapserverStyle();
744
745 Clazz c = new Clazz(" ");
746
747 Style s = new Style();
748 s.setOutlineColor(linecolor.replace(",", " "));
749
750 if (backcolor != null && backcolor.length() > 0) {
751 s.setColor(backcolor.replace(",", " "));
752 }
753
754 s.setSize(linewidth);
755 s.setSymbol(symbol);
756 c.addItem(s);
757
758 String textcolor = getTextColorString(theme);
759 int textsize = parseTextSize(theme);
760
761 if (textcolor != null && textcolor.length() > 0 && textsize > 0) {
762 Label l = new Label();
763 l.setColor(textcolor.replace(",", " "));
764 l.setSize(textsize);
765 c.addItem(l);
766 }
767
768 ms.addClazz(c);
769
770 return ms.toString();
771 }
772
773
774 public static String getAreaBackgroundColorString(Document theme) {
775 return XMLUtils.xpathString(theme, XPATH_AREA_BACKGROUND_COLOR, null);
776 }
777
778
779 public static Color parseAreaBackgroundColor(Document theme) {
780 return parseColor(getAreaBackgroundColorString(theme));
781 }
782
783
784 public static int parseAreaTransparency(Document theme) {
785 return parseInteger(getAreaTransparencyString(theme), 50);
786 }
787
788
789 public static boolean parseAreaShowBorder(Document theme) {
790 return parseBoolean(getAreaShowBorderString(theme), false);
791 }
792
793
794 private static String getAreaShowBorderString(Document theme) {
795 return XMLUtils.xpathString(theme, XPATH_AREA_SHOW_BORDER, null);
796 }
797 }
798 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org