Mercurial > mxd2map
changeset 26:3e24fffdf2bb
Moved reader components to reader folder.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 08 Apr 2011 12:26:17 +0200 |
parents | cbd67b1100d8 |
children | e5fdc37f8f94 |
files | ChangeLog src/java/de/intevation/mxd/ClassBreakRendererReader.java src/java/de/intevation/mxd/FeatureLayerReader.java src/java/de/intevation/mxd/ILayerReader.java src/java/de/intevation/mxd/IReader.java src/java/de/intevation/mxd/IRendererReader.java src/java/de/intevation/mxd/ISymbolReader.java src/java/de/intevation/mxd/MXDReader.java src/java/de/intevation/mxd/MapReader.java src/java/de/intevation/mxd/SimpleMarkerSymbolReader.java src/java/de/intevation/mxd/SimpleRendererReader.java src/java/de/intevation/mxd/UniqueValueRendererReader.java src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java src/java/de/intevation/mxd/reader/FeatureLayerReader.java src/java/de/intevation/mxd/reader/ILayerReader.java src/java/de/intevation/mxd/reader/IReader.java src/java/de/intevation/mxd/reader/IRendererReader.java src/java/de/intevation/mxd/reader/ISymbolReader.java src/java/de/intevation/mxd/reader/MXDReader.java src/java/de/intevation/mxd/reader/MapReader.java src/java/de/intevation/mxd/reader/SimpleMarkerSymbolReader.java src/java/de/intevation/mxd/reader/SimpleRendererReader.java src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java |
diffstat | 23 files changed, 614 insertions(+), 597 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Apr 08 11:47:59 2011 +0200 +++ b/ChangeLog Fri Apr 08 12:26:17 2011 +0200 @@ -1,3 +1,20 @@ +2011-04-08 Raimund Renkert <raimund.renkert@intevation.de> + + Moved reader components to reader folder. + + * src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java, + src/java/de/intevation/mxd/reader/FeatureLayerReader.java, + src/java/de/intevation/mxd/reader/ILayerReader.java, + src/java/de/intevation/mxd/reader/IReader.java, + src/java/de/intevation/mxd/reader/IRendererReader.java, + src/java/de/intevation/mxd/reader/ISymbolReader.java, + src/java/de/intevation/mxd/reader/MXDReader.java, + src/java/de/intevation/mxd/reader/MapReader.java, + src/java/de/intevation/mxd/reader/SimpleMarkerSymbolReader.java, + src/java/de/intevation/mxd/reader/SimpleRendererReader.java, + src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java: + Moved. + 2011-04-08 Raimund Renkert <raimund.renkert@intevation.de> * src/java/de/intevation/mxd/Converter.java: Initial implementation for the
--- a/src/java/de/intevation/mxd/ClassBreakRendererReader.java Fri Apr 08 11:47:59 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -//package de.intevation.mxd.renderer; - -import java.io.IOException; - -import org.apache.log4j.Logger; - -import com.esri.arcgis.carto.IFeatureRenderer; -import com.esri.arcgis.carto.ClassBreaksRenderer; - -/** - * Reads the ClassBreaksRender Object Attributes. - * - * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> - */ -public class ClassBreakRendererReader implements IRendererReader{ - - //Member - private static final Logger logger = - Logger.getLogger(ClassBreakRendererReader.class); - - private ClassBreaksRenderer renderer; - - //Constructor - public ClassBreakRendererReader(IFeatureRenderer renderer) throws Exception{ - logger.debug("contructor()"); - if(renderer instanceof ClassBreaksRenderer) - this.renderer = (ClassBreaksRenderer)renderer; - else - throw new Exception("Not a ClassBreaksRenderer!"); - } - - - //Methods - public boolean read() throws IOException{ - logger.debug("read()"); - System.out.println("--------------------"); - System.out.println("Renderer information:"); - System.out.println("Ramp\t\t = " + renderer.getColorRamp()); - System.out.println("Class count\t\t = " + renderer.getClassCount()); - - for(int i = 0; i < renderer.getClassCount(); i++){ - System.out.println("Class " + i + "\t\t = " + renderer.esri_getClass(i)); - } - System.out.println("Break count\t\t = " + renderer.getBreakCount()); - for(int i = 0; i < renderer.getBreakCount(); i++){ - System.out.println("Break " + i + "\t\t = " + renderer.getBreak(i)); - } - System.out.println(""); - return true; - } - - public void getRenderer() throws IOException{ - logger.debug("getRenderer() -> not implemented jet."); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/src/java/de/intevation/mxd/FeatureLayerReader.java Fri Apr 08 11:47:59 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -//package de.intevation.mxd.layer; - -import java.io.IOException; - -import org.apache.log4j.Logger; - -import com.esri.arcgis.carto.ILayer; -import com.esri.arcgis.carto.FeatureLayer; -import com.esri.arcgis.geometry.ISpatialReference; -import com.esri.arcgis.geometry.ProjectedCoordinateSystem; -import com.esri.arcgis.geometry.IProjection; -import com.esri.arcgis.geometry.Projection; -import com.esri.arcgis.display.ISymbol; -import com.esri.arcgis.display.SimpleMarkerSymbol; -/** - * Reads Layer information.. - * - * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> - */ -public class FeatureLayerReader implements ILayerReader{ - - private static final Logger logger = Logger.getLogger(FeatureLayerReader.class); - - private ILayer layer; - - //Constructor - public FeatureLayerReader(ILayer layer){ - this.layer = layer; - } - - //Methods - /** - * Reads the Layer content. - */ - public boolean read() throws IOException{ - logger.debug("read()"); - if(layer instanceof FeatureLayer){ - FeatureLayer fl = (FeatureLayer)layer; - System.out.println("--------------------"); - System.out.println("Layer information:"); - System.out.println("Layername\t\t = " + fl.getName()); - System.out.println("Min-/Maxscale\t = " + fl.getMinimumScale() + - "/" + fl.getMaximumScale()); - ISymbol symbol = fl.getSelectionSymbol(); - if(symbol instanceof SimpleMarkerSymbol) - System.out.println("Symboltype\t\t = " + - ((SimpleMarkerSymbol)symbol).getNameString()); - - System.out.println("Status\t\t = " + fl.isVisible()); - System.out.println("Definition Query\t = " + fl.getDefinitionExpression()); - System.out.println(""); - return true; - } - else{ - System.out.println("Layer type unknown! " + layer.getClass().toString()); - } - - return false; - } - - public void getLayer() throws IOException{ - logger.debug("getLayer() -> not implemented jet."); - return; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/src/java/de/intevation/mxd/ILayerReader.java Fri Apr 08 11:47:59 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -//package de.intevation.mxd.layer; - -import java.io.IOException; - -/** - * The interface to the layer reader. - * - * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> - */ -public interface ILayerReader{ - - public boolean read() throws IOException; - public void getLayer() throws IOException; - -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/src/java/de/intevation/mxd/IReader.java Fri Apr 08 11:47:59 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -//package de.intevation.mxd.layer; - -import java.io.IOException; - -/** - * The interface to the MXD-Reader. - * - * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> - */ -public interface IReader { - /** - * Initializes the reader component. - */ - boolean init() throws IOException; - - /** - * Method to perform actions at the of reader usage. - */ - boolean shutdown() throws IOException; - - /** - * Set the filename. - */ - void setFilename(String name); - - /** - * Read the content. - */ - boolean read() throws IOException; - - /** - * Request DOM Document containing the map data. - */ - void getMapDocument(); -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/src/java/de/intevation/mxd/IRendererReader.java Fri Apr 08 11:47:59 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -//package de.intevation.mxd.renderer; - -import java.io.IOException; - -import com.esri.arcgis.carto.IFeatureRenderer; - -/** - * The interface to the renderer reader. - * - * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> - */ -public interface IRendererReader{ - - public boolean read() throws IOException; - public void getRenderer() throws IOException; - -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/src/java/de/intevation/mxd/ISymbolReader.java Fri Apr 08 11:47:59 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -//package de.intevation.mxd.symbol; - -import java.io.IOException; - -/** - * The interface to the symbol reader. - * - * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> - */ -public interface ISymbolReader{ - - public boolean read() throws IOException; - public void getSymbol() throws IOException; - -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/src/java/de/intevation/mxd/MXDReader.java Fri Apr 08 11:47:59 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,138 +0,0 @@ -//package de.intevation.mxd; - -import java.io.IOException; - -import org.apache.log4j.Logger; - -import com.esri.arcgis.geodatabase.IClass; -import com.esri.arcgis.carto.ILayer; -import com.esri.arcgis.carto.IMap; -import com.esri.arcgis.carto.MapDocument; -import com.esri.arcgis.carto.FeatureLayer; -import com.esri.arcgis.carto.IFeatureRenderer; -import com.esri.arcgis.carto.SimpleRenderer; -import com.esri.arcgis.carto.ClassBreaksRenderer; -import com.esri.arcgis.carto.UniqueValueRenderer; - -import com.esri.arcgis.geodatabase.IFeatureClass; -import com.esri.arcgis.geodatabase.FeatureClass; -import com.esri.arcgis.geometry.ISpatialReference; -import com.esri.arcgis.geometry.ProjectedCoordinateSystem; -import com.esri.arcgis.geometry.IProjection; -import com.esri.arcgis.geometry.Projection; - -/** - * The MXD file reader. - * - * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> - */ -public class MXDReader implements IReader { - - //Member - private String filename = ""; - private ArcGISInitializer initializer = null; - private IMap map; - - private static final Logger logger = Logger.getLogger(MXDReader.class); - - //Constructor - public MXDReader() throws IOException{ - logger.debug("constructor()"); - initializer = new ArcGISInitializer(); - } - - - //Methods - - /** - * Initialize the ArcGIS Objects. - */ - public boolean init() throws IOException{ - logger.debug("init()"); - initializer.initArcGIS(); - initializer.initArcGISLicenses(); - return true; - } - - /** - * Shutdown the ArcGIS Objects. - */ - public boolean shutdown() throws IOException{ - logger.debug("shutdown()"); - if(initializer == null){ - throw new IOException("Faild to shutdown!"); - } - else{ - initializer.shutdownArcGIS(); - return true; - } - } - - /** - * Set the path and filename to the MXD-File. - */ - public void setFilename(String name){ - logger.debug("setFilename()"); - filename = name; - } - - /** - * Read the MXD file content. - */ - public boolean read() throws IOException{ - logger.debug("read()"); - if(filename == ""){ - throw new IOException("Please set filename!"); - } - else{ - MapDocument m = new MapDocument(); - if(!m.isMapDocument(filename)){ - throw new IOException(filename + " is not a map!"); - } - m.open(filename, null); - map = m.getMap(0); - MapReader mreader = new MapReader (map); - mreader.read(); - for(int i = 0; i < map.getLayerCount();i++){ - ILayer layer = map.getLayer(0); - ILayerReader lr = new FeatureLayerReader(layer); - lr.read(); - if (layer instanceof FeatureLayer){ - IFeatureRenderer renderer = ((FeatureLayer)layer).getRenderer(); - IRendererReader rreader; - try{ - if(renderer instanceof SimpleRenderer){ - rreader = new SimpleRendererReader(renderer); - rreader.read(); - } - else if(renderer instanceof ClassBreaksRenderer){ - rreader = new ClassBreakRendererReader(renderer); - rreader.read(); - } - else if(renderer instanceof UniqueValueRenderer){ - rreader = new UniqueValueRendererReader(renderer); - rreader.read(); - } - else{ - System.out.println("No known renderer!"); - System.out.println("Implement new renderer for " + - renderer.getClass().toString()); - } - } - catch(Exception e){ - e.printStackTrace(); - } - } - } - } - return true; - } - - /** - * Get the mapinformation as DOM document. TODO: implement me! - */ - public void getMapDocument(){ - logger.debug("getMapDocument() -> not implemented jet."); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/src/java/de/intevation/mxd/MapReader.java Fri Apr 08 11:47:59 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -//package de.intevation.mxd; - -import java.io.IOException; - -import org.apache.log4j.Logger; - -import com.esri.arcgis.carto.IMap; -import com.esri.arcgis.carto.Map; -import com.esri.arcgis.geometry.ISpatialReference; -import com.esri.arcgis.geometry.ProjectedCoordinateSystem; -import com.esri.arcgis.geometry.GeographicCoordinateSystem; -import com.esri.arcgis.geometry.IProjection; -import com.esri.arcgis.geometry.Projection; -/** - * Reads map information. - * - * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> - */ -public class MapReader{ - - //Member - IMap map; - - private static final Logger logger = Logger.getLogger(MapReader.class); - - //Constructor - public MapReader(IMap map){ - logger.debug("constructor()"); - this.map = map; - } - - - //Methods - - /** - * Reads the Map attributes. - */ - public void read() throws IOException{ - logger.debug("read()"); - ISpatialReference sr = map.getSpatialReference(); - logger.debug("Instance: " + sr.getClass().toString()); - if(sr instanceof ProjectedCoordinateSystem){ - ProjectedCoordinateSystem pcs = (ProjectedCoordinateSystem)sr; - Projection p = (Projection)pcs.getProjection(); - System.out.println("Projection = " + p.getName()); - } - else if(sr instanceof GeographicCoordinateSystem){ - GeographicCoordinateSystem gcs = (GeographicCoordinateSystem)sr; - System.out.println("Name = " + gcs.getName()); - } - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/src/java/de/intevation/mxd/SimpleMarkerSymbolReader.java Fri Apr 08 11:47:59 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -//package de.intevation.mxd.symbol; - -import java.io.IOException; - -import org.apache.log4j.Logger; - -import com.esri.arcgis.display.ISymbol; -import com.esri.arcgis.display.SimpleMarkerSymbol; -import com.esri.arcgis.display.esriSimpleMarkerStyle; -import com.esri.arcgis.display.IRgbColor; -import com.esri.arcgis.display.RgbColor; - -/** - * Reads simple marker symbol information. - * - * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> - */ -public class SimpleMarkerSymbolReader implements ISymbolReader{ - - //Member - private static final Logger logger = Logger.getLogger(SimpleMarkerSymbolReader.class); - - private SimpleMarkerSymbol symbol; - - //Constructor - public SimpleMarkerSymbolReader(ISymbol symbol) throws Exception{ - logger.debug("contructor()"); - if(symbol instanceof SimpleMarkerSymbol) - this.symbol = (SimpleMarkerSymbol)symbol; - else - throw new Exception("Not a SimpleMarkerSymbol!"); - } - - - //Methods - public boolean read() throws IOException{ - logger.debug("read()"); - System.out.println("--------------------"); - System.out.println("Symbol information:"); - System.out.println("Name\t\t = " + symbol.getNameString()); - - if(symbol.getStyle() == esriSimpleMarkerStyle.esriSMSCircle) - System.out.println("Style\t\t = Point"); - if(symbol.getColor() instanceof IRgbColor){ - IRgbColor color = (IRgbColor)symbol.getColor(); - System.out.println("Color\t\t = (" + color.getRed() + - "," + color.getGreen() + - "," + color.getBlue() + ")"); - System.out.println("Transparency\t = " + color.getTransparency()); - } - else{ - System.out.println("Color type unknown! " + - symbol.getColor().getClass().toString()); - } - if(symbol.getOutlineColor() instanceof RgbColor){ - RgbColor color = (RgbColor)symbol.getOutlineColor(); - System.out.println("Outlinecolor\t = (" + color.getRed() + - "," + color.getGreen() + - "," + color.getBlue() + ")"); - System.out.println("Transparency\t = " + color.getTransparency()); - } - else{ - System.out.println("Color type unknown! " + - symbol.getOutlineColor().getClass().toString()); - } - - System.out.println("Size\t\t = " + symbol.getSize()); - System.out.println("OutlineSize\t\t = " + symbol.getOutlineSize()); - System.out.println("Angle\t\t = " + symbol.getAngle()); - System.out.println("Offset\t\t = " + symbol.getXOffset() + - "," + symbol.getYOffset()); - System.out.println(""); - return true; - } - - public void getSymbol() throws IOException{ - logger.debug("getSymbol() -> not implemented jet."); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/src/java/de/intevation/mxd/SimpleRendererReader.java Fri Apr 08 11:47:59 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -//package de.intevation.mxd.renderer; - -import java.io.IOException; - -import org.apache.log4j.Logger; - -import com.esri.arcgis.carto.IFeatureRenderer; -import com.esri.arcgis.display.ISymbol; -import com.esri.arcgis.carto.SimpleRenderer; -import com.esri.arcgis.display.SimpleMarkerSymbol; - -/** - * Reads simple renderer information. - * - * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> - */ -public class SimpleRendererReader implements IRendererReader{ - - //Member - private ISymbol symbol; - private IFeatureRenderer renderer; - private static final Logger logger = Logger.getLogger(FeatureLayerReader.class); - - //Constructor - public SimpleRendererReader(IFeatureRenderer renderer){ - this.renderer = renderer; - } - - - //Methods - public boolean read() throws IOException{ - logger.debug("read()"); - if(renderer instanceof SimpleRenderer){ - SimpleRenderer sr = (SimpleRenderer)renderer; - System.out.println("--------------------"); - System.out.println("Renderer inforamtion:"); - System.out.println("Label\t\t = " + sr.getLabel()); - System.out.println("Description\t\t = " + sr.getDescription()); - System.out.println(""); - symbol = sr.getSymbol(); - try{ - ISymbolReader isr= new SimpleMarkerSymbolReader(symbol); - isr.read(); - return true; - } - catch(Exception e){ - e.printStackTrace(); - } - } - return false; - } - - public void getRenderer() throws IOException{ - logger.debug("getRenderer() -> not implemented jet."); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/src/java/de/intevation/mxd/UniqueValueRendererReader.java Fri Apr 08 11:47:59 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -//package de.intevation.mxd.renderer; - -import java.io.IOException; - -import org.apache.log4j.Logger; - -import com.esri.arcgis.carto.IFeatureRenderer; -import com.esri.arcgis.display.ISymbol; -import com.esri.arcgis.carto.UniqueValueRenderer; - -/** - * Reads unique vaule renderer information. - * - * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> - */ -public class UniqueValueRendererReader implements IRendererReader{ - - //Member - private ISymbol symbol; - private IFeatureRenderer renderer; - private static final Logger logger = Logger.getLogger(FeatureLayerReader.class); - - //Constructor - public UniqueValueRendererReader(IFeatureRenderer renderer){ - this.renderer = renderer; - } - - - //Methods - public boolean read() throws IOException{ - logger.debug("read()"); - if(renderer instanceof UniqueValueRenderer){ - UniqueValueRenderer sr = (UniqueValueRenderer)renderer; - System.out.println("--------------------"); - System.out.println("Renderer inforamtion:"); - System.out.println("Value count\t\t = " + sr.getValueCount()); - for(int i = 0; i < sr.getValueCount(); i++){ - String val = sr.getValue(i); - System.out.println("Value\t\t = " + val); - System.out.println("Label\t\t = " + sr.getLabel(val)); - System.out.println("Description\t\t = " + sr.getDescription(val)); - } - System.out.println(""); - symbol = sr.getDefaultSymbol(); - try{ - ISymbolReader isr= new SimpleMarkerSymbolReader(symbol); - isr.read(); - return true; - } - catch(Exception e){ - e.printStackTrace(); - } - } - return false; - } - - public void getRenderer() throws IOException{ - logger.debug("getRenderer() -> not implemented jet."); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java Fri Apr 08 12:26:17 2011 +0200 @@ -0,0 +1,56 @@ +//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; + +/** + * Reads the ClassBreaksRender Object Attributes. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class ClassBreakRendererReader implements IRendererReader{ + + //Member + private static final Logger logger = + Logger.getLogger(ClassBreakRendererReader.class); + + private ClassBreaksRenderer renderer; + + //Constructor + public ClassBreakRendererReader(IFeatureRenderer renderer) throws Exception{ + logger.debug("contructor()"); + if(renderer instanceof ClassBreaksRenderer) + this.renderer = (ClassBreaksRenderer)renderer; + else + throw new Exception("Not a ClassBreaksRenderer!"); + } + + + //Methods + public boolean read() throws IOException{ + logger.debug("read()"); + System.out.println("--------------------"); + System.out.println("Renderer information:"); + System.out.println("Ramp\t\t = " + renderer.getColorRamp()); + System.out.println("Class count\t\t = " + renderer.getClassCount()); + + for(int i = 0; i < renderer.getClassCount(); i++){ + System.out.println("Class " + i + "\t\t = " + renderer.esri_getClass(i)); + } + System.out.println("Break count\t\t = " + renderer.getBreakCount()); + for(int i = 0; i < renderer.getBreakCount(); i++){ + System.out.println("Break " + i + "\t\t = " + renderer.getBreak(i)); + } + System.out.println(""); + return true; + } + + public void getRenderer() throws IOException{ + logger.debug("getRenderer() -> not implemented jet."); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/de/intevation/mxd/reader/FeatureLayerReader.java Fri Apr 08 12:26:17 2011 +0200 @@ -0,0 +1,66 @@ +//package de.intevation.mxd.reader; + +import java.io.IOException; + +import org.apache.log4j.Logger; + +import com.esri.arcgis.carto.ILayer; +import com.esri.arcgis.carto.FeatureLayer; +import com.esri.arcgis.geometry.ISpatialReference; +import com.esri.arcgis.geometry.ProjectedCoordinateSystem; +import com.esri.arcgis.geometry.IProjection; +import com.esri.arcgis.geometry.Projection; +import com.esri.arcgis.display.ISymbol; +import com.esri.arcgis.display.SimpleMarkerSymbol; +/** + * Reads Layer information.. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class FeatureLayerReader implements ILayerReader{ + + private static final Logger logger = Logger.getLogger(FeatureLayerReader.class); + + private ILayer layer; + + //Constructor + public FeatureLayerReader(ILayer layer){ + this.layer = layer; + } + + //Methods + /** + * Reads the Layer content. + */ + public boolean read() throws IOException{ + logger.debug("read()"); + if(layer instanceof FeatureLayer){ + FeatureLayer fl = (FeatureLayer)layer; + System.out.println("--------------------"); + System.out.println("Layer information:"); + System.out.println("Layername\t\t = " + fl.getName()); + System.out.println("Min-/Maxscale\t = " + fl.getMinimumScale() + + "/" + fl.getMaximumScale()); + ISymbol symbol = fl.getSelectionSymbol(); + if(symbol instanceof SimpleMarkerSymbol) + System.out.println("Symboltype\t\t = " + + ((SimpleMarkerSymbol)symbol).getNameString()); + + System.out.println("Status\t\t = " + fl.isVisible()); + System.out.println("Definition Query\t = " + fl.getDefinitionExpression()); + System.out.println(""); + return true; + } + else{ + System.out.println("Layer type unknown! " + layer.getClass().toString()); + } + + return false; + } + + public void getLayer() throws IOException{ + logger.debug("getLayer() -> not implemented jet."); + return; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/de/intevation/mxd/reader/ILayerReader.java Fri Apr 08 12:26:17 2011 +0200 @@ -0,0 +1,16 @@ +//package de.intevation.mxd.reader; + +import java.io.IOException; + +/** + * The interface to the layer reader. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public interface ILayerReader{ + + public boolean read() throws IOException; + public void getLayer() throws IOException; + +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/de/intevation/mxd/reader/IReader.java Fri Apr 08 12:26:17 2011 +0200 @@ -0,0 +1,36 @@ +//package de.intevation.mxd.reader; + +import java.io.IOException; + +/** + * The interface to the MXD-Reader. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public interface IReader { + /** + * Initializes the reader component. + */ + boolean init() throws IOException; + + /** + * Method to perform actions at the of reader usage. + */ + boolean shutdown() throws IOException; + + /** + * Set the filename. + */ + void setFilename(String name); + + /** + * Read the content. + */ + boolean read() throws IOException; + + /** + * Request DOM Document containing the map data. + */ + void getMapDocument(); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/de/intevation/mxd/reader/IRendererReader.java Fri Apr 08 12:26:17 2011 +0200 @@ -0,0 +1,18 @@ +//package de.intevation.mxd.reader; + +import java.io.IOException; + +import com.esri.arcgis.carto.IFeatureRenderer; + +/** + * The interface to the renderer reader. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public interface IRendererReader{ + + public boolean read() throws IOException; + public void getRenderer() throws IOException; + +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/de/intevation/mxd/reader/ISymbolReader.java Fri Apr 08 12:26:17 2011 +0200 @@ -0,0 +1,16 @@ +//package de.intevation.mxd.reader; + +import java.io.IOException; + +/** + * The interface to the symbol reader. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public interface ISymbolReader{ + + public boolean read() throws IOException; + public void getSymbol() throws IOException; + +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/de/intevation/mxd/reader/MXDReader.java Fri Apr 08 12:26:17 2011 +0200 @@ -0,0 +1,138 @@ +//package de.intevation.mxd.reader; + +import java.io.IOException; + +import org.apache.log4j.Logger; + +import com.esri.arcgis.geodatabase.IClass; +import com.esri.arcgis.carto.ILayer; +import com.esri.arcgis.carto.IMap; +import com.esri.arcgis.carto.MapDocument; +import com.esri.arcgis.carto.FeatureLayer; +import com.esri.arcgis.carto.IFeatureRenderer; +import com.esri.arcgis.carto.SimpleRenderer; +import com.esri.arcgis.carto.ClassBreaksRenderer; +import com.esri.arcgis.carto.UniqueValueRenderer; + +import com.esri.arcgis.geodatabase.IFeatureClass; +import com.esri.arcgis.geodatabase.FeatureClass; +import com.esri.arcgis.geometry.ISpatialReference; +import com.esri.arcgis.geometry.ProjectedCoordinateSystem; +import com.esri.arcgis.geometry.IProjection; +import com.esri.arcgis.geometry.Projection; + +/** + * The MXD file reader. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class MXDReader implements IReader { + + //Member + private String filename = ""; + private ArcGISInitializer initializer = null; + private IMap map; + + private static final Logger logger = Logger.getLogger(MXDReader.class); + + //Constructor + public MXDReader() throws IOException{ + logger.debug("constructor()"); + initializer = new ArcGISInitializer(); + } + + + //Methods + + /** + * Initialize the ArcGIS Objects. + */ + public boolean init() throws IOException{ + logger.debug("init()"); + initializer.initArcGIS(); + initializer.initArcGISLicenses(); + return true; + } + + /** + * Shutdown the ArcGIS Objects. + */ + public boolean shutdown() throws IOException{ + logger.debug("shutdown()"); + if(initializer == null){ + throw new IOException("Faild to shutdown!"); + } + else{ + initializer.shutdownArcGIS(); + return true; + } + } + + /** + * Set the path and filename to the MXD-File. + */ + public void setFilename(String name){ + logger.debug("setFilename()"); + filename = name; + } + + /** + * Read the MXD file content. + */ + public boolean read() throws IOException{ + logger.debug("read()"); + if(filename == ""){ + throw new IOException("Please set filename!"); + } + else{ + MapDocument m = new MapDocument(); + if(!m.isMapDocument(filename)){ + throw new IOException(filename + " is not a map!"); + } + m.open(filename, null); + map = m.getMap(0); + MapReader mreader = new MapReader (map); + mreader.read(); + for(int i = 0; i < map.getLayerCount();i++){ + ILayer layer = map.getLayer(0); + ILayerReader lr = new FeatureLayerReader(layer); + lr.read(); + if (layer instanceof FeatureLayer){ + IFeatureRenderer renderer = ((FeatureLayer)layer).getRenderer(); + IRendererReader rreader; + try{ + if(renderer instanceof SimpleRenderer){ + rreader = new SimpleRendererReader(renderer); + rreader.read(); + } + else if(renderer instanceof ClassBreaksRenderer){ + rreader = new ClassBreakRendererReader(renderer); + rreader.read(); + } + else if(renderer instanceof UniqueValueRenderer){ + rreader = new UniqueValueRendererReader(renderer); + rreader.read(); + } + else{ + System.out.println("No known renderer!"); + System.out.println("Implement new renderer for " + + renderer.getClass().toString()); + } + } + catch(Exception e){ + e.printStackTrace(); + } + } + } + } + return true; + } + + /** + * Get the mapinformation as DOM document. TODO: implement me! + */ + public void getMapDocument(){ + logger.debug("getMapDocument() -> not implemented jet."); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/de/intevation/mxd/reader/MapReader.java Fri Apr 08 12:26:17 2011 +0200 @@ -0,0 +1,53 @@ +//package de.intevation.mxd.reader; + +import java.io.IOException; + +import org.apache.log4j.Logger; + +import com.esri.arcgis.carto.IMap; +import com.esri.arcgis.carto.Map; +import com.esri.arcgis.geometry.ISpatialReference; +import com.esri.arcgis.geometry.ProjectedCoordinateSystem; +import com.esri.arcgis.geometry.GeographicCoordinateSystem; +import com.esri.arcgis.geometry.IProjection; +import com.esri.arcgis.geometry.Projection; +/** + * Reads map information. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class MapReader{ + + //Member + IMap map; + + private static final Logger logger = Logger.getLogger(MapReader.class); + + //Constructor + public MapReader(IMap map){ + logger.debug("constructor()"); + this.map = map; + } + + + //Methods + + /** + * Reads the Map attributes. + */ + public void read() throws IOException{ + logger.debug("read()"); + ISpatialReference sr = map.getSpatialReference(); + logger.debug("Instance: " + sr.getClass().toString()); + if(sr instanceof ProjectedCoordinateSystem){ + ProjectedCoordinateSystem pcs = (ProjectedCoordinateSystem)sr; + Projection p = (Projection)pcs.getProjection(); + System.out.println("Projection = " + p.getName()); + } + else if(sr instanceof GeographicCoordinateSystem){ + GeographicCoordinateSystem gcs = (GeographicCoordinateSystem)sr; + System.out.println("Name = " + gcs.getName()); + } + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/de/intevation/mxd/reader/SimpleMarkerSymbolReader.java Fri Apr 08 12:26:17 2011 +0200 @@ -0,0 +1,80 @@ +//package de.intevation.mxd.reader; + +import java.io.IOException; + +import org.apache.log4j.Logger; + +import com.esri.arcgis.display.ISymbol; +import com.esri.arcgis.display.SimpleMarkerSymbol; +import com.esri.arcgis.display.esriSimpleMarkerStyle; +import com.esri.arcgis.display.IRgbColor; +import com.esri.arcgis.display.RgbColor; + +/** + * Reads simple marker symbol information. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class SimpleMarkerSymbolReader implements ISymbolReader{ + + //Member + private static final Logger logger = Logger.getLogger(SimpleMarkerSymbolReader.class); + + private SimpleMarkerSymbol symbol; + + //Constructor + public SimpleMarkerSymbolReader(ISymbol symbol) throws Exception{ + logger.debug("contructor()"); + if(symbol instanceof SimpleMarkerSymbol) + this.symbol = (SimpleMarkerSymbol)symbol; + else + throw new Exception("Not a SimpleMarkerSymbol!"); + } + + + //Methods + public boolean read() throws IOException{ + logger.debug("read()"); + System.out.println("--------------------"); + System.out.println("Symbol information:"); + System.out.println("Name\t\t = " + symbol.getNameString()); + + if(symbol.getStyle() == esriSimpleMarkerStyle.esriSMSCircle) + System.out.println("Style\t\t = Point"); + if(symbol.getColor() instanceof IRgbColor){ + IRgbColor color = (IRgbColor)symbol.getColor(); + System.out.println("Color\t\t = (" + color.getRed() + + "," + color.getGreen() + + "," + color.getBlue() + ")"); + System.out.println("Transparency\t = " + color.getTransparency()); + } + else{ + System.out.println("Color type unknown! " + + symbol.getColor().getClass().toString()); + } + if(symbol.getOutlineColor() instanceof RgbColor){ + RgbColor color = (RgbColor)symbol.getOutlineColor(); + System.out.println("Outlinecolor\t = (" + color.getRed() + + "," + color.getGreen() + + "," + color.getBlue() + ")"); + System.out.println("Transparency\t = " + color.getTransparency()); + } + else{ + System.out.println("Color type unknown! " + + symbol.getOutlineColor().getClass().toString()); + } + + System.out.println("Size\t\t = " + symbol.getSize()); + System.out.println("OutlineSize\t\t = " + symbol.getOutlineSize()); + System.out.println("Angle\t\t = " + symbol.getAngle()); + System.out.println("Offset\t\t = " + symbol.getXOffset() + + "," + symbol.getYOffset()); + System.out.println(""); + return true; + } + + public void getSymbol() throws IOException{ + logger.debug("getSymbol() -> not implemented jet."); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/de/intevation/mxd/reader/SimpleRendererReader.java Fri Apr 08 12:26:17 2011 +0200 @@ -0,0 +1,57 @@ +//package de.intevation.mxdaderr; + +import java.io.IOException; + +import org.apache.log4j.Logger; + +import com.esri.arcgis.carto.IFeatureRenderer; +import com.esri.arcgis.display.ISymbol; +import com.esri.arcgis.carto.SimpleRenderer; +import com.esri.arcgis.display.SimpleMarkerSymbol; + +/** + * Reads simple renderer information. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class SimpleRendererReader implements IRendererReader{ + + //Member + private ISymbol symbol; + private IFeatureRenderer renderer; + private static final Logger logger = Logger.getLogger(FeatureLayerReader.class); + + //Constructor + public SimpleRendererReader(IFeatureRenderer renderer){ + this.renderer = renderer; + } + + + //Methods + public boolean read() throws IOException{ + logger.debug("read()"); + if(renderer instanceof SimpleRenderer){ + SimpleRenderer sr = (SimpleRenderer)renderer; + System.out.println("--------------------"); + System.out.println("Renderer inforamtion:"); + System.out.println("Label\t\t = " + sr.getLabel()); + System.out.println("Description\t\t = " + sr.getDescription()); + System.out.println(""); + symbol = sr.getSymbol(); + try{ + ISymbolReader isr= new SimpleMarkerSymbolReader(symbol); + isr.read(); + return true; + } + catch(Exception e){ + e.printStackTrace(); + } + } + return false; + } + + public void getRenderer() throws IOException{ + logger.debug("getRenderer() -> not implemented jet."); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java Fri Apr 08 12:26:17 2011 +0200 @@ -0,0 +1,61 @@ +//package de.intevation.mxd.reader; + +import java.io.IOException; + +import org.apache.log4j.Logger; + +import com.esri.arcgis.carto.IFeatureRenderer; +import com.esri.arcgis.display.ISymbol; +import com.esri.arcgis.carto.UniqueValueRenderer; + +/** + * Reads unique vaule renderer information. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class UniqueValueRendererReader implements IRendererReader{ + + //Member + private ISymbol symbol; + private IFeatureRenderer renderer; + private static final Logger logger = Logger.getLogger(FeatureLayerReader.class); + + //Constructor + public UniqueValueRendererReader(IFeatureRenderer renderer){ + this.renderer = renderer; + } + + + //Methods + public boolean read() throws IOException{ + logger.debug("read()"); + if(renderer instanceof UniqueValueRenderer){ + UniqueValueRenderer sr = (UniqueValueRenderer)renderer; + System.out.println("--------------------"); + System.out.println("Renderer inforamtion:"); + System.out.println("Value count\t\t = " + sr.getValueCount()); + for(int i = 0; i < sr.getValueCount(); i++){ + String val = sr.getValue(i); + System.out.println("Value\t\t = " + val); + System.out.println("Label\t\t = " + sr.getLabel(val)); + System.out.println("Description\t\t = " + sr.getDescription(val)); + } + System.out.println(""); + symbol = sr.getDefaultSymbol(); + try{ + ISymbolReader isr= new SimpleMarkerSymbolReader(symbol); + isr.read(); + return true; + } + catch(Exception e){ + e.printStackTrace(); + } + } + return false; + } + + public void getRenderer() throws IOException{ + logger.debug("getRenderer() -> not implemented jet."); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :