diff 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
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/reader/PictureMarkerSymbolReader.java	Wed Jun 15 16:13:32 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/PictureMarkerSymbolReader.java	Wed Jun 15 16:48:42 2011 +0200
@@ -8,6 +8,7 @@
 import com.esri.arcgis.carto.PictureElement;
 
 import org.w3c.dom.Element;
+import java.io.IOException;
 
 /**
  * Reads picture marker symbol information.
@@ -55,30 +56,69 @@
      *
      * @return The XML node.
      */
-    public Element read()
-    throws Exception {
+    public Element read() {
         //TODO Read the picture from mxd and write it as base64 string to the
         //     XML Element.
         logger.debug("read()");
         Element symbolElement = util.addSymbol(parent);
 
-        symbolElement.setAttribute(
-            "angle",
-            String.valueOf(symbol.getAngle()));
-        symbolElement.setAttribute(
-            "size",
-            String.valueOf(symbol.getSize()));
-        symbolElement.setAttribute(
-            "x_offset",
-            String.valueOf(symbol.getXOffset()));
-        symbolElement.setAttribute(
-            "y_offset",
-            String.valueOf(symbol.getYOffset()));
-        symbolElement.setAttribute(
-            "name",
-            symbol.getNameString());
-        PictureElement pElem = new PictureElement();
-        pElem.importPicture(symbol.getPicture());
+        try {
+            symbolElement.setAttribute(
+                "angle",
+                String.valueOf(symbol.getAngle()));
+        }
+        catch(IOException ioe) {
+            logger.warn("Could not read angle. Setting angle to 0.");
+            symbolElement.setAttribute("angle", "0");
+        }
+
+        try {
+            symbolElement.setAttribute(
+                "size",
+                String.valueOf(symbol.getSize()));
+        }
+        catch (IOException ioe) {
+            logger.warn("Could not read size. Setting size to 1.");
+            symbolElement.setAttribute("size", "0");
+        }
+
+        try {
+            symbolElement.setAttribute(
+                "x_offset",
+                String.valueOf(symbol.getXOffset()));
+        }
+        catch(IOException ioe) {
+            logger.warn("Could not read x-offset. Setting x-offset to 0");
+            symbolElement.setAttribute("x_offset", "0");
+        }
+
+        try {
+            symbolElement.setAttribute(
+                "y_offset",
+                String.valueOf(symbol.getYOffset()));
+        }
+        catch(IOException ioe) {
+            logger.warn("Could not read y-offset. Setting y-offset to 0.");
+            symbolElement.setAttribute("y_offset", "0");
+        }
+
+        try {
+            symbolElement.setAttribute(
+                "name",
+                symbol.getNameString());
+        }
+        catch(IOException ioe) {
+            logger.warn("Could not read name. Setting name to \"default\"");
+            symbolElement.setAttribute("name", "default");
+        }
+
+        try {
+            PictureElement pElem = new PictureElement();
+            pElem.importPicture(symbol.getPicture());
+        }
+        catch(IOException ioe) {
+            logger.warn("Could not read picture. No fallback defined.");
+        }
         symbolElement.setAttribute("style", "picture");
         symbolElement.setAttribute("type", "marker");
         return symbolElement;
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)