Mercurial > mxd2map
comparison src/java/de/intevation/mxd/writer/LineStyleWriter.java @ 145:b2c5a66022f1
Exception handling for number conversions in writer modules.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 27 Jun 2011 18:22:21 +0200 |
parents | 8f30f7e802d6 |
children | 03daf386f19a |
comparison
equal
deleted
inserted
replaced
144:ad3f540fd1c3 | 145:b2c5a66022f1 |
---|---|
41 */ | 41 */ |
42 public boolean write(Element symbolElement) { | 42 public boolean write(Element symbolElement) { |
43 logger.debug("write(Element)"); | 43 logger.debug("write(Element)"); |
44 symbolSetObj symbolSet = map.getSymbolset(); | 44 symbolSetObj symbolSet = map.getSymbolset(); |
45 if(symbolElement.hasAttribute("width")) { | 45 if(symbolElement.hasAttribute("width")) { |
46 double w = Double.parseDouble(symbolElement.getAttribute("width")); | 46 double w = 0; |
47 try { | |
48 w = Double.parseDouble(symbolElement.getAttribute("width")); | |
49 } | |
50 catch(NumberFormatException nfe) { | |
51 logger.warn("Error setting width. No line width set."); | |
52 w = 0; | |
53 } | |
47 if(w < 1.0) { | 54 if(w < 1.0) { |
48 return false; | 55 return false; |
49 } | 56 } |
50 style.setWidth((int)Double.parseDouble( | 57 style.setWidth((int)w); |
51 symbolElement.getAttribute("width"))); | |
52 } | 58 } |
53 if(symbolElement.hasAttribute("angle")) { | 59 if(symbolElement.hasAttribute("angle")) { |
54 style.setAngle( | 60 try { |
55 Double.parseDouble(symbolElement.getAttribute("angle"))); | 61 style.setAngle( |
62 Double.parseDouble(symbolElement.getAttribute("angle"))); | |
63 } | |
64 catch(NumberFormatException nfe) { | |
65 logger.info("Error setting angle. Could not get value."); | |
66 } | |
56 } | 67 } |
57 if(symbolElement.hasAttribute("color")) { | 68 if(symbolElement.hasAttribute("color")) { |
58 String c = symbolElement.getAttribute("color"); | 69 String c = symbolElement.getAttribute("color"); |
59 Color col = Color.decode(c); | 70 Color col = Color.decode(c); |
60 colorObj color = new colorObj( | 71 colorObj color = new colorObj( |
64 -4); | 75 -4); |
65 style.setColor(color); | 76 style.setColor(color); |
66 } | 77 } |
67 | 78 |
68 if(symbolElement.hasAttribute("size")) { | 79 if(symbolElement.hasAttribute("size")) { |
69 style.setSize((int)Double.parseDouble( | 80 try { |
70 symbolElement.getAttribute("size"))); | 81 style.setSize((int)Double.parseDouble( |
82 symbolElement.getAttribute("size"))); | |
83 } | |
84 catch(NumberFormatException nfe) { | |
85 logger.warn("Error setting size. Setting size to 1."); | |
86 style.setSize (1); | |
87 } | |
71 } | 88 } |
72 String type = symbolElement.getAttribute("type"); | 89 String type = symbolElement.getAttribute("type"); |
73 if(type.equals("marker")) { | 90 if(type.equals("marker")) { |
74 SymbolWriter sw = new SymbolWriter(this.map, this.cl); | 91 SymbolWriter sw = new SymbolWriter(this.map, this.cl); |
75 sw.write(symbolElement); | 92 sw.write(symbolElement); |