Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/SimpleLineSymbolReader.java @ 80:83932f18dddc
All symbol reader now extend the abstract symbol reader.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 27 May 2011 13:15:15 +0200 |
parents | 7eba97e8201b |
children | 59e06c405a9a |
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 */ |
80
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
24 public class SimpleLineSymbolReader |
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
25 extends AbstractSymbolReader { |
61
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 /** |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 * The logger. |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 */ |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 private static final Logger logger = |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 Logger.getLogger(SimpleLineSymbolReader.class); |
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 /** |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 * Private member. |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 */ |
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 |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 public SimpleLineSymbolReader(ISymbol symbol) |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 throws Exception { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 logger.debug("contructor()"); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 if(symbol instanceof SimpleLineSymbol) { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 this.symbol = (SimpleLineSymbol)symbol; |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 else { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 throw new Exception("Not a SimpleLineSymbol!"); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 |
67
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
49 public SimpleLineSymbolReader(ILineSymbol symbol) |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
50 throws Exception { |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
51 logger.debug("contructor()"); |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
52 if(symbol instanceof SimpleLineSymbol) { |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
53 this.symbol = (SimpleLineSymbol)symbol; |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
54 } |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
55 else { |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
56 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
|
57 } |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
58 } |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
59 |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
60 /** |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
61 * Reads the symbol attributes. |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 * |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 * @return The XML node. |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 */ |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 public Element read() |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
67
diff
changeset
|
66 throws Exception { |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
67 logger.debug("read()"); |
80
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
68 Element symbolElement = util.addSymbol(parent); |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
69 |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
70 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
|
71 symbolElement.setAttribute("style", "line"); |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
72 symbolElement.setAttribute("type", "simple"); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
73 if(symbol.getColor() instanceof IRgbColor) { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
74 IRgbColor color = (IRgbColor)symbol.getColor(); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
75 Color c = new Color ( |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
76 color.getRed(), |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
77 color.getGreen(), |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
78 color.getBlue()); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
79 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); |
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 else { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
82 RgbColor col = new RgbColor(); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
83 col.setRGB(symbol.getColor().getRGB()); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
84 Color c = new Color ( |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
85 col.getRed(), |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
86 col.getGreen(), |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
87 col.getBlue()); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
88 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
89 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
90 |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
91 symbolElement.setAttribute("width", String.valueOf(symbol.getWidth())); |
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 int style = symbol.getStyle(); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
94 switch(style) { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
95 case esriSimpleLineStyle.esriSLSSolid: |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
61
diff
changeset
|
96 symbolElement.setAttribute("linestyle", "solid"); break; |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
97 case esriSimpleLineStyle.esriSLSDash: |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
61
diff
changeset
|
98 symbolElement.setAttribute("linestyle", "dash"); break; |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
99 case esriSimpleLineStyle.esriSLSDot: |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
61
diff
changeset
|
100 symbolElement.setAttribute("linestyle", "dot"); break; |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
101 case esriSimpleLineStyle.esriSLSDashDot: |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
61
diff
changeset
|
102 symbolElement.setAttribute("linestyle", "dashdot"); break; |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
103 case esriSimpleLineStyle.esriSLSDashDotDot: |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
61
diff
changeset
|
104 symbolElement.setAttribute("linestyle", "dashdotdot"); break; |
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
61
diff
changeset
|
105 default: symbolElement.setAttribute ("linestyle", "none"); |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
106 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
107 return symbolElement; |
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 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
110 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |