Mercurial > mxd2map
view src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java @ 114:93699e8f2d1f
contrib/python/FixWorkspacePaths.py, contrib/python/foobar.py:
Added some sample-scripts for working with MXD-files
author | Stephan Holl <stephan.holl@intevation.de> |
---|---|
date | Wed, 15 Jun 2011 16:13:32 +0200 |
parents | 59e06c405a9a |
children | c8a1361ddd38 |
line wrap: on
line source
package de.intevation.mxd.reader; import org.apache.log4j.Logger; import com.esri.arcgis.carto.IFeatureRenderer; import com.esri.arcgis.display.ISymbol; import com.esri.arcgis.carto.UniqueValueRenderer; import org.w3c.dom.Element; import de.intevation.mxd.utils.MapToXMLUtils; /** * Reads unique vaule renderer information. * * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> */ public class UniqueValueRendererReader implements IRendererReader { /** * The logger. */ private static final Logger logger = Logger.getLogger(FeatureLayerReader.class); /** * Private Member. */ private UniqueValueRenderer renderer; private Element layer; private MapToXMLUtils util; public UniqueValueRendererReader(IFeatureRenderer renderer) throws Exception { logger.debug("constructor()"); if (renderer instanceof UniqueValueRenderer) { this.renderer = (UniqueValueRenderer)renderer; } else { throw new Exception ("Not an instance of UniqueValueRenderer."); } } /** * Setter for the parent XML element. * * @param parent The XML parent node. */ public void setParent(Element parent) { this.layer = parent; } /** * Setter for XML document helper. * * @param util The helper class for storing map information. */ public void setUtil(MapToXMLUtils util) { this.util = util; } /** * Reads the renderer attributes. * * @return The parent XML node. */ public Element read() throws Exception { logger.debug("read()"); for(int i = 0; i < renderer.getClassCount() - 1; i++) { Element rendererElement = util.addRenderer(layer); String value = renderer.getValue(i); rendererElement.setAttribute("name", renderer.esri_getClass(i)); rendererElement.setAttribute("description", renderer.getDescription(value)); rendererElement.setAttribute("value", value); rendererElement.setAttribute("label", renderer.getLabel(value)); rendererElement.setAttribute( "field_count", String.valueOf(renderer.getFieldCount())); for(int j = 0; j < renderer.getFieldCount(); j++) { rendererElement.setAttribute( "expression_field_" + j, renderer.getField(j)); } rendererElement.setAttribute("expression_operator", "="); ISymbol sym = renderer.getSymbol(value); MarkerSymbolReader markerReader = new MarkerSymbolReader(); LineSymbolReader lineReader = new LineSymbolReader(); FillSymbolReader fillReader = new FillSymbolReader(); if(markerReader.canRead(sym)) { markerReader.setSymbol(sym); markerReader.setUtil(util); markerReader.setParent(rendererElement); markerReader.read(); } else if(lineReader.canRead(sym)) { lineReader.setSymbol(sym); lineReader.setUtil(util); lineReader.setParent(rendererElement); lineReader.read(); } else if(fillReader.canRead(sym)) { fillReader.setSymbol(sym); fillReader.setUtil(util); fillReader.setParent(rendererElement); fillReader.read(); } else { logger.debug("Not a known symbol type: " + sym.getClass().toString()); } } return layer; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :