Revision 10627 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/operations/strategies/DefaultStrategy.java

View differences:

DefaultStrategy.java
52 52
import org.apache.log4j.Logger;
53 53
import org.cresques.cts.ICoordTrans;
54 54

  
55
import com.iver.cit.gvsig.fmap.DriverException;
55
import com.hardcode.gdbms.driver.exceptions.InitializeDriverException;
56
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
57
import com.hardcode.gdbms.engine.data.driver.DriverException;
58
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException;
59
import com.iver.cit.gvsig.exceptions.visitors.StopVisitorException;
60
import com.iver.cit.gvsig.exceptions.visitors.VisitorException;
56 61
import com.iver.cit.gvsig.fmap.ViewPort;
57 62
import com.iver.cit.gvsig.fmap.core.IGeometry;
58 63
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
59 64
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes;
60
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
61 65
import com.iver.cit.gvsig.fmap.layers.FBitSet;
62 66
import com.iver.cit.gvsig.fmap.layers.FLayer;
63 67
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
......
104 108
	/**
105 109
	 * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByRect(java.awt.geom.Rectangle2D)
106 110
	 */
107
	public FBitSet queryByRect(Rectangle2D rect, CancellableMonitorable cancel) throws DriverException {
111
	public FBitSet queryByRect(Rectangle2D rect, CancellableMonitorable cancel) throws ReadDriverException, VisitorException {
108 112
		QueryByRectVisitor visitor = new QueryByRectVisitor();
109 113

  
110 114
		visitor.setRect(rect);
111

  
112
		try {
113
			process(visitor, cancel);
114
		} catch (VisitException e) {
115
			throw new RuntimeException(
116
				"QueryByRectVisitor lanza una VisitException?");
117
		}
118

  
115
		process(visitor, cancel);
119 116
		return visitor.getBitSet();
120 117
	}
121 118

  
......
124 121
	 * 		int)
125 122
	 */
126 123
	public FBitSet queryByShape(IGeometry g, int relationship, CancellableMonitorable cancel)
127
		throws DriverException, VisitException {
124
		throws ReadDriverException, VisitorException {
128 125
		QueryByGeometryVisitor visitor = new QueryByGeometryVisitor(g, relationship);
129 126
		process(visitor);
130 127

  
......
145 142
	}
146 143

  
147 144
	/**
145
	 * @throws ReadDriverException
148 146
	 * @see com.iver.cit.gvsig.fmap.operations.LayerOperations#draw(java.awt.image.BufferedImage,
149 147
	 * 		java.awt.Graphics2D, ISymbol)
150 148
	 */
151 149
	public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
152
		Cancellable cancel) throws DriverException {
150
		Cancellable cancel) throws ReadDriverException {
153 151
		try {
154 152
			ReadableVectorial adapter = ((SingleLayer) capa).getSource();
155 153
			ICoordTrans ct = getCapa().getCoordTrans();
......
242 240
			    }
243 241
			} */
244 242

  
245
		} catch (DriverIOException e) {
246
			throw new DriverException(e);
247
		} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
248
		    throw new DriverException(e);
249
		} catch (DriverException e) {
250
		    throw new DriverException(e);
251
        }
243
		} catch (ExpansionFileReadException e) {
244
			throw new ReadDriverException(getCapa().getName(),e);
245
		} catch (InitializeDriverException e) {
246
			throw new ReadDriverException(getCapa().getName(),e);
247
		}
252 248
	}
253 249

  
254 250

  
......
262 258
	}
263 259

  
264 260
	/**
261
	 * @throws ExpansionFileReadException
265 262
	 * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#process(com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor,
266 263
	 * 		java.util.BitSet)
267 264
	 */
268 265
	public void process(FeatureVisitor visitor, BitSet subset)
269
		throws DriverException, VisitException {
266
		throws ReadDriverException, ExpansionFileReadException, VisitorException {
270 267
		process(visitor, subset, null);
271 268
	}
272 269

  
......
274 271
	 * DOCUMENT ME!
275 272
	 *
276 273
	 * @param visitor DOCUMENT ME!
277
	 *
278
	 * @throws DriverException DOCUMENT ME!
279
	 * @throws VisitException
280
	 *
281 274
	 * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#process(com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor)
282 275
	 */
283 276
	public void process(FeatureVisitor visitor)
284
		throws DriverException, VisitException {
277
		throws ReadDriverException, VisitorException {
285 278
		process(visitor, (CancellableMonitorable)null);
286 279
	}
287 280

  
......
290 283
	 * 		double)
291 284
	 */
292 285
	public FBitSet queryByPoint(Point2D p, double tolerance, CancellableMonitorable cancel)
293
		throws DriverException {
286
		throws ReadDriverException, VisitorException {
294 287
        // TODO: OJO!!!!. Est? implementado como un rectangulo.
295 288
        // Lo correcto deber?a ser calculando las distancias reales
296 289
        // es decir, con un c?rculo.
......
303 296
	 * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#print(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort)
304 297
	 */
305 298
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, PrintRequestAttributeSet properties)
306
		throws DriverException {
299
		throws ReadDriverException {
307 300
		if (capa instanceof FLyrVect) {
308 301
			((FLyrVect)capa).beforePrinting(properties);
309 302
			draw(null, g, viewPort, cancel); // Quiero ejecutar el draw del padre, que es el que va sin acelaraci?n!!
......
313 306
		}
314 307
	}
315 308

  
316
	public void process(FeatureVisitor visitor, Rectangle2D rectangle) throws DriverException, VisitException {
309
	public void process(FeatureVisitor visitor, Rectangle2D rectangle) throws ReadDriverException, ExpansionFileReadException, VisitorException {
317 310
		process(visitor, rectangle, null);
318 311
	}
319 312

  
......
325 318
	 * @param va
326 319
	 * @param visitor
327 320
	 * @return
328
	 * @throws DriverIOException
329 321
	 */
330
	protected boolean verifyCancelation(Cancellable cancel, ReadableVectorial va, FeatureVisitor visitor) throws DriverIOException{
322
	protected boolean verifyCancelation(Cancellable cancel, ReadableVectorial va, FeatureVisitor visitor){
331 323
		if(cancel != null){
332 324
			if(cancel.isCanceled()){
333
				va.stop();
334
				visitor.stop(capa);
325
				try {
326
					va.stop();
327
					visitor.stop(capa);
328
				} catch (VisitorException e) {
329
					return false;
330
				} catch (ReadDriverException e) {
331
					return false;
332
				}
335 333
//				logger.info("visitor canceled");
336 334
				return true;
337 335
			}
......
339 337
		return false;
340 338
	}
341 339

  
342
	public void process(FeatureVisitor visitor, BitSet subset, CancellableMonitorable cancel) throws DriverException, VisitException {
343
		try {
340
	public void process(FeatureVisitor visitor, BitSet subset, CancellableMonitorable cancel) throws ReadDriverException, ExpansionFileReadException, VisitorException {
341
//		try {
344 342
//			logger.info("visitor.start()");
345 343

  
346 344
			if (visitor.start(capa)) {
347 345
				ReadableVectorial va = ((SingleLayer) capa).getSource();
348
				va.start();
346
				try {
347
					va.start();
348
				} catch (InitializeDriverException e) {
349
					throw new ReadDriverException(getCapa().getName(),e);
350
				}
349 351
				for (int i = 0; i < va.getShapeCount(); i++) {
350 352

  
351 353
					if(verifyCancelation(cancel, va, visitor))
......
362 364
//				logger.info("visitor.stop()");
363 365
				visitor.stop(capa);
364 366
			}
365
		} catch (DriverIOException e) {
366
			throw new DriverException(e);
367
		}
367
//		} catch (ExpansionFileReadException e) {
368
//			throw new ReadDriverException();
369
//		}
368 370
	}
369 371

  
370
	public void process(FeatureVisitor visitor, CancellableMonitorable cancel) throws DriverException, VisitException {
372
	public void process(FeatureVisitor visitor, CancellableMonitorable cancel) throws ReadDriverException, VisitorException {
371 373
		try {
372 374
//			logger.info("visitor.start()");
373 375

  
......
392 394
//				logger.info("visitor.stop()");
393 395
				visitor.stop(capa);
394 396
			}
395
		} catch (DriverIOException e) {
396
			throw new DriverException(e);
397
		} catch (ExpansionFileReadException e) {
398
			throw new ReadDriverException(getCapa().getName(),e);
399
		} catch (InitializeDriverException e) {
400
			throw new ReadDriverException(getCapa().getName(),e);
397 401
		}
398 402
	}
399 403

  
400
	public void process(FeatureVisitor visitor, Rectangle2D rectangle, CancellableMonitorable cancel) throws DriverException, VisitException {
404
	public void process(FeatureVisitor visitor, Rectangle2D rectangle, CancellableMonitorable cancel) throws ReadDriverException, ExpansionFileReadException, VisitorException {
401 405
		FilterRectVisitor filterVisitor = new FilterRectVisitor();
402 406
		filterVisitor.setRectangle(rectangle);
403 407
		filterVisitor.setWrappedVisitor(visitor);
404
		try {
405
			process(filterVisitor, cancel);
406
		} catch (VisitException e) {
407
			throw new RuntimeException(
408
				"process(visitor,rectangle) lanza una VisitException?");
409
		}
408
		process(filterVisitor, cancel);
410 409
	}
411 410

  
412
	public FBitSet queryByPoint(Point2D p, double tolerance) throws DriverException {
411
	public FBitSet queryByPoint(Point2D p, double tolerance) throws ReadDriverException, VisitorException {
413 412
		return queryByPoint(p, tolerance, null);
414 413
	}
415 414

  
416
	public FBitSet queryByRect(Rectangle2D rect) throws DriverException {
415
	public FBitSet queryByRect(Rectangle2D rect) throws ReadDriverException, VisitorException {
417 416
		return queryByRect(rect, null);
418 417
	}
419 418

  
420
	public FBitSet queryByShape(IGeometry g, int relationship) throws DriverException, VisitException {
419
	public FBitSet queryByShape(IGeometry g, int relationship) throws ReadDriverException, VisitorException {
421 420
		return queryByShape(g, relationship, null);
422 421
	}
423 422

  
......
430 429
	 * Else, a secuential scan would be better
431 430
	 * @param rectangle
432 431
	 * @return
432
	 * @throws ExpansionFileReadException
433 433
	 * @throws DriverException
434 434
	 */
435
	protected boolean isSpatialIndexNecessary(Rectangle2D extent) throws DriverException {
435
	protected boolean isSpatialIndexNecessary(Rectangle2D extent) throws ReadDriverException, ExpansionFileReadException {
436 436
		FLyrVect lyr = (FLyrVect) getCapa();
437 437
		double areaExtent = extent.getWidth() * extent.getHeight();
438 438
		double areaFullExtent = lyr.getFullExtent().getWidth() *

Also available in: Unified diff