# HG changeset patch # User Raimund Renkert # Date 1308149322 -7200 # Node ID fb93f20478ccd647e66475b13a43ae439d9de5e5 # Parent 93699e8f2d1f1eb314b01affaa79aac988340fbe Improved exception handling for symbol reader. diff -r 93699e8f2d1f -r fb93f20478cc ChangeLog --- a/ChangeLog Wed Jun 15 16:13:32 2011 +0200 +++ b/ChangeLog Wed Jun 15 16:48:42 2011 +0200 @@ -1,3 +1,30 @@ +2011-06-15 Raimund Renkert + + Improved exception handling. + + * src/java/de/intevation/mxd/reader/ArrowMarkerSymbolReader.java, + src/java/de/intevation/mxd/reader/CartoLineSymbolReader.java, + src/java/de/intevation/mxd/reader/CharacterMarkerSymbolReader.java, + src/java/de/intevation/mxd/reader/FillSymbolReader.java, + src/java/de/intevation/mxd/reader/HashLineSymbolReader.java, + src/java/de/intevation/mxd/reader/ISymbolReader.java, + src/java/de/intevation/mxd/reader/LineFillSymbolReader.java, + src/java/de/intevation/mxd/reader/LineSymbolReader.java, + src/java/de/intevation/mxd/reader/MarkerFillSymbolReader.java, + src/java/de/intevation/mxd/reader/MarkerLineSymbolReader.java, + src/java/de/intevation/mxd/reader/MarkerSymbolReader.java, + src/java/de/intevation/mxd/reader/MultiLayerFillSymbolReader.java, + src/java/de/intevation/mxd/reader/MultiLayerLineSymbolReader.java, + src/java/de/intevation/mxd/reader/MultiLayerMarkerSymbolReader.java, + src/java/de/intevation/mxd/reader/PictureLineSymbolReader.java, + src/java/de/intevation/mxd/reader/PictureMarkerSymbolReader.java, + src/java/de/intevation/mxd/reader/SimpleFillSymbolReader.java, + src/java/de/intevation/mxd/reader/SimpleLineSymbolReader.java, + src/java/de/intevation/mxd/reader/SimpleMarkerSymbolReader.java: + If an exception is thrown while getting symbol attributes, a default + value is set to the attribute and a warning is written to the log + file. + 2011-06-15 Stephan Holl * contrib/python/FixWorkspacePaths.py, contrib/python/foobar.py: diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/ArrowMarkerSymbolReader.java --- a/src/java/de/intevation/mxd/reader/ArrowMarkerSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/ArrowMarkerSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -5,9 +5,13 @@ import com.esri.arcgis.display.ISymbol; import com.esri.arcgis.display.IMarkerSymbol; import com.esri.arcgis.display.ArrowMarkerSymbol; -import com.esri.arcgis.display.IColor; +import com.esri.arcgis.display.IRgbColor; +import com.esri.arcgis.display.RgbColor; import org.w3c.dom.Element; +import java.awt.Color; + +import java.io.IOException; /** * Reads arrow marker symbol information. @@ -55,39 +59,111 @@ * * @return The XML node. */ - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); Element symbolElement = util.addSymbol(parent); - IColor c = symbol.getColor(); - 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( - "color", - String.valueOf(c.getRGB())); - symbolElement.setAttribute( - "tranparency", - String.valueOf(c.getTransparency())); - symbolElement.setAttribute( - "name", - symbol.getNameString()); - symbolElement.setAttribute( - "length", - String.valueOf(symbol.getLength())); - symbolElement.setAttribute( - "width", - String.valueOf(symbol.getWidth())); + try{ + if(symbol.getColor() instanceof IRgbColor) { + IRgbColor color = (IRgbColor)symbol.getColor(); + Color c = new Color ( + color.getRed(), + color.getGreen(), + color.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("transparency", + String.valueOf(color.getTransparency())); + } + else { + RgbColor col = new RgbColor(); + col.setRGB(symbol.getColor().getRGB()); + Color c = new Color ( + col.getRed(), + col.getGreen(), + col.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("transparency", + String.valueOf(col.getTransparency())); + } + } + catch(IOException ioe) { + logger.warn( + "Could not read color." + + " Setting color to black with no transparency."); + Color black = new Color(0, 0, 0); + symbolElement.setAttribute("color", String.valueOf(black.getRGB())); + symbolElement.setAttribute("transparency", "-1"); + } + + 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", "1"); + } + + 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 { + symbolElement.setAttribute( + "length", + String.valueOf(symbol.getLength())); + } + catch(IOException ioe) { + logger.warn("Could not read length. Setting length to 1."); + symbolElement.setAttribute("length", "1"); + } + + try { + symbolElement.setAttribute( + "width", + String.valueOf(symbol.getWidth())); + } + catch(IOException ioe) { + logger.warn("Could not read width. Setting width to 1."); + symbolElement.setAttribute("width", "1"); + } symbolElement.setAttribute("style", "arrow"); symbolElement.setAttribute("type", "marker"); return symbolElement; diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/CartoLineSymbolReader.java --- a/src/java/de/intevation/mxd/reader/CartoLineSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/CartoLineSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -14,6 +14,7 @@ import com.esri.arcgis.display.esriLineJoinStyle; import org.w3c.dom.Element; +import java.io.IOException; /** * Reads cartoline symbol information. @@ -62,39 +63,74 @@ * * @return The XML node. */ - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); Element symbolElement = util.addSymbol(parent); - symbolElement.setAttribute("name", symbol.getNameString()); - symbolElement.setAttribute("type", "line"); - symbolElement.setAttribute("style", "carto"); - if(symbol.getColor() instanceof IRgbColor) { - IRgbColor color = (IRgbColor)symbol.getColor(); - Color c = new Color ( - color.getRed(), - color.getGreen(), - color.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + try { + symbolElement.setAttribute("name", symbol.getNameString()); } - else { - RgbColor col = new RgbColor(); - col.setRGB(symbol.getColor().getRGB()); - Color c = new Color ( - col.getRed(), - col.getGreen(), - col.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + catch(IOException ioe) { + logger.warn("Could not read name. Setting name to \"default\""); + symbolElement.setAttribute("name", "default"); } - int cap = symbol.getCap(); + + try { + if(symbol.getColor() instanceof IRgbColor) { + IRgbColor color = (IRgbColor)symbol.getColor(); + Color c = new Color ( + color.getRed(), + color.getGreen(), + color.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + } + else { + RgbColor col = new RgbColor(); + col.setRGB(symbol.getColor().getRGB()); + Color c = new Color ( + col.getRed(), + col.getGreen(), + col.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + } + } + catch(IOException ioe) { + logger.warn( + "Could not read color." + + " Setting color to black with no transparency"); + Color black = new Color(0, 0, 0); + symbolElement.setAttribute("color", String.valueOf(black.getRGB())); + symbolElement.setAttribute("transparency", "-1"); + } + + int cap; + try { + cap = symbol.getCap(); + } + catch(IOException ioe) { + logger.warn( + "Could not read line cap." + + " Setting line cap to \"butt\""); + cap = -1; + } String capStyle = "butt"; switch(cap) { case esriLineCapStyle.esriLCSRound: capStyle = "round"; break; case esriLineCapStyle.esriLCSSquare: capStyle = "square"; break; default: break; } - int join = symbol.getJoin(); + + + int join; + try { + join = symbol.getJoin(); + } + catch(IOException ioe) { + logger.warn( + "Could not read line join." + + " Setting line join to \"bevel\"."); + join = -1; + } String joinStyle = "bevel"; switch(join) { case esriLineJoinStyle.esriLJSRound: joinStyle = "round"; break; @@ -103,19 +139,54 @@ } symbolElement.setAttribute("cap", capStyle); symbolElement.setAttribute("join", joinStyle); - symbolElement.setAttribute( - "linestart", - String.valueOf(symbol.getLineStartOffset())); - symbolElement.setAttribute( - "miterlimit", - String.valueOf(symbol.getMiterLimit())); - symbolElement.setAttribute( - "offset", - String.valueOf(symbol.getOffset())); - symbolElement.setAttribute("width", String.valueOf(symbol.getWidth())); + try { + symbolElement.setAttribute( + "linestart", + String.valueOf(symbol.getLineStartOffset())); + } + catch(IOException ioe) { + logger.warn( + "Could not read line start offset." + + " Setting line start offset to 0."); + symbolElement.setAttribute("linestart", "0"); + } + + try { + symbolElement.setAttribute( + "miterlimit", + String.valueOf(symbol.getMiterLimit())); + } + catch(IOException ioe) { + logger.warn( + "Could not read miter limit. " + + " Setting miter limit to 0."); + symbolElement.setAttribute("miterlimit", "0"); + } + + try { + symbolElement.setAttribute( + "offset", + String.valueOf(symbol.getOffset())); + } + catch(IOException ioe) { + logger.warn("Could not read offset. Setting offset to 0."); + symbolElement.setAttribute("offset", "0"); + } + + try { + symbolElement.setAttribute( + "width", + String.valueOf(symbol.getWidth())); + } + catch(IOException ioe) { + logger.warn("Could not read width. Setting width to 1."); + symbolElement.setAttribute("width", "1"); + } //TODO Read further attributes depending on the Mapscript functionality: // Template, MarkerSymbol, LineDecorations + symbolElement.setAttribute("type", "line"); + symbolElement.setAttribute("style", "carto"); return symbolElement; } diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/CharacterMarkerSymbolReader.java --- a/src/java/de/intevation/mxd/reader/CharacterMarkerSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/CharacterMarkerSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -9,9 +9,9 @@ import com.esri.arcgis.display.IRgbColor; import com.esri.arcgis.display.RgbColor; - import org.w3c.dom.Element; import java.awt.Color; +import java.io.IOException; /** * Reads character marker symbol information. @@ -59,62 +59,120 @@ * * @return The XML node. */ - public Element read() - throws Exception { + public Element read() { 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()); - symbolElement.setAttribute( - "char", - String.valueOf(symbol.getCharacterIndex())); - - if(symbol.getColor() instanceof IRgbColor) { - IRgbColor color = (IRgbColor)symbol.getColor(); - Color c = new Color ( - color.getRed(), - color.getGreen(), - color.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); - symbolElement.setAttribute("transparency", - String.valueOf(color.getTransparency())); + try { + symbolElement.setAttribute( + "angle", + String.valueOf(symbol.getAngle())); } - else { - RgbColor col = new RgbColor(); - col.setRGB(symbol.getColor().getRGB()); - Color c = new Color ( - col.getRed(), - col.getGreen(), - col.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); - symbolElement.setAttribute("transparency", - String.valueOf(col.getTransparency())); + catch(IOException ioe) { + logger.warn("Could not read angle. Setting angle to 0."); + symbolElement.setAttribute("angle", "0"); } - Font f = symbol.getFont(); - symbolElement.setAttribute("font", f.getName()); - symbolElement.setAttribute("char_set", String.valueOf(f.getCharset())); - symbolElement.setAttribute("bold", String.valueOf(f.getBold())); - symbolElement.setAttribute("italic", String.valueOf(f.getItalic())); - symbolElement.setAttribute("font_size", String.valueOf(f.getSize())); - symbolElement.setAttribute( - "strike_through", - String.valueOf(f.getStrikethrough())); - symbolElement.setAttribute("weight", String.valueOf(f.getWeight())); + try { + symbolElement.setAttribute( + "size", + String.valueOf(symbol.getSize())); + } + catch(IOException ioe) { + logger.warn("Could not read size. Setting size to 1"); + symbolElement.setAttribute("size", "1"); + } + + 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 { + symbolElement.setAttribute( + "char", + String.valueOf(symbol.getCharacterIndex())); + } + catch(IOException ioe) { + logger.warn( + "Could not read character." + + " Setting character number to 60"); + symbolElement.setAttribute("char", "60"); + } + + try { + if(symbol.getColor() instanceof IRgbColor) { + IRgbColor color = (IRgbColor)symbol.getColor(); + Color c = new Color ( + color.getRed(), + color.getGreen(), + color.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("transparency", + String.valueOf(color.getTransparency())); + } + else { + RgbColor col = new RgbColor(); + col.setRGB(symbol.getColor().getRGB()); + Color c = new Color ( + col.getRed(), + col.getGreen(), + col.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("transparency", + String.valueOf(col.getTransparency())); + } + } + catch(IOException ioe) { + logger.warn( + "Could not read color." + + " Setting color to black with no transparency."); + Color black = new Color(0, 0, 0); + symbolElement.setAttribute("color", String.valueOf(black.getRGB())); + symbolElement.setAttribute("transparency", "-1"); + } + + try { + Font f = symbol.getFont(); + symbolElement.setAttribute("font", f.getName()); + symbolElement.setAttribute("char_set", String.valueOf(f.getCharset())); + symbolElement.setAttribute("bold", String.valueOf(f.getBold())); + symbolElement.setAttribute("italic", String.valueOf(f.getItalic())); + symbolElement.setAttribute("font_size", String.valueOf(f.getSize())); + symbolElement.setAttribute( + "strike_through", + String.valueOf(f.getStrikethrough())); + symbolElement.setAttribute("weight", String.valueOf(f.getWeight())); + } + catch(IOException ioe) { + logger.warn("Could not read font. Setting font to \"Unknown\"."); + symbolElement.setAttribute("font", "Unknown"); + } symbolElement.setAttribute("style", "char"); symbolElement.setAttribute("type", "marker"); return symbolElement; diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/FillSymbolReader.java --- a/src/java/de/intevation/mxd/reader/FillSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/FillSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -48,44 +48,60 @@ this.symbol= null; } - public Element read() throws Exception { + public Element read() { ISymbolReader sreader = null; if(symbol != null) { - if(symbol instanceof SimpleFillSymbol) { - sreader = new SimpleFillSymbolReader(symbol); - } - else if(symbol instanceof MultiLayerFillSymbol) { - sreader = new MultiLayerFillSymbolReader(symbol); + try { + if(symbol instanceof SimpleFillSymbol) { + sreader = new SimpleFillSymbolReader(symbol); + } + else if(symbol instanceof MultiLayerFillSymbol) { + sreader = new MultiLayerFillSymbolReader(symbol); + } + else if(symbol instanceof MarkerFillSymbol) { + sreader = new MarkerFillSymbolReader(symbol); + } + else if(symbol instanceof LineFillSymbol) { + sreader = new LineFillSymbolReader(symbol); + } + else { + logger.debug("The reader for type " + symbol.getClass().toString() + + " is not implemented!"); + return parent; + } } - else if(symbol instanceof MarkerFillSymbol) { - sreader = new MarkerFillSymbolReader(symbol); - } - else if(symbol instanceof LineFillSymbol) { - sreader = new LineFillSymbolReader(symbol); - } - else { - logger.debug("The reader for type " + symbol.getClass().toString() + - " is not implemented!"); + catch(Exception e) { + logger.error( + "Could not read the symbol " + + symbol.getClass().toString()); return parent; } } else if(fillSymbol != null) { - if(fillSymbol instanceof SimpleFillSymbol) { - sreader = new SimpleFillSymbolReader(fillSymbol); - } - else if(fillSymbol instanceof MultiLayerFillSymbol) { - sreader = new MultiLayerFillSymbolReader(fillSymbol); + try { + if(fillSymbol instanceof SimpleFillSymbol) { + sreader = new SimpleFillSymbolReader(fillSymbol); + } + else if(fillSymbol instanceof MultiLayerFillSymbol) { + sreader = new MultiLayerFillSymbolReader(fillSymbol); + } + else if(fillSymbol instanceof MarkerFillSymbol) { + sreader = new MarkerFillSymbolReader(fillSymbol); + } + else if(fillSymbol instanceof LineFillSymbol) { + sreader = new LineFillSymbolReader(fillSymbol); + } + else { + logger.debug("The reader for type " + + fillSymbol.getClass().toString() + + " is not implemented!"); + return parent; + } } - else if(fillSymbol instanceof MarkerFillSymbol) { - sreader = new MarkerFillSymbolReader(fillSymbol); - } - else if(fillSymbol instanceof LineFillSymbol) { - sreader = new LineFillSymbolReader(fillSymbol); - } - else { - logger.debug("The reader for type " + - fillSymbol.getClass().toString() + - " is not implemented!"); + catch(Exception e) { + logger.error( + "Could not read the symbol " + + symbol.getClass().toString()); return parent; } } diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/HashLineSymbolReader.java --- a/src/java/de/intevation/mxd/reader/HashLineSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/HashLineSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -14,6 +14,7 @@ import com.esri.arcgis.display.esriLineJoinStyle; import org.w3c.dom.Element; +import java.io.IOException; /** * Reads cartoline symbol information. @@ -61,39 +62,70 @@ * * @return The XML node. */ - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); Element symbolElement = util.addSymbol(parent); - symbolElement.setAttribute("name", symbol.getNameString()); - symbolElement.setAttribute("type", "line"); - symbolElement.setAttribute("style", "hash"); - if(symbol.getColor() instanceof IRgbColor) { - IRgbColor color = (IRgbColor)symbol.getColor(); - Color c = new Color ( - color.getRed(), - color.getGreen(), - color.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + try { + symbolElement.setAttribute("name", symbol.getNameString()); } - else { - RgbColor col = new RgbColor(); - col.setRGB(symbol.getColor().getRGB()); - Color c = new Color ( - col.getRed(), - col.getGreen(), - col.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + catch(IOException ioe) { + logger.warn("Could not read name. Setting name to \"default\"."); + symbolElement.setAttribute("name", "default"); } - int cap = symbol.getCap(); + + try { + if(symbol.getColor() instanceof IRgbColor) { + IRgbColor color = (IRgbColor)symbol.getColor(); + Color c = new Color ( + color.getRed(), + color.getGreen(), + color.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + } + else { + RgbColor col = new RgbColor(); + col.setRGB(symbol.getColor().getRGB()); + Color c = new Color ( + col.getRed(), + col.getGreen(), + col.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + } + } + catch(IOException ioe) { + logger.warn( + "Could not read color." + + " Setting color to black with no transparency."); + Color black = new Color(0, 0, 0); + symbolElement.setAttribute("color", String.valueOf(black.getRGB())); + symbolElement.setAttribute("transparency", "-1"); + } + int cap; + try { + cap = symbol.getCap(); + } + catch(IOException ioe) { + logger.warn("Could not read line cap. Setting line cap to \"butt\""); + cap = -1; + } String capStyle = "butt"; switch(cap) { case esriLineCapStyle.esriLCSRound: capStyle = "round"; break; case esriLineCapStyle.esriLCSSquare: capStyle = "square"; break; default: break; } - int join = symbol.getJoin(); + + int join; + try { + join = symbol.getJoin(); + } + catch(IOException ioe) { + logger.warn( + "Could not read line join." + + " Setting line join to \"bevel\"."); + join = -1; + } String joinStyle = "bevel"; switch(join) { case esriLineJoinStyle.esriLJSRound: joinStyle = "round"; break; @@ -102,21 +134,64 @@ } symbolElement.setAttribute("cap", capStyle); symbolElement.setAttribute("join", joinStyle); - symbolElement.setAttribute( - "linestart", - String.valueOf(symbol.getLineStartOffset())); - symbolElement.setAttribute( - "miterlimit", - String.valueOf(symbol.getMiterLimit())); - symbolElement.setAttribute( - "offset", - String.valueOf(symbol.getOffset())); - symbolElement.setAttribute("width", String.valueOf(symbol.getWidth())); - ILineSymbol ls = symbol.getHashSymbol(); - readHashSymbol(ls, symbolElement); + try { + symbolElement.setAttribute( + "linestart", + String.valueOf(symbol.getLineStartOffset())); + } + catch(IOException ioe) { + logger.warn( + "Could not read line start offset." + + " Setting line start offset to 0."); + symbolElement.setAttribute("linestart", "0"); + } + + try { + symbolElement.setAttribute( + "miterlimit", + String.valueOf(symbol.getMiterLimit())); + } + catch(IOException ioe) { + logger.warn( + "Could not read miter limit." + + " Setting miter limit to 0."); + symbolElement.setAttribute("miterlimit", "0"); + } + + try { + symbolElement.setAttribute( + "offset", + String.valueOf(symbol.getOffset())); + } + catch(IOException ioe) { + logger.warn("Could not read offset. Setting offset to 0."); + symbolElement.setAttribute("offset", "0"); + } + + try { + symbolElement.setAttribute( + "width", + String.valueOf(symbol.getWidth())); + } + catch(IOException ioe) { + logger.warn("Could not read width. Setting width to 1."); + symbolElement.setAttribute("width", "1"); + } + + try { + ILineSymbol ls = symbol.getHashSymbol(); + readHashSymbol(ls, symbolElement); + } + catch(Exception e) { + logger.warn( + "Could not read HashSymbol." + + " No fallback symbol defined."); + } //TODO Read further HashLine specific attributes: // LineDecoration, Template. + symbolElement.setAttribute("type", "line"); + symbolElement.setAttribute("style", "hash"); return symbolElement; } diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/ISymbolReader.java --- a/src/java/de/intevation/mxd/reader/ISymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/ISymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -13,7 +13,7 @@ */ public interface ISymbolReader{ - Element read() throws Exception; + Element read(); void setParent(Element parent); void setUtil(MapToXMLUtils util); diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/LineFillSymbolReader.java --- a/src/java/de/intevation/mxd/reader/LineFillSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/LineFillSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -12,6 +12,7 @@ import com.esri.arcgis.display.RgbColor; import org.w3c.dom.Element; +import java.io.IOException; /** * Reads marker line symbol information. @@ -60,68 +61,119 @@ * * @return The XML node. */ - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); Element symbolElement = util.addSymbol(parent); - symbolElement.setAttribute("name", symbol.getNameString()); + try { + symbolElement.setAttribute("name", symbol.getNameString()); + } + catch(IOException ioe) { + logger.warn("Could not read name. Setting name to \"default\"."); + symbolElement.setAttribute("name", "default"); + } symbolElement.setAttribute("style", "fill"); - symbolElement.setAttribute( - "offset", - String.valueOf(symbol.getOffset())); - symbolElement.setAttribute( - "separation", - String.valueOf(symbol.getSeparation())); - symbolElement.setAttribute("angle", String.valueOf(symbol.getAngle())); - if(symbol.getColor() instanceof IRgbColor) { - IRgbColor color = (IRgbColor)symbol.getColor(); - Color c = new Color ( - color.getRed(), - color.getGreen(), - color.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); - symbolElement.setAttribute("transparency", - String.valueOf(color.getTransparency())); + try { + symbolElement.setAttribute( + "offset", + String.valueOf(symbol.getOffset())); } - else { - RgbColor col = new RgbColor(); - col.setRGB(symbol.getColor().getRGB()); - Color c = new Color ( - col.getRed(), - col.getGreen(), - col.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); - symbolElement.setAttribute("transparency", - String.valueOf(col.getTransparency())); + catch(IOException ioe) { + logger.warn("Could not read offset. Setting offset to 0."); + symbolElement.setAttribute("offset", "0"); } - ILineSymbol ols = symbol.getOutline(); - LineSymbolReader olsr = new LineSymbolReader(); - if(olsr.canRead(ols)) { - olsr.setSymbol(ols); - olsr.setUtil(util); - olsr.setParent(symbolElement); - olsr.read(); - } - else { - logger.debug("The type of " + ols.getClass().toString() + - " is not implemented!"); + try { + symbolElement.setAttribute( + "separation", + String.valueOf(symbol.getSeparation())); } - ILineSymbol ls = symbol.getLineSymbol(); - LineSymbolReader lsr = new LineSymbolReader(); - if(lsr.canRead(ls)) { - symbolElement.setAttribute("hatch", "1"); - lsr.setSymbol(ls); - lsr.setUtil(util); - lsr.setParent(symbolElement); - lsr.read(); + catch(IOException ioe) { + logger.warn("Could not read separation. setting separation to 1."); + symbolElement.setAttribute("separation", "1"); } - else { - logger.debug("The type of " + ls.getClass().toString() + - " is not implemented!"); + + try { + symbolElement.setAttribute( + "angle", + String.valueOf(symbol.getAngle())); + } + catch(IOException e) { + logger.warn("Could not read angle. Setting angle to 0."); + symbolElement.setAttribute("angle", "0"); + } + + try { + if(symbol.getColor() instanceof IRgbColor) { + IRgbColor color = (IRgbColor)symbol.getColor(); + Color c = new Color ( + color.getRed(), + color.getGreen(), + color.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("transparency", + String.valueOf(color.getTransparency())); + } + else { + RgbColor col = new RgbColor(); + col.setRGB(symbol.getColor().getRGB()); + Color c = new Color ( + col.getRed(), + col.getGreen(), + col.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("transparency", + String.valueOf(col.getTransparency())); + } + } + catch(IOException ioe) { + logger.warn( + "Could not read color." + + " Setting color to black with no transparency."); + Color black = new Color(0, 0, 0); + symbolElement.setAttribute( + "color", + String.valueOf(black.getRGB())); + symbolElement.setAttribute("transparency", "-1"); + } + + try { + ILineSymbol ols = symbol.getOutline(); + LineSymbolReader olsr = new LineSymbolReader(); + if(olsr.canRead(ols)) { + olsr.setSymbol(ols); + olsr.setUtil(util); + olsr.setParent(symbolElement); + olsr.read(); + } + else { + logger.debug("The type of " + ols.getClass().toString() + + " is not implemented!"); + } + } + catch(Exception e) { + logger.warn("Could not read outline. No fallback defined."); + } + + try { + ILineSymbol ls = symbol.getLineSymbol(); + LineSymbolReader lsr = new LineSymbolReader(); + if(lsr.canRead(ls)) { + symbolElement.setAttribute("hatch", "1"); + lsr.setSymbol(ls); + lsr.setUtil(util); + lsr.setParent(symbolElement); + lsr.read(); + } + else { + logger.debug("The type of " + ls.getClass().toString() + + " is not implemented!"); + } + } + catch(Exception e) { + logger.warn("Could not read line symbol. No fallback defined"); } return parent; } diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/LineSymbolReader.java --- a/src/java/de/intevation/mxd/reader/LineSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/LineSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -50,56 +50,72 @@ this.symbol= null; } - public Element read() throws Exception { + public Element read() { ISymbolReader sreader = null; if(symbol != null) { - if(symbol instanceof SimpleLineSymbol) { - sreader = new SimpleLineSymbolReader(symbol); - } - else if(symbol instanceof MarkerLineSymbol) { - sreader = new MarkerLineSymbolReader(symbol); - } - else if(symbol instanceof PictureLineSymbol) { - sreader = new PictureLineSymbolReader(symbol); + try { + if(symbol instanceof SimpleLineSymbol) { + sreader = new SimpleLineSymbolReader(symbol); + } + else if(symbol instanceof MarkerLineSymbol) { + sreader = new MarkerLineSymbolReader(symbol); + } + else if(symbol instanceof PictureLineSymbol) { + sreader = new PictureLineSymbolReader(symbol); + } + else if(symbol instanceof MultiLayerLineSymbol) { + sreader = new MultiLayerLineSymbolReader(symbol); + } + else if(symbol instanceof CartographicLineSymbol) { + sreader = new CartoLineSymbolReader(symbol); + } + else if(symbol instanceof HashLineSymbol) { + sreader = new HashLineSymbolReader(symbol); + } + else { + logger.debug("The reader for type " + symbol.getClass().toString() + + " is not implemented!"); + return parent; + } } - else if(symbol instanceof MultiLayerLineSymbol) { - sreader = new MultiLayerLineSymbolReader(symbol); - } - else if(symbol instanceof CartographicLineSymbol) { - sreader = new CartoLineSymbolReader(symbol); - } - else if(symbol instanceof HashLineSymbol) { - sreader = new HashLineSymbolReader(symbol); - } - else { - logger.debug("The reader for type " + symbol.getClass().toString() + - " is not implemented!"); + catch(Exception e) { + logger.error( + "Could not read the symbol " + + symbol.getClass().toString()); return parent; } } else if(lineSymbol != null) { - if(lineSymbol instanceof SimpleLineSymbol) { - sreader = new SimpleLineSymbolReader(lineSymbol); - } - else if(lineSymbol instanceof MarkerLineSymbol) { - sreader = new MarkerLineSymbolReader(lineSymbol); - } - else if(lineSymbol instanceof PictureLineSymbol) { - sreader = new PictureLineSymbolReader(lineSymbol); + try { + if(lineSymbol instanceof SimpleLineSymbol) { + sreader = new SimpleLineSymbolReader(lineSymbol); + } + else if(lineSymbol instanceof MarkerLineSymbol) { + sreader = new MarkerLineSymbolReader(lineSymbol); + } + else if(lineSymbol instanceof PictureLineSymbol) { + sreader = new PictureLineSymbolReader(lineSymbol); + } + else if(lineSymbol instanceof MultiLayerLineSymbol) { + sreader = new MultiLayerLineSymbolReader(lineSymbol); + } + else if(lineSymbol instanceof CartographicLineSymbol) { + sreader = new CartoLineSymbolReader(lineSymbol); + } + else if(lineSymbol instanceof HashLineSymbol) { + sreader = new HashLineSymbolReader(lineSymbol); + } + else { + logger.debug("The reader for type " + + lineSymbol.getClass().toString() + + " is not implemented!"); + return parent; + } } - else if(lineSymbol instanceof MultiLayerLineSymbol) { - sreader = new MultiLayerLineSymbolReader(lineSymbol); - } - else if(lineSymbol instanceof CartographicLineSymbol) { - sreader = new CartoLineSymbolReader(lineSymbol); - } - else if(lineSymbol instanceof HashLineSymbol) { - sreader = new HashLineSymbolReader(lineSymbol); - } - else { - logger.debug("The reader for type " + - lineSymbol.getClass().toString() + - " is not implemented!"); + catch(Exception e) { + logger.error( + "Could not read the symbol " + + symbol.getClass().toString()); return parent; } } diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/MarkerFillSymbolReader.java --- a/src/java/de/intevation/mxd/reader/MarkerFillSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/MarkerFillSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -14,6 +14,7 @@ import com.esri.arcgis.display.RgbColor; import org.w3c.dom.Element; +import java.io.IOException; /** * Reads marker line symbol information. @@ -62,28 +63,72 @@ * * @return The XML node. */ - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); Element symbolElement = util.addSymbol(parent); - symbolElement.setAttribute("name", symbol.getNameString()); + try { + symbolElement.setAttribute("name", symbol.getNameString()); + } + catch(IOException ioe) { + logger.warn("Could not read name. Setting name to \"default\"."); + symbolElement.setAttribute("name", "default"); + } symbolElement.setAttribute("style", "fill"); - symbolElement.setAttribute( - "xoffset", - String.valueOf(symbol.getXOffset())); - symbolElement.setAttribute( - "yoffset", - String.valueOf(symbol.getYOffset())); - symbolElement.setAttribute( - "xseparation", - String.valueOf(symbol.getXSeparation())); - symbolElement.setAttribute( - "yseparation", - String.valueOf(symbol.getYSeparation())); - int style = symbol.getStyle(); + try { + symbolElement.setAttribute( + "xoffset", + String.valueOf(symbol.getXOffset())); + } + catch(IOException ioe) { + logger.warn("Could not read x-offset. Setting x-offset to 0"); + symbolElement.setAttribute("xoffset", "0"); + } + + try { + symbolElement.setAttribute( + "yoffset", + String.valueOf(symbol.getYOffset())); + } + catch(IOException ioe) { + logger.warn("Could not read y-offset. Setting y-offset to 0."); + symbolElement.setAttribute("yoffset", "0"); + } + + try { + symbolElement.setAttribute( + "xseparation", + String.valueOf(symbol.getXSeparation())); + } + catch(IOException ioe) { + logger.warn( + "Could not read x-separation." + + " Setting x-separation to 0."); + symbolElement.setAttribute("xseparation", "0"); + } + + try { + symbolElement.setAttribute( + "yseparation", + String.valueOf(symbol.getYSeparation())); + } + catch(IOException ioe) { + logger.warn( + "Could not read y-separation." + + " Setting y-separation to 0."); + symbolElement.setAttribute("yseparation", "0"); + } + + int style; + try { + style = symbol.getStyle(); + } + catch(IOException ioe) { + logger.warn("Could not read style. Setting style to \"empty\""); + style = -1; + } switch(style) { case esriSimpleFillStyle.esriSFSCross: symbolElement.setAttribute("fillstyle", "cross"); break; @@ -103,52 +148,72 @@ default: symbolElement.setAttribute("fillstyle", "empty"); } - if(symbol.getColor() instanceof IRgbColor) { - IRgbColor color = (IRgbColor)symbol.getColor(); - Color c = new Color ( - color.getRed(), - color.getGreen(), - color.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); - symbolElement.setAttribute("transparency", - String.valueOf(color.getTransparency())); + try { + if(symbol.getColor() instanceof IRgbColor) { + IRgbColor color = (IRgbColor)symbol.getColor(); + Color c = new Color ( + color.getRed(), + color.getGreen(), + color.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("transparency", + String.valueOf(color.getTransparency())); + } + else { + RgbColor col = new RgbColor(); + col.setRGB(symbol.getColor().getRGB()); + Color c = new Color ( + col.getRed(), + col.getGreen(), + col.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("transparency", + String.valueOf(col.getTransparency())); + } } - else { - RgbColor col = new RgbColor(); - col.setRGB(symbol.getColor().getRGB()); - Color c = new Color ( - col.getRed(), - col.getGreen(), - col.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); - symbolElement.setAttribute("transparency", - String.valueOf(col.getTransparency())); + catch(IOException ioe) { + logger.warn( + "Could not read color." + + " Setting color to black with no transparency."); + Color black = new Color (0, 0, 0); + symbolElement.setAttribute("color", String.valueOf(black.getRGB())); + symbolElement.setAttribute("transparency", "-1"); } - ILineSymbol ls = symbol.getOutline(); - LineSymbolReader lsr = new LineSymbolReader(); - if(lsr.canRead(ls)) { - lsr.setSymbol(ls); - lsr.setUtil(util); - lsr.setParent(symbolElement); - lsr.read(); + try { + ILineSymbol ls = symbol.getOutline(); + LineSymbolReader lsr = new LineSymbolReader(); + if(lsr.canRead(ls)) { + lsr.setSymbol(ls); + lsr.setUtil(util); + lsr.setParent(symbolElement); + lsr.read(); + } + else { + logger.debug("The type of " + ls.getClass().toString() + + " is not implemented!"); + } } - else { - logger.debug("The type of " + ls.getClass().toString() + - " is not implemented!"); + catch(Exception e) { + logger.warn("Could not read outline. No fallback defined."); } - IMarkerSymbol sym = symbol.getMarkerSymbol(); - MarkerSymbolReader msr = new MarkerSymbolReader(); - if(msr.canRead(sym)) { - msr.setSymbol(sym); - msr.setParent(symbolElement); - msr.setUtil(util); - msr.read(); + try { + IMarkerSymbol sym = symbol.getMarkerSymbol(); + MarkerSymbolReader msr = new MarkerSymbolReader(); + if(msr.canRead(sym)) { + msr.setSymbol(sym); + msr.setParent(symbolElement); + msr.setUtil(util); + msr.read(); + } + else { + logger.debug("The type of " + sym.getClass().toString() + + " is not implemented!"); + } } - else { - logger.debug("The type of " + sym.getClass().toString() + - " is not implemented!"); + catch(Exception e) { + logger.warn("Could not read marker symbol. No fallback defined."); } return parent; } diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/MarkerLineSymbolReader.java --- a/src/java/de/intevation/mxd/reader/MarkerLineSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/MarkerLineSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -56,19 +56,25 @@ * * @return The XML node. */ - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); - IMarkerSymbol sym = symbol.getMarkerSymbol(); - if(sym instanceof MultiLayerMarkerSymbol) { - ISymbolReader sreader = new MultiLayerMarkerSymbolReader(sym); - sreader.setParent(parent); - sreader.setUtil(util); - sreader.read(); + try { + IMarkerSymbol sym = symbol.getMarkerSymbol(); + if(sym instanceof MultiLayerMarkerSymbol) { + ISymbolReader sreader = new MultiLayerMarkerSymbolReader(sym); + sreader.setParent(parent); + sreader.setUtil(util); + sreader.read(); + } + else { + logger.debug("The type of " + sym.getClass().toString() + + " is not implemented!"); + } } - else { - logger.debug("The type of " + sym.getClass().toString() + - " is not implemented!"); + catch(Exception e) { + logger.error( + "Could not read the symbol " + + symbol.getClass().toString()); } return parent; } diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/MarkerSymbolReader.java --- a/src/java/de/intevation/mxd/reader/MarkerSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/MarkerSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -51,53 +51,70 @@ this.markerSymbol = null; } - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); ISymbolReader sreader = null; if(symbol != null) { - if(symbol instanceof SimpleMarkerSymbol) { - sreader = new SimpleMarkerSymbolReader(symbol); - } - else if(symbol instanceof ArrowMarkerSymbol) { - sreader = new ArrowMarkerSymbolReader(symbol); - } - else if(symbol instanceof CharacterMarkerSymbol) { - sreader = new CharacterMarkerSymbolReader(symbol); + try { + if(symbol instanceof SimpleMarkerSymbol) { + sreader = new SimpleMarkerSymbolReader(symbol); + } + else if(symbol instanceof ArrowMarkerSymbol) { + sreader = new ArrowMarkerSymbolReader(symbol); + } + else if(symbol instanceof CharacterMarkerSymbol) { + sreader = new CharacterMarkerSymbolReader(symbol); + } + else if(symbol instanceof PictureMarkerSymbol) { + sreader = new PictureMarkerSymbolReader(symbol); + } + else if(symbol instanceof MultiLayerMarkerSymbol) { + sreader = new MultiLayerMarkerSymbolReader(symbol); + } + else { + logger.debug("The reader for type " + symbol.getClass().toString() + + " is not implemented!"); + return parent; + } } - else if(symbol instanceof PictureMarkerSymbol) { - sreader = new PictureMarkerSymbolReader(symbol); - } - else if(symbol instanceof MultiLayerMarkerSymbol) { - sreader = new MultiLayerMarkerSymbolReader(symbol); - } - else { - logger.debug("The reader for type " + symbol.getClass().toString() + - " is not implemented!"); + catch(Exception e) { + logger.error( + "Could not read the symbol " + + symbol.getClass().toString()); return parent; + } } else if(markerSymbol != null) { - if(markerSymbol instanceof SimpleMarkerSymbol) { - sreader = new SimpleMarkerSymbolReader(markerSymbol); - } - else if(markerSymbol instanceof ArrowMarkerSymbol) { - sreader = new ArrowMarkerSymbolReader(markerSymbol); - } - else if(markerSymbol instanceof CharacterMarkerSymbol) { - sreader = new CharacterMarkerSymbolReader(markerSymbol); + try { + if(markerSymbol instanceof SimpleMarkerSymbol) { + sreader = new SimpleMarkerSymbolReader(markerSymbol); + } + else if(markerSymbol instanceof ArrowMarkerSymbol) { + sreader = new ArrowMarkerSymbolReader(markerSymbol); + } + else if(markerSymbol instanceof CharacterMarkerSymbol) { + sreader = new CharacterMarkerSymbolReader(markerSymbol); + } + else if(markerSymbol instanceof PictureMarkerSymbol) { + sreader = new PictureMarkerSymbolReader(markerSymbol); + } + else if(markerSymbol instanceof MultiLayerMarkerSymbol) { + sreader = new MultiLayerMarkerSymbolReader(markerSymbol); + } + else { + logger.debug("The reader for type " + symbol.getClass().toString() + + " is not implemented!"); + return parent; + } } - else if(markerSymbol instanceof PictureMarkerSymbol) { - sreader = new PictureMarkerSymbolReader(markerSymbol); - } - else if(markerSymbol instanceof MultiLayerMarkerSymbol) { - sreader = new MultiLayerMarkerSymbolReader(markerSymbol); - } - else { - logger.debug("The reader for type " + symbol.getClass().toString() + - " is not implemented!"); + catch(Exception e) { + logger.error( + "Could not read the symbol " + + symbol.getClass().toString()); return parent; + } } if (sreader != null) { diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/MultiLayerFillSymbolReader.java --- a/src/java/de/intevation/mxd/reader/MultiLayerFillSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/MultiLayerFillSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -55,23 +55,29 @@ * * @return The XML node. */ - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); - for(int i = 0; i < symbol.getLayerCount(); i++) { - ISymbol sym = (ISymbol)symbol.getLayer(i); + try { + for(int i = 0; i < symbol.getLayerCount(); i++) { + ISymbol sym = (ISymbol)symbol.getLayer(i); - FillSymbolReader fsr = new FillSymbolReader(); - if(fsr.canRead(sym)) { - fsr.setSymbol(sym); - fsr.setParent(parent); - fsr.setUtil(util); - fsr.read(); + FillSymbolReader fsr = new FillSymbolReader(); + if(fsr.canRead(sym)) { + fsr.setSymbol(sym); + fsr.setParent(parent); + fsr.setUtil(util); + fsr.read(); + } + else { + logger.debug("The type of " + sym.getClass().toString() + + " is not implemented!"); + } } - else { - logger.debug("The type of " + sym.getClass().toString() + - " is not implemented!"); - } + } + catch(Exception e) { + logger.error( + "Could not read the symbol " + + symbol.getClass().toString()); } return parent; } diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/MultiLayerLineSymbolReader.java --- a/src/java/de/intevation/mxd/reader/MultiLayerLineSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/MultiLayerLineSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -54,15 +54,21 @@ * * @return The XML node. */ - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); - for(int i = 0; i < symbol.getLayerCount(); i++) { - ISymbol sym = (ISymbol)symbol.getLayer(i); - ISymbolReader sreader = new LineSymbolReader(sym); - sreader.setParent(parent); - sreader.setUtil(util); - sreader.read(); + try { + for(int i = 0; i < symbol.getLayerCount(); i++) { + ISymbol sym = (ISymbol)symbol.getLayer(i); + ISymbolReader sreader = new LineSymbolReader(sym); + sreader.setParent(parent); + sreader.setUtil(util); + sreader.read(); + } + } + catch(Exception e) { + logger.error( + "Could not read the symbol " + + symbol.getClass().toString()); } return parent; } diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/MultiLayerMarkerSymbolReader.java --- a/src/java/de/intevation/mxd/reader/MultiLayerMarkerSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/MultiLayerMarkerSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -54,15 +54,21 @@ * * @return The XML node. */ - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); - for(int i = 0; i < symbol.getLayerCount(); i++) { - ISymbol sym = (ISymbol)symbol.getLayer(i); - ISymbolReader sreader = new MarkerSymbolReader(sym); - sreader.setParent(parent); - sreader.setUtil(util); - sreader.read(); + try { + for(int i = 0; i < symbol.getLayerCount(); i++) { + ISymbol sym = (ISymbol)symbol.getLayer(i); + ISymbolReader sreader = new MarkerSymbolReader(sym); + sreader.setParent(parent); + sreader.setUtil(util); + sreader.read(); + } + } + catch(Exception e) { + logger.error( + "Could not read symbol " + + symbol.getClass().toString()); } return parent; } diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/PictureLineSymbolReader.java --- a/src/java/de/intevation/mxd/reader/PictureLineSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/PictureLineSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -13,6 +13,7 @@ import com.esri.arcgis.display.RgbColor; import org.w3c.dom.Element; +import java.io.IOException; /** * Reads picture line symbol information. @@ -60,44 +61,91 @@ * * @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("name", symbol.getNameString()); + try { + symbolElement.setAttribute("name", symbol.getNameString()); + } + catch(IOException ioe) { + logger.warn("Could not read name. Setting name ti \"default\""); + symbolElement.setAttribute("name", "default"); + } + + try { + if(symbol.getColor() instanceof IRgbColor) { + IRgbColor color = (IRgbColor)symbol.getColor(); + Color c = new Color ( + color.getRed(), + color.getGreen(), + color.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + } + else { + RgbColor col = new RgbColor(); + col.setRGB(symbol.getColor().getRGB()); + Color c = new Color ( + col.getRed(), + col.getGreen(), + col.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + } + } + catch(IOException ioe) { + logger.warn( + "Could not read color." + + " Setting color to black with no transparency"); + Color black = new Color (0, 0, 0); + symbolElement.setAttribute("color", String.valueOf(black.getRGB())); + symbolElement.setAttribute("transparency", "-1"); + } + + try { + symbolElement.setAttribute( + "offset", + String.valueOf(symbol.getOffset())); + } + catch(IOException ioe) { + logger.warn("Could not read offset. Setting offset to 0."); + symbolElement.setAttribute("offset", "0"); + } + + try { + symbolElement.setAttribute( + "x_scale", + String.valueOf(symbol.getXScale())); + } + catch(IOException ioe) { + logger.warn("Could not read x-scale. Setting x-scale to 0"); + symbolElement.setAttribute("x_scale", "0"); + } + + try { + symbolElement.setAttribute( + "y_scale", + String.valueOf(symbol.getYScale())); + } + catch(IOException ioe) { + logger.warn("Could not read y-scale. Setting y-scale to 0."); + symbolElement.setAttribute("y_scale", "0"); + } + + try { + symbolElement.setAttribute( + "width", + String.valueOf(symbol.getWidth())); + } + catch(IOException ioe) { + logger.warn("Could not read width. Setting width to 1."); + symbolElement.setAttribute("width", "1"); + } + symbolElement.setAttribute("type", "line"); symbolElement.setAttribute("style", "picture"); - if(symbol.getColor() instanceof IRgbColor) { - IRgbColor color = (IRgbColor)symbol.getColor(); - Color c = new Color ( - color.getRed(), - color.getGreen(), - color.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); - } - else { - RgbColor col = new RgbColor(); - col.setRGB(symbol.getColor().getRGB()); - Color c = new Color ( - col.getRed(), - col.getGreen(), - col.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); - } - symbolElement.setAttribute( - "offset", - String.valueOf(symbol.getOffset())); - symbolElement.setAttribute( - "x_scale", - String.valueOf(symbol.getXScale())); - symbolElement.setAttribute( - "y_scale", - String.valueOf(symbol.getYScale())); - symbolElement.setAttribute("width", String.valueOf(symbol.getWidth())); return symbolElement; } } diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/PictureMarkerSymbolReader.java --- 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; diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/SimpleFillSymbolReader.java --- a/src/java/de/intevation/mxd/reader/SimpleFillSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/SimpleFillSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -13,6 +13,7 @@ import com.esri.arcgis.display.RgbColor; import org.w3c.dom.Element; +import java.io.IOException; /** * Reads simple marker symbol information. @@ -58,14 +59,29 @@ * * @return The XML node. */ - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); Element symbolElement = util.addSymbol(parent); - symbolElement.setAttribute("name", symbol.getNameString()); + try { + symbolElement.setAttribute("name", symbol.getNameString()); + } + catch(IOException ioe) { + logger.warn("Could not read name. Setting name to \"default\""); + symbolElement.setAttribute("name", "default"); + } symbolElement.setAttribute("style", "fill"); - int style = symbol.getStyle(); + int style; + try { + style = symbol.getStyle(); + } + catch(IOException ioe) { + logger.warn( + "Could not read fill style." + + " Setting fill style to \"empty\""); + style = -1; + } + switch(style) { case esriSimpleFillStyle.esriSFSCross: symbolElement.setAttribute("fillstyle", "cross"); break; @@ -85,39 +101,54 @@ default: symbolElement.setAttribute("fillstyle", "empty"); } - if(symbol.getColor() instanceof IRgbColor) { - IRgbColor color = (IRgbColor)symbol.getColor(); - Color c = new Color ( - color.getRed(), - color.getGreen(), - color.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); - symbolElement.setAttribute("transparency", - String.valueOf(color.getTransparency())); + try { + if(symbol.getColor() instanceof IRgbColor) { + IRgbColor color = (IRgbColor)symbol.getColor(); + Color c = new Color ( + color.getRed(), + color.getGreen(), + color.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("transparency", + String.valueOf(color.getTransparency())); + } + else { + RgbColor col = new RgbColor(); + col.setRGB(symbol.getColor().getRGB()); + Color c = new Color ( + col.getRed(), + col.getGreen(), + col.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("transparency", + String.valueOf(col.getTransparency())); + } } - else { - RgbColor col = new RgbColor(); - col.setRGB(symbol.getColor().getRGB()); - Color c = new Color ( - col.getRed(), - col.getGreen(), - col.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); - symbolElement.setAttribute("transparency", - String.valueOf(col.getTransparency())); + catch(IOException ioe) { + logger.warn( + "Could not read color." + + " Setting color to black with no transparency"); + Color black = new Color(0, 0, 0); + symbolElement.setAttribute("color", String.valueOf(black.getRGB())); + symbolElement.setAttribute("transparency", "-1"); } - ILineSymbol ls = symbol.getOutline(); - LineSymbolReader lsr = new LineSymbolReader(); - if(lsr.canRead(ls)) { - lsr.setSymbol(ls); - lsr.setUtil(util); - lsr.setParent(symbolElement); - lsr.read(); + try { + ILineSymbol ls = symbol.getOutline(); + LineSymbolReader lsr = new LineSymbolReader(); + if(lsr.canRead(ls)) { + lsr.setSymbol(ls); + lsr.setUtil(util); + lsr.setParent(symbolElement); + lsr.read(); + } + else { + logger.debug("The type of " + ls.getClass().toString() + + " is not implemented!"); + } } - else { - logger.debug("The type of " + ls.getClass().toString() + - " is not implemented!"); + catch(Exception e) { + logger.warn("Could not read line symbol. No fallback defined."); } return symbolElement; diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/SimpleLineSymbolReader.java --- a/src/java/de/intevation/mxd/reader/SimpleLineSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/SimpleLineSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -12,6 +12,7 @@ import com.esri.arcgis.display.RgbColor; import org.w3c.dom.Element; +import java.io.IOException; /** * Reads simple line symbol information. @@ -59,35 +60,64 @@ * * @return The XML node. */ - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); Element symbolElement = util.addSymbol(parent); - symbolElement.setAttribute("name", symbol.getNameString()); - symbolElement.setAttribute("type", "line"); - symbolElement.setAttribute("style", "simple"); - if(symbol.getColor() instanceof IRgbColor) { - IRgbColor color = (IRgbColor)symbol.getColor(); - Color c = new Color ( - color.getRed(), - color.getGreen(), - color.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + try { + symbolElement.setAttribute("name", symbol.getNameString()); } - else { - RgbColor col = new RgbColor(); - col.setRGB(symbol.getColor().getRGB()); - Color c = new Color ( - col.getRed(), - col.getGreen(), - col.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + catch(IOException ioe) { + logger.warn("Could not read name. Setting name to \"default\""); + symbolElement.setAttribute("name", "default"); } - symbolElement.setAttribute("width", String.valueOf(symbol.getWidth())); + try { + if(symbol.getColor() instanceof IRgbColor) { + IRgbColor color = (IRgbColor)symbol.getColor(); + Color c = new Color ( + color.getRed(), + color.getGreen(), + color.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + } + else { + RgbColor col = new RgbColor(); + col.setRGB(symbol.getColor().getRGB()); + Color c = new Color ( + col.getRed(), + col.getGreen(), + col.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + } + } + catch(IOException ioe) { + logger.warn( + "Could not read color." + + " Setting color to black with no transparency."); + Color black = new Color(0, 0, 0); + symbolElement.setAttribute("color", String.valueOf(black.getRGB())); + symbolElement.setAttribute("transparency", "-1"); + } - int style = symbol.getStyle(); + try { + symbolElement.setAttribute("width", String.valueOf(symbol.getWidth())); + } + catch(IOException ioe) { + logger.warn("Could not read width. Setting width to 1."); + symbolElement.setAttribute("width", "1"); + } + + int style; + try { + style = symbol.getStyle(); + } + catch(IOException ioe) { + logger.warn( + "Could not read line style." + + " Setting line style to \"none\"."); + style = -1; + } switch(style) { case esriSimpleLineStyle.esriSLSSolid: symbolElement.setAttribute("linestyle", "solid"); break; @@ -101,6 +131,10 @@ symbolElement.setAttribute("linestyle", "dashdotdot"); break; default: symbolElement.setAttribute ("linestyle", "none"); } + + symbolElement.setAttribute("type", "line"); + symbolElement.setAttribute("style", "simple"); + return symbolElement; } } diff -r 93699e8f2d1f -r fb93f20478cc src/java/de/intevation/mxd/reader/SimpleMarkerSymbolReader.java --- a/src/java/de/intevation/mxd/reader/SimpleMarkerSymbolReader.java Wed Jun 15 16:13:32 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/SimpleMarkerSymbolReader.java Wed Jun 15 16:48:42 2011 +0200 @@ -12,6 +12,7 @@ import com.esri.arcgis.display.RgbColor; import org.w3c.dom.Element; +import java.io.IOException; /** * Reads simple marker symbol information. @@ -59,69 +60,141 @@ * * @return The XML node. */ - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); Element symbolElement = util.addSymbol(parent); - symbolElement.setAttribute("name", symbol.getNameString()); - if(symbol.getStyle() == esriSimpleMarkerStyle.esriSMSCircle) - symbolElement.setAttribute("style", "point"); - - if(symbol.getColor() instanceof IRgbColor) { - IRgbColor color = (IRgbColor)symbol.getColor(); - Color c = new Color ( - color.getRed(), - color.getGreen(), - color.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); - symbolElement.setAttribute("transparency", - String.valueOf(color.getTransparency())); + try { + symbolElement.setAttribute("name", symbol.getNameString()); } - else { - RgbColor col = new RgbColor(); - col.setRGB(symbol.getColor().getRGB()); - Color c = new Color ( - col.getRed(), - col.getGreen(), - col.getBlue()); - symbolElement.setAttribute("color", String.valueOf(c.getRGB())); - symbolElement.setAttribute("transparency", - String.valueOf(col.getTransparency())); + catch(IOException ioe) { + logger.warn("Could not read name. Setting name to \"default\"."); + symbolElement.setAttribute("name", "default"); } - symbolElement.setAttribute("size", String.valueOf(symbol.getSize())); - symbolElement.setAttribute("outline_size", - String.valueOf(symbol.getOutlineSize())); - if(symbol.getOutlineColor() instanceof IRgbColor) { - IRgbColor color = (IRgbColor)symbol.getOutlineColor(); - Color c = new Color ( - color.getRed(), - color.getGreen(), - color.getBlue()); + try { + if(symbol.getStyle() == esriSimpleMarkerStyle.esriSMSCircle) + symbolElement.setAttribute("style", "point"); + } + catch(IOException ioe) { + logger.warn( + "Could not read marker style." + + " Setting marker style to point."); + symbolElement.setAttribute("style", "point"); + } + + try { + if(symbol.getColor() instanceof IRgbColor) { + IRgbColor color = (IRgbColor)symbol.getColor(); + Color c = new Color ( + color.getRed(), + color.getGreen(), + color.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("transparency", + String.valueOf(color.getTransparency())); + } + else { + RgbColor col = new RgbColor(); + col.setRGB(symbol.getColor().getRGB()); + Color c = new Color ( + col.getRed(), + col.getGreen(), + col.getBlue()); + symbolElement.setAttribute("color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("transparency", + String.valueOf(col.getTransparency())); + } + } + catch(IOException ioe) { + logger.warn( + "Could not read color." + + " Setting color to black with no transparency."); + Color black = new Color(0, 0, 0); + symbolElement.setAttribute("color", String.valueOf(black.getRGB())); + symbolElement.setAttribute("transparency", "-1"); + } + + try { symbolElement.setAttribute( + "size", + String.valueOf(symbol.getSize())); + } + catch(IOException ioe) { + logger.warn("Could not read size. Setting size to 1."); + symbolElement.setAttribute("size", "1"); + } + + try { + symbolElement.setAttribute( + "outline_size", + String.valueOf(symbol.getOutlineSize())); + } + catch(IOException ioe) { + logger.warn( + "Could not read outline size." + + " Setting outline size to 1."); + symbolElement.setAttribute("outline_size", "1"); + } + + try { + if(symbol.getOutlineColor() instanceof IRgbColor) { + IRgbColor color = (IRgbColor)symbol.getOutlineColor(); + Color c = new Color ( + color.getRed(), + color.getGreen(), + color.getBlue()); + symbolElement.setAttribute( + "outline_color", + String.valueOf(c.getRGB())); + symbolElement.setAttribute("outline_transparency", + String.valueOf(color.getTransparency())); + } + else { + RgbColor col = new RgbColor(); + col.setRGB(symbol.getOutlineColor().getRGB()); + Color c = new Color ( + col.getRed(), + col.getGreen(), + col.getBlue()); + symbolElement.setAttribute( "outline_color", String.valueOf(c.getRGB())); - symbolElement.setAttribute("outline_transparency", - String.valueOf(color.getTransparency())); + symbolElement.setAttribute("outline_transparency", + String.valueOf(col.getTransparency())); + } } - else { - RgbColor col = new RgbColor(); - col.setRGB(symbol.getOutlineColor().getRGB()); - Color c = new Color ( - col.getRed(), - col.getGreen(), - col.getBlue()); + catch(IOException ioe) { + logger.warn( + "Could not read outline color." + + " Setting outline color to black with no transparency."); + Color black = new Color(0, 0, 0); symbolElement.setAttribute( "outline_color", - String.valueOf(c.getRGB())); - symbolElement.setAttribute("outline_transparency", - String.valueOf(col.getTransparency())); + String.valueOf(black.getRGB())); + symbolElement.setAttribute("outline_transparency", "-1"); } - symbolElement.setAttribute("angle", String.valueOf(symbol.getAngle())); - symbolElement.setAttribute("offset", - symbol.getXOffset() + "," + symbol.getYOffset()); + 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( + "offset", + symbol.getXOffset() + "," + symbol.getYOffset()); + } + catch(IOException ioe) { + logger.warn("Could not read offset. Setting offset to 0."); + symbolElement.setAttribute("offset", "0"); + } + symbolElement.setAttribute("type", "marker"); return symbolElement; }