Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
2075:f42b0e624e97 | 2076:41037d51c8b6 |
---|---|
33 "/theme/field[@name='linesize']/@default"; | 33 "/theme/field[@name='linesize']/@default"; |
34 | 34 |
35 public static final String XPATH_LINE_STYLE = | 35 public static final String XPATH_LINE_STYLE = |
36 "/theme/field[@name='linetype']/@default"; | 36 "/theme/field[@name='linetype']/@default"; |
37 | 37 |
38 public static final String XPATH_POINT_SIZE = | |
39 "/theme/field[@name='pointsize']/@default"; | |
40 | |
38 public final static String XPATH_SHOW_BORDER = | 41 public final static String XPATH_SHOW_BORDER = |
39 "/theme/field[@name='showborder']/@default"; | 42 "/theme/field[@name='showborder']/@default"; |
40 | 43 |
41 public final static String XPATH_SHOW_POINTS = | 44 public final static String XPATH_SHOW_POINTS = |
42 "/theme/field[@name='showpoints']/@default"; | 45 "/theme/field[@name='showpoints']/@default"; |
93 return defaultsTo; | 96 return defaultsTo; |
94 } | 97 } |
95 } | 98 } |
96 | 99 |
97 | 100 |
101 public static int parseInteger(String value, int defaultsTo) { | |
102 if (value == null || value.length() == 0) { | |
103 return defaultsTo; | |
104 } | |
105 | |
106 try { | |
107 return Integer.valueOf(value); | |
108 } | |
109 catch (NumberFormatException nfe) { | |
110 // do nothing | |
111 } | |
112 | |
113 return defaultsTo; | |
114 } | |
115 | |
116 | |
98 /** | 117 /** |
99 * Parses line width, defaulting to 0. | 118 * Parses line width, defaulting to 0. |
100 * @param theme the theme | 119 * @param theme the theme |
101 */ | 120 */ |
102 public static int parseLineWidth(Document theme) { | 121 public static int parseLineWidth(Document theme) { |
110 } | 129 } |
111 catch (NumberFormatException nfe) { | 130 catch (NumberFormatException nfe) { |
112 logger.warn("Unable to set line size from string: '" + size + "'"); | 131 logger.warn("Unable to set line size from string: '" + size + "'"); |
113 } | 132 } |
114 return 0; | 133 return 0; |
134 } | |
135 | |
136 | |
137 public static int parsePointWidth(Document theme) { | |
138 String width = XMLUtils.xpathString(theme, XPATH_POINT_SIZE, null); | |
139 | |
140 return parseInteger(width, 3); | |
115 } | 141 } |
116 | 142 |
117 | 143 |
118 /** | 144 /** |
119 * Parses the line style, defaulting to '10'. | 145 * Parses the line style, defaulting to '10'. |