Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java @ 1753:741ba9e34c7d
Apply the attributes 'showpoints' and 'showline'.
flys-artifacts/trunk@3056 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 21 Oct 2011 14:02:07 +0000 |
parents | 415ec0223dff |
children | 1636686070f7 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Fri Oct 21 13:25:24 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Fri Oct 21 14:02:07 2011 +0000 @@ -24,9 +24,15 @@ public static final String XPATH_LINE_SIZE = "/theme/field[@name='linesize']/@default"; + public static final String XPATH_LINE_STYLE = + "/theme/field[@name='linetype']/@default"; + public final static String XPATH_SHOW_POINTS = "/theme/field[@name='showpoints']/@default"; + public final static String XPATH_SHOW_LINE = + "/theme/field[@name='showlines']/@default"; + public final static String XPATH_TEXT_COLOR = "/theme/field[@name='textcolor']/@default"; @@ -62,13 +68,44 @@ return Integer.valueOf(size); } catch (NumberFormatException nfe) { - //logger.warn("Unable to set line size from string: '" + size + "'"); + logger.warn("Unable to set line size from string: '" + size + "'"); } return 0; } /** + * Parses the line style, defaulting to '10'. + * @param theme The theme. + */ + public static float[] parseLineStyle(Document theme) { + String dash = XMLUtils.xpathString(theme, XPATH_LINE_STYLE, null); + + float[] def = {10}; + if (dash == null || dash.length() == 0) { + return def; + } + + String[] pattern = dash.split(","); + if(pattern.length == 1) { + return def; + } + + try { + float[] dashes = new float[pattern.length]; + for (int i = 0; i < pattern.length; i++) { + dashes[i] = Float.parseFloat(pattern[i]); + } + return dashes; + } + catch(NumberFormatException nfe) { + logger.warn("Unable to set dash from string: '" + dash + "'"); + return def; + } + } + + + /** * Parses text size, defaulting to 10. * @param theme The theme. */ @@ -106,6 +143,24 @@ /** + * Parses the attribute 'showlines', defaults to true. + * @param theme The theme. + */ + public static boolean parseShowLine(Document theme) { + String show = XMLUtils.xpathString(theme, XPATH_SHOW_LINE, null); + if (show == null || show.length() == 0) { + return true; + } + if (show.equals("false")) { + return false; + } + else { + return true; + } + } + + + /** * Parses text color. * @param theme The theme. */ @@ -211,7 +266,6 @@ * @return Color, null in case of issues. */ public static Color parseRGB(String rgbtext) { - logger.debug("parseColor: " + rgbtext); if (rgbtext == null) { return null; }