comparison src/java/de/intevation/mxd/reader/SimpleFillSymbolReader.java @ 36:472aa36d0e01

Added a new layer reader and symbol reader.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 12 Apr 2011 14:43:58 +0200
parents
children ef7ca23c4233
comparison
equal deleted inserted replaced
35:7873682a1a11 36:472aa36d0e01
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.SimpleFillSymbol;
9 import com.esri.arcgis.display.esriSimpleMarkerStyle;
10 import com.esri.arcgis.display.IRgbColor;
11 import com.esri.arcgis.display.RgbColor;
12
13 import org.w3c.dom.Element;
14
15 import de.intevation.mxd.utils.MapToXMLUtils;
16
17 /**
18 * Reads simple marker symbol information.
19 *
20 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
21 */
22 public class SimpleFillSymbolReader implements ISymbolReader{
23
24 /**
25 * The logger.
26 */
27 private static final Logger logger =
28 Logger.getLogger(SimpleFillSymbolReader.class);
29
30 /**
31 * Private member.
32 */
33 private Element renderer;
34 private SimpleFillSymbol symbol;
35 private MapToXMLUtils util;
36
37
38 public SimpleFillSymbolReader(ISymbol symbol) throws Exception{
39 logger.debug("contructor()");
40 if(symbol instanceof SimpleFillSymbol)
41 this.symbol = (SimpleFillSymbol)symbol;
42 else
43 throw new Exception("Not a SimpleFillSymbol!");
44 }
45
46 /**
47 * Setter for the parent XML element.
48 *
49 * @param parent The XML parent node.
50 */
51 public void setParent(Element parent) {
52 this.renderer = parent;
53 }
54
55 /**
56 * Setter for XML document helper.
57 *
58 * @param util The helper class for storing map information.
59 */
60 public void setUtil(MapToXMLUtils util) {
61 this.util = util;
62 }
63
64 /**
65 * Reads the symbol attributes.
66 *
67 * @return The XML node.
68 */
69 public Element read()
70 throws IOException {
71 logger.debug("read()");
72 Element symbolElement;
73 try {
74 symbolElement = util.addSymbol(renderer);
75 }
76 catch(Exception e) {
77 e.printStackTrace();
78 return null;
79 }
80
81 symbolElement.setAttribute("name", symbol.getNameString());
82 if(symbol.getStyle() == esriSimpleMarkerStyle.esriSMSCircle)
83 symbolElement.setAttribute("style", "point");
84
85 if(symbol.getColor() instanceof IRgbColor) {
86 IRgbColor color = (IRgbColor)symbol.getColor();
87 symbolElement.setAttribute("color", "(" + color.getRed() +
88 "," + color.getGreen() +
89 "," + color.getBlue() + ")");
90 symbolElement.setAttribute("transparency",
91 String.valueOf(color.getTransparency()));
92 }
93 else {
94 RgbColor col = new RgbColor();
95 col.setRGB(symbol.getColor().getRGB());
96 symbolElement.setAttribute("color", "(" + col.getRed() +
97 "," + col.getGreen() +
98 "," + col.getBlue() + ")");
99 symbolElement.setAttribute("transparency",
100 String.valueOf(col.getTransparency()));
101 }
102 //TODO read further attributes.
103 return symbolElement;
104 }
105 }
106 // 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)