Mercurial > mxd2map
comparison src/java/de/intevation/mxd/reader/SimpleMarkerSymbolReader.java @ 31:40c0b4e5f91a
Added utility class to store map attributes.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 11 Apr 2011 16:04:03 +0200 |
parents | 3e24fffdf2bb |
children | 8381aa59078e |
comparison
equal
deleted
inserted
replaced
30:c34c450edb06 | 31:40c0b4e5f91a |
---|---|
8 import com.esri.arcgis.display.SimpleMarkerSymbol; | 8 import com.esri.arcgis.display.SimpleMarkerSymbol; |
9 import com.esri.arcgis.display.esriSimpleMarkerStyle; | 9 import com.esri.arcgis.display.esriSimpleMarkerStyle; |
10 import com.esri.arcgis.display.IRgbColor; | 10 import com.esri.arcgis.display.IRgbColor; |
11 import com.esri.arcgis.display.RgbColor; | 11 import com.esri.arcgis.display.RgbColor; |
12 | 12 |
13 import org.w3c.dom.Element; | |
14 | |
13 /** | 15 /** |
14 * Reads simple marker symbol information. | 16 * Reads simple marker symbol information. |
15 * | 17 * |
16 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | 18 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
17 */ | 19 */ |
18 public class SimpleMarkerSymbolReader implements ISymbolReader{ | 20 public class SimpleMarkerSymbolReader implements ISymbolReader{ |
19 | 21 |
20 //Member | 22 /** |
21 private static final Logger logger = Logger.getLogger(SimpleMarkerSymbolReader.class); | 23 * The logger. |
24 */ | |
25 private static final Logger logger = | |
26 Logger.getLogger(SimpleMarkerSymbolReader.class); | |
22 | 27 |
28 /** | |
29 * Private member. | |
30 */ | |
31 private Element renderer; | |
23 private SimpleMarkerSymbol symbol; | 32 private SimpleMarkerSymbol symbol; |
33 private MapToXMLUtils util; | |
24 | 34 |
25 //Constructor | 35 |
26 public SimpleMarkerSymbolReader(ISymbol symbol) throws Exception{ | 36 public SimpleMarkerSymbolReader(ISymbol symbol) throws Exception{ |
27 logger.debug("contructor()"); | 37 logger.debug("contructor()"); |
28 if(symbol instanceof SimpleMarkerSymbol) | 38 if(symbol instanceof SimpleMarkerSymbol) |
29 this.symbol = (SimpleMarkerSymbol)symbol; | 39 this.symbol = (SimpleMarkerSymbol)symbol; |
30 else | 40 else |
31 throw new Exception("Not a SimpleMarkerSymbol!"); | 41 throw new Exception("Not a SimpleMarkerSymbol!"); |
32 } | 42 } |
33 | 43 |
44 /** | |
45 * Setter for the parent XML element. | |
46 * | |
47 * @param parent The XML parent node. | |
48 */ | |
49 public void setParent(Element parent) { | |
50 this.renderer = parent; | |
51 } | |
34 | 52 |
35 //Methods | 53 /** |
36 public boolean read() throws IOException{ | 54 * Setter for XML document helper. |
55 * | |
56 * @param util The helper class for storing map information. | |
57 */ | |
58 public void setUtil(MapToXMLUtils util) { | |
59 this.util = util; | |
60 } | |
61 | |
62 /** | |
63 * Reads the symbol attributes. | |
64 * | |
65 * @return The XML node. | |
66 */ | |
67 public Element read() | |
68 throws IOException { | |
37 logger.debug("read()"); | 69 logger.debug("read()"); |
38 System.out.println("--------------------"); | 70 Element symbolElement; |
39 System.out.println("Symbol information:"); | 71 try { |
40 System.out.println("Name\t\t = " + symbol.getNameString()); | 72 symbolElement = util.addSymbol(renderer); |
73 } | |
74 catch(Exception e) { | |
75 e.printStackTrace(); | |
76 return null; | |
77 } | |
41 | 78 |
79 symbolElement.setAttribute("name", symbol.getNameString()); | |
42 if(symbol.getStyle() == esriSimpleMarkerStyle.esriSMSCircle) | 80 if(symbol.getStyle() == esriSimpleMarkerStyle.esriSMSCircle) |
43 System.out.println("Style\t\t = Point"); | 81 symbolElement.setAttribute("style", "point"); |
44 if(symbol.getColor() instanceof IRgbColor){ | 82 |
83 if(symbol.getColor() instanceof IRgbColor) { | |
45 IRgbColor color = (IRgbColor)symbol.getColor(); | 84 IRgbColor color = (IRgbColor)symbol.getColor(); |
46 System.out.println("Color\t\t = (" + color.getRed() + | 85 symbolElement.setAttribute("color", "(" + color.getRed() + |
47 "," + color.getGreen() + | 86 "," + color.getGreen() + |
48 "," + color.getBlue() + ")"); | 87 "," + color.getBlue() + ")"); |
49 System.out.println("Transparency\t = " + color.getTransparency()); | 88 symbolElement.setAttribute("transparency", |
89 String.valueOf(color.getTransparency())); | |
50 } | 90 } |
51 else{ | 91 else { |
92 System.out.println("Color type unknown! " + | |
93 symbol.getColor().getClass().toString()); | |
94 } | |
95 | |
96 symbolElement.setAttribute("size", String.valueOf(symbol.getSize())); | |
97 symbolElement.setAttribute("outline_size", | |
98 String.valueOf(symbol.getOutlineSize())); | |
99 if(symbol.getOutlineColor() instanceof IRgbColor) { | |
100 IRgbColor color = (IRgbColor)symbol.getOutlineColor(); | |
101 symbolElement.setAttribute("outline_color", "(" + color.getRed() + | |
102 "," + color.getGreen() + | |
103 "," + color.getBlue() + ")"); | |
104 symbolElement.setAttribute("outline_transparency", | |
105 String.valueOf(color.getTransparency())); | |
106 } | |
107 else { | |
52 System.out.println("Color type unknown! " + | 108 System.out.println("Color type unknown! " + |
53 symbol.getColor().getClass().toString()); | 109 symbol.getColor().getClass().toString()); |
54 } | 110 } |
55 if(symbol.getOutlineColor() instanceof RgbColor){ | |
56 RgbColor color = (RgbColor)symbol.getOutlineColor(); | |
57 System.out.println("Outlinecolor\t = (" + color.getRed() + | |
58 "," + color.getGreen() + | |
59 "," + color.getBlue() + ")"); | |
60 System.out.println("Transparency\t = " + color.getTransparency()); | |
61 } | |
62 else{ | |
63 System.out.println("Color type unknown! " + | |
64 symbol.getOutlineColor().getClass().toString()); | |
65 } | |
66 | 111 |
67 System.out.println("Size\t\t = " + symbol.getSize()); | 112 symbolElement.setAttribute("angle", String.valueOf(symbol.getAngle())); |
68 System.out.println("OutlineSize\t\t = " + symbol.getOutlineSize()); | 113 symbolElement.setAttribute("offset", |
69 System.out.println("Angle\t\t = " + symbol.getAngle()); | 114 symbol.getXOffset() + "," + symbol.getYOffset()); |
70 System.out.println("Offset\t\t = " + symbol.getXOffset() + | |
71 "," + symbol.getYOffset()); | |
72 System.out.println(""); | |
73 return true; | |
74 } | |
75 | 115 |
76 public void getSymbol() throws IOException{ | 116 return symbolElement; |
77 logger.debug("getSymbol() -> not implemented jet."); | |
78 } | 117 } |
79 } | 118 } |
80 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 119 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |