Mercurial > mxd2map
changeset 93:3993b5adf67c
Write the character symbol correctly to the mapfile and the symbolset.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 01 Jun 2011 11:48:57 +0200 |
parents | 35e2b555b305 |
children | 273e49f51cfb |
files | ChangeLog src/java/de/intevation/mxd/reader/CharacterMarkerSymbolReader.java src/java/de/intevation/mxd/writer/SymbolWriter.java |
diffstat | 3 files changed, 43 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Jun 01 10:24:10 2011 +0200 +++ b/ChangeLog Wed Jun 01 11:48:57 2011 +0200 @@ -1,3 +1,12 @@ +2011-06-01 Raimund Renkert <raimund.renkert@intevation.de> + + * src/java/de/intevation/mxd/reader/CharacterMarkerSymbolReader.java: + Read and convert the symbol color and convert to integer. + + * src/java/de/intevation/mxd/writer/SymbolWriter.java: + Set the correct character and font string. Save the symbolset to the + mapfile path. + 2011-05-31 Raimund Renkert <raimund.renkert@intevation.de> * src/java/de/intevation/mxd/writer/MapScriptWriter.java:
--- a/src/java/de/intevation/mxd/reader/CharacterMarkerSymbolReader.java Wed Jun 01 10:24:10 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/CharacterMarkerSymbolReader.java Wed Jun 01 11:48:57 2011 +0200 @@ -7,8 +7,12 @@ import com.esri.arcgis.display.CharacterMarkerSymbol; import com.esri.arcgis.display.IColor; import com.esri.arcgis.support.ms.stdole.Font; +import com.esri.arcgis.display.IRgbColor; +import com.esri.arcgis.display.RgbColor; + import org.w3c.dom.Element; +import java.awt.Color; /** * Reads character marker symbol information. @@ -61,7 +65,6 @@ logger.debug("read()"); Element symbolElement = util.addSymbol(parent); - IColor c = symbol.getColor(); symbolElement.setAttribute( "angle", String.valueOf(symbol.getAngle())); @@ -75,18 +78,34 @@ "y_offset", String.valueOf(symbol.getYOffset())); symbolElement.setAttribute( - "color", - String.valueOf(c.getRGB())); - symbolElement.setAttribute( - "tranparency", - String.valueOf(c.getTransparency())); - symbolElement.setAttribute( "name", symbol.getNameString()); symbolElement.setAttribute( "char", String.valueOf(symbol.getCharacterIndex())); + if(symbol.getColor() instanceof IRgbColor) { + IRgbColor color = (IRgbColor)symbol.getColor(); + Color c = new Color ( + color.getRed(), + color.getGreen(), + color.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("transparency", + String.valueOf(color.getTransparency())); + } + else { + RgbColor col = new RgbColor(); + col.setRGB(symbol.getColor().getRGB()); + Color c = new Color ( + col.getRed(), + col.getGreen(), + col.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("transparency", + String.valueOf(col.getTransparency())); + } + Font f = symbol.getFont(); symbolElement.setAttribute("font", f.getName()); symbolElement.setAttribute("char_set", String.valueOf(f.getCharset()));
--- a/src/java/de/intevation/mxd/writer/SymbolWriter.java Wed Jun 01 10:24:10 2011 +0200 +++ b/src/java/de/intevation/mxd/writer/SymbolWriter.java Wed Jun 01 11:48:57 2011 +0200 @@ -99,10 +99,13 @@ private void writeCharacter(symbolObj symbol, Element symbolElement) { logger.debug("writeCharacter(symbolObj, Element)"); //TODO Write the symbol correctly. See Issue 3885 on trac.osgeo.org - symbol.setFont(symbolElement.getAttribute("font")); + String font = symbolElement.getAttribute("font"); + //Remove all blank character to match the mapserver fonts.txt. + font = font.replaceAll(" ", ""); + symbol.setFont(font); symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_TRUETYPE.swigValue()); symbol.setAntialias(1); - symbol.setCharacter("#&" + symbolElement.getAttribute("char") + ";"); + symbol.setCharacter("&#" + symbolElement.getAttribute("char") + ";"); } public boolean canWrite(String type) { @@ -118,12 +121,12 @@ private void saveSymbolSet(symbolSetObj symbols) throws Exception { - String path = "";// TODO Get the correct path. Mapfile path or symbolset path + String path = this.map.getMappath(); if(path.equals("")) { return; } - else if(path.endsWith(".map")) { - path.replace(".map", ".sym"); + else { + path += "symbols.sym"; } symbols.save(path); }