comparison src/java/de/intevation/mxd/reader/MXDReader.java @ 313:9bb629743d2c

Remove uneccessary else and indention
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 14 Sep 2012 17:03:54 +0200
parents 503d3a453a04
children 1d77ea6a915d
comparison
equal deleted inserted replaced
312:503d3a453a04 313:9bb629743d2c
137 throws Exception { 137 throws Exception {
138 logger.debug("read()"); 138 logger.debug("read()");
139 if(filename.isEmpty()) { 139 if(filename.isEmpty()) {
140 throw new IOException("Please set filename!"); 140 throw new IOException("Please set filename!");
141 } 141 }
142 else { 142 util.addFilename(filename);
143 util.addFilename(filename); 143 openMapDocument();
144 openMapDocument(); 144 MapReader mreader;
145 MapReader mreader; 145 try {
146 mreader = new MapReader (map);
147 mreader.setUtil(util);
148 mreader.read();
149
150 }
151 catch(Exception e) {
152 throw e;
153 }
154
155 for(int i = 0; i < map.getLayerCount();i++) {
156 ILayer layer = map.getLayer(i);
146 try { 157 try {
147 mreader = new MapReader (map); 158 if (layer instanceof FeatureLayer) {
148 mreader.setUtil(util); 159 FeatureLayerReader lr = new FeatureLayerReader(layer);
149 mreader.read(); 160 lr.setUtil(util);
150 161 Element layerElement = lr.read();
162 if (layerElement == null) {
163 continue;
164 }
165 IFeatureRenderer renderer =
166 ((FeatureLayer)layer).getRenderer();
167 IRendererReader rreader;
168 if(renderer instanceof SimpleRenderer) {
169 rreader = new SimpleRendererReader(renderer);
170 rreader.setParent(layerElement);
171 rreader.setUtil(util);
172 rreader.read();
173 }
174 else if(renderer instanceof ClassBreaksRenderer) {
175 rreader = new ClassBreakRendererReader(renderer);
176 rreader.setParent(layerElement);
177 rreader.setUtil(util);
178 rreader.read();
179 }
180 else if(renderer instanceof UniqueValueRenderer) {
181 rreader = new UniqueValueRendererReader(renderer);
182 rreader.setParent(layerElement);
183 rreader.setUtil(util);
184 rreader.read();
185 }
186 else{
187 logger.debug("Not a known renderer type " +
188 renderer.getClass().toString());
189 }
190 }
191 else if(layer instanceof GdbRasterCatalogLayer) {
192 GdbRasterCatalogLayerReader gclr =
193 new GdbRasterCatalogLayerReader(layer);
194 gclr.setUtil(util);
195 Element layerElement = gclr.read();
196 IFeatureRenderer renderer =
197 ((GdbRasterCatalogLayer)layer).getRenderer();
198 IRendererReader rreader;
199 if(renderer instanceof SimpleRenderer) {
200 rreader = new SimpleRendererReader(renderer);
201 rreader.setParent(layerElement);
202 rreader.setUtil(util);
203 rreader.read();
204 }
205 else if(renderer instanceof ClassBreaksRenderer) {
206 rreader = new ClassBreakRendererReader(renderer);
207 rreader.setParent(layerElement);
208 rreader.setUtil(util);
209 rreader.read();
210 }
211 else if(renderer instanceof UniqueValueRenderer) {
212 rreader = new UniqueValueRendererReader(renderer);
213 rreader.setParent(layerElement);
214 rreader.setUtil(util);
215 rreader.read();
216 }
217 else {
218 logger.debug("Not a known renderer type " +
219 renderer.getClass().toString());
220 }
221 }
222 else if(layer instanceof GroupLayer) {
223 GroupLayerReader gl = new GroupLayerReader(layer);
224 gl.setUtil(util);
225 Element layerElement = gl.read("");
226 if(layerElement == null) {
227 throw new IOException ("Error reading grouplayer.");
228 }
229 }
230 else if(layer instanceof WMSMapLayer) {
231 WMSMapLayerReader lr = new WMSMapLayerReader(layer);
232 lr.setUtil(util);
233 Element layerElement = lr.read("");
234 if(layerElement == null) {
235 throw new IOException ("Error reading WMSMapLayer.");
236 }
237 }
238 else if(layer instanceof WMSGroupLayer) {
239 WMSGroupLayerReader lr = new WMSGroupLayerReader(layer);
240 lr.setUtil(util);
241 Element layerElement = lr.read("");
242 if(layerElement == null) {
243 throw new IOException ("Error reading WMSGrouplayer.");
244 }
245 }
246 else if(layer instanceof WMSLayer) {
247 WMSLayerReader lr = new WMSLayerReader(layer);
248 lr.setUtil(util);
249 Element layerElement = lr.read();
250 if(layerElement == null) {
251 throw new IOException ("Error reading WMSlayer.");
252 }
253 }
254 else if(layer instanceof RasterLayer) {
255 RasterLayerReader lr =
256 new RasterLayerReader(layer);
257 lr.setUtil(util);
258 Element layerElement = lr.read();
259 if(layerElement == null) {
260 throw new IOException ("Error reading RasterLayer.");
261 }
262 /* TODO implement support for classes in Raster Layers
263 IRasterRenderer renderer =
264 ((RasterLayer)layer).getRenderer();
265 IRendererReader rreader;
266 if(renderer instanceof SimpleRenderer) {
267 rreader = new SimpleRendererReader(renderer);
268 rreader.setParent(layerElement);
269 rreader.setUtil(util);
270 rreader.read();
271 }
272 else if(renderer instanceof ClassBreaksRenderer) {
273 rreader = new ClassBreakRendererReader(renderer);
274 rreader.setParent(layerElement);
275 rreader.setUtil(util);
276 rreader.read();
277 }
278 else if(renderer instanceof UniqueValueRenderer) {
279 rreader = new UniqueValueRendererReader(renderer);
280 rreader.setParent(layerElement);
281 rreader.setUtil(util);
282 rreader.read();
283 }
284 else {
285 logger.debug("Not a known renderer type " +
286 renderer.getClass().toString());
287 }
288 */
289 }
290 else {
291 logger.info(
292 "Layertype not known: " +
293 layer.getClass().toString());
294 }
151 } 295 }
152 catch(Exception e) { 296 catch(Exception e) {
153 throw e; 297 invalidLayerCount++;
154 } 298 if(i == 0 && (i + 1) == map.getLayerCount() ||
155 299 invalidLayerCount == map.getLayerCount()) {
156 for(int i = 0; i < map.getLayerCount();i++) { 300 throw new IOException(
157 ILayer layer = map.getLayer(i); 301 "No valid layer in MXD file." +
158 try { 302 " Aborting.");
159 if (layer instanceof FeatureLayer) {
160 FeatureLayerReader lr = new FeatureLayerReader(layer);
161 lr.setUtil(util);
162 Element layerElement = lr.read();
163 if (layerElement == null) {
164 continue;
165 }
166 IFeatureRenderer renderer =
167 ((FeatureLayer)layer).getRenderer();
168 IRendererReader rreader;
169 if(renderer instanceof SimpleRenderer) {
170 rreader = new SimpleRendererReader(renderer);
171 rreader.setParent(layerElement);
172 rreader.setUtil(util);
173 rreader.read();
174 }
175 else if(renderer instanceof ClassBreaksRenderer) {
176 rreader = new ClassBreakRendererReader(renderer);
177 rreader.setParent(layerElement);
178 rreader.setUtil(util);
179 rreader.read();
180 }
181 else if(renderer instanceof UniqueValueRenderer) {
182 rreader = new UniqueValueRendererReader(renderer);
183 rreader.setParent(layerElement);
184 rreader.setUtil(util);
185 rreader.read();
186 }
187 else{
188 logger.debug("Not a known renderer type " +
189 renderer.getClass().toString());
190 }
191 }
192 else if(layer instanceof GdbRasterCatalogLayer) {
193 GdbRasterCatalogLayerReader gclr =
194 new GdbRasterCatalogLayerReader(layer);
195 gclr.setUtil(util);
196 Element layerElement = gclr.read();
197 IFeatureRenderer renderer =
198 ((GdbRasterCatalogLayer)layer).getRenderer();
199 IRendererReader rreader;
200 if(renderer instanceof SimpleRenderer) {
201 rreader = new SimpleRendererReader(renderer);
202 rreader.setParent(layerElement);
203 rreader.setUtil(util);
204 rreader.read();
205 }
206 else if(renderer instanceof ClassBreaksRenderer) {
207 rreader = new ClassBreakRendererReader(renderer);
208 rreader.setParent(layerElement);
209 rreader.setUtil(util);
210 rreader.read();
211 }
212 else if(renderer instanceof UniqueValueRenderer) {
213 rreader = new UniqueValueRendererReader(renderer);
214 rreader.setParent(layerElement);
215 rreader.setUtil(util);
216 rreader.read();
217 }
218 else {
219 logger.debug("Not a known renderer type " +
220 renderer.getClass().toString());
221 }
222 }
223 else if(layer instanceof GroupLayer) {
224 GroupLayerReader gl = new GroupLayerReader(layer);
225 gl.setUtil(util);
226 Element layerElement = gl.read("");
227 if(layerElement == null) {
228 throw new IOException ("Error reading grouplayer.");
229 }
230 }
231 else if(layer instanceof WMSMapLayer) {
232 WMSMapLayerReader lr = new WMSMapLayerReader(layer);
233 lr.setUtil(util);
234 Element layerElement = lr.read("");
235 if(layerElement == null) {
236 throw new IOException ("Error reading WMSMapLayer.");
237 }
238 }
239 else if(layer instanceof WMSGroupLayer) {
240 WMSGroupLayerReader lr = new WMSGroupLayerReader(layer);
241 lr.setUtil(util);
242 Element layerElement = lr.read("");
243 if(layerElement == null) {
244 throw new IOException ("Error reading WMSGrouplayer.");
245 }
246 }
247 else if(layer instanceof WMSLayer) {
248 WMSLayerReader lr = new WMSLayerReader(layer);
249 lr.setUtil(util);
250 Element layerElement = lr.read();
251 if(layerElement == null) {
252 throw new IOException ("Error reading WMSlayer.");
253 }
254 }
255 else if(layer instanceof RasterLayer) {
256 RasterLayerReader lr =
257 new RasterLayerReader(layer);
258 lr.setUtil(util);
259 Element layerElement = lr.read();
260 if(layerElement == null) {
261 throw new IOException ("Error reading RasterLayer.");
262 }
263 /* TODO implement support for classes in Raster Layers
264 IRasterRenderer renderer =
265 ((RasterLayer)layer).getRenderer();
266 IRendererReader rreader;
267 if(renderer instanceof SimpleRenderer) {
268 rreader = new SimpleRendererReader(renderer);
269 rreader.setParent(layerElement);
270 rreader.setUtil(util);
271 rreader.read();
272 }
273 else if(renderer instanceof ClassBreaksRenderer) {
274 rreader = new ClassBreakRendererReader(renderer);
275 rreader.setParent(layerElement);
276 rreader.setUtil(util);
277 rreader.read();
278 }
279 else if(renderer instanceof UniqueValueRenderer) {
280 rreader = new UniqueValueRendererReader(renderer);
281 rreader.setParent(layerElement);
282 rreader.setUtil(util);
283 rreader.read();
284 }
285 else {
286 logger.debug("Not a known renderer type " +
287 renderer.getClass().toString());
288 }
289 */
290 }
291 else {
292 logger.info(
293 "Layertype not known: " +
294 layer.getClass().toString());
295 }
296 }
297 catch(Exception e) {
298 invalidLayerCount++;
299 if(i == 0 && (i + 1) == map.getLayerCount() ||
300 invalidLayerCount == map.getLayerCount()) {
301 throw new IOException(
302 "No valid layer in MXD file." +
303 " Aborting.");
304 }
305 } 303 }
306 } 304 }
307 } 305 }
308 return true; 306 return true;
309 } 307 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)