Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java @ 2076:41037d51c8b6
Added support for pointsize in chart themes.
flys-artifacts/trunk@3589 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 04 Jan 2012 16:13:10 +0000 |
parents | 4cdd9c4896f6 |
children | 27cc95e65f18 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Wed Jan 04 15:23:26 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Wed Jan 04 16:13:10 2012 +0000 @@ -35,6 +35,9 @@ public static final String XPATH_LINE_STYLE = "/theme/field[@name='linetype']/@default"; + public static final String XPATH_POINT_SIZE = + "/theme/field[@name='pointsize']/@default"; + public final static String XPATH_SHOW_BORDER = "/theme/field[@name='showborder']/@default"; @@ -95,6 +98,22 @@ } + public static int parseInteger(String value, int defaultsTo) { + if (value == null || value.length() == 0) { + return defaultsTo; + } + + try { + return Integer.valueOf(value); + } + catch (NumberFormatException nfe) { + // do nothing + } + + return defaultsTo; + } + + /** * Parses line width, defaulting to 0. * @param theme the theme @@ -115,6 +134,13 @@ } + public static int parsePointWidth(Document theme) { + String width = XMLUtils.xpathString(theme, XPATH_POINT_SIZE, null); + + return parseInteger(width, 3); + } + + /** * Parses the line style, defaulting to '10'. * @param theme The theme.