Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/PictureLineSymbolReader.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 |
---|---|
64
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.mxd.reader; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
2 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
3 import java.io.IOException; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
4 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
5 import java.awt.Color; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
6 import java.awt.Image; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 import org.apache.log4j.Logger; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 import com.esri.arcgis.display.ISymbol; |
67
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
11 import com.esri.arcgis.display.ILineSymbol; |
64
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 import com.esri.arcgis.display.PictureLineSymbol; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 import com.esri.arcgis.support.ms.stdole.Picture; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 import com.esri.arcgis.display.esriSimpleLineStyle; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 import com.esri.arcgis.display.IRgbColor; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
16 import com.esri.arcgis.display.RgbColor; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 import org.w3c.dom.Element; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.mxd.utils.MapToXMLUtils; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 /** |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 * Reads picture line symbol information. |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 * |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 */ |
80
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
26 public class PictureLineSymbolReader |
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
27 extends AbstractSymbolReader { |
64
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 /** |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 * The logger. |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 */ |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 private static final Logger logger = |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 Logger.getLogger(SimpleLineSymbolReader.class); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 /** |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 * Private member. |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 */ |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 private PictureLineSymbol symbol; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 public PictureLineSymbolReader(ISymbol symbol) |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 throws Exception { |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 logger.debug("contructor()"); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 if(symbol instanceof PictureLineSymbol) { |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 this.symbol = (PictureLineSymbol)symbol; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 } |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 else { |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 throw new Exception("Not a PictureLineSymbol!"); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 } |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 } |
c73647bd71c0
Added picture 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:
64
diff
changeset
|
51 public PictureLineSymbolReader(ILineSymbol symbol) |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
52 throws Exception { |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
53 logger.debug("contructor()"); |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
54 if(symbol instanceof PictureLineSymbol) { |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
55 this.symbol = (PictureLineSymbol)symbol; |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
56 } |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
57 else { |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
58 throw new Exception("Not a PictureLineSymbol!"); |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
59 } |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
60 } |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
61 |
64
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 /** |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 * Reads the symbol attributes. |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 * |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 * @return The XML node. |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 */ |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
67 public Element read() |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
67
diff
changeset
|
68 throws Exception { |
64
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
69 logger.debug("read()"); |
80
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
70 Element symbolElement = util.addSymbol(parent); |
64
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
71 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
72 symbolElement.setAttribute("name", symbol.getNameString()); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
73 symbolElement.setAttribute("style", "picture"); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
74 if(symbol.getColor() instanceof IRgbColor) { |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
75 IRgbColor color = (IRgbColor)symbol.getColor(); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
76 Color c = new Color ( |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
77 color.getRed(), |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
78 color.getGreen(), |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
79 color.getBlue()); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
81 } |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
82 else { |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
83 RgbColor col = new RgbColor(); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
84 col.setRGB(symbol.getColor().getRGB()); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
85 Color c = new Color ( |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
86 col.getRed(), |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
87 col.getGreen(), |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
88 col.getBlue()); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
89 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
90 } |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
91 symbolElement.setAttribute( |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
92 "offset", |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
93 String.valueOf(symbol.getOffset())); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
94 symbolElement.setAttribute( |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
95 "x_scale", |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
96 String.valueOf(symbol.getXScale())); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
97 symbolElement.setAttribute( |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
98 "y_scale", |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
99 String.valueOf(symbol.getYScale())); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
100 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
101 symbolElement.setAttribute("width", String.valueOf(symbol.getWidth())); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
102 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
103 Picture pic = symbol.getPicture(); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
104 Image im = pic.toImage(); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
105 //TODO Save the image. |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
106 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
107 return symbolElement; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
108 } |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
109 } |
c73647bd71c0
Added picture 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 : |