Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Mon Jun 18 11:31:39 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Mon Jun 18 12:29:29 2012 +0000 @@ -43,6 +43,9 @@ public static final String XPATH_POINT_SIZE = "/theme/field[@name='pointsize']/@default"; + public static final String XPATH_POINT_COLOR = + "/theme/field[@name='pointcolor']/@default"; + public final static String XPATH_SHOW_BORDER = "/theme/field[@name='showborder']/@default"; @@ -188,6 +191,13 @@ } + public static Color parsePointColor(Document theme) { + String color = XMLUtils.xpathString(theme, XPATH_POINT_COLOR, null); + + return parseColor(color); + } + + /** * Parses the line style, defaulting to '10'. * @param theme The theme. @@ -458,6 +468,37 @@ return parseBoolean(show, false); } + + public static Color parseColor(String colorString) { + if (colorString == null || colorString.length() == 0) { + return null; + } + else if (colorString.indexOf("#") == 0) { + return parseHexColor(colorString); + } + else if (colorString.indexOf(",") >= 0) { + return parseRGB(colorString); + } + + return null; + } + + + /** + * Parse a string like "#00CC22" and return the corresponding color. + * + * @param hex The hex color value. + * + * @return a Color or null, if <i>hex</i> is empty. + */ + public static Color parseHexColor(String hex) { + if (hex == null) { + return null; + } + + return Color.decode(hex); + } + /** * Parse a string like "103, 100, 0" and return a corresping color. * @param rgbtext Color as string representation, e.g. "255,0,20".