annotate src/java/de/intevation/mxd/reader/FeatureLayerReader.java @ 31:40c0b4e5f91a

Added utility class to store map attributes.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 11 Apr 2011 16:04:03 +0200
parents 77cfa8092611
children c51376f8e24c
rev   line source
26
3e24fffdf2bb Moved reader components to reader folder.
Raimund Renkert <rrenkert@intevation.de>
parents: 25
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.ILayer;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8 import com.esri.arcgis.carto.FeatureLayer;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 import com.esri.arcgis.geometry.ISpatialReference;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 import com.esri.arcgis.geometry.ProjectedCoordinateSystem;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 import com.esri.arcgis.geometry.IProjection;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 import com.esri.arcgis.geometry.Projection;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 import com.esri.arcgis.display.ISymbol;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 import com.esri.arcgis.display.SimpleMarkerSymbol;
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
15
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
16 import org.w3c.dom.Attr;
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
17 import org.w3c.dom.Document;
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
18 import org.w3c.dom.Element;
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
19 import org.w3c.dom.Node;
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
20 import org.w3c.dom.NodeList;
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
21
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23 * Reads Layer information..
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 *
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25 * @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
26 */
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27 public class FeatureLayerReader implements ILayerReader{
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
29 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
30 * The logger.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
31 */
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
32 private static final Logger logger =
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
33 Logger.getLogger(FeatureLayerReader.class);
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
35 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
36 * Privte member.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
37 */
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
38 private FeatureLayer layer;
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
39 private MapToXMLUtils util;
25
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: 29
diff changeset
41
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
42 public FeatureLayerReader(ILayer layer)
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
43 throws Exception {
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
44 if(layer instanceof FeatureLayer)
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
45 this.layer = (FeatureLayer)layer;
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
46 else
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
47 throw new Exception("Not an instance of FeatureLayer: " +
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
48 layer.getClass().toString());
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
49 }
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: 29
diff changeset
52 * Setter for XML document helper.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
53 *
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
54 * @param util The helper for storing map information.
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
55 */
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
56 public void setUtil(MapToXMLUtils util){
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
57 this.util = util;
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
58 }
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
59
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
60 /**
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 * Reads the Layer content.
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
62 *
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
63 * @return The layer XML element.
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 */
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
65 public Element read()
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
66 throws IOException {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67 logger.debug("read()");
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
68 Element layerElement;
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
69 try {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
70 layerElement = util.addLayer();
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
71 }
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
72 catch(Exception e) {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
73 e.printStackTrace();
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
74 return null;
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
75 }
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
76
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
77 layerElement.setAttribute("name", layer.getName());
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
78 layerElement.setAttribute("min_scale",
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
79 String.valueOf(layer.getMinimumScale()));
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
80 layerElement.setAttribute("max_scale",
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
81 String.valueOf(layer.getMaximumScale()));
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
82 if(layer.isVisible()) {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
83 layerElement.setAttribute("status", "on");
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84 }
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
85 else {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
86 layerElement.setAttribute("status", "off");
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
87 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
88
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
89 layerElement.setAttribute("definition_query",
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
90 layer.getDefinitionExpression());
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
91
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
92 return layerElement;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
93 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
94 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
95 // 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)