comparison flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java @ 3090:22def36d37b7

Apply point color in XYStyle. flys-artifacts/trunk@4689 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 18 Jun 2012 12:29:29 +0000
parents 5642a83420f2
children 1d79c85bd8c2
comparison
equal deleted inserted replaced
3089:7e4c8590067a 3090:22def36d37b7
41 "/theme/field[@name='linetype']/@default"; 41 "/theme/field[@name='linetype']/@default";
42 42
43 public static final String XPATH_POINT_SIZE = 43 public static final String XPATH_POINT_SIZE =
44 "/theme/field[@name='pointsize']/@default"; 44 "/theme/field[@name='pointsize']/@default";
45 45
46 public static final String XPATH_POINT_COLOR =
47 "/theme/field[@name='pointcolor']/@default";
48
46 public final static String XPATH_SHOW_BORDER = 49 public final static String XPATH_SHOW_BORDER =
47 "/theme/field[@name='showborder']/@default"; 50 "/theme/field[@name='showborder']/@default";
48 51
49 public final static String XPATH_SHOW_POINTS = 52 public final static String XPATH_SHOW_POINTS =
50 "/theme/field[@name='showpoints']/@default"; 53 "/theme/field[@name='showpoints']/@default";
183 186
184 public static int parsePointWidth(Document theme) { 187 public static int parsePointWidth(Document theme) {
185 String width = XMLUtils.xpathString(theme, XPATH_POINT_SIZE, null); 188 String width = XMLUtils.xpathString(theme, XPATH_POINT_SIZE, null);
186 189
187 return parseInteger(width, 3); 190 return parseInteger(width, 3);
191 }
192
193
194 public static Color parsePointColor(Document theme) {
195 String color = XMLUtils.xpathString(theme, XPATH_POINT_COLOR, null);
196
197 return parseColor(color);
188 } 198 }
189 199
190 200
191 /** 201 /**
192 * Parses the line style, defaulting to '10'. 202 * Parses the line style, defaulting to '10'.
454 * @param theme The theme. 464 * @param theme The theme.
455 */ 465 */
456 public static boolean parseShowLineLabelBG(Document theme) { 466 public static boolean parseShowLineLabelBG(Document theme) {
457 String show = XMLUtils.xpathString(theme, XPATH_LINE_LABEL_SHOWBG, null); 467 String show = XMLUtils.xpathString(theme, XPATH_LINE_LABEL_SHOWBG, null);
458 return parseBoolean(show, false); 468 return parseBoolean(show, false);
469 }
470
471
472 public static Color parseColor(String colorString) {
473 if (colorString == null || colorString.length() == 0) {
474 return null;
475 }
476 else if (colorString.indexOf("#") == 0) {
477 return parseHexColor(colorString);
478 }
479 else if (colorString.indexOf(",") >= 0) {
480 return parseRGB(colorString);
481 }
482
483 return null;
484 }
485
486
487 /**
488 * Parse a string like "#00CC22" and return the corresponding color.
489 *
490 * @param hex The hex color value.
491 *
492 * @return a Color or null, if <i>hex</i> is empty.
493 */
494 public static Color parseHexColor(String hex) {
495 if (hex == null) {
496 return null;
497 }
498
499 return Color.decode(hex);
459 } 500 }
460 501
461 /** 502 /**
462 * Parse a string like "103, 100, 0" and return a corresping color. 503 * Parse a string like "103, 100, 0" and return a corresping color.
463 * @param rgbtext Color as string representation, e.g. "255,0,20". 504 * @param rgbtext Color as string representation, e.g. "255,0,20".

http://dive4elements.wald.intevation.org