Mercurial > mxd2map
diff src/java/de/intevation/mxd/writer/MapScriptWriter.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 | 395307e8b7ee |
children | 9b5fb5e5914d |
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java Fri Apr 15 14:14:49 2011 +0200 +++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java Fri Apr 15 15:44:54 2011 +0200 @@ -26,17 +26,25 @@ import de.intevation.mxd.utils.XMLUtils; /** - * The MXD file reader. + * The Mapfile Writer. + * This Writer uses the MapScript Java API to create Mapfiles from a DOM. * * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> */ public class MapScriptWriter implements IWriter { + /** + * The Logger. + */ + private static final Logger logger = Logger.getLogger(MapScriptWriter.class); + + /** + * Private member. + */ private Document root; private mapObj map; - private static final Logger logger = Logger.getLogger(MapScriptWriter.class); public MapScriptWriter() { map = new mapObj(""); @@ -46,6 +54,12 @@ map = new mapObj(path); } + /** + * Write the mapfile. + * @param doc The root document containin the map attributes. + * + * @return Currently always true. + */ public boolean write(Document doc) { logger.debug("write()"); this.root = doc; @@ -69,6 +83,9 @@ return true; } + /** + * Create the map object and set the attributes. + */ private void writeMap() { logger.debug("writeMap()"); //Get the map. @@ -126,6 +143,9 @@ //map.setScaledenom(Double.parseDouble(mapNode.getAttribute("scale"))); } + /** + * Create layer objects and set the attributes. + */ private void writeLayer() { logger.debug("writeLayer()"); Element mapNode = (Element)XMLUtils.xpath( @@ -194,7 +214,7 @@ } /** - * Adds teh symbols and styles to the mapfile. + * Adds the symbols and styles to the mapfile. * @param co Mapscript class object. * @param classElement Dom element containing the style and symbol * attributes. @@ -220,7 +240,8 @@ col.getBlue(), -4); style.setColor(color); - style.setSize(Double.parseDouble(symbolElement.getAttribute("size"))); + style.setSize(Double.parseDouble( + symbolElement.getAttribute("size"))); Color oCol = Color.decode( symbolElement.getAttribute("outline_color")); colorObj outlineColor = new colorObj( @@ -229,11 +250,13 @@ oCol.getBlue(), -4); style.setOutlinecolor(outlineColor); - style.setOutlinewidth( - Double.parseDouble(symbolElement.getAttribute("outline_size"))); - style.setSymbolByName(map, symbolElement.getAttribute("name")); + style.setOutlinewidth(Double.parseDouble( + symbolElement.getAttribute("outline_size"))); - symbolObj sym = symbolSet.getSymbolByName(symbolElement.getAttribute("name")); + String name = symbolElement.getAttribute("name"); + style.setSymbolByName(map, name); + symbolObj sym = symbolSet.getSymbolByName(name); + String symType = symbolElement.getAttribute("style"); if(symType.equals("point")) { lineObj points = new lineObj(); @@ -248,7 +271,7 @@ /** * Save the symbol set. - * @param + * @param symbols The symbol set. */ private void saveSymbolSet(symbolSetObj symbols) { Element fileNode = (Element)XMLUtils.xpath(