Mercurial > mxd2map
comparison src/java/de/intevation/mxd/writer/FillStyleWriter.java @ 181:0bde090506f9
Added comments.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 11 Jul 2011 14:28:38 +0200 |
parents | f4eb506499f5 |
children | c79c3c6fc99a |
comparison
equal
deleted
inserted
replaced
180:f4eb506499f5 | 181:0bde090506f9 |
---|---|
29 * The Logger. | 29 * The Logger. |
30 */ | 30 */ |
31 private static final Logger logger = | 31 private static final Logger logger = |
32 Logger.getLogger(FillStyleWriter.class); | 32 Logger.getLogger(FillStyleWriter.class); |
33 | 33 |
34 /** | |
35 * Private member. | |
36 */ | |
34 private mapObj map; | 37 private mapObj map; |
35 private classObj cl; | 38 private classObj cl; |
36 private styleObj style; | 39 private styleObj style; |
37 private colorObj fill; | 40 private colorObj fill; |
38 | 41 |
42 /** | |
43 * Constructor with map object and class object. | |
44 * | |
45 * @param map The map object. | |
46 * @param cl The class object containing the style. | |
47 */ | |
39 public FillStyleWriter (mapObj map, classObj cl) { | 48 public FillStyleWriter (mapObj map, classObj cl) { |
40 logger.debug("contructor(mapObj, classObj)"); | 49 logger.debug("contructor(mapObj, classObj)"); |
41 this.map = map; | 50 this.map = map; |
42 this.cl = cl; | 51 this.cl = cl; |
43 this.style = new styleObj(cl); | 52 this.style = new styleObj(cl); |
44 } | 53 } |
45 | 54 |
46 /** | 55 /** |
47 * Write the content. | 56 * Write the content. |
57 * | |
58 * @param symbolElement DOM element containing style attributes. | |
48 */ | 59 */ |
49 public boolean write(Element symbolElement) { | 60 public boolean write(Element symbolElement) { |
50 logger.debug("write()Element"); | 61 logger.debug("write()Element"); |
51 symbolSetObj symbolSet = map.getSymbolset(); | 62 symbolSetObj symbolSet = map.getSymbolset(); |
52 | 63 |
131 catch(NumberFormatException nfe) { | 142 catch(NumberFormatException nfe) { |
132 logger.warn("Error setting outline width."); | 143 logger.warn("Error setting outline width."); |
133 style.setOutlinewidth(0.0); | 144 style.setOutlinewidth(0.0); |
134 } | 145 } |
135 } | 146 } |
136 | |
137 } | 147 } |
138 | 148 |
139 return true; | 149 return true; |
140 } | 150 } |
141 | 151 |
142 /** | 152 /** |
143 * Write the outline for a polygon. | 153 * Write the outline for a polygon. |
154 * | |
155 * @param symbolElement Dom element containing the symbol attributes. | |
144 */ | 156 */ |
145 private void writeOutline(Element symbolElement) { | 157 private void writeOutline(Element symbolElement) { |
146 logger.debug("writeOutline()"); | 158 logger.debug("writeOutline()"); |
147 //write transparent outline | 159 //write transparent outline |
148 colorObj color = new colorObj(-1, -1, -1, -4); | 160 colorObj color = new colorObj(-1, -1, -1, -4); |
189 catch(NumberFormatException nfe) { | 201 catch(NumberFormatException nfe) { |
190 logger.warn("Error setting outline width."); | 202 logger.warn("Error setting outline width."); |
191 outline.setOutlinewidth(0.0); | 203 outline.setOutlinewidth(0.0); |
192 } | 204 } |
193 if(symbolElement.hasAttribute("linestyle")) { | 205 if(symbolElement.hasAttribute("linestyle")) { |
206 //Write predefined dashed or dotted lines. | |
194 String ls = symbolElement.getAttribute("linestyle"); | 207 String ls = symbolElement.getAttribute("linestyle"); |
195 double[] vals; | 208 double[] vals; |
196 if(ls.equals("dash")) { | 209 if(ls.equals("dash")) { |
197 outline.setPatternlength(2); | 210 outline.setPatternlength(2); |
198 vals = new double[] {4.0, 4.0, 0, 0, 0, 0, 0, 0, 0, 0}; | 211 vals = new double[] {4.0, 4.0, 0, 0, 0, 0, 0, 0, 0, 0}; |
213 vals = new double[] {5.0, 3.0, 1.0, 3.0, 1.0, 4.0, 0, 0, 0, 0}; | 226 vals = new double[] {5.0, 3.0, 1.0, 3.0, 1.0, 4.0, 0, 0, 0, 0}; |
214 outline.setPattern(vals); | 227 outline.setPattern(vals); |
215 } | 228 } |
216 } | 229 } |
217 else if(symbolElement.hasAttribute("pattern_count")) { | 230 else if(symbolElement.hasAttribute("pattern_count")) { |
231 //Write dashed or dotted lines defined with a template. | |
218 int count = 0; | 232 int count = 0; |
219 try { | 233 try { |
220 count = Integer.parseInt( | 234 count = Integer.parseInt( |
221 symbolElement.getAttribute("pattern_count")); | 235 symbolElement.getAttribute("pattern_count")); |
222 double[] vals = new double[10]; | 236 double[] vals = new double[10]; |
254 } | 268 } |
255 } | 269 } |
256 | 270 |
257 /** | 271 /** |
258 * Write marker attributes and a symbol for the polygon fill. | 272 * Write marker attributes and a symbol for the polygon fill. |
273 * | |
274 * @param symbolElement DOM element containingg the symbol attributes. | |
275 * @param gap The initial gap at the begining of a line. | |
259 */ | 276 */ |
260 private void writeMarker(Element symbolElement, double gap) { | 277 private void writeMarker(Element symbolElement, double gap) { |
261 logger.debug("writeMarker()"); | 278 logger.debug("writeMarker()"); |
262 String name = symbolElement.getAttribute("name"); | 279 String name = symbolElement.getAttribute("name"); |
263 String type = symbolElement.getAttribute("type"); | 280 String type = symbolElement.getAttribute("type"); |
361 } | 378 } |
362 } | 379 } |
363 | 380 |
364 /** | 381 /** |
365 * Write simple fill attributes. | 382 * Write simple fill attributes. |
383 * | |
384 * @param symbolElement DOM element containing the symbol attributes. | |
366 */ | 385 */ |
367 private void writeSimple(Element symbolElement) { | 386 private void writeSimple(Element symbolElement) { |
368 logger.debug("writeSimple(Element)"); | 387 logger.debug("writeSimple(Element)"); |
369 if(symbolElement.hasAttribute("transparency")) { | 388 if(symbolElement.hasAttribute("transparency")) { |
370 double value = 0; | 389 double value = 0; |