annotate src/java/de/intevation/mxd/reader/SimpleMarkerSymbolReader.java @ 33:c51376f8e24c

Separated converter components into packages.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 12 Apr 2011 13:20:49 +0200
parents 8381aa59078e
children 7a927921eb6c
rev   line source
33
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 32
diff changeset
1 package de.intevation.mxd.reader;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 import java.io.IOException;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
4
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
6
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
7 import com.esri.arcgis.display.ISymbol;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8 import com.esri.arcgis.display.SimpleMarkerSymbol;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 import com.esri.arcgis.display.esriSimpleMarkerStyle;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 import com.esri.arcgis.display.IRgbColor;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 import com.esri.arcgis.display.RgbColor;
32
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
12 import com.esri.arcgis.display.IColor;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
14 import org.w3c.dom.Element;
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
15
33
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 32
diff changeset
16 import de.intevation.mxd.utils.MapToXMLUtils;
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 32
diff changeset
17
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 * Reads simple marker symbol information.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 *
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22 */
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23 public class SimpleMarkerSymbolReader implements ISymbolReader{
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
25 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
26 * The logger.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
27 */
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
28 private static final Logger logger =
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
29 Logger.getLogger(SimpleMarkerSymbolReader.class);
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
31 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
32 * Private member.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
33 */
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
34 private Element renderer;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35 private SimpleMarkerSymbol symbol;
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
36 private MapToXMLUtils util;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
38
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 public SimpleMarkerSymbolReader(ISymbol symbol) throws Exception{
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 logger.debug("contructor()");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 if(symbol instanceof SimpleMarkerSymbol)
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 this.symbol = (SimpleMarkerSymbol)symbol;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 else
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 throw new Exception("Not a SimpleMarkerSymbol!");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
45 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
46
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
47 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
48 * Setter for the parent XML element.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
49 *
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
50 * @param parent The XML parent node.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
51 */
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
52 public void setParent(Element parent) {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
53 this.renderer = parent;
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
54 }
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
55
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
56 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
57 * Setter for XML document helper.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
58 *
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
59 * @param util The helper class for storing map information.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
60 */
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
61 public void setUtil(MapToXMLUtils util) {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
62 this.util = util;
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
63 }
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
64
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
65 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
66 * Reads the symbol attributes.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
67 *
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
68 * @return The XML node.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
69 */
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
70 public Element read()
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
71 throws IOException {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 logger.debug("read()");
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
73 Element symbolElement;
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
74 try {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
75 symbolElement = util.addSymbol(renderer);
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
76 }
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
77 catch(Exception e) {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
78 e.printStackTrace();
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
79 return null;
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
80 }
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
81
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
82 symbolElement.setAttribute("name", symbol.getNameString());
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
83 if(symbol.getStyle() == esriSimpleMarkerStyle.esriSMSCircle)
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
84 symbolElement.setAttribute("style", "point");
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
85
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
86 if(symbol.getColor() instanceof IRgbColor) {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
87 IRgbColor color = (IRgbColor)symbol.getColor();
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
88 symbolElement.setAttribute("color", "(" + color.getRed() +
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
89 "," + color.getGreen() +
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
90 "," + color.getBlue() + ")");
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
91 symbolElement.setAttribute("transparency",
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
92 String.valueOf(color.getTransparency()));
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
93 }
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
94 else {
32
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
95 RgbColor col = new RgbColor();
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
96 col.setRGB(symbol.getColor().getRGB());
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
97 symbolElement.setAttribute("color", "(" + col.getRed() +
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
98 "," + col.getGreen() +
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
99 "," + col.getBlue() + ")");
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
100 symbolElement.setAttribute("transparency",
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
101 String.valueOf(col.getTransparency()));
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
102 }
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
103
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
104 symbolElement.setAttribute("size", String.valueOf(symbol.getSize()));
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
105 symbolElement.setAttribute("outline_size",
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
106 String.valueOf(symbol.getOutlineSize()));
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
107 if(symbol.getOutlineColor() instanceof IRgbColor) {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
108 IRgbColor color = (IRgbColor)symbol.getOutlineColor();
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
109 symbolElement.setAttribute("outline_color", "(" + color.getRed() +
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
110 "," + color.getGreen() +
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
111 "," + color.getBlue() + ")");
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
112 symbolElement.setAttribute("outline_transparency",
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
113 String.valueOf(color.getTransparency()));
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
114 }
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
115 else {
32
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
116 RgbColor col = new RgbColor();
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
117 col.setRGB(symbol.getOutlineColor().getRGB());
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
118 symbolElement.setAttribute("outline_color", "(" + col.getRed() +
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
119 "," + col.getGreen() +
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
120 "," + col.getBlue() + ")");
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
121 symbolElement.setAttribute("outline_transparency",
8381aa59078e Convert all symbol colors to RgbColor.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
122 String.valueOf(col.getTransparency()));
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
123 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
124
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
125 symbolElement.setAttribute("angle", String.valueOf(symbol.getAngle()));
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
126 symbolElement.setAttribute("offset",
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
127 symbol.getXOffset() + "," + symbol.getYOffset());
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
128
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
129 return symbolElement;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
130 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
131 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
132 // 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)