Mercurial > mxd2map
comparison src/java/de/intevation/mxd/reader/LineFillSymbolReader.java @ 76:3087c89a5bb8
Added line fill symbol reader.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 27 May 2011 12:32:08 +0200 |
parents | |
children | 83932f18dddc |
comparison
equal
deleted
inserted
replaced
75:9ea64427ac7e | 76:3087c89a5bb8 |
---|---|
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.IFillSymbol; | |
11 import com.esri.arcgis.display.ILineSymbol; | |
12 import com.esri.arcgis.display.LineFillSymbol; | |
13 import com.esri.arcgis.display.esriSimpleFillStyle; | |
14 import com.esri.arcgis.display.MultiLayerMarkerSymbol; | |
15 import com.esri.arcgis.display.IRgbColor; | |
16 import com.esri.arcgis.display.RgbColor; | |
17 | |
18 import org.w3c.dom.Element; | |
19 import de.intevation.mxd.utils.MapToXMLUtils; | |
20 | |
21 /** | |
22 * Reads marker line symbol information. | |
23 * | |
24 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | |
25 */ | |
26 public class LineFillSymbolReader | |
27 extends AbstractSymbolReader{ | |
28 | |
29 /** | |
30 * The logger. | |
31 */ | |
32 private static final Logger logger = | |
33 Logger.getLogger(LineFillSymbolReader.class); | |
34 | |
35 /** | |
36 * Private member. | |
37 */ | |
38 private LineFillSymbol symbol; | |
39 | |
40 | |
41 public LineFillSymbolReader(ISymbol symbol) | |
42 throws Exception { | |
43 logger.debug("contructor()"); | |
44 if(symbol instanceof LineFillSymbol) { | |
45 this.symbol = (LineFillSymbol)symbol; | |
46 } | |
47 else { | |
48 throw new Exception("Not a LineFillSymbol!"); | |
49 } | |
50 } | |
51 | |
52 | |
53 public LineFillSymbolReader(IFillSymbol symbol) | |
54 throws Exception { | |
55 logger.debug("contructor()"); | |
56 if(symbol instanceof LineFillSymbol) { | |
57 this.symbol = (LineFillSymbol)symbol; | |
58 } | |
59 else { | |
60 throw new Exception("Not a LineFillSymbol!"); | |
61 } | |
62 } | |
63 | |
64 /** | |
65 * Reads the symbol attributes. | |
66 * | |
67 * @return The XML node. | |
68 */ | |
69 public Element read() | |
70 throws Exception { | |
71 logger.debug("read()"); | |
72 | |
73 Element symbolElement = util.addSymbol(parent); | |
74 | |
75 symbolElement.setAttribute("name", symbol.getNameString()); | |
76 symbolElement.setAttribute("style", "fill"); | |
77 symbolElement.setAttribute( | |
78 "offset", | |
79 String.valueOf(symbol.getOffset())); | |
80 symbolElement.setAttribute( | |
81 "separation", | |
82 String.valueOf(symbol.getSeparation())); | |
83 | |
84 if(symbol.getColor() instanceof IRgbColor) { | |
85 IRgbColor color = (IRgbColor)symbol.getColor(); | |
86 Color c = new Color ( | |
87 color.getRed(), | |
88 color.getGreen(), | |
89 color.getBlue()); | |
90 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); | |
91 symbolElement.setAttribute("transparency", | |
92 String.valueOf(color.getTransparency())); | |
93 } | |
94 else { | |
95 RgbColor col = new RgbColor(); | |
96 col.setRGB(symbol.getColor().getRGB()); | |
97 Color c = new Color ( | |
98 col.getRed(), | |
99 col.getGreen(), | |
100 col.getBlue()); | |
101 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); | |
102 symbolElement.setAttribute("transparency", | |
103 String.valueOf(col.getTransparency())); | |
104 } | |
105 | |
106 ILineSymbol ols = symbol.getOutline(); | |
107 LineSymbolReader olsr = new LineSymbolReader(); | |
108 if(olsr.canRead(ols)) { | |
109 olsr.setSymbol(ols); | |
110 olsr.setUtil(util); | |
111 olsr.setParent(symbolElement); | |
112 olsr.read(); | |
113 } | |
114 else { | |
115 logger.debug("The type of " + ols.getClass().toString() + | |
116 " is not implemented!"); | |
117 } | |
118 ILineSymbol ls = symbol.getLineSymbol(); | |
119 LineSymbolReader lsr = new LineSymbolReader(); | |
120 if(lsr.canRead(ls)) { | |
121 lsr.setSymbol(ls); | |
122 lsr.setUtil(util); | |
123 lsr.setParent(symbolElement); | |
124 lsr.read(); | |
125 } | |
126 else { | |
127 logger.debug("The type of " + ls.getClass().toString() + | |
128 " is not implemented!"); | |
129 } | |
130 return parent; | |
131 } | |
132 } | |
133 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |