Mercurial > mxd2map
comparison src/java/de/intevation/mxd/reader/PictureLineSymbolReader.java @ 115:fb93f20478cc
Improved exception handling for symbol reader.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 15 Jun 2011 16:48:42 +0200 |
parents | 18e4f143896b |
children | a4ab239509f1 |
comparison
equal
deleted
inserted
replaced
114:93699e8f2d1f | 115:fb93f20478cc |
---|---|
11 import com.esri.arcgis.support.ms.stdole.Picture; | 11 import com.esri.arcgis.support.ms.stdole.Picture; |
12 import com.esri.arcgis.display.IRgbColor; | 12 import com.esri.arcgis.display.IRgbColor; |
13 import com.esri.arcgis.display.RgbColor; | 13 import com.esri.arcgis.display.RgbColor; |
14 | 14 |
15 import org.w3c.dom.Element; | 15 import org.w3c.dom.Element; |
16 import java.io.IOException; | |
16 | 17 |
17 /** | 18 /** |
18 * Reads picture line symbol information. | 19 * Reads picture line symbol information. |
19 * | 20 * |
20 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | 21 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
58 /** | 59 /** |
59 * Reads the symbol attributes. | 60 * Reads the symbol attributes. |
60 * | 61 * |
61 * @return The XML node. | 62 * @return The XML node. |
62 */ | 63 */ |
63 public Element read() | 64 public Element read() { |
64 throws Exception { | |
65 //TODO Read the picture from mxd and write it as base64 string to the | 65 //TODO Read the picture from mxd and write it as base64 string to the |
66 // XML Element. | 66 // XML Element. |
67 logger.debug("read()"); | 67 logger.debug("read()"); |
68 Element symbolElement = util.addSymbol(parent); | 68 Element symbolElement = util.addSymbol(parent); |
69 | 69 |
70 symbolElement.setAttribute("name", symbol.getNameString()); | 70 try { |
71 symbolElement.setAttribute("name", symbol.getNameString()); | |
72 } | |
73 catch(IOException ioe) { | |
74 logger.warn("Could not read name. Setting name ti \"default\""); | |
75 symbolElement.setAttribute("name", "default"); | |
76 } | |
77 | |
78 try { | |
79 if(symbol.getColor() instanceof IRgbColor) { | |
80 IRgbColor color = (IRgbColor)symbol.getColor(); | |
81 Color c = new Color ( | |
82 color.getRed(), | |
83 color.getGreen(), | |
84 color.getBlue()); | |
85 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); | |
86 } | |
87 else { | |
88 RgbColor col = new RgbColor(); | |
89 col.setRGB(symbol.getColor().getRGB()); | |
90 Color c = new Color ( | |
91 col.getRed(), | |
92 col.getGreen(), | |
93 col.getBlue()); | |
94 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); | |
95 } | |
96 } | |
97 catch(IOException ioe) { | |
98 logger.warn( | |
99 "Could not read color." + | |
100 " Setting color to black with no transparency"); | |
101 Color black = new Color (0, 0, 0); | |
102 symbolElement.setAttribute("color", String.valueOf(black.getRGB())); | |
103 symbolElement.setAttribute("transparency", "-1"); | |
104 } | |
105 | |
106 try { | |
107 symbolElement.setAttribute( | |
108 "offset", | |
109 String.valueOf(symbol.getOffset())); | |
110 } | |
111 catch(IOException ioe) { | |
112 logger.warn("Could not read offset. Setting offset to 0."); | |
113 symbolElement.setAttribute("offset", "0"); | |
114 } | |
115 | |
116 try { | |
117 symbolElement.setAttribute( | |
118 "x_scale", | |
119 String.valueOf(symbol.getXScale())); | |
120 } | |
121 catch(IOException ioe) { | |
122 logger.warn("Could not read x-scale. Setting x-scale to 0"); | |
123 symbolElement.setAttribute("x_scale", "0"); | |
124 } | |
125 | |
126 try { | |
127 symbolElement.setAttribute( | |
128 "y_scale", | |
129 String.valueOf(symbol.getYScale())); | |
130 } | |
131 catch(IOException ioe) { | |
132 logger.warn("Could not read y-scale. Setting y-scale to 0."); | |
133 symbolElement.setAttribute("y_scale", "0"); | |
134 } | |
135 | |
136 try { | |
137 symbolElement.setAttribute( | |
138 "width", | |
139 String.valueOf(symbol.getWidth())); | |
140 } | |
141 catch(IOException ioe) { | |
142 logger.warn("Could not read width. Setting width to 1."); | |
143 symbolElement.setAttribute("width", "1"); | |
144 } | |
145 | |
71 symbolElement.setAttribute("type", "line"); | 146 symbolElement.setAttribute("type", "line"); |
72 symbolElement.setAttribute("style", "picture"); | 147 symbolElement.setAttribute("style", "picture"); |
73 if(symbol.getColor() instanceof IRgbColor) { | |
74 IRgbColor color = (IRgbColor)symbol.getColor(); | |
75 Color c = new Color ( | |
76 color.getRed(), | |
77 color.getGreen(), | |
78 color.getBlue()); | |
79 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); | |
80 } | |
81 else { | |
82 RgbColor col = new RgbColor(); | |
83 col.setRGB(symbol.getColor().getRGB()); | |
84 Color c = new Color ( | |
85 col.getRed(), | |
86 col.getGreen(), | |
87 col.getBlue()); | |
88 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); | |
89 } | |
90 symbolElement.setAttribute( | |
91 "offset", | |
92 String.valueOf(symbol.getOffset())); | |
93 symbolElement.setAttribute( | |
94 "x_scale", | |
95 String.valueOf(symbol.getXScale())); | |
96 symbolElement.setAttribute( | |
97 "y_scale", | |
98 String.valueOf(symbol.getYScale())); | |
99 | 148 |
100 symbolElement.setAttribute("width", String.valueOf(symbol.getWidth())); | |
101 return symbolElement; | 149 return symbolElement; |
102 } | 150 } |
103 } | 151 } |
104 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 152 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |