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.IFeatureRenderer; rrenkert@25: import com.esri.arcgis.display.ISymbol; rrenkert@25: import com.esri.arcgis.carto.SimpleRenderer; rrenkert@25: rrenkert@31: import org.w3c.dom.Element; rrenkert@31: rrenkert@33: import de.intevation.mxd.utils.MapToXMLUtils; rrenkert@33: rrenkert@25: /** rrenkert@25: * Reads simple renderer information. rrenkert@25: * rrenkert@25: * @author Raimund Renkert rrenkert@25: */ rrenkert@31: public class SimpleRendererReader rrenkert@31: implements IRendererReader { rrenkert@25: rrenkert@31: /** rrenkert@31: * The logger. rrenkert@31: */ rrenkert@31: private static final Logger logger = rrenkert@31: Logger.getLogger(FeatureLayerReader.class); rrenkert@31: rrenkert@31: /** rrenkert@31: * Private member. rrenkert@31: */ rrenkert@25: private ISymbol symbol; rrenkert@31: private SimpleRenderer renderer; rrenkert@31: private Element layer; rrenkert@31: private MapToXMLUtils util; rrenkert@25: rrenkert@25: rrenkert@31: public SimpleRendererReader(IFeatureRenderer renderer) rrenkert@31: throws Exception { rrenkert@31: logger.debug("constructor()"); rrenkert@31: if(renderer instanceof SimpleRenderer) { rrenkert@31: this.renderer = (SimpleRenderer)renderer; rrenkert@25: } rrenkert@31: else{ rrenkert@31: throw new Exception ("Not an instance of SimpleRenderer!"); rrenkert@31: } rrenkert@25: } rrenkert@25: rrenkert@31: /** rrenkert@31: * Setter for the parent XML element. rrenkert@31: * rrenkert@31: * @param parent The XML parent node. rrenkert@31: */ rrenkert@31: public void setParent(Element parent) { rrenkert@31: this.layer = parent; rrenkert@31: } rrenkert@31: rrenkert@31: /** rrenkert@31: * Setter for the XML document helper. rrenkert@31: * rrenkert@31: * @param util The helper class for storing map information. rrenkert@31: */ rrenkert@31: public void setUtil(MapToXMLUtils util) { rrenkert@31: this.util = util; rrenkert@31: } rrenkert@31: rrenkert@31: /** rrenkert@31: * Reads the renderer attributes. rrenkert@31: * rrenkert@31: * @return The XML node. rrenkert@31: */ rrenkert@31: public Element read() rrenkert@31: throws IOException { rrenkert@31: logger.debug("read()"); rrenkert@31: Element rendererElement; rrenkert@31: try { rrenkert@31: rendererElement = util.addRenderer(layer); rrenkert@31: } rrenkert@31: catch(Exception e) { rrenkert@31: e.printStackTrace(); rrenkert@31: return null; rrenkert@31: } rrenkert@31: rrenkert@31: rendererElement.setAttribute("label", renderer.getLabel()); rrenkert@31: rendererElement.setAttribute("description", renderer.getDescription()); rrenkert@31: symbol = renderer.getSymbol(); rrenkert@31: try{ rrenkert@31: ISymbolReader isr= new SimpleMarkerSymbolReader(symbol); rrenkert@31: isr.setParent(rendererElement); rrenkert@31: isr.setUtil(util); rrenkert@31: isr.read(); rrenkert@31: return rendererElement; rrenkert@31: } rrenkert@31: catch(Exception e){ rrenkert@31: e.printStackTrace(); rrenkert@31: } rrenkert@31: return rendererElement; rrenkert@25: } rrenkert@25: } rrenkert@25: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :