Mercurial > mxd2map
view src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java @ 52:cd541e73d523
* mapserver/rundir/Readme.txt: New. This is a folder containing the
MXD-files for conversion. The resulting MAP-file can be run from
here; all Paths are relative from here so request will find its
symbols, fonts, logfiles etc.
* mapserver/mapfile/mapfile_header.include: Added SHAPEPATH for
the Visualization of the frida-shapefiles.
author | Stephan Holl <stephan.holl@intevation.de> |
---|---|
date | Wed, 11 May 2011 10:08:25 +0200 |
parents | 90d4de478f15 |
children | b41fcf268827 |
line wrap: on
line source
package de.intevation.mxd.reader; import java.io.IOException; import org.apache.log4j.Logger; import com.esri.arcgis.carto.IFeatureRenderer; import com.esri.arcgis.carto.ClassBreaksRenderer; import com.esri.arcgis.display.ISymbol; import com.esri.arcgis.display.SimpleMarkerSymbol; import com.esri.arcgis.display.SimpleFillSymbol; import org.w3c.dom.Element; import de.intevation.mxd.utils.MapToXMLUtils; /** * Reads the ClassBreaksRender Object Attributes. * * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> */ public class ClassBreakRendererReader implements IRendererReader { /** * The logger. */ private static final Logger logger = Logger.getLogger(ClassBreakRendererReader.class); /** * Private member. */ private ClassBreaksRenderer renderer; private Element layer; private MapToXMLUtils util; public ClassBreakRendererReader(IFeatureRenderer renderer) throws Exception { logger.debug("contructor()"); if(renderer instanceof ClassBreaksRenderer) this.renderer = (ClassBreaksRenderer)renderer; else throw new Exception("Not a ClassBreaksRenderer!"); } /** * 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 XML node. */ public Element read() throws IOException { logger.debug("read()"); for(int i = 0; i < renderer.getBreakCount(); i++){ Element rendererElement; try { rendererElement = util.addRenderer(layer); rendererElement.setAttribute("value", String.valueOf(renderer.getBreak(i))); 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( "min_value", String.valueOf(renderer.getMinimumBreak())); rendererElement.setAttribute("expression_operator", "<="); ISymbol sym = renderer.getSymbol(i); ISymbolReader symReader; if(sym instanceof SimpleFillSymbol) { symReader = new SimpleFillSymbolReader(renderer.getSymbol(i)); symReader.setUtil(util); symReader.setParent(rendererElement); symReader.read(); } else if(sym instanceof SimpleMarkerSymbol) { symReader = new SimpleMarkerSymbolReader(renderer.getSymbol(i)); symReader.setUtil(util); symReader.setParent(rendererElement); symReader.read(); } else { System.out.println("No known class type: " + sym.getClass().toString()); } } catch(Exception e) { e.printStackTrace(); return null; } } return layer; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :