comparison src/java/de/intevation/mxd/reader/MultiLayerMarkerSymbolReader.java @ 46:34a93dad7604

Added MultiLayerMarkerSymbol(ArrowMarkerSymbol) support.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 18 Apr 2011 17:51:33 +0200
parents
children 5fc813f40fa5
comparison
equal deleted inserted replaced
45:90d4de478f15 46:34a93dad7604
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 multi layer marker symbol information.
21 *
22 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
23 */
24 public class MultiLayerMarkerSymbolReader implements ISymbolReader{
25
26 /**
27 * The logger.
28 */
29 private static final Logger logger =
30 Logger.getLogger(MultiLayerMarkerSymbolReader.class);
31
32 /**
33 * Private member.
34 */
35 private Element renderer;
36 private MultiLayerMarkerSymbol symbol;
37 private MapToXMLUtils util;
38
39
40 public MultiLayerMarkerSymbolReader(ISymbol symbol)
41 throws Exception {
42 logger.debug("contructor()");
43 if(symbol instanceof MultiLayerMarkerSymbol) {
44 this.symbol = (MultiLayerMarkerSymbol)symbol;
45 }
46 else {
47 throw new Exception("Not a MultiLayerMarkerSymbol!");
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 for(int i = 0; i < symbol.getLayerCount(); i++) {
87 IMarkerSymbol sym = symbol.getLayer(i);
88 if (sym instanceof ArrowMarkerSymbol) {
89 ArrowMarkerSymbol arrow = (ArrowMarkerSymbol)sym;
90 IColor c = arrow.getColor();
91 symbolElement.setAttribute(
92 "name",
93 arrow.getNameString());
94 symbolElement.setAttribute(
95 "length",
96 String.valueOf(arrow.getLength()));
97 symbolElement.setAttribute(
98 "width",
99 String.valueOf(arrow.getWidth()));
100 symbolElement.setAttribute(
101 "angle",
102 String.valueOf(arrow.getAngle()));
103 symbolElement.setAttribute(
104 "size",
105 String.valueOf(arrow.getSize()));
106 symbolElement.setAttribute(
107 "x_offset",
108 String.valueOf(arrow.getXOffset()));
109 symbolElement.setAttribute(
110 "y_offset",
111 String.valueOf(arrow.getYOffset()));
112 symbolElement.setAttribute(
113 "color",
114 String.valueOf(c.getRGB()));
115 symbolElement.setAttribute(
116 "tranparency",
117 String.valueOf(c.getTransparency()));
118 symbolElement.setAttribute("style", "arrow");
119 }
120 }
121 return symbolElement;
122 }
123 }
124 // 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)