annotate src/java/de/intevation/mxd/reader/SimpleLineSymbolReader.java @ 78:df17d4c2f9eb

Merged in Raimunds changes
author Stephan Holl <stephan.holl@intevation.de>
date Thu, 26 May 2011 16:13:50 +0200
parents 5ed9e720b6cd
children 7eba97e8201b
rev   line source
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
1 package de.intevation.mxd.reader;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 import java.io.IOException;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
4
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
5 import java.awt.Color;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
6
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
7 import org.apache.log4j.Logger;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 import com.esri.arcgis.display.ISymbol;
67
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
10 import com.esri.arcgis.display.ILineSymbol;
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 import com.esri.arcgis.display.SimpleLineSymbol;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 import com.esri.arcgis.display.esriSimpleLineStyle;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 import com.esri.arcgis.display.IRgbColor;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 import com.esri.arcgis.display.RgbColor;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 import org.w3c.dom.Element;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 import de.intevation.mxd.utils.MapToXMLUtils;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 * Reads simple line symbol information.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 *
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23 */
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 public class SimpleLineSymbolReader implements ISymbolReader{
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27 * The logger.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28 */
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29 private static final Logger logger =
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30 Logger.getLogger(SimpleLineSymbolReader.class);
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33 * Private member.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34 */
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35 private Element renderer;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
36 private SimpleLineSymbol symbol;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37 private MapToXMLUtils util;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 public SimpleLineSymbolReader(ISymbol symbol)
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 throws Exception {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 logger.debug("contructor()");
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 if(symbol instanceof SimpleLineSymbol) {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 this.symbol = (SimpleLineSymbol)symbol;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
45 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
46 else {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
47 throw new Exception("Not a SimpleLineSymbol!");
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
48 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
49 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
50
67
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
51
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
52 public SimpleLineSymbolReader(ILineSymbol symbol)
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
53 throws Exception {
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
54 logger.debug("contructor()");
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
55 if(symbol instanceof SimpleLineSymbol) {
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
56 this.symbol = (SimpleLineSymbol)symbol;
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
57 }
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
58 else {
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
59 throw new Exception("Not a SimpleLineSymbol!");
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
60 }
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
61 }
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
62
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 * Setter for the parent XML element.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
65 *
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
66 * @param parent The XML parent node.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67 */
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68 public void setParent(Element parent) {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 this.renderer = parent;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
70 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
71
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73 * Setter for XML document helper.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74 *
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
75 * @param util The helper class for storing map information.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
76 */
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
77 public void setUtil(MapToXMLUtils util) {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
78 this.util = util;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
79 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
80
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
81 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
82 * Reads the symbol attributes.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
83 *
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84 * @return The XML node.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85 */
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86 public Element read()
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
87 throws IOException {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
88 logger.debug("read()");
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
89 Element symbolElement;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
90 try {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
91 symbolElement = util.addSymbol(renderer);
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
92 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
93 catch(Exception e) {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
94 e.printStackTrace();
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
95 return null;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
96 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
97
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
98 symbolElement.setAttribute("name", symbol.getNameString());
62
e468cf8701ea Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 61
diff changeset
99 symbolElement.setAttribute("style", "line");
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
100 symbolElement.setAttribute("type", "simple");
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
101 if(symbol.getColor() instanceof IRgbColor) {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
102 IRgbColor color = (IRgbColor)symbol.getColor();
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
103 Color c = new Color (
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
104 color.getRed(),
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105 color.getGreen(),
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
106 color.getBlue());
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107 symbolElement.setAttribute("color", String.valueOf(c.getRGB()));
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
108 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
109 else {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
110 RgbColor col = new RgbColor();
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
111 col.setRGB(symbol.getColor().getRGB());
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
112 Color c = new Color (
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
113 col.getRed(),
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
114 col.getGreen(),
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
115 col.getBlue());
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
116 symbolElement.setAttribute("color", String.valueOf(c.getRGB()));
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
117 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
118
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
119 symbolElement.setAttribute("width", String.valueOf(symbol.getWidth()));
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
120
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
121 int style = symbol.getStyle();
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
122 switch(style) {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
123 case esriSimpleLineStyle.esriSLSSolid:
62
e468cf8701ea Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 61
diff changeset
124 symbolElement.setAttribute("linestyle", "solid"); break;
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
125 case esriSimpleLineStyle.esriSLSDash:
62
e468cf8701ea Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 61
diff changeset
126 symbolElement.setAttribute("linestyle", "dash"); break;
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
127 case esriSimpleLineStyle.esriSLSDot:
62
e468cf8701ea Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 61
diff changeset
128 symbolElement.setAttribute("linestyle", "dot"); break;
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
129 case esriSimpleLineStyle.esriSLSDashDot:
62
e468cf8701ea Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 61
diff changeset
130 symbolElement.setAttribute("linestyle", "dashdot"); break;
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
131 case esriSimpleLineStyle.esriSLSDashDotDot:
62
e468cf8701ea Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 61
diff changeset
132 symbolElement.setAttribute("linestyle", "dashdotdot"); break;
e468cf8701ea Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 61
diff changeset
133 default: symbolElement.setAttribute ("linestyle", "none");
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
134 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
135 return symbolElement;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
136 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
137 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
138 // 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)