Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/SimpleLineSymbolReader.java @ 103:163d474165b0
Added check for ArcGISDesktop environment.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 10 Jun 2011 14:04:03 +0200 |
parents | 18e4f143896b |
children | fb93f20478cc |
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.awt.Color; |
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 org.apache.log4j.Logger; |
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 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
|
8 import com.esri.arcgis.display.ILineSymbol; |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 import com.esri.arcgis.display.SimpleLineSymbol; |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 import com.esri.arcgis.display.esriSimpleLineStyle; |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 import com.esri.arcgis.display.IRgbColor; |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 import com.esri.arcgis.display.RgbColor; |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 import org.w3c.dom.Element; |
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 /** |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 * Reads simple line symbol information. |
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 * @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
|
20 */ |
80
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
21 public class SimpleLineSymbolReader |
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
22 extends AbstractSymbolReader { |
61
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 /** |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 * The logger. |
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 private static final Logger logger = |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 Logger.getLogger(SimpleLineSymbolReader.class); |
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 /** |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 * Private member. |
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 SimpleLineSymbol symbol; |
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 public SimpleLineSymbolReader(ISymbol symbol) |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 throws Exception { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 logger.debug("contructor()"); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 if(symbol instanceof SimpleLineSymbol) { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 this.symbol = (SimpleLineSymbol)symbol; |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 else { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 throw new Exception("Not a SimpleLineSymbol!"); |
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 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 |
67
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
46 public SimpleLineSymbolReader(ILineSymbol symbol) |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
47 throws Exception { |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
48 logger.debug("contructor()"); |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
49 if(symbol instanceof SimpleLineSymbol) { |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
50 this.symbol = (SimpleLineSymbol)symbol; |
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 else { |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
53 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
|
54 } |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
55 } |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
56 |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 /** |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 * Reads the symbol attributes. |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 * |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
60 * @return The XML node. |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
61 */ |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 public Element read() |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
67
diff
changeset
|
63 throws Exception { |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 logger.debug("read()"); |
80
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
65 Element symbolElement = util.addSymbol(parent); |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
67 symbolElement.setAttribute("name", symbol.getNameString()); |
97
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
68 symbolElement.setAttribute("type", "line"); |
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
69 symbolElement.setAttribute("style", "simple"); |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
70 if(symbol.getColor() instanceof IRgbColor) { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
71 IRgbColor color = (IRgbColor)symbol.getColor(); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
72 Color c = new Color ( |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
73 color.getRed(), |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
74 color.getGreen(), |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
75 color.getBlue()); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
76 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
77 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
78 else { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
79 RgbColor col = new RgbColor(); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 col.setRGB(symbol.getColor().getRGB()); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
81 Color c = new Color ( |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
82 col.getRed(), |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
83 col.getGreen(), |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
84 col.getBlue()); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
85 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
86 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
87 |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
88 symbolElement.setAttribute("width", String.valueOf(symbol.getWidth())); |
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 int style = symbol.getStyle(); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
91 switch(style) { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
92 case esriSimpleLineStyle.esriSLSSolid: |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
61
diff
changeset
|
93 symbolElement.setAttribute("linestyle", "solid"); break; |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
94 case esriSimpleLineStyle.esriSLSDash: |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
61
diff
changeset
|
95 symbolElement.setAttribute("linestyle", "dash"); break; |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
96 case esriSimpleLineStyle.esriSLSDot: |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
61
diff
changeset
|
97 symbolElement.setAttribute("linestyle", "dot"); break; |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
98 case esriSimpleLineStyle.esriSLSDashDot: |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
61
diff
changeset
|
99 symbolElement.setAttribute("linestyle", "dashdot"); break; |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
100 case esriSimpleLineStyle.esriSLSDashDotDot: |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
61
diff
changeset
|
101 symbolElement.setAttribute("linestyle", "dashdotdot"); break; |
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
61
diff
changeset
|
102 default: symbolElement.setAttribute ("linestyle", "none"); |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
103 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
104 return symbolElement; |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
105 } |
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |