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