# HG changeset patch # User Raimund Renkert # Date 1303293395 -7200 # Node ID 0fecdcc28b1b618edfb0c828c429c28fab065f96 # Parent 8e6d529e9a22b24efa4341e49f68a622520b2d3e Created one method for each symbol type in the writer. diff -r 8e6d529e9a22 -r 0fecdcc28b1b ChangeLog --- a/ChangeLog Wed Apr 20 11:48:46 2011 +0200 +++ b/ChangeLog Wed Apr 20 11:56:35 2011 +0200 @@ -1,3 +1,9 @@ +2011-04-20 Raimund Renkert + + * src/java/de/intevation/mxd/writer/MapScriptWriter.java: + Created one method for each symbol type. + Write the character symbol attributes to the map. + 2011-04-20 Raimund Renkert * src/java/de/intevation/mxd/reader/CharacterMarkerSymbolReader.java: diff -r 8e6d529e9a22 -r 0fecdcc28b1b src/java/de/intevation/mxd/writer/MapScriptWriter.java --- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java Wed Apr 20 11:48:46 2011 +0200 +++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java Wed Apr 20 11:56:35 2011 +0200 @@ -272,30 +272,67 @@ String symType = symbolElement.getAttribute("style"); if(symType.equals("point")) { - lineObj points = new lineObj(); - points.add(new pointObj(1,1,0)); - sym.setType(MS_SYMBOL_TYPE.MS_SYMBOL_ELLIPSE.swigValue()); - sym.setPoints(points); - sym.setFilled(1); + writePointSymbol(sym, symbolElement); } else if (symType.equals("arrow")) { - double len = Double.parseDouble(symbolElement.getAttribute("length")); - double width = Double.parseDouble(symbolElement.getAttribute("width")); - double ratio = len/width; - lineObj points = new lineObj(); - - points.add(new pointObj(0, 0, 0)); - points.add(new pointObj((1*ratio), 0.5, 0)); - points.add(new pointObj(0, 1, 0)); - points.add(new pointObj(0, 0, 0)); - sym.setType(MS_SYMBOL_TYPE.MS_SYMBOL_VECTOR.swigValue()); - sym.setPoints(points); - sym.setFilled(1); + writeArrowSymbol(sym, symbolElement); + } + else if (symType.equals("char")) { + writeCharSymbol(sym, symbolElement); } } saveSymbolSet(symbolSet); } + + /** + * Write point symbols to the map. + * @param symbol The symbol object. + * @param symbolElement The DOM object containing the attributes. + */ + private void writePointSymbol(symbolObj symbol, Element symbolElement) { + lineObj points = new lineObj(); + points.add(new pointObj(1,1,0)); + symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_ELLIPSE.swigValue()); + symbol.setPoints(points); + symbol.setFilled(1); + } + + + /** + * Write arrow symbol to the map. + * @param symbol The symbol object. + * @param symbolElement The DOM object containig the attributes. + */ + private void writeArrowSymbol(symbolObj symbol, Element symbolElement) { + double len = Double.parseDouble(symbolElement.getAttribute("length")); + double width = Double.parseDouble(symbolElement.getAttribute("width")); + double ratio = len/width; + lineObj points = new lineObj(); + + points.add(new pointObj(0, 0, 0)); + points.add(new pointObj((1*ratio), 0.5, 0)); + points.add(new pointObj(0, 1, 0)); + points.add(new pointObj(0, 0, 0)); + symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_VECTOR.swigValue()); + symbol.setPoints(points); + symbol.setFilled(1); + } + + + /** + * Write font symbols to the map. + * @param symbol The symbol object. + * @param symbolElement The DOM object containing the attributes. + */ + private void writeCharSymbol(symbolObj symbol, Element symbolElement) { + symbol.setFont(symbolElement.getAttribute("font")); + symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_TRUETYPE.swigValue()); + symbol.setAntialias(1); + symbol.setCharacter("#&" + symbolElement.getAttribute("char") + ";"); + } + + /** * Save the symbol set. * @param symbols The symbol set.