comparison artifacts/src/main/java/org/dive4elements/river/themes/ThemeDocument.java @ 6906:7a9cbb3a3d5a

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

http://dive4elements.wald.intevation.org