Mercurial > mxd2map
comparison src/java/de/intevation/mxd/reader/PictureLineSymbolReader.java @ 64:c73647bd71c0
Added picture line symbol reader.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 24 May 2011 17:32:43 +0200 |
parents | |
children | 5ed9e720b6cd |
comparison
equal
deleted
inserted
replaced
63:5c5ef5768893 | 64:c73647bd71c0 |
---|---|
1 package de.intevation.mxd.reader; | |
2 | |
3 import java.io.IOException; | |
4 | |
5 import java.awt.Color; | |
6 import java.awt.Image; | |
7 | |
8 import org.apache.log4j.Logger; | |
9 | |
10 import com.esri.arcgis.display.ISymbol; | |
11 import com.esri.arcgis.display.PictureLineSymbol; | |
12 import com.esri.arcgis.support.ms.stdole.Picture; | |
13 import com.esri.arcgis.display.esriSimpleLineStyle; | |
14 import com.esri.arcgis.display.IRgbColor; | |
15 import com.esri.arcgis.display.RgbColor; | |
16 | |
17 import org.w3c.dom.Element; | |
18 import de.intevation.mxd.utils.MapToXMLUtils; | |
19 | |
20 /** | |
21 * Reads picture line symbol information. | |
22 * | |
23 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | |
24 */ | |
25 public class PictureLineSymbolReader implements ISymbolReader{ | |
26 | |
27 /** | |
28 * The logger. | |
29 */ | |
30 private static final Logger logger = | |
31 Logger.getLogger(SimpleLineSymbolReader.class); | |
32 | |
33 /** | |
34 * Private member. | |
35 */ | |
36 private Element renderer; | |
37 private PictureLineSymbol symbol; | |
38 private MapToXMLUtils util; | |
39 | |
40 | |
41 public PictureLineSymbolReader(ISymbol symbol) | |
42 throws Exception { | |
43 logger.debug("contructor()"); | |
44 if(symbol instanceof PictureLineSymbol) { | |
45 this.symbol = (PictureLineSymbol)symbol; | |
46 } | |
47 else { | |
48 throw new Exception("Not a PictureLineSymbol!"); | |
49 } | |
50 } | |
51 | |
52 /** | |
53 * Setter for the parent XML element. | |
54 * | |
55 * @param parent The XML parent node. | |
56 */ | |
57 public void setParent(Element parent) { | |
58 this.renderer = parent; | |
59 } | |
60 | |
61 /** | |
62 * Setter for XML document helper. | |
63 * | |
64 * @param util The helper class for storing map information. | |
65 */ | |
66 public void setUtil(MapToXMLUtils util) { | |
67 this.util = util; | |
68 } | |
69 | |
70 /** | |
71 * Reads the symbol attributes. | |
72 * | |
73 * @return The XML node. | |
74 */ | |
75 public Element read() | |
76 throws IOException { | |
77 logger.debug("read()"); | |
78 Element symbolElement; | |
79 try { | |
80 symbolElement = util.addSymbol(renderer); | |
81 } | |
82 catch(Exception e) { | |
83 e.printStackTrace(); | |
84 return null; | |
85 } | |
86 | |
87 symbolElement.setAttribute("name", symbol.getNameString()); | |
88 symbolElement.setAttribute("style", "picture"); | |
89 if(symbol.getColor() instanceof IRgbColor) { | |
90 IRgbColor color = (IRgbColor)symbol.getColor(); | |
91 Color c = new Color ( | |
92 color.getRed(), | |
93 color.getGreen(), | |
94 color.getBlue()); | |
95 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); | |
96 } | |
97 else { | |
98 RgbColor col = new RgbColor(); | |
99 col.setRGB(symbol.getColor().getRGB()); | |
100 Color c = new Color ( | |
101 col.getRed(), | |
102 col.getGreen(), | |
103 col.getBlue()); | |
104 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); | |
105 } | |
106 symbolElement.setAttribute( | |
107 "offset", | |
108 String.valueOf(symbol.getOffset())); | |
109 symbolElement.setAttribute( | |
110 "x_scale", | |
111 String.valueOf(symbol.getXScale())); | |
112 symbolElement.setAttribute( | |
113 "y_scale", | |
114 String.valueOf(symbol.getYScale())); | |
115 | |
116 symbolElement.setAttribute("width", String.valueOf(symbol.getWidth())); | |
117 | |
118 Picture pic = symbol.getPicture(); | |
119 Image im = pic.toImage(); | |
120 //TODO Save the image. | |
121 | |
122 return symbolElement; | |
123 } | |
124 } | |
125 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |