annotate src/java/de/intevation/mxd/reader/PictureMarkerSymbolReader.java @ 62:e468cf8701ea

Prepared the converter to handle and write line symbols.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 24 May 2011 14:16:25 +0200
parents 4e0464c620f0
children 5c5ef5768893
rev   line source
58
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
1 package de.intevation.mxd.reader;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 import java.io.IOException;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
4
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
6
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
7 import com.esri.arcgis.display.ISymbol;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8 import com.esri.arcgis.display.PictureMarkerSymbol;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 import com.esri.arcgis.display.IColor;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 import com.esri.arcgis.carto.PictureElement;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 import org.w3c.dom.Element;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 import de.intevation.mxd.utils.MapToXMLUtils;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 * Reads picture marker symbol information.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 *
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 */
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 public class PictureMarkerSymbolReader implements ISymbolReader{
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23 * The logger.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 */
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25 private static final Logger logger =
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 Logger.getLogger(PictureMarkerSymbolReader.class);
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29 * Private member.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30 */
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31 private Element renderer;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 private PictureMarkerSymbol symbol;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33 private MapToXMLUtils util;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
36 public PictureMarkerSymbolReader(ISymbol symbol)
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37 throws Exception {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 logger.debug("contructor()");
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 if(symbol instanceof PictureMarkerSymbol) {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 this.symbol = (PictureMarkerSymbol)symbol;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 else {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 throw new Exception("Not a PictureMarkerSymbol!");
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
45 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
46
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
47 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
48 * Setter for the parent XML element.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
49 *
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
50 * @param parent The XML parent node.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
51 */
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
52 public void setParent(Element parent) {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
53 this.renderer = parent;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
55
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
56 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
57 * Setter for XML document helper.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
58 *
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59 * @param util The helper class for storing map information.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
60 */
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 public void setUtil(MapToXMLUtils util) {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
62 this.util = util;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
65 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
66 * Reads the symbol attributes.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67 *
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68 * @return The XML node.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 */
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
70 public Element read()
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
71 throws IOException {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 logger.debug("read()");
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73 Element symbolElement;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74 try {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
75 symbolElement = util.addSymbol(renderer);
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
76 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
77 catch(Exception e) {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
78 e.printStackTrace();
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
79 return null;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
80 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
81
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
82 symbolElement.setAttribute(
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
83 "angle",
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84 String.valueOf(symbol.getAngle()));
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85 symbolElement.setAttribute(
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86 "size",
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
87 String.valueOf(symbol.getSize()));
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
88 symbolElement.setAttribute(
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
89 "x_offset",
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
90 String.valueOf(symbol.getXOffset()));
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
91 symbolElement.setAttribute(
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
92 "y_offset",
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
93 String.valueOf(symbol.getYOffset()));
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
94 symbolElement.setAttribute(
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
95 "name",
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
96 symbol.getNameString());
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
97 PictureElement pElem = new PictureElement();
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
98 pElem.importPicture(symbol.getPicture());
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
99 System.out.println("Path:" + pElem.getPath());
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
100 symbolElement.setAttribute("style", "picture");
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
101 return symbolElement;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
102 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
103 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
104 // 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)