Mercurial > mxd2map
diff src/java/de/intevation/mxd/reader/MXDReader.java @ 43:ef7ca23c4233
Added comments, done some code styling and removed typos.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 15 Apr 2011 15:44:54 +0200 |
parents | a1bc7220efe7 |
children | b41fcf268827 |
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/reader/MXDReader.java Fri Apr 15 14:14:49 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/MXDReader.java Fri Apr 15 15:44:54 2011 +0200 @@ -25,30 +25,35 @@ * * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> */ -public class MXDReader implements IReader { +public class MXDReader +implements IReader { + /** + * The Logger. + */ + private static final Logger logger = Logger.getLogger(MXDReader.class); - //Member + /** + * Private member. + */ private String filename = ""; private ArcGISInitializer initializer = null; private MapToXMLUtils util; private IMap map; - private static final Logger logger = Logger.getLogger(MXDReader.class); - //Constructor - public MXDReader() throws IOException{ + public MXDReader() + throws IOException { logger.debug("constructor()"); initializer = new ArcGISInitializer(); util = new MapToXMLUtils(); } - //Methods - /** * Initialize the ArcGIS Objects. */ - public boolean init() throws IOException{ + public boolean init() + throws IOException { logger.debug("init()"); initializer.initArcGIS(); initializer.initArcGISLicenses(); @@ -58,12 +63,13 @@ /** * Shutdown the ArcGIS Objects. */ - public boolean shutdown() throws IOException{ + public boolean shutdown() + throws IOException { logger.debug("shutdown()"); - if(initializer == null){ + if(initializer == null) { throw new IOException("Faild to shutdown!"); } - else{ + else { initializer.shutdownArcGIS(); return true; } @@ -72,29 +78,32 @@ /** * Set the path and filename to the MXD-File. */ - public void setFilename(String name){ + public void setFilename(String name) { logger.debug("setFilename()"); filename = name; } - private void openMapDocument() throws IOException{ + private void openMapDocument() + throws IOException { MapDocument m = new MapDocument(); - if(!m.isMapDocument(filename)){ + if(!m.isMapDocument(filename)) { throw new IOException(filename + " is not a map!"); } m.open(filename, null); map = m.getMap(0); } + /** * Read the MXD file content. */ - public boolean read() throws IOException{ + public boolean read() + throws IOException { logger.debug("read()"); - if(filename == ""){ + if(filename == "") { throw new IOException("Please set filename!"); } - else{ + else { util.addFilename(filename); openMapDocument(); MapReader mreader; @@ -108,28 +117,29 @@ e.printStackTrace(); } - for(int i = 0; i < map.getLayerCount();i++){ + for(int i = 0; i < map.getLayerCount();i++) { ILayer layer = map.getLayer(i); - try{ - if (layer instanceof FeatureLayer){ + try { + if (layer instanceof FeatureLayer) { FeatureLayerReader lr = new FeatureLayerReader(layer); lr.setUtil(util); Element layerElement = lr.read(); - IFeatureRenderer renderer = ((FeatureLayer)layer).getRenderer(); + IFeatureRenderer renderer = + ((FeatureLayer)layer).getRenderer(); IRendererReader rreader; - if(renderer instanceof SimpleRenderer){ + if(renderer instanceof SimpleRenderer) { rreader = new SimpleRendererReader(renderer); rreader.setParent(layerElement); rreader.setUtil(util); rreader.read(); } - else if(renderer instanceof ClassBreaksRenderer){ + else if(renderer instanceof ClassBreaksRenderer) { rreader = new ClassBreakRendererReader(renderer); rreader.setParent(layerElement); rreader.setUtil(util); rreader.read(); } - else if(renderer instanceof UniqueValueRenderer){ + else if(renderer instanceof UniqueValueRenderer) { rreader = new UniqueValueRendererReader(renderer); rreader.setParent(layerElement); rreader.setUtil(util); @@ -146,34 +156,35 @@ new GdbRasterCatalogLayerReader(layer); gclr.setUtil(util); Element layerElement = gclr.read(); - IFeatureRenderer renderer = ((GdbRasterCatalogLayer)layer).getRenderer(); + IFeatureRenderer renderer = + ((GdbRasterCatalogLayer)layer).getRenderer(); IRendererReader rreader; - if(renderer instanceof SimpleRenderer){ + if(renderer instanceof SimpleRenderer) { rreader = new SimpleRendererReader(renderer); rreader.setParent(layerElement); rreader.setUtil(util); rreader.read(); } - else if(renderer instanceof ClassBreaksRenderer){ + else if(renderer instanceof ClassBreaksRenderer) { rreader = new ClassBreakRendererReader(renderer); rreader.setParent(layerElement); rreader.setUtil(util); rreader.read(); } - else if(renderer instanceof UniqueValueRenderer){ + else if(renderer instanceof UniqueValueRenderer) { rreader = new UniqueValueRendererReader(renderer); rreader.setParent(layerElement); rreader.setUtil(util); rreader.read(); } - else{ + else { System.out.println("No known renderer!"); System.out.println("Implement new renderer for " + renderer.getClass().toString()); } } } - catch(Exception e){ + catch(Exception e) { e.printStackTrace(); } } @@ -182,8 +193,10 @@ return true; } - - public Document getMapDocument(){ + /** + * Get the root DOM document. + */ + public Document getMapDocument() { logger.debug("getMapDocument()"); return util.getDocument(); }