comparison src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java @ 74:7eba97e8201b

Catch all exceptions in the MXDReader.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 26 May 2011 18:11:29 +0200
parents acbe36fb45e0
children 59e06c405a9a
comparison
equal deleted inserted replaced
73:acbe36fb45e0 74:7eba97e8201b
1 package de.intevation.mxd.reader; 1 package de.intevation.mxd.reader;
2 2
3 import java.io.IOException; 3 import java.lang.Exception;
4 4
5 import org.apache.log4j.Logger; 5 import org.apache.log4j.Logger;
6 6
7 import com.esri.arcgis.carto.IFeatureRenderer; 7 import com.esri.arcgis.carto.IFeatureRenderer;
8 import com.esri.arcgis.carto.ClassBreaksRenderer; 8 import com.esri.arcgis.carto.ClassBreaksRenderer;
67 * Reads the Renderer attributes. 67 * Reads the Renderer attributes.
68 * 68 *
69 * @return The XML node. 69 * @return The XML node.
70 */ 70 */
71 public Element read() 71 public Element read()
72 throws IOException { 72 throws Exception {
73 logger.debug("read()"); 73 logger.debug("read()");
74 74
75 for(int i = 0; i < renderer.getBreakCount(); i++){ 75 for(int i = 0; i < renderer.getBreakCount(); i++){
76 Element rendererElement; 76 Element rendererElement = util.addRenderer(layer);
77 try { 77 rendererElement.setAttribute("value",
78 rendererElement = util.addRenderer(layer); 78 String.valueOf(renderer.getBreak(i)));
79 rendererElement.setAttribute("value", 79 rendererElement.setAttribute(
80 String.valueOf(renderer.getBreak(i))); 80 "field_count",
81 String.valueOf(renderer.getFieldCount()));
82 for(int j = 0; j < renderer.getFieldCount(); j++) {
81 rendererElement.setAttribute( 83 rendererElement.setAttribute(
82 "field_count", 84 "expression_field_" + j,
83 String.valueOf(renderer.getFieldCount())); 85 renderer.getField(j));
84 for(int j = 0; j < renderer.getFieldCount(); j++) {
85 rendererElement.setAttribute(
86 "expression_field_" + j,
87 renderer.getField(j));
88 86
89 } 87 }
90 rendererElement.setAttribute( 88 rendererElement.setAttribute(
91 "min_value", 89 "min_value",
92 String.valueOf(renderer.getMinimumBreak())); 90 String.valueOf(renderer.getMinimumBreak()));
93 rendererElement.setAttribute("expression_operator", "<="); 91 rendererElement.setAttribute("expression_operator", "<=");
94 92
95 ISymbol sym = renderer.getSymbol(i); 93 ISymbol sym = renderer.getSymbol(i);
96 MarkerSymbolReader markerReader = new MarkerSymbolReader(); 94 MarkerSymbolReader markerReader = new MarkerSymbolReader();
97 LineSymbolReader lineReader = new LineSymbolReader(); 95 LineSymbolReader lineReader = new LineSymbolReader();
98 FillSymbolReader fillReader = new FillSymbolReader(); 96 FillSymbolReader fillReader = new FillSymbolReader();
99 if(markerReader.canRead(sym)) { 97 if(markerReader.canRead(sym)) {
100 markerReader.setSymbol(sym); 98 markerReader.setSymbol(sym);
101 markerReader.setUtil(util); 99 markerReader.setUtil(util);
102 markerReader.setParent(rendererElement); 100 markerReader.setParent(rendererElement);
103 markerReader.read(); 101 markerReader.read();
104 }
105 else if(lineReader.canRead(sym)) {
106 lineReader.setSymbol(sym);
107 lineReader.setUtil(util);
108 lineReader.setParent(rendererElement);
109 lineReader.read();
110 }
111 else if(fillReader.canRead(sym)) {
112 fillReader.setSymbol(sym);
113 fillReader.setUtil(util);
114 fillReader.setParent(rendererElement);
115 fillReader.read();
116 }
117 else {
118 logger.debug("Not a known symbol type: " +
119 sym.getClass().toString());
120 }
121 } 102 }
122 catch(Exception e) { 103 else if(lineReader.canRead(sym)) {
123 e.printStackTrace(); 104 lineReader.setSymbol(sym);
124 return null; 105 lineReader.setUtil(util);
106 lineReader.setParent(rendererElement);
107 lineReader.read();
108 }
109 else if(fillReader.canRead(sym)) {
110 fillReader.setSymbol(sym);
111 fillReader.setUtil(util);
112 fillReader.setParent(rendererElement);
113 fillReader.read();
114 }
115 else {
116 logger.debug("Not a known symbol type: " +
117 sym.getClass().toString());
125 } 118 }
126 } 119 }
127 return layer; 120 return layer;
128 } 121 }
129 } 122 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)