comparison src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 49:0fecdcc28b1b

Created one method for each symbol type in the writer.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 20 Apr 2011 11:56:35 +0200
parents 34a93dad7604
children 691864097eb1
comparison
equal deleted inserted replaced
48:8e6d529e9a22 49:0fecdcc28b1b
270 style.setSymbolByName(map, name); 270 style.setSymbolByName(map, name);
271 symbolObj sym = symbolSet.getSymbolByName(name); 271 symbolObj sym = symbolSet.getSymbolByName(name);
272 272
273 String symType = symbolElement.getAttribute("style"); 273 String symType = symbolElement.getAttribute("style");
274 if(symType.equals("point")) { 274 if(symType.equals("point")) {
275 lineObj points = new lineObj(); 275 writePointSymbol(sym, symbolElement);
276 points.add(new pointObj(1,1,0));
277 sym.setType(MS_SYMBOL_TYPE.MS_SYMBOL_ELLIPSE.swigValue());
278 sym.setPoints(points);
279 sym.setFilled(1);
280 } 276 }
281 else if (symType.equals("arrow")) { 277 else if (symType.equals("arrow")) {
282 double len = Double.parseDouble(symbolElement.getAttribute("length")); 278 writeArrowSymbol(sym, symbolElement);
283 double width = Double.parseDouble(symbolElement.getAttribute("width")); 279 }
284 double ratio = len/width; 280 else if (symType.equals("char")) {
285 lineObj points = new lineObj(); 281 writeCharSymbol(sym, symbolElement);
286
287 points.add(new pointObj(0, 0, 0));
288 points.add(new pointObj((1*ratio), 0.5, 0));
289 points.add(new pointObj(0, 1, 0));
290 points.add(new pointObj(0, 0, 0));
291 sym.setType(MS_SYMBOL_TYPE.MS_SYMBOL_VECTOR.swigValue());
292 sym.setPoints(points);
293 sym.setFilled(1);
294 } 282 }
295 } 283 }
296 saveSymbolSet(symbolSet); 284 saveSymbolSet(symbolSet);
297 } 285 }
286
287
288 /**
289 * Write point symbols to the map.
290 * @param symbol The symbol object.
291 * @param symbolElement The DOM object containing the attributes.
292 */
293 private void writePointSymbol(symbolObj symbol, Element symbolElement) {
294 lineObj points = new lineObj();
295 points.add(new pointObj(1,1,0));
296 symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_ELLIPSE.swigValue());
297 symbol.setPoints(points);
298 symbol.setFilled(1);
299 }
300
301
302 /**
303 * Write arrow symbol to the map.
304 * @param symbol The symbol object.
305 * @param symbolElement The DOM object containig the attributes.
306 */
307 private void writeArrowSymbol(symbolObj symbol, Element symbolElement) {
308 double len = Double.parseDouble(symbolElement.getAttribute("length"));
309 double width = Double.parseDouble(symbolElement.getAttribute("width"));
310 double ratio = len/width;
311 lineObj points = new lineObj();
312
313 points.add(new pointObj(0, 0, 0));
314 points.add(new pointObj((1*ratio), 0.5, 0));
315 points.add(new pointObj(0, 1, 0));
316 points.add(new pointObj(0, 0, 0));
317 symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_VECTOR.swigValue());
318 symbol.setPoints(points);
319 symbol.setFilled(1);
320 }
321
322
323 /**
324 * Write font symbols to the map.
325 * @param symbol The symbol object.
326 * @param symbolElement The DOM object containing the attributes.
327 */
328 private void writeCharSymbol(symbolObj symbol, Element symbolElement) {
329 symbol.setFont(symbolElement.getAttribute("font"));
330 symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_TRUETYPE.swigValue());
331 symbol.setAntialias(1);
332 symbol.setCharacter("#&" + symbolElement.getAttribute("char") + ";");
333 }
334
298 335
299 /** 336 /**
300 * Save the symbol set. 337 * Save the symbol set.
301 * @param symbols The symbol set. 338 * @param symbols The symbol set.
302 */ 339 */
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)