annotate src/java/de/intevation/mxd/reader/PictureMarkerSymbolReader.java @ 67:5ed9e720b6cd

Read the hash symbol in the hash line symbol reader.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 25 May 2011 15:48:55 +0200
parents 5c5ef5768893
children b41fcf268827
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;
63
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
8 import com.esri.arcgis.display.IMarkerSymbol;
58
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 import com.esri.arcgis.display.PictureMarkerSymbol;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 import com.esri.arcgis.display.IColor;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 import com.esri.arcgis.carto.PictureElement;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 import org.w3c.dom.Element;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 import de.intevation.mxd.utils.MapToXMLUtils;
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 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 * Reads picture marker symbol information.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 *
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 * @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
20 */
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 public class PictureMarkerSymbolReader implements ISymbolReader{
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 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 * The logger.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25 */
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 private static final Logger logger =
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27 Logger.getLogger(PictureMarkerSymbolReader.class);
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 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30 * Private member.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31 */
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 private Element renderer;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33 private PictureMarkerSymbol symbol;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34 private MapToXMLUtils util;
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
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37 public PictureMarkerSymbolReader(ISymbol symbol)
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 throws Exception {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 logger.debug("contructor()");
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 if(symbol instanceof PictureMarkerSymbol) {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 this.symbol = (PictureMarkerSymbol)symbol;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 else {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 throw new Exception("Not a PictureMarkerSymbol!");
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
63
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
48
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
49 public PictureMarkerSymbolReader(IMarkerSymbol symbol)
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
50 throws Exception {
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
51 logger.debug("contructor()");
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
52 if(symbol instanceof PictureMarkerSymbol) {
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
53 this.symbol = (PictureMarkerSymbol)symbol;
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
54 }
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
55 else {
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
56 throw new Exception("Not a PictureMarkerSymbol!");
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
57 }
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
58 }
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
59
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
60
58
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
62 * Setter for the parent XML element.
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 * @param parent The XML parent node.
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 public void setParent(Element parent) {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67 this.renderer = parent;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68 }
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 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
71 * Setter for XML document helper.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 *
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73 * @param util The helper class for storing map information.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74 */
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
75 public void setUtil(MapToXMLUtils util) {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
76 this.util = util;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
77 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
78
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
79 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
80 * Reads the symbol attributes.
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 * @return The XML node.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
83 */
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84 public Element read()
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85 throws IOException {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86 logger.debug("read()");
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
87 Element symbolElement;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
88 try {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
89 symbolElement = util.addSymbol(renderer);
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
90 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
91 catch(Exception e) {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
92 e.printStackTrace();
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
93 return null;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
94 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
95
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
96 symbolElement.setAttribute(
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
97 "angle",
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
98 String.valueOf(symbol.getAngle()));
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
99 symbolElement.setAttribute(
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
100 "size",
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
101 String.valueOf(symbol.getSize()));
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
102 symbolElement.setAttribute(
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
103 "x_offset",
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
104 String.valueOf(symbol.getXOffset()));
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105 symbolElement.setAttribute(
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
106 "y_offset",
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107 String.valueOf(symbol.getYOffset()));
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
108 symbolElement.setAttribute(
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
109 "name",
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
110 symbol.getNameString());
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
111 PictureElement pElem = new PictureElement();
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
112 pElem.importPicture(symbol.getPicture());
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
113 System.out.println("Path:" + pElem.getPath());
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
114 symbolElement.setAttribute("style", "picture");
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
115 return symbolElement;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
116 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
117 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
118 // 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)