comparison flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java @ 1876:dd467951335c

Added support for labels in Mapserver layers and options to modify its style. flys-artifacts/trunk@3234 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 11 Nov 2011 09:43:36 +0000
parents 5364b86a0880
children 84cf67a2a19e
comparison
equal deleted inserted replaced
1875:4fb81eb8b45b 1876:dd467951335c
9 9
10 import de.intevation.artifacts.common.utils.XMLUtils; 10 import de.intevation.artifacts.common.utils.XMLUtils;
11 11
12 import de.intevation.flys.artifacts.model.MapserverStyle; 12 import de.intevation.flys.artifacts.model.MapserverStyle;
13 import de.intevation.flys.artifacts.model.MapserverStyle.Clazz; 13 import de.intevation.flys.artifacts.model.MapserverStyle.Clazz;
14 import de.intevation.flys.artifacts.model.MapserverStyle.Style;
15 import de.intevation.flys.artifacts.model.MapserverStyle.Label;
14 16
15 17
16 /** 18 /**
17 * Utility to deal with themes and their representations. 19 * Utility to deal with themes and their representations.
18 */ 20 */
169 /** 171 /**
170 * Parses text color. 172 * Parses text color.
171 * @param theme The theme. 173 * @param theme The theme.
172 */ 174 */
173 public static Color parseTextColor(Document theme) { 175 public static Color parseTextColor(Document theme) {
174 String color = XMLUtils.xpathString(theme, XPATH_TEXT_COLOR, null); 176 return parseRGB(getTextColorString(theme));
175 return parseRGB(color);
176 } 177 }
177 178
178 179
179 /** 180 /**
180 * Parses the font. 181 * Parses the font.
293 public static String getLineColorString(Document theme) { 294 public static String getLineColorString(Document theme) {
294 return XMLUtils.xpathString(theme, XPATH_LINE_COLOR, null); 295 return XMLUtils.xpathString(theme, XPATH_LINE_COLOR, null);
295 } 296 }
296 297
297 298
299 public static String getTextColorString(Document theme) {
300 return XMLUtils.xpathString(theme, XPATH_TEXT_COLOR, null);
301 }
302
303
298 public static String getSymbol(Document theme) { 304 public static String getSymbol(Document theme) {
299 return XMLUtils.xpathString(theme, XPATH_SYMBOL, null); 305 return XMLUtils.xpathString(theme, XPATH_SYMBOL, null);
300 } 306 }
301 307
302 308
318 int linewidth = parseLineWidth(theme); 324 int linewidth = parseLineWidth(theme);
319 325
320 MapserverStyle ms = new MapserverStyle(); 326 MapserverStyle ms = new MapserverStyle();
321 327
322 Clazz c = new Clazz(" "); 328 Clazz c = new Clazz(" ");
323 c.setOutlineColor(linecolor); 329
324 c.setSize(linewidth); 330 Style s = new Style();
325 c.setSymbol(symbol); 331 s.setOutlineColor(linecolor);
332 s.setSize(linewidth);
333 s.setSymbol(symbol);
334 c.addItem(s);
335
336 String textcolor = getTextColorString(theme);
337 int textsize = parseTextSize(theme);
338
339 if (textcolor != null && textcolor.length() > 0 && textsize > 0) {
340 Label l = new Label();
341 l.setColor(textcolor.replace(",", ""));
342 l.setSize(textsize);
343 c.addItem(l);
344 }
326 345
327 ms.addClazz(c); 346 ms.addClazz(c);
328 347
329 return ms.toString(); 348 return ms.toString();
330 } 349 }

http://dive4elements.wald.intevation.org