Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
1752:b7b424ae32a8 | 1753:741ba9e34c7d |
---|---|
22 "/theme/field[@name='linecolor']/@default"; | 22 "/theme/field[@name='linecolor']/@default"; |
23 | 23 |
24 public static final String XPATH_LINE_SIZE = | 24 public static final String XPATH_LINE_SIZE = |
25 "/theme/field[@name='linesize']/@default"; | 25 "/theme/field[@name='linesize']/@default"; |
26 | 26 |
27 public static final String XPATH_LINE_STYLE = | |
28 "/theme/field[@name='linetype']/@default"; | |
29 | |
27 public final static String XPATH_SHOW_POINTS = | 30 public final static String XPATH_SHOW_POINTS = |
28 "/theme/field[@name='showpoints']/@default"; | 31 "/theme/field[@name='showpoints']/@default"; |
32 | |
33 public final static String XPATH_SHOW_LINE = | |
34 "/theme/field[@name='showlines']/@default"; | |
29 | 35 |
30 public final static String XPATH_TEXT_COLOR = | 36 public final static String XPATH_TEXT_COLOR = |
31 "/theme/field[@name='textcolor']/@default"; | 37 "/theme/field[@name='textcolor']/@default"; |
32 | 38 |
33 public final static String XPATH_TEXT_SIZE = | 39 public final static String XPATH_TEXT_SIZE = |
60 | 66 |
61 try { | 67 try { |
62 return Integer.valueOf(size); | 68 return Integer.valueOf(size); |
63 } | 69 } |
64 catch (NumberFormatException nfe) { | 70 catch (NumberFormatException nfe) { |
65 //logger.warn("Unable to set line size from string: '" + size + "'"); | 71 logger.warn("Unable to set line size from string: '" + size + "'"); |
66 } | 72 } |
67 return 0; | 73 return 0; |
74 } | |
75 | |
76 | |
77 /** | |
78 * Parses the line style, defaulting to '10'. | |
79 * @param theme The theme. | |
80 */ | |
81 public static float[] parseLineStyle(Document theme) { | |
82 String dash = XMLUtils.xpathString(theme, XPATH_LINE_STYLE, null); | |
83 | |
84 float[] def = {10}; | |
85 if (dash == null || dash.length() == 0) { | |
86 return def; | |
87 } | |
88 | |
89 String[] pattern = dash.split(","); | |
90 if(pattern.length == 1) { | |
91 return def; | |
92 } | |
93 | |
94 try { | |
95 float[] dashes = new float[pattern.length]; | |
96 for (int i = 0; i < pattern.length; i++) { | |
97 dashes[i] = Float.parseFloat(pattern[i]); | |
98 } | |
99 return dashes; | |
100 } | |
101 catch(NumberFormatException nfe) { | |
102 logger.warn("Unable to set dash from string: '" + dash + "'"); | |
103 return def; | |
104 } | |
68 } | 105 } |
69 | 106 |
70 | 107 |
71 /** | 108 /** |
72 * Parses text size, defaulting to 10. | 109 * Parses text size, defaulting to 10. |
104 } | 141 } |
105 } | 142 } |
106 | 143 |
107 | 144 |
108 /** | 145 /** |
146 * Parses the attribute 'showlines', defaults to true. | |
147 * @param theme The theme. | |
148 */ | |
149 public static boolean parseShowLine(Document theme) { | |
150 String show = XMLUtils.xpathString(theme, XPATH_SHOW_LINE, null); | |
151 if (show == null || show.length() == 0) { | |
152 return true; | |
153 } | |
154 if (show.equals("false")) { | |
155 return false; | |
156 } | |
157 else { | |
158 return true; | |
159 } | |
160 } | |
161 | |
162 | |
163 /** | |
109 * Parses text color. | 164 * Parses text color. |
110 * @param theme The theme. | 165 * @param theme The theme. |
111 */ | 166 */ |
112 public static Color parseTextColor(Document theme) { | 167 public static Color parseTextColor(Document theme) { |
113 String color = XMLUtils.xpathString(theme, XPATH_TEXT_COLOR, null); | 168 String color = XMLUtils.xpathString(theme, XPATH_TEXT_COLOR, null); |
209 * Parse a string like "103, 100, 0" and return a corresping color. | 264 * Parse a string like "103, 100, 0" and return a corresping color. |
210 * @param rgbtext Color as string representation, e.g. "255,0,20". | 265 * @param rgbtext Color as string representation, e.g. "255,0,20". |
211 * @return Color, null in case of issues. | 266 * @return Color, null in case of issues. |
212 */ | 267 */ |
213 public static Color parseRGB(String rgbtext) { | 268 public static Color parseRGB(String rgbtext) { |
214 logger.debug("parseColor: " + rgbtext); | |
215 if (rgbtext == null) { | 269 if (rgbtext == null) { |
216 return null; | 270 return null; |
217 } | 271 } |
218 String rgb[] = rgbtext.split(","); | 272 String rgb[] = rgbtext.split(","); |
219 Color c = null; | 273 Color c = null; |