comparison src/java/de/intevation/mxd/reader/SimpleRendererReader.java @ 116:c8a1361ddd38

Improved exceptionhandlin for renderer reader.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 15 Jun 2011 18:37:27 +0200
parents 59e06c405a9a
children a4ab239509f1
comparison
equal deleted inserted replaced
115:fb93f20478cc 116:c8a1361ddd38
5 import com.esri.arcgis.carto.IFeatureRenderer; 5 import com.esri.arcgis.carto.IFeatureRenderer;
6 import com.esri.arcgis.display.ISymbol; 6 import com.esri.arcgis.display.ISymbol;
7 import com.esri.arcgis.carto.SimpleRenderer; 7 import com.esri.arcgis.carto.SimpleRenderer;
8 8
9 import org.w3c.dom.Element; 9 import org.w3c.dom.Element;
10 import java.io.IOException;
10 11
11 import de.intevation.mxd.utils.MapToXMLUtils; 12 import de.intevation.mxd.utils.MapToXMLUtils;
12 13
13 /** 14 /**
14 * Reads simple renderer information. 15 * Reads simple renderer information.
65 /** 66 /**
66 * Reads the renderer attributes. 67 * Reads the renderer attributes.
67 * 68 *
68 * @return The XML node. 69 * @return The XML node.
69 */ 70 */
70 public Element read() 71 public Element read() {
71 throws Exception {
72 logger.debug("read()"); 72 logger.debug("read()");
73 Element rendererElement; 73 Element rendererElement;
74 rendererElement = util.addRenderer(layer); 74 rendererElement = util.addRenderer(layer);
75 75
76 rendererElement.setAttribute("label", renderer.getLabel()); 76 try {
77 rendererElement.setAttribute("description", renderer.getDescription()); 77 rendererElement.setAttribute("label", renderer.getLabel());
78 symbol = renderer.getSymbol(); 78 }
79 catch(IOException ioe) {
80 logger.warn(
81 "Could not read label name." +
82 "Setting label name to \"default-label\"");
83 rendererElement.setAttribute("label", "default-label");
84 }
79 85
80 MarkerSymbolReader markerReader = new MarkerSymbolReader(); 86 try {
81 LineSymbolReader lineReader = new LineSymbolReader(); 87 rendererElement.setAttribute(
82 FillSymbolReader fillReader = new FillSymbolReader(); 88 "description",
83 if(markerReader.canRead(symbol)) { 89 renderer.getDescription());
84 markerReader.setSymbol(symbol);
85 markerReader.setUtil(util);
86 markerReader.setParent(rendererElement);
87 markerReader.read();
88 } 90 }
89 else if(lineReader.canRead(symbol)) { 91 catch(IOException ioe) {
90 lineReader.setSymbol(symbol); 92 logger.warn(
91 lineReader.setUtil(util); 93 "Could not read description." +
92 lineReader.setParent(rendererElement); 94 " Setting empty description.");
93 lineReader.read(); 95 rendererElement.setAttribute("description", "");
94 } 96 }
95 else if(fillReader.canRead(symbol)) { 97
96 fillReader.setSymbol(symbol); 98 try {
97 fillReader.setUtil(util); 99 symbol = renderer.getSymbol();
98 fillReader.setParent(rendererElement); 100
99 fillReader.read(); 101 MarkerSymbolReader markerReader = new MarkerSymbolReader();
102 LineSymbolReader lineReader = new LineSymbolReader();
103 FillSymbolReader fillReader = new FillSymbolReader();
104 if(markerReader.canRead(symbol)) {
105 markerReader.setSymbol(symbol);
106 markerReader.setUtil(util);
107 markerReader.setParent(rendererElement);
108 markerReader.read();
109 }
110 else if(lineReader.canRead(symbol)) {
111 lineReader.setSymbol(symbol);
112 lineReader.setUtil(util);
113 lineReader.setParent(rendererElement);
114 lineReader.read();
115 }
116 else if(fillReader.canRead(symbol)) {
117 fillReader.setSymbol(symbol);
118 fillReader.setUtil(util);
119 fillReader.setParent(rendererElement);
120 fillReader.read();
121 }
122 else {
123 logger.debug(
124 "No known Symbol type: " +
125 symbol.getClass().toString());
126 }
100 } 127 }
101 else { 128 catch(Exception e) {
102 logger.debug("No known Symbol type: " + symbol.getClass().toString()); 129 logger.error("Could not read symbol. Stopped reading renderer.");
103 } 130 }
104 return layer; 131 return layer;
105 } 132 }
106 } 133 }
107 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 134 // 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)