annotate src/java/de/intevation/mxd/reader/SimpleFillSymbolReader.java @ 80:83932f18dddc

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