Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/SimpleFillSymbolReader.java @ 106:609c234e8e23
merged with reimunds changes
author | Stephan Holl <stephan.holl@intevation.de> |
---|---|
date | Tue, 07 Jun 2011 15:50:43 +0200 |
parents | 59e06c405a9a |
children | fb93f20478cc |
rev | line source |
---|---|
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.mxd.reader; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
2 |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
3 import java.awt.Color; |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
4 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
6 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 import com.esri.arcgis.display.ISymbol; |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
8 import com.esri.arcgis.display.ILineSymbol; |
72
2cbe423b1fda
Added wrapper for fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
69
diff
changeset
|
9 import com.esri.arcgis.display.IFillSymbol; |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 import com.esri.arcgis.display.SimpleFillSymbol; |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
11 import com.esri.arcgis.display.esriSimpleFillStyle; |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 import com.esri.arcgis.display.IRgbColor; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 import com.esri.arcgis.display.RgbColor; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 import org.w3c.dom.Element; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
16 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 /** |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 * Reads simple marker symbol information. |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 * |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
22 public class SimpleFillSymbolReader |
80
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
23 extends AbstractSymbolReader { |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 /** |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 * The logger. |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 */ |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 private static final Logger logger = |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 Logger.getLogger(SimpleFillSymbolReader.class); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 /** |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 * Private member. |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 */ |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 private SimpleFillSymbol symbol; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 public SimpleFillSymbolReader(ISymbol symbol) throws Exception{ |
72
2cbe423b1fda
Added wrapper for fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
69
diff
changeset
|
37 logger.debug("contructor(ISymbol)"); |
2cbe423b1fda
Added wrapper for fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
69
diff
changeset
|
38 if(symbol instanceof SimpleFillSymbol) { |
2cbe423b1fda
Added wrapper for fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
69
diff
changeset
|
39 this.symbol = (SimpleFillSymbol)symbol; |
2cbe423b1fda
Added wrapper for fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
69
diff
changeset
|
40 } |
2cbe423b1fda
Added wrapper for fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
69
diff
changeset
|
41 else { |
2cbe423b1fda
Added wrapper for fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
69
diff
changeset
|
42 throw new Exception("Not a SimpleFillSymbol!"); |
2cbe423b1fda
Added wrapper for fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
69
diff
changeset
|
43 } |
2cbe423b1fda
Added wrapper for fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
69
diff
changeset
|
44 } |
2cbe423b1fda
Added wrapper for fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
69
diff
changeset
|
45 |
2cbe423b1fda
Added wrapper for fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
69
diff
changeset
|
46 public SimpleFillSymbolReader(IFillSymbol symbol) throws Exception{ |
2cbe423b1fda
Added wrapper for fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
69
diff
changeset
|
47 logger.debug("contructor(IFillSymbol)"); |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
48 if(symbol instanceof SimpleFillSymbol) { |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 this.symbol = (SimpleFillSymbol)symbol; |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
50 } |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
51 else { |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 throw new Exception("Not a SimpleFillSymbol!"); |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
53 } |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 } |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 /** |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 * Reads the symbol attributes. |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 * |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 * @return The XML node. |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
60 */ |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
61 public Element read() |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
62 throws Exception { |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 logger.debug("read()"); |
80
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
64 Element symbolElement = util.addSymbol(parent); |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 symbolElement.setAttribute("name", symbol.getNameString()); |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
67 symbolElement.setAttribute("style", "fill"); |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
68 int style = symbol.getStyle(); |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
69 switch(style) { |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
70 case esriSimpleFillStyle.esriSFSCross: |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
71 symbolElement.setAttribute("fillstyle", "cross"); break; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
72 case esriSimpleFillStyle.esriSFSSolid: |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
73 symbolElement.setAttribute("fillstyle", "solid"); break; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
74 case esriSimpleFillStyle.esriSFSVertical: |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
75 symbolElement.setAttribute("fillstyle", "vertical"); break; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
76 case esriSimpleFillStyle.esriSFSHorizontal: |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
77 symbolElement.setAttribute("fillstyle", "horizontal"); break; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
78 case esriSimpleFillStyle.esriSFSForwardDiagonal: |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
79 symbolElement.setAttribute("fillstyle", "fwdiagonal"); break; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
80 case esriSimpleFillStyle.esriSFSBackwardDiagonal: |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
81 symbolElement.setAttribute("fillstyle", "bwdiagonal"); break; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
82 case esriSimpleFillStyle.esriSFSDiagonalCross: |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
83 symbolElement.setAttribute("fillstyle", "diagonalcross"); |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
84 break; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
85 default: symbolElement.setAttribute("fillstyle", "empty"); |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
86 } |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
87 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
88 if(symbol.getColor() instanceof IRgbColor) { |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
89 IRgbColor color = (IRgbColor)symbol.getColor(); |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
90 Color c = new Color ( |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
91 color.getRed(), |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
92 color.getGreen(), |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
93 color.getBlue()); |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
94 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
95 symbolElement.setAttribute("transparency", |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
96 String.valueOf(color.getTransparency())); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
97 } |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
98 else { |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
99 RgbColor col = new RgbColor(); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
100 col.setRGB(symbol.getColor().getRGB()); |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
101 Color c = new Color ( |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
102 col.getRed(), |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
103 col.getGreen(), |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
104 col.getBlue()); |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
105 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
106 symbolElement.setAttribute("transparency", |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
107 String.valueOf(col.getTransparency())); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
108 } |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
109 |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
110 ILineSymbol ls = symbol.getOutline(); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
111 LineSymbolReader lsr = new LineSymbolReader(); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
112 if(lsr.canRead(ls)) { |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
113 lsr.setSymbol(ls); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
114 lsr.setUtil(util); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
115 lsr.setParent(symbolElement); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
116 lsr.read(); |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
117 } |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
118 else { |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
119 logger.debug("The type of " + ls.getClass().toString() + |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
120 " is not implemented!"); |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
121 } |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
122 |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
123 return symbolElement; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
124 } |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
125 } |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
126 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |