comparison src/java/de/intevation/mxd/writer/SymbolWriter.java @ 141:8f30f7e802d6

Manage symbol names and symbol comparison.
author vc11884admin@VC11884.win.bsh.de
date Mon, 27 Jun 2011 16:07:13 +0200
parents 11d63bf00326
children b2c5a66022f1
comparison
equal deleted inserted replaced
137:cd55975ba0c4 141:8f30f7e802d6
52 } 52 }
53 else if (symType.equals("arrow")) { 53 else if (symType.equals("arrow")) {
54 writeArrow(sym, symbolElement); 54 writeArrow(sym, symbolElement);
55 } 55 }
56 else if (symType.equals("char")) { 56 else if (symType.equals("char")) {
57 //TODO Does not work at all... waiting for fix. 57 int exists = symbolExists(symbolElement);
58 writeCharacter(sym, symbolElement); 58 if(exists == -1) {
59 String old = symbolElement.getAttribute("name");
60 symbolElement.setAttribute(
61 "name",
62 old + symbolSet.getNumsymbols() + 1);
63 writeCharacter(sym, symbolElement);
64 }
65 else {
66 symbolElement.setAttribute(
67 "name",
68 symbolSet.getSymbol(exists).getName());
69 }
59 } 70 }
60 else if (type.equals("line")) { 71 else if (type.equals("line")) {
61 writeHatch(sym); 72 writeHatch(sym);
62 } 73 }
63 else { 74 else {
104 logger.debug("writeCharacter(symbolObj, Element)"); 115 logger.debug("writeCharacter(symbolObj, Element)");
105 //TODO Write the symbol correctly. See Issue 3885 on trac.osgeo.org 116 //TODO Write the symbol correctly. See Issue 3885 on trac.osgeo.org
106 String font = symbolElement.getAttribute("font"); 117 String font = symbolElement.getAttribute("font");
107 //Remove all blank character to match the mapserver fonts.txt. 118 //Remove all blank character to match the mapserver fonts.txt.
108 font = font.replaceAll(" ", ""); 119 font = font.replaceAll(" ", "");
120 symbol.setName(symbolElement.getAttribute("name"));
109 symbol.setFont(font); 121 symbol.setFont(font);
110 symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_TRUETYPE.swigValue()); 122 symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_TRUETYPE.swigValue());
111 symbol.setAntialias(1); 123 symbol.setAntialias(1);
112 symbol.setCharacter("&#" + symbolElement.getAttribute("char") + ";"); 124 symbol.setCharacter("&#" + symbolElement.getAttribute("char") + ";");
113 } 125 }
138 else { 150 else {
139 path += "symbols.sym"; 151 path += "symbols.sym";
140 } 152 }
141 symbols.save(path); 153 symbols.save(path);
142 } 154 }
155
156 private int symbolExists (Element elem) {
157 symbolSetObj symbolSet = map.getSymbolset();
158 for (int i = 0; i < symbolSet.getNumsymbols(); i++) {
159 symbolObj sym = symbolSet.getSymbol(i);
160 int stype = sym.getType();
161 String etype = elem.getAttribute("style");
162 if(stype == MS_SYMBOL_TYPE.MS_SYMBOL_ELLIPSE.swigValue () &&
163 etype.equals("point")) {
164 return i;
165 }
166 else if(stype == MS_SYMBOL_TYPE.MS_SYMBOL_VECTOR.swigValue () &&
167 etype.equals("arrow")) {
168 return i;
169 }
170 else if(stype == MS_SYMBOL_TYPE.MS_SYMBOL_TRUETYPE.swigValue () &&
171 etype.equals("char")) {
172 String font = elem.getAttribute("font");
173 font = font.replaceAll(" ", "");
174 String c = elem.getAttribute("char");
175 c = "&#" + c + ";";
176 if (font.equals(sym.getFont()) &&
177 c.equals(sym.getCharacter())) {
178 return i;
179 }
180
181 }
182 else if(stype == MS_SYMBOL_TYPE.MS_SYMBOL_HATCH.swigValue () &&
183 etype.equals("hatch")) {
184 return i;
185 }
186
187 }
188 return -1;
189 }
143 } 190 }
144 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 191 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)