comparison src/java/de/intevation/mxd/reader/FeatureLayerReader.java @ 29:77cfa8092611

Write FeatureLayer attributes to XML document.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 08 Apr 2011 17:36:22 +0200
parents 3e24fffdf2bb
children 40c0b4e5f91a
comparison
equal deleted inserted replaced
28:0e71a1f71ec0 29:77cfa8092611
10 import com.esri.arcgis.geometry.ProjectedCoordinateSystem; 10 import com.esri.arcgis.geometry.ProjectedCoordinateSystem;
11 import com.esri.arcgis.geometry.IProjection; 11 import com.esri.arcgis.geometry.IProjection;
12 import com.esri.arcgis.geometry.Projection; 12 import com.esri.arcgis.geometry.Projection;
13 import com.esri.arcgis.display.ISymbol; 13 import com.esri.arcgis.display.ISymbol;
14 import com.esri.arcgis.display.SimpleMarkerSymbol; 14 import com.esri.arcgis.display.SimpleMarkerSymbol;
15
16 import org.w3c.dom.Attr;
17 import org.w3c.dom.Document;
18 import org.w3c.dom.Element;
19 import org.w3c.dom.Node;
20 import org.w3c.dom.NodeList;
21
15 /** 22 /**
16 * Reads Layer information.. 23 * Reads Layer information..
17 * 24 *
18 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> 25 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
19 */ 26 */
20 public class FeatureLayerReader implements ILayerReader{ 27 public class FeatureLayerReader implements ILayerReader{
21 28
22 private static final Logger logger = Logger.getLogger(FeatureLayerReader.class); 29 private static final Logger logger = Logger.getLogger(FeatureLayerReader.class);
23 30
24 private ILayer layer; 31 private FeatureLayer layer;
32 private Document document;
25 33
26 //Constructor 34 //Constructor
27 public FeatureLayerReader(ILayer layer){ 35 public FeatureLayerReader(ILayer layer) throws Exception{
28 this.layer = layer; 36 if(layer instanceof FeatureLayer)
37 this.layer = (FeatureLayer)layer;
38 else
39 throw new Exception("Not an instance of FeatureLayer: " +
40 layer.getClass().toString());
29 } 41 }
30 42
31 //Methods 43 //Methods
44 /**
45 * Setter for XML document.
46 */
47 public void setDocument(Document doc){
48 this.document = doc;
49 }
50
32 /** 51 /**
33 * Reads the Layer content. 52 * Reads the Layer content.
34 */ 53 */
35 public boolean read() throws IOException{ 54 public boolean read() throws IOException{
36 logger.debug("read()"); 55 logger.debug("read()");
37 if(layer instanceof FeatureLayer){ 56 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(document,
38 FeatureLayer fl = (FeatureLayer)layer; 57 "", "");
39 System.out.println("--------------------");
40 System.out.println("Layer information:");
41 System.out.println("Layername\t\t = " + fl.getName());
42 System.out.println("Min-/Maxscale\t = " + fl.getMinimumScale() +
43 "/" + fl.getMaximumScale());
44 ISymbol symbol = fl.getSelectionSymbol();
45 if(symbol instanceof SimpleMarkerSymbol)
46 System.out.println("Symboltype\t\t = " +
47 ((SimpleMarkerSymbol)symbol).getNameString());
48 58
49 System.out.println("Status\t\t = " + fl.isVisible()); 59 Element layerElement = creator.create("layer");
50 System.out.println("Definition Query\t = " + fl.getDefinitionExpression()); 60 creator.addAttr(layerElement, "name", layer.getName());
51 System.out.println(""); 61 creator.addAttr(layerElement,
52 return true; 62 "min_scale",
63 String.valueOf(layer.getMinimumScale()));
64 creator.addAttr(layerElement,
65 "max_scale",
66 String.valueOf(layer.getMaximumScale()));
67 if(layer.isVisible())
68 creator.addAttr(layerElement, "status", "on");
69 else
70 creator.addAttr(layerElement, "status", "off");
71 creator.addAttr(layerElement,
72 "definition_query",
73 layer.getDefinitionExpression());
74 NodeList list = document.getElementsByTagName("map");
75 if(list.getLength() > 1){
76 throw new IOException("Error while creating DOM! Found" +
77 " more than one map object!");
53 } 78 }
54 else{ 79 else{
55 System.out.println("Layer type unknown! " + layer.getClass().toString()); 80 Node map = list.item(0);
81 map.appendChild(layerElement);
56 } 82 }
57 83 return true;
58 return false;
59 } 84 }
60 85
61 public void getLayer() throws IOException{ 86 public void getLayer() throws IOException{
62 logger.debug("getLayer() -> not implemented jet."); 87 logger.debug("getLayer() -> not implemented jet.");
63 return; 88 return;
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)