comparison src/java/de/intevation/mxd/writer/MarkerStyleWriter.java @ 87:7d4cf2db43f1

Added new writer classes to be flexible in creating mapfiles.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 31 May 2011 17:54:43 +0200
parents
children 11d63bf00326
comparison
equal deleted inserted replaced
86:e19c5eb43099 87:7d4cf2db43f1
1 package de.intevation.mxd.writer;
2
3 import java.awt.Color;
4
5 import org.apache.log4j.Logger;
6
7 import org.w3c.dom.Element;
8
9 import edu.umn.gis.mapscript.mapObj;
10 import edu.umn.gis.mapscript.classObj;
11 import edu.umn.gis.mapscript.styleObj;
12 import edu.umn.gis.mapscript.colorObj;
13 import edu.umn.gis.mapscript.symbolSetObj;
14
15
16 /**
17 * The interface to the mapfile writer.
18 *
19 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
20 */
21 public class MarkerStyleWriter {
22
23 /**
24 * The Logger.
25 */
26 private static final Logger logger = Logger.getLogger(MarkerStyleWriter.class);
27
28 private mapObj map;
29 private classObj cl;
30 private styleObj style;
31
32 public MarkerStyleWriter (mapObj map, classObj cl) {
33 this.map = map;
34 this.cl = cl;
35 this.style = new styleObj(cl);
36 }
37
38 /**
39 * Write the content.
40 */
41 public boolean write(Element symbolElement)
42 throws Exception {
43 logger.debug("write(Element)");
44 symbolSetObj symbolSet = map.getSymbolset();
45
46 if (symbolElement.hasAttribute("angle")) {
47 style.setAngle(
48 Double.parseDouble(symbolElement.getAttribute("angle")));
49 }
50 if(symbolElement.hasAttribute("color")) {
51 String c = symbolElement.getAttribute("color");
52 Color col = Color.decode(c);
53 colorObj color = new colorObj(
54 col.getRed(),
55 col.getGreen(),
56 col.getBlue(),
57 -4);
58 style.setColor(color);
59 }
60 if (symbolElement.hasAttribute ("size")) {
61 style.setSize(Double.parseDouble(
62 symbolElement.getAttribute("size")));
63 }
64 if(symbolElement.hasAttribute("outline_color")) {
65 Color oCol = Color.decode(
66 symbolElement.getAttribute("outline_color"));
67 colorObj outlineColor = new colorObj(
68 oCol.getRed(),
69 oCol.getGreen(),
70 oCol.getBlue(),
71 -4);
72 style.setOutlinecolor(outlineColor);
73 style.setOutlinewidth(Double.parseDouble(
74 symbolElement.getAttribute("outline_size")));
75 }
76
77 String name = symbolElement.getAttribute("name");
78 style.setSymbolByName(map, name);
79
80 String symType = symbolElement.getAttribute("style");
81 if(symType.equals("point") ||
82 symType.equals("arrow") ||
83 symType.equals("char")) {
84 SymbolWriter sw = new SymbolWriter(this.map, this.cl);
85 sw.write(symbolElement);
86 }
87 else {
88 return false;
89 }
90 return true;
91 }
92 }
93 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)