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