comparison src/java/de/intevation/mxd/reader/PictureMarkerSymbolReader.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
6 import com.esri.arcgis.display.IMarkerSymbol; 6 import com.esri.arcgis.display.IMarkerSymbol;
7 import com.esri.arcgis.display.PictureMarkerSymbol; 7 import com.esri.arcgis.display.PictureMarkerSymbol;
8 import com.esri.arcgis.carto.PictureElement; 8 import com.esri.arcgis.carto.PictureElement;
9 9
10 import org.w3c.dom.Element; 10 import org.w3c.dom.Element;
11 import java.io.IOException;
11 12
12 /** 13 /**
13 * Reads picture marker symbol information. 14 * Reads picture marker symbol information.
14 * 15 *
15 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> 16 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
53 /** 54 /**
54 * Reads the symbol attributes. 55 * Reads the symbol attributes.
55 * 56 *
56 * @return The XML node. 57 * @return The XML node.
57 */ 58 */
58 public Element read() 59 public Element read() {
59 throws Exception {
60 //TODO Read the picture from mxd and write it as base64 string to the 60 //TODO Read the picture from mxd and write it as base64 string to the
61 // XML Element. 61 // XML Element.
62 logger.debug("read()"); 62 logger.debug("read()");
63 Element symbolElement = util.addSymbol(parent); 63 Element symbolElement = util.addSymbol(parent);
64 64
65 symbolElement.setAttribute( 65 try {
66 "angle", 66 symbolElement.setAttribute(
67 String.valueOf(symbol.getAngle())); 67 "angle",
68 symbolElement.setAttribute( 68 String.valueOf(symbol.getAngle()));
69 "size", 69 }
70 String.valueOf(symbol.getSize())); 70 catch(IOException ioe) {
71 symbolElement.setAttribute( 71 logger.warn("Could not read angle. Setting angle to 0.");
72 "x_offset", 72 symbolElement.setAttribute("angle", "0");
73 String.valueOf(symbol.getXOffset())); 73 }
74 symbolElement.setAttribute( 74
75 "y_offset", 75 try {
76 String.valueOf(symbol.getYOffset())); 76 symbolElement.setAttribute(
77 symbolElement.setAttribute( 77 "size",
78 "name", 78 String.valueOf(symbol.getSize()));
79 symbol.getNameString()); 79 }
80 PictureElement pElem = new PictureElement(); 80 catch (IOException ioe) {
81 pElem.importPicture(symbol.getPicture()); 81 logger.warn("Could not read size. Setting size to 1.");
82 symbolElement.setAttribute("size", "0");
83 }
84
85 try {
86 symbolElement.setAttribute(
87 "x_offset",
88 String.valueOf(symbol.getXOffset()));
89 }
90 catch(IOException ioe) {
91 logger.warn("Could not read x-offset. Setting x-offset to 0");
92 symbolElement.setAttribute("x_offset", "0");
93 }
94
95 try {
96 symbolElement.setAttribute(
97 "y_offset",
98 String.valueOf(symbol.getYOffset()));
99 }
100 catch(IOException ioe) {
101 logger.warn("Could not read y-offset. Setting y-offset to 0.");
102 symbolElement.setAttribute("y_offset", "0");
103 }
104
105 try {
106 symbolElement.setAttribute(
107 "name",
108 symbol.getNameString());
109 }
110 catch(IOException ioe) {
111 logger.warn("Could not read name. Setting name to \"default\"");
112 symbolElement.setAttribute("name", "default");
113 }
114
115 try {
116 PictureElement pElem = new PictureElement();
117 pElem.importPicture(symbol.getPicture());
118 }
119 catch(IOException ioe) {
120 logger.warn("Could not read picture. No fallback defined.");
121 }
82 symbolElement.setAttribute("style", "picture"); 122 symbolElement.setAttribute("style", "picture");
83 symbolElement.setAttribute("type", "marker"); 123 symbolElement.setAttribute("type", "marker");
84 return symbolElement; 124 return symbolElement;
85 } 125 }
86 } 126 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)