rrenkert@33: package de.intevation.mxd.reader; rrenkert@25: rrenkert@25: import java.io.IOException; rrenkert@25: rrenkert@25: import org.apache.log4j.Logger; rrenkert@25: rrenkert@25: import com.esri.arcgis.carto.ILayer; rrenkert@25: import com.esri.arcgis.carto.FeatureLayer; rrenkert@29: rrenkert@29: import org.w3c.dom.Element; rrenkert@29: rrenkert@33: import de.intevation.mxd.utils.MapToXMLUtils; rrenkert@33: rrenkert@25: /** rrenkert@25: * Reads Layer information.. rrenkert@25: * rrenkert@25: * @author Raimund Renkert rrenkert@25: */ rrenkert@25: public class FeatureLayerReader implements ILayerReader{ rrenkert@25: rrenkert@31: /** rrenkert@31: * The logger. rrenkert@31: */ rrenkert@31: private static final Logger logger = rrenkert@31: Logger.getLogger(FeatureLayerReader.class); rrenkert@25: rrenkert@31: /** rrenkert@31: * Privte member. rrenkert@31: */ rrenkert@29: private FeatureLayer layer; rrenkert@31: private MapToXMLUtils util; rrenkert@25: rrenkert@31: rrenkert@31: public FeatureLayerReader(ILayer layer) rrenkert@31: throws Exception { rrenkert@29: if(layer instanceof FeatureLayer) rrenkert@29: this.layer = (FeatureLayer)layer; rrenkert@29: else rrenkert@29: throw new Exception("Not an instance of FeatureLayer: " + rrenkert@31: layer.getClass().toString()); rrenkert@25: } rrenkert@25: rrenkert@25: /** rrenkert@31: * Setter for XML document helper. rrenkert@31: * rrenkert@31: * @param util The helper for storing map information. rrenkert@29: */ rrenkert@31: public void setUtil(MapToXMLUtils util){ rrenkert@31: this.util = util; rrenkert@29: } rrenkert@29: rrenkert@29: /** rrenkert@25: * Reads the Layer content. rrenkert@31: * rrenkert@31: * @return The layer XML element. rrenkert@25: */ rrenkert@31: public Element read() rrenkert@31: throws IOException { rrenkert@25: logger.debug("read()"); rrenkert@31: Element layerElement; rrenkert@31: try { rrenkert@31: layerElement = util.addLayer(); rrenkert@31: } rrenkert@31: catch(Exception e) { rrenkert@31: e.printStackTrace(); rrenkert@31: return null; rrenkert@31: } rrenkert@25: rrenkert@31: layerElement.setAttribute("name", layer.getName()); rrenkert@31: layerElement.setAttribute("min_scale", rrenkert@31: String.valueOf(layer.getMinimumScale())); rrenkert@31: layerElement.setAttribute("max_scale", rrenkert@31: String.valueOf(layer.getMaximumScale())); rrenkert@31: if(layer.isVisible()) { rrenkert@31: layerElement.setAttribute("status", "on"); rrenkert@25: } rrenkert@31: else { rrenkert@31: layerElement.setAttribute("status", "off"); rrenkert@25: } rrenkert@25: rrenkert@40: int type = layer.getShapeType(); rrenkert@40: switch (type) { rrenkert@40: case 0: layerElement.setAttribute("type", "none"); rrenkert@40: case 1: layerElement.setAttribute("type", "point"); rrenkert@40: } rrenkert@40: rrenkert@31: layerElement.setAttribute("definition_query", rrenkert@31: layer.getDefinitionExpression()); rrenkert@31: rrenkert@31: return layerElement; rrenkert@25: } rrenkert@25: } rrenkert@25: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :