Mercurial > mxd2map
comparison src/java/de/intevation/mxd/reader/PictureMarkerSymbolReader.java @ 58:4e0464c620f0
Introduced the picture symbol reader.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 20 May 2011 15:34:35 +0200 |
parents | |
children | 5c5ef5768893 |
comparison
equal
deleted
inserted
replaced
57:8da6555f1c12 | 58:4e0464c620f0 |
---|---|
1 package de.intevation.mxd.reader; | |
2 | |
3 import java.io.IOException; | |
4 | |
5 import org.apache.log4j.Logger; | |
6 | |
7 import com.esri.arcgis.display.ISymbol; | |
8 import com.esri.arcgis.display.PictureMarkerSymbol; | |
9 import com.esri.arcgis.display.IColor; | |
10 import com.esri.arcgis.carto.PictureElement; | |
11 | |
12 import org.w3c.dom.Element; | |
13 import de.intevation.mxd.utils.MapToXMLUtils; | |
14 | |
15 /** | |
16 * Reads picture marker symbol information. | |
17 * | |
18 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | |
19 */ | |
20 public class PictureMarkerSymbolReader implements ISymbolReader{ | |
21 | |
22 /** | |
23 * The logger. | |
24 */ | |
25 private static final Logger logger = | |
26 Logger.getLogger(PictureMarkerSymbolReader.class); | |
27 | |
28 /** | |
29 * Private member. | |
30 */ | |
31 private Element renderer; | |
32 private PictureMarkerSymbol symbol; | |
33 private MapToXMLUtils util; | |
34 | |
35 | |
36 public PictureMarkerSymbolReader(ISymbol symbol) | |
37 throws Exception { | |
38 logger.debug("contructor()"); | |
39 if(symbol instanceof PictureMarkerSymbol) { | |
40 this.symbol = (PictureMarkerSymbol)symbol; | |
41 } | |
42 else { | |
43 throw new Exception("Not a PictureMarkerSymbol!"); | |
44 } | |
45 } | |
46 | |
47 /** | |
48 * Setter for the parent XML element. | |
49 * | |
50 * @param parent The XML parent node. | |
51 */ | |
52 public void setParent(Element parent) { | |
53 this.renderer = parent; | |
54 } | |
55 | |
56 /** | |
57 * Setter for XML document helper. | |
58 * | |
59 * @param util The helper class for storing map information. | |
60 */ | |
61 public void setUtil(MapToXMLUtils util) { | |
62 this.util = util; | |
63 } | |
64 | |
65 /** | |
66 * Reads the symbol attributes. | |
67 * | |
68 * @return The XML node. | |
69 */ | |
70 public Element read() | |
71 throws IOException { | |
72 logger.debug("read()"); | |
73 Element symbolElement; | |
74 try { | |
75 symbolElement = util.addSymbol(renderer); | |
76 } | |
77 catch(Exception e) { | |
78 e.printStackTrace(); | |
79 return null; | |
80 } | |
81 | |
82 symbolElement.setAttribute( | |
83 "angle", | |
84 String.valueOf(symbol.getAngle())); | |
85 symbolElement.setAttribute( | |
86 "size", | |
87 String.valueOf(symbol.getSize())); | |
88 symbolElement.setAttribute( | |
89 "x_offset", | |
90 String.valueOf(symbol.getXOffset())); | |
91 symbolElement.setAttribute( | |
92 "y_offset", | |
93 String.valueOf(symbol.getYOffset())); | |
94 symbolElement.setAttribute( | |
95 "name", | |
96 symbol.getNameString()); | |
97 PictureElement pElem = new PictureElement(); | |
98 pElem.importPicture(symbol.getPicture()); | |
99 System.out.println("Path:" + pElem.getPath()); | |
100 symbolElement.setAttribute("style", "picture"); | |
101 return symbolElement; | |
102 } | |
103 } | |
104 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |