comparison src/java/de/intevation/mxd/reader/CharacterMarkerSymbolReader.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 8e6d529e9a22
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.CharacterMarkerSymbol;
11 import com.esri.arcgis.display.IColor;
12 import com.esri.arcgis.support.ms.stdole.Font;
13
14 import org.w3c.dom.Element;
15 import de.intevation.mxd.utils.MapToXMLUtils;
16
17 /**
18 * Reads character marker symbol information.
19 *
20 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
21 */
22 public class CharacterMarkerSymbolReader implements ISymbolReader{
23
24 /**
25 * The logger.
26 */
27 private static final Logger logger =
28 Logger.getLogger(CharacterMarkerSymbolReader.class);
29
30 /**
31 * Private member.
32 */
33 private Element renderer;
34 private CharacterMarkerSymbol symbol;
35 private MapToXMLUtils util;
36
37
38 public CharacterMarkerSymbolReader(ISymbol symbol)
39 throws Exception {
40 logger.debug("contructor()");
41 if(symbol instanceof CharacterMarkerSymbol) {
42 this.symbol = (CharacterMarkerSymbol)symbol;
43 }
44 else {
45 throw new Exception("Not a CharacterMarkerSymbol!");
46 }
47 }
48
49 /**
50 * Setter for the parent XML element.
51 *
52 * @param parent The XML parent node.
53 */
54 public void setParent(Element parent) {
55 this.renderer = parent;
56 }
57
58 /**
59 * Setter for XML document helper.
60 *
61 * @param util The helper class for storing map information.
62 */
63 public void setUtil(MapToXMLUtils util) {
64 this.util = util;
65 }
66
67 /**
68 * Reads the symbol attributes.
69 *
70 * @return The XML node.
71 */
72 public Element read()
73 throws IOException {
74 logger.debug("read()");
75 Element symbolElement;
76 try {
77 symbolElement = util.addSymbol(renderer);
78 }
79 catch(Exception e) {
80 e.printStackTrace();
81 return null;
82 }
83
84 IColor c = symbol.getColor();
85 symbolElement.setAttribute(
86 "angle",
87 String.valueOf(symbol.getAngle()));
88 symbolElement.setAttribute(
89 "size",
90 String.valueOf(symbol.getSize()));
91 symbolElement.setAttribute(
92 "x_offset",
93 String.valueOf(symbol.getXOffset()));
94 symbolElement.setAttribute(
95 "y_offset",
96 String.valueOf(symbol.getYOffset()));
97 symbolElement.setAttribute(
98 "color",
99 String.valueOf(c.getRGB()));
100 symbolElement.setAttribute(
101 "tranparency",
102 String.valueOf(c.getTransparency()));
103 symbolElement.setAttribute(
104 "name",
105 symbol.getNameString());
106 Font f = symbol.getFont();
107 //TODO Read the font attributes.
108 symbolElement.setAttribute("style", "char");
109 return symbolElement;
110 }
111 }
112 // 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)