Mercurial > mxd2map
comparison src/java/de/intevation/mxd/reader/SimpleMarkerSymbolReader.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 | 475ee3e4bc8b |
children | a4ab239509f1 |
comparison
equal
deleted
inserted
replaced
114:93699e8f2d1f | 115:fb93f20478cc |
---|---|
10 import com.esri.arcgis.display.esriSimpleMarkerStyle; | 10 import com.esri.arcgis.display.esriSimpleMarkerStyle; |
11 import com.esri.arcgis.display.IRgbColor; | 11 import com.esri.arcgis.display.IRgbColor; |
12 import com.esri.arcgis.display.RgbColor; | 12 import com.esri.arcgis.display.RgbColor; |
13 | 13 |
14 import org.w3c.dom.Element; | 14 import org.w3c.dom.Element; |
15 import java.io.IOException; | |
15 | 16 |
16 /** | 17 /** |
17 * Reads simple marker symbol information. | 18 * Reads simple marker symbol information. |
18 * | 19 * |
19 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | 20 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
57 /** | 58 /** |
58 * Reads the symbol attributes. | 59 * Reads the symbol attributes. |
59 * | 60 * |
60 * @return The XML node. | 61 * @return The XML node. |
61 */ | 62 */ |
62 public Element read() | 63 public Element read() { |
63 throws Exception { | |
64 logger.debug("read()"); | 64 logger.debug("read()"); |
65 Element symbolElement = util.addSymbol(parent); | 65 Element symbolElement = util.addSymbol(parent); |
66 | 66 |
67 symbolElement.setAttribute("name", symbol.getNameString()); | 67 try { |
68 if(symbol.getStyle() == esriSimpleMarkerStyle.esriSMSCircle) | 68 symbolElement.setAttribute("name", symbol.getNameString()); |
69 } | |
70 catch(IOException ioe) { | |
71 logger.warn("Could not read name. Setting name to \"default\"."); | |
72 symbolElement.setAttribute("name", "default"); | |
73 } | |
74 | |
75 try { | |
76 if(symbol.getStyle() == esriSimpleMarkerStyle.esriSMSCircle) | |
77 symbolElement.setAttribute("style", "point"); | |
78 } | |
79 catch(IOException ioe) { | |
80 logger.warn( | |
81 "Could not read marker style." + | |
82 " Setting marker style to point."); | |
69 symbolElement.setAttribute("style", "point"); | 83 symbolElement.setAttribute("style", "point"); |
70 | 84 } |
71 if(symbol.getColor() instanceof IRgbColor) { | 85 |
72 IRgbColor color = (IRgbColor)symbol.getColor(); | 86 try { |
73 Color c = new Color ( | 87 if(symbol.getColor() instanceof IRgbColor) { |
74 color.getRed(), | 88 IRgbColor color = (IRgbColor)symbol.getColor(); |
75 color.getGreen(), | 89 Color c = new Color ( |
76 color.getBlue()); | 90 color.getRed(), |
77 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); | 91 color.getGreen(), |
78 symbolElement.setAttribute("transparency", | 92 color.getBlue()); |
79 String.valueOf(color.getTransparency())); | 93 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); |
80 } | 94 symbolElement.setAttribute("transparency", |
81 else { | 95 String.valueOf(color.getTransparency())); |
82 RgbColor col = new RgbColor(); | 96 } |
83 col.setRGB(symbol.getColor().getRGB()); | 97 else { |
84 Color c = new Color ( | 98 RgbColor col = new RgbColor(); |
85 col.getRed(), | 99 col.setRGB(symbol.getColor().getRGB()); |
86 col.getGreen(), | 100 Color c = new Color ( |
87 col.getBlue()); | 101 col.getRed(), |
88 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); | 102 col.getGreen(), |
89 symbolElement.setAttribute("transparency", | 103 col.getBlue()); |
90 String.valueOf(col.getTransparency())); | 104 symbolElement.setAttribute("color", String.valueOf(c.getRGB())); |
91 } | 105 symbolElement.setAttribute("transparency", |
92 | 106 String.valueOf(col.getTransparency())); |
93 symbolElement.setAttribute("size", String.valueOf(symbol.getSize())); | 107 } |
94 symbolElement.setAttribute("outline_size", | 108 } |
95 String.valueOf(symbol.getOutlineSize())); | 109 catch(IOException ioe) { |
96 if(symbol.getOutlineColor() instanceof IRgbColor) { | 110 logger.warn( |
97 IRgbColor color = (IRgbColor)symbol.getOutlineColor(); | 111 "Could not read color." + |
98 Color c = new Color ( | 112 " Setting color to black with no transparency."); |
99 color.getRed(), | 113 Color black = new Color(0, 0, 0); |
100 color.getGreen(), | 114 symbolElement.setAttribute("color", String.valueOf(black.getRGB())); |
101 color.getBlue()); | 115 symbolElement.setAttribute("transparency", "-1"); |
102 symbolElement.setAttribute( | 116 } |
117 | |
118 try { | |
119 symbolElement.setAttribute( | |
120 "size", | |
121 String.valueOf(symbol.getSize())); | |
122 } | |
123 catch(IOException ioe) { | |
124 logger.warn("Could not read size. Setting size to 1."); | |
125 symbolElement.setAttribute("size", "1"); | |
126 } | |
127 | |
128 try { | |
129 symbolElement.setAttribute( | |
130 "outline_size", | |
131 String.valueOf(symbol.getOutlineSize())); | |
132 } | |
133 catch(IOException ioe) { | |
134 logger.warn( | |
135 "Could not read outline size." + | |
136 " Setting outline size to 1."); | |
137 symbolElement.setAttribute("outline_size", "1"); | |
138 } | |
139 | |
140 try { | |
141 if(symbol.getOutlineColor() instanceof IRgbColor) { | |
142 IRgbColor color = (IRgbColor)symbol.getOutlineColor(); | |
143 Color c = new Color ( | |
144 color.getRed(), | |
145 color.getGreen(), | |
146 color.getBlue()); | |
147 symbolElement.setAttribute( | |
148 "outline_color", | |
149 String.valueOf(c.getRGB())); | |
150 symbolElement.setAttribute("outline_transparency", | |
151 String.valueOf(color.getTransparency())); | |
152 } | |
153 else { | |
154 RgbColor col = new RgbColor(); | |
155 col.setRGB(symbol.getOutlineColor().getRGB()); | |
156 Color c = new Color ( | |
157 col.getRed(), | |
158 col.getGreen(), | |
159 col.getBlue()); | |
160 symbolElement.setAttribute( | |
103 "outline_color", | 161 "outline_color", |
104 String.valueOf(c.getRGB())); | 162 String.valueOf(c.getRGB())); |
105 symbolElement.setAttribute("outline_transparency", | 163 symbolElement.setAttribute("outline_transparency", |
106 String.valueOf(color.getTransparency())); | 164 String.valueOf(col.getTransparency())); |
107 } | 165 } |
108 else { | 166 } |
109 RgbColor col = new RgbColor(); | 167 catch(IOException ioe) { |
110 col.setRGB(symbol.getOutlineColor().getRGB()); | 168 logger.warn( |
111 Color c = new Color ( | 169 "Could not read outline color." + |
112 col.getRed(), | 170 " Setting outline color to black with no transparency."); |
113 col.getGreen(), | 171 Color black = new Color(0, 0, 0); |
114 col.getBlue()); | |
115 symbolElement.setAttribute( | 172 symbolElement.setAttribute( |
116 "outline_color", | 173 "outline_color", |
117 String.valueOf(c.getRGB())); | 174 String.valueOf(black.getRGB())); |
118 symbolElement.setAttribute("outline_transparency", | 175 symbolElement.setAttribute("outline_transparency", "-1"); |
119 String.valueOf(col.getTransparency())); | 176 } |
120 } | 177 |
121 | 178 try { |
122 symbolElement.setAttribute("angle", String.valueOf(symbol.getAngle())); | 179 symbolElement.setAttribute( |
123 symbolElement.setAttribute("offset", | 180 "angle", |
124 symbol.getXOffset() + "," + symbol.getYOffset()); | 181 String.valueOf(symbol.getAngle())); |
182 } | |
183 catch(IOException ioe) { | |
184 logger.warn("Could not read angle. Setting angle to 0."); | |
185 symbolElement.setAttribute("angle", "0"); | |
186 } | |
187 | |
188 try { | |
189 symbolElement.setAttribute( | |
190 "offset", | |
191 symbol.getXOffset() + "," + symbol.getYOffset()); | |
192 } | |
193 catch(IOException ioe) { | |
194 logger.warn("Could not read offset. Setting offset to 0."); | |
195 symbolElement.setAttribute("offset", "0"); | |
196 } | |
197 | |
125 symbolElement.setAttribute("type", "marker"); | 198 symbolElement.setAttribute("type", "marker"); |
126 return symbolElement; | 199 return symbolElement; |
127 } | 200 } |
128 } | 201 } |
129 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 202 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |