Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/SimpleRendererReader.java @ 94:273e49f51cfb
Merged with Stephans commit.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 01 Jun 2011 11:52:53 +0200 |
parents | 59e06c405a9a |
children | c8a1361ddd38 |
rev | line source |
---|---|
33
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
1 package de.intevation.mxd.reader; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
2 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
4 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
5 import com.esri.arcgis.carto.IFeatureRenderer; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
6 import com.esri.arcgis.display.ISymbol; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 import com.esri.arcgis.carto.SimpleRenderer; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
9 import org.w3c.dom.Element; |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
10 |
33
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
11 import de.intevation.mxd.utils.MapToXMLUtils; |
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
12 |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 /** |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 * Reads simple renderer information. |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 * |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
16 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 */ |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
18 public class SimpleRendererReader |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
19 implements IRendererReader { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
21 /** |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
22 * The logger. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
23 */ |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
24 private static final Logger logger = |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
25 Logger.getLogger(SimpleRendererReader.class); |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
26 |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
27 /** |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
28 * Private member. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
29 */ |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 private ISymbol symbol; |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
31 private SimpleRenderer renderer; |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
32 private Element layer; |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
33 private MapToXMLUtils util; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
36 public SimpleRendererReader(IFeatureRenderer renderer) |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
37 throws Exception { |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
38 logger.debug("constructor()"); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
39 if(renderer instanceof SimpleRenderer) { |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
40 this.renderer = (SimpleRenderer)renderer; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 } |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
42 else{ |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
43 throw new Exception ("Not an instance of SimpleRenderer!"); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
44 } |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
47 /** |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
48 * Setter for the parent XML element. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
49 * |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
50 * @param parent The XML parent node. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
51 */ |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
52 public void setParent(Element parent) { |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
53 this.layer = parent; |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
54 } |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
55 |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
56 /** |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
57 * Setter for the XML document helper. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
58 * |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
59 * @param util The helper class for storing map information. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
60 */ |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
61 public void setUtil(MapToXMLUtils util) { |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
62 this.util = util; |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
63 } |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
64 |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
65 /** |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
66 * Reads the renderer attributes. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
67 * |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
68 * @return The XML node. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
69 */ |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
70 public Element read() |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
71 throws Exception { |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
72 logger.debug("read()"); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
73 Element rendererElement; |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
74 rendererElement = util.addRenderer(layer); |
60
37ff67a4991d
Added TODO for line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
46
diff
changeset
|
75 |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
76 rendererElement.setAttribute("label", renderer.getLabel()); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
77 rendererElement.setAttribute("description", renderer.getDescription()); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
78 symbol = renderer.getSymbol(); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
79 |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
80 MarkerSymbolReader markerReader = new MarkerSymbolReader(); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
81 LineSymbolReader lineReader = new LineSymbolReader(); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
82 FillSymbolReader fillReader = new FillSymbolReader(); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
83 if(markerReader.canRead(symbol)) { |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
84 markerReader.setSymbol(symbol); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
85 markerReader.setUtil(util); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
86 markerReader.setParent(rendererElement); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
87 markerReader.read(); |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
88 } |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
89 else if(lineReader.canRead(symbol)) { |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
90 lineReader.setSymbol(symbol); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
91 lineReader.setUtil(util); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
92 lineReader.setParent(rendererElement); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
93 lineReader.read(); |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
94 } |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
95 else if(fillReader.canRead(symbol)) { |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
96 fillReader.setSymbol(symbol); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
97 fillReader.setUtil(util); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
98 fillReader.setParent(rendererElement); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
99 fillReader.read(); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
100 } |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
101 else { |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
102 logger.debug("No known Symbol type: " + symbol.getClass().toString()); |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
103 } |
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
72
diff
changeset
|
104 return layer; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
105 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
106 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
107 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |