comparison src/java/de/intevation/mxd/reader/ClassBreakRendererReader.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 0f5819732288
comparison
equal deleted inserted replaced
115:fb93f20478cc 116:c8a1361ddd38
9 import com.esri.arcgis.display.ISymbol; 9 import com.esri.arcgis.display.ISymbol;
10 10
11 import org.w3c.dom.Element; 11 import org.w3c.dom.Element;
12 12
13 import de.intevation.mxd.utils.MapToXMLUtils; 13 import de.intevation.mxd.utils.MapToXMLUtils;
14 import java.io.IOException;
14 15
15 /** 16 /**
16 * Reads the ClassBreaksRender Object Attributes. 17 * Reads the ClassBreaksRender Object Attributes.
17 * 18 *
18 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> 19 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
64 /** 65 /**
65 * Reads the Renderer attributes. 66 * Reads the Renderer attributes.
66 * 67 *
67 * @return The XML node. 68 * @return The XML node.
68 */ 69 */
69 public Element read() 70 public Element read() {
70 throws Exception {
71 logger.debug("read()"); 71 logger.debug("read()");
72 72
73 for(int i = 0; i < renderer.getBreakCount(); i++){ 73 int count = 0;
74 try {
75 count = renderer.getBreakCount();
76 }
77 catch(IOException ioe) {
78 logger.warn(
79 "No break symbols found in renderer." +
80 " Stopped reading this renderer.");
81 return layer;
82 }
83
84 for(int i = 0; i < count; i++){
74 Element rendererElement = util.addRenderer(layer); 85 Element rendererElement = util.addRenderer(layer);
75 rendererElement.setAttribute("value", 86 try {
76 String.valueOf(renderer.getBreak(i))); 87 rendererElement.setAttribute("value",
77 rendererElement.setAttribute( 88 String.valueOf(renderer.getBreak(i)));
78 "field_count", 89
79 String.valueOf(renderer.getFieldCount()));
80 for(int j = 0; j < renderer.getFieldCount(); j++) {
81 rendererElement.setAttribute( 90 rendererElement.setAttribute(
82 "expression_field_" + j, 91 "field_count",
83 renderer.getField(j)); 92 String.valueOf(renderer.getFieldCount()));
93 for(int j = 0; j < renderer.getFieldCount(); j++) {
94 rendererElement.setAttribute(
95 "expression_field_" + j,
96 renderer.getField(j));
84 97
98 }
99 rendererElement.setAttribute(
100 "min_value",
101 String.valueOf(renderer.getMinimumBreak()));
102 rendererElement.setAttribute("expression_operator", "<=");
103
104 ISymbol sym = renderer.getSymbol(i);
105 MarkerSymbolReader markerReader = new MarkerSymbolReader();
106 LineSymbolReader lineReader = new LineSymbolReader();
107 FillSymbolReader fillReader = new FillSymbolReader();
108 if(markerReader.canRead(sym)) {
109 markerReader.setSymbol(sym);
110 markerReader.setUtil(util);
111 markerReader.setParent(rendererElement);
112 markerReader.read();
113 }
114 else if(lineReader.canRead(sym)) {
115 lineReader.setSymbol(sym);
116 lineReader.setUtil(util);
117 lineReader.setParent(rendererElement);
118 lineReader.read();
119 }
120 else if(fillReader.canRead(sym)) {
121 fillReader.setSymbol(sym);
122 fillReader.setUtil(util);
123 fillReader.setParent(rendererElement);
124 fillReader.read();
125 }
126 else {
127 logger.debug("Not a known symbol type: " +
128 sym.getClass().toString());
129 }
85 } 130 }
86 rendererElement.setAttribute( 131 catch(Exception e) {
87 "min_value", 132 logger.error(
88 String.valueOf(renderer.getMinimumBreak())); 133 "Could not read data for " + i +
89 rendererElement.setAttribute("expression_operator", "<="); 134 ". break of renderer. Stopped reading this renderer.");
90 135 return layer;
91 ISymbol sym = renderer.getSymbol(i);
92 MarkerSymbolReader markerReader = new MarkerSymbolReader();
93 LineSymbolReader lineReader = new LineSymbolReader();
94 FillSymbolReader fillReader = new FillSymbolReader();
95 if(markerReader.canRead(sym)) {
96 markerReader.setSymbol(sym);
97 markerReader.setUtil(util);
98 markerReader.setParent(rendererElement);
99 markerReader.read();
100 }
101 else if(lineReader.canRead(sym)) {
102 lineReader.setSymbol(sym);
103 lineReader.setUtil(util);
104 lineReader.setParent(rendererElement);
105 lineReader.read();
106 }
107 else if(fillReader.canRead(sym)) {
108 fillReader.setSymbol(sym);
109 fillReader.setUtil(util);
110 fillReader.setParent(rendererElement);
111 fillReader.read();
112 }
113 else {
114 logger.debug("Not a known symbol type: " +
115 sym.getClass().toString());
116 } 136 }
117 } 137 }
118 return layer; 138 return layer;
119 } 139 }
120 } 140 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)