Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/SimpleRendererReader.java @ 60:37ff67a4991d
Added TODO for line symbol reader.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 20 May 2011 16:27:25 +0200 |
parents | 34a93dad7604 |
children | e00deee347a5 |
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 java.io.IOException; |
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 org.apache.log4j.Logger; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
6 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 import com.esri.arcgis.carto.IFeatureRenderer; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 import com.esri.arcgis.display.ISymbol; |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
9 import com.esri.arcgis.display.SimpleMarkerSymbol; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
10 import com.esri.arcgis.display.SimpleFillSymbol; |
46
34a93dad7604
Added MultiLayerMarkerSymbol(ArrowMarkerSymbol) support.
Raimund Renkert <rrenkert@intevation.de>
parents:
44
diff
changeset
|
11 import com.esri.arcgis.display.MultiLayerMarkerSymbol; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 import com.esri.arcgis.carto.SimpleRenderer; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
14 import org.w3c.dom.Element; |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
15 |
33
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
16 import de.intevation.mxd.utils.MapToXMLUtils; |
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
17 |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 /** |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 * Reads simple renderer information. |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 * |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 * @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
|
22 */ |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
23 public class SimpleRendererReader |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
24 implements IRendererReader { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 |
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 * The logger. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
28 */ |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
29 private static final Logger logger = |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
30 Logger.getLogger(SimpleRendererReader.class); |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
31 |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
32 /** |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
33 * Private member. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
34 */ |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 private ISymbol symbol; |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
36 private SimpleRenderer renderer; |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
37 private Element layer; |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
38 private MapToXMLUtils util; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
41 public SimpleRendererReader(IFeatureRenderer renderer) |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
42 throws Exception { |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
43 logger.debug("constructor()"); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
44 if(renderer instanceof SimpleRenderer) { |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
45 this.renderer = (SimpleRenderer)renderer; |
25
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 else{ |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
48 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
|
49 } |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
50 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
52 /** |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
53 * Setter for the parent XML element. |
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 * @param parent The XML parent node. |
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 public void setParent(Element parent) { |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
58 this.layer = parent; |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
59 } |
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 /** |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
62 * Setter for the XML document helper. |
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 * @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
|
65 */ |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
66 public void setUtil(MapToXMLUtils util) { |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
67 this.util = util; |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
68 } |
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 /** |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
71 * Reads the renderer attributes. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
72 * |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
73 * @return The XML node. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
74 */ |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
75 public Element read() |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
76 throws IOException { |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
77 logger.debug("read()"); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
78 Element rendererElement; |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
79 try { |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
80 rendererElement = util.addRenderer(layer); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
81 |
44
9b5fb5e5914d
Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
82 rendererElement.setAttribute("label", renderer.getLabel()); |
9b5fb5e5914d
Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
83 rendererElement.setAttribute("description", renderer.getDescription()); |
9b5fb5e5914d
Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
84 symbol = renderer.getSymbol(); |
60
37ff67a4991d
Added TODO for line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
46
diff
changeset
|
85 |
37ff67a4991d
Added TODO for line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
46
diff
changeset
|
86 //TODO This reader can also read simple line symbols. Just add |
37ff67a4991d
Added TODO for line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
46
diff
changeset
|
87 //another else if statement with the corresponding reader. |
37ff67a4991d
Added TODO for line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
46
diff
changeset
|
88 //In MXD-files simple- and marker lines use the MultiLayerLineSymbol. |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
89 if(symbol instanceof SimpleMarkerSymbol){ |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
90 ISymbolReader isr= new SimpleMarkerSymbolReader(symbol); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
91 isr.setParent(rendererElement); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
92 isr.setUtil(util); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
93 isr.read(); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
94 } |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
95 else if(symbol instanceof SimpleFillSymbol){ |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
96 ISymbolReader isr = new SimpleFillSymbolReader(symbol); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
97 isr.setParent(rendererElement); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
98 isr.setUtil(util); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
99 isr.read(); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
100 } |
46
34a93dad7604
Added MultiLayerMarkerSymbol(ArrowMarkerSymbol) support.
Raimund Renkert <rrenkert@intevation.de>
parents:
44
diff
changeset
|
101 else if(symbol instanceof MultiLayerMarkerSymbol) { |
34a93dad7604
Added MultiLayerMarkerSymbol(ArrowMarkerSymbol) support.
Raimund Renkert <rrenkert@intevation.de>
parents:
44
diff
changeset
|
102 ISymbolReader isr = new MultiLayerMarkerSymbolReader(symbol); |
34a93dad7604
Added MultiLayerMarkerSymbol(ArrowMarkerSymbol) support.
Raimund Renkert <rrenkert@intevation.de>
parents:
44
diff
changeset
|
103 isr.setParent(rendererElement); |
34a93dad7604
Added MultiLayerMarkerSymbol(ArrowMarkerSymbol) support.
Raimund Renkert <rrenkert@intevation.de>
parents:
44
diff
changeset
|
104 isr.setUtil(util); |
34a93dad7604
Added MultiLayerMarkerSymbol(ArrowMarkerSymbol) support.
Raimund Renkert <rrenkert@intevation.de>
parents:
44
diff
changeset
|
105 isr.read(); |
34a93dad7604
Added MultiLayerMarkerSymbol(ArrowMarkerSymbol) support.
Raimund Renkert <rrenkert@intevation.de>
parents:
44
diff
changeset
|
106 } |
34a93dad7604
Added MultiLayerMarkerSymbol(ArrowMarkerSymbol) support.
Raimund Renkert <rrenkert@intevation.de>
parents:
44
diff
changeset
|
107 else { |
34a93dad7604
Added MultiLayerMarkerSymbol(ArrowMarkerSymbol) support.
Raimund Renkert <rrenkert@intevation.de>
parents:
44
diff
changeset
|
108 System.out.println("No known Symbol type: " + symbol.getClass().toString()); |
34a93dad7604
Added MultiLayerMarkerSymbol(ArrowMarkerSymbol) support.
Raimund Renkert <rrenkert@intevation.de>
parents:
44
diff
changeset
|
109 } |
44
9b5fb5e5914d
Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
110 return layer; |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
111 } |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
112 catch(Exception e) { |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
113 e.printStackTrace(); |
44
9b5fb5e5914d
Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
114 return null; |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
115 } |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
116 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
117 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
118 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |