Mercurial > mxd2map
comparison src/java/de/intevation/mxd/writer/SymbolWriter.java @ 106:609c234e8e23
merged with reimunds changes
author | Stephan Holl <stephan.holl@intevation.de> |
---|---|
date | Tue, 07 Jun 2011 15:50:43 +0200 |
parents | 18e4f143896b |
children | 11d63bf00326 |
comparison
equal
deleted
inserted
replaced
105:db18c1b33936 | 106:609c234e8e23 |
---|---|
1 package de.intevation.mxd.writer; | 1 package de.intevation.mxd.writer; |
2 | 2 |
3 import org.apache.log4j.Logger; | 3 import org.apache.log4j.Logger; |
4 import java.io.File; | |
5 import java.io.FileInputStream; | |
6 import java.io.BufferedInputStream; | |
7 import java.util.Properties; | |
8 | 4 |
9 import org.w3c.dom.Element; | 5 import org.w3c.dom.Element; |
10 | 6 |
11 import edu.umn.gis.mapscript.mapObj; | 7 import edu.umn.gis.mapscript.mapObj; |
12 import edu.umn.gis.mapscript.classObj; | 8 import edu.umn.gis.mapscript.classObj; |
48 logger.debug("write(Element)"); | 44 logger.debug("write(Element)"); |
49 symbolSetObj symbolSet = map.getSymbolset(); | 45 symbolSetObj symbolSet = map.getSymbolset(); |
50 | 46 |
51 String name = symbolElement.getAttribute("name"); | 47 String name = symbolElement.getAttribute("name"); |
52 symbolObj sym = symbolSet.getSymbolByName(name); | 48 symbolObj sym = symbolSet.getSymbolByName(name); |
53 | |
54 String symType = symbolElement.getAttribute("style"); | 49 String symType = symbolElement.getAttribute("style"); |
50 String type = symbolElement.getAttribute("type"); | |
55 if(symType.equals("point")) { | 51 if(symType.equals("point")) { |
56 writeSimple(sym); | 52 writeSimple(sym); |
57 } | 53 } |
58 else if (symType.equals("arrow")) { | 54 else if (symType.equals("arrow")) { |
59 writeArrow(sym, symbolElement); | 55 writeArrow(sym, symbolElement); |
60 } | 56 } |
61 else if (symType.equals("char")) { | 57 else if (symType.equals("char")) { |
62 //TODO Does not work at all... waiting for fix. | 58 //TODO Does not work at all... waiting for fix. |
63 writeCharacter(sym, symbolElement); | 59 writeCharacter(sym, symbolElement); |
60 } | |
61 else if (type.equals("line")) { | |
62 writeHatch(sym); | |
64 } | 63 } |
65 else { | 64 else { |
66 return false; | 65 return false; |
67 } | 66 } |
68 | 67 |
97 } | 96 } |
98 | 97 |
99 private void writeCharacter(symbolObj symbol, Element symbolElement) { | 98 private void writeCharacter(symbolObj symbol, Element symbolElement) { |
100 logger.debug("writeCharacter(symbolObj, Element)"); | 99 logger.debug("writeCharacter(symbolObj, Element)"); |
101 //TODO Write the symbol correctly. See Issue 3885 on trac.osgeo.org | 100 //TODO Write the symbol correctly. See Issue 3885 on trac.osgeo.org |
102 symbol.setFont(symbolElement.getAttribute("font")); | 101 String font = symbolElement.getAttribute("font"); |
102 //Remove all blank character to match the mapserver fonts.txt. | |
103 font = font.replaceAll(" ", ""); | |
104 symbol.setFont(font); | |
103 symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_TRUETYPE.swigValue()); | 105 symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_TRUETYPE.swigValue()); |
104 symbol.setAntialias(1); | 106 symbol.setAntialias(1); |
105 symbol.setCharacter("#&" + symbolElement.getAttribute("char") + ";"); | 107 symbol.setCharacter("&#" + symbolElement.getAttribute("char") + ";"); |
108 } | |
109 | |
110 private void writeHatch(symbolObj symbol) { | |
111 logger.debug("writeHatch(symbolObj)"); | |
112 symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_HATCH.swigValue()); | |
106 } | 113 } |
107 | 114 |
108 public boolean canWrite(String type) { | 115 public boolean canWrite(String type) { |
109 if (type.equals("point") || | 116 if (type.equals("point") || |
110 type.equals("arrow") || | 117 type.equals("arrow") || |
111 type.equals("char")) { | 118 type.equals("char") || |
119 type.equals("line")) { | |
112 return true; | 120 return true; |
113 } | 121 } |
114 else { | 122 else { |
115 return false; | 123 return false; |
116 } | 124 } |
117 } | 125 } |
118 | 126 |
119 private void saveSymbolSet(symbolSetObj symbols) | 127 private void saveSymbolSet(symbolSetObj symbols) |
120 throws Exception { | 128 throws Exception { |
121 String path = "";// TODO Get the correct path. Mapfile path or symbolset path | 129 String path = this.map.getMappath(); |
122 if(path.equals("")) { | 130 if(path.equals("")) { |
123 return; | 131 return; |
124 } | 132 } |
125 else if(path.endsWith(".map")) { | 133 else { |
126 path.replace(".map", ".sym"); | 134 path += "symbols.sym"; |
127 } | 135 } |
128 symbols.save(path); | 136 symbols.save(path); |
129 } | 137 } |
130 } | 138 } |
131 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 139 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |