comparison src/java/de/intevation/mxd/writer/MarkerStyleWriter.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 0bde090506f9
comparison
equal deleted inserted replaced
144:ad3f540fd1c3 145:b2c5a66022f1
41 public boolean write(Element symbolElement) { 41 public boolean write(Element symbolElement) {
42 logger.debug("write(Element)"); 42 logger.debug("write(Element)");
43 symbolSetObj symbolSet = map.getSymbolset(); 43 symbolSetObj symbolSet = map.getSymbolset();
44 44
45 if (symbolElement.hasAttribute("angle")) { 45 if (symbolElement.hasAttribute("angle")) {
46 style.setAngle( 46 try {
47 Double.parseDouble(symbolElement.getAttribute("angle"))); 47 style.setAngle(
48 Double.parseDouble(symbolElement.getAttribute("angle")));
49 }
50 catch(NumberFormatException nfe) {
51 logger.warn("Error setting angle.");
52 style.setAngle(0.0);
53 }
48 } 54 }
49 if(symbolElement.hasAttribute("color")) { 55 if(symbolElement.hasAttribute("color")) {
50 String c = symbolElement.getAttribute("color"); 56 String c = symbolElement.getAttribute("color");
51 Color col = Color.decode(c); 57 Color col = Color.decode(c);
52 colorObj color = new colorObj( 58 colorObj color = new colorObj(
55 col.getBlue(), 61 col.getBlue(),
56 -4); 62 -4);
57 style.setColor(color); 63 style.setColor(color);
58 } 64 }
59 if (symbolElement.hasAttribute ("size")) { 65 if (symbolElement.hasAttribute ("size")) {
60 style.setSize(Double.parseDouble( 66 try {
61 symbolElement.getAttribute("size"))); 67 style.setSize(Double.parseDouble(
68 symbolElement.getAttribute("size")));
69 }
70 catch(NumberFormatException nfe) {
71 logger.warn("Error setting size. Setting to deafult: 1.");
72 style.setSize(1);
73 }
62 } 74 }
63 if(symbolElement.hasAttribute("outline_color")) { 75 if(symbolElement.hasAttribute("outline_color")) {
64 Color oCol = Color.decode( 76 Color oCol = Color.decode(
65 symbolElement.getAttribute("outline_color")); 77 symbolElement.getAttribute("outline_color"));
66 colorObj outlineColor = new colorObj( 78 colorObj outlineColor = new colorObj(
67 oCol.getRed(), 79 oCol.getRed(),
68 oCol.getGreen(), 80 oCol.getGreen(),
69 oCol.getBlue(), 81 oCol.getBlue(),
70 -4); 82 -4);
71 style.setOutlinecolor(outlineColor); 83 style.setOutlinecolor(outlineColor);
72 style.setOutlinewidth(Double.parseDouble( 84 try {
73 symbolElement.getAttribute("outline_size"))); 85 style.setOutlinewidth(Double.parseDouble(
86 symbolElement.getAttribute("outline_size")));
87 }
88 catch(NumberFormatException nfe) {
89 logger.warn("Error setting outline width.");
90 }
74 } 91 }
75 String symType = symbolElement.getAttribute("style"); 92 String symType = symbolElement.getAttribute("style");
76 if(symType.equals("point") || 93 if(symType.equals("point") ||
77 symType.equals("arrow") || 94 symType.equals("arrow") ||
78 symType.equals("char")) { 95 symType.equals("char")) {
83 return false; 100 return false;
84 } 101 }
85 String name = symbolElement.getAttribute("name"); 102 String name = symbolElement.getAttribute("name");
86 style.setSymbolByName(map, name); 103 style.setSymbolByName(map, name);
87 104
88
89 return true; 105 return true;
90 } 106 }
91 } 107 }
92 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 108 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)