Revision 4419 trunk/extensions/extGeoProcessing/src/com/iver/gvsig/geoprocessing/impl/buffer/BufferGeoprocess.java

View differences:

BufferGeoprocess.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.10  2006-03-14 18:32:46  fjp
48
* Revision 1.11  2006-03-14 19:35:13  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.10  2006/03/14 18:32:46  fjp
49 52
* Cambio con LayerDefinition para que sea compatible con la definici?n de tablas tambi?n.
50 53
*
51 54
* Revision 1.9  2006/03/07 21:01:33  azabala
......
89 92
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition;
90 93
import com.iver.cit.gvsig.fmap.drivers.LayerDefinition;
91 94
import com.iver.cit.gvsig.fmap.drivers.SHPLayerDefinition;
95
import com.iver.cit.gvsig.fmap.layers.FBitSet;
92 96
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
97
import com.iver.cit.gvsig.fmap.operations.CancellableMonitorable;
98
import com.iver.cit.gvsig.fmap.operations.DefaultCancellableMonitorable;
93 99
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy;
94 100
import com.iver.cit.gvsig.fmap.operations.strategies.StrategyManager;
95 101
import com.iver.gvsig.geoprocessing.impl.AbstractGeoprocess;
96 102
import com.iver.gvsig.geoprocessing.model.GeoprocessException;
97 103
import com.iver.gvsig.geoprocessing.model.IOneLayerGeoprocess;
98 104
import com.iver.gvsig.geoprocessing.schemabuilder.XTypes;
99
import com.iver.utiles.swing.threads.BackgroundExecution;
100
import com.iver.utiles.swing.threads.CancelableTask;
101
import com.iver.utiles.swing.threads.MonitorableTask;
105
import com.iver.utiles.swing.threads.IMonitorableTask;
102 106
/**
103 107
 * Geoprocess that computes a buffer area around each
104 108
 * feature's geometry of the input layer.
......
222 226
	/**
223 227
	 * Computes buffer geoprocess, and saves results in
224 228
	 * solution layer.
225
	 * 
226
	 * TODO Hay que incluir una condicion de parada (del tipo while(notCancel)
227
	 * para permitir que el usuario pueda parar esto
228 229
	 */
229 230
	public void process() throws GeoprocessException{
230 231
			BufferComputeStrategy bufferStrategy = 
......
285 286
		}
286 287
		return resultLayerDefinition;
287 288
	}
288
/*
289
	public CancelableTask createTask() {
290
		return new MonitorableTask(){
291

  
292
			public int getInitialStep() {
293
				return 0;
294
			}
295

  
296
			public int getFinishStep() {
289
	
290
	private DefaultCancellableMonitorable createCancelMonitor(){
291
		DefaultCancellableMonitorable monitor 
292
			= new DefaultCancellableMonitorable();
293
		monitor.setInitialStep(0);
294
		if(!dissolveBuffers){
295
			//if we dont look for adjacents, is a determinated
296
			//task (we know how many steps we are going to do
297
			monitor.setDeterminatedProcess(true);
298
			if(this.bufferOnlySelection){
299
				FBitSet selection = firstLayer.
300
					getRecordset().
301
					getSelection();
302
				int numSelected = selection.cardinality();
303
				monitor.setFinalStep(numSelected);
304
			}else{
297 305
				try {
298
					return firstLayer.getSource().getShapeCount();
306
					monitor.setFinalStep(firstLayer.getSource().getShapeCount());
299 307
				} catch (DriverIOException e) {
300
					return 0;
308
					e.printStackTrace();
301 309
				}
302 310
			}
311
		}else{
312
			monitor.setDeterminatedProcess(false);
313
		}//if dissolvebuffer
314
		return monitor;
315
	}
316
	
317
	
318
	
319
	public IMonitorableTask createTask() {
320
			final CancellableMonitorable cancelMonitor = 
321
				createCancelMonitor();
322
			
323
			return new IMonitorableTask(){
324
				private boolean finished = false;
325
				public int getInitialStep() {
326
					return cancelMonitor.getInitialStep();
327
				}
303 328

  
304
			public int getCurrentStep() {
305
				
306
			}
329
				public int getFinishStep() {
330
					return cancelMonitor.getFinalStep();
331
				}
307 332

  
308
			public String getStatusMessage() {
309
				// TODO Auto-generated method stub
310
				return null;
311
			}
333
				public int getCurrentStep() {
334
					return cancelMonitor.getCurrentStep();
335
				}
312 336

  
313
			public String getNote() {
314
				// TODO Auto-generated method stub
315
				return null;
316
			}
337
				public String getStatusMessage() {
338
					//FIXME Cambiar esto por un mecanismo de eventos,
339
					//de forma que la tarea lo que tenga sea un escuchador
340
					//que cambie el mensaje de estado segun los eventos
341
					//de tareas que se est?n realizando
342
					return "Computing buffers...";
343
				}
317 344

  
318
			public void cancel() {
319
				// TODO Auto-generated method stub
320
				
321
			}
345
				public String getNote() {
346
//					FIXME Cambiar esto por un mecanismo de eventos,
347
					//de forma que la tarea lo que tenga sea un escuchador
348
					//que cambie el mensaje de estado segun los eventos
349
					//de tareas que se est?n realizando
350
					return "Processing individual features: " +
351
					getCurrentStep()+ 
352
					" de "+
353
					getFinishStep();
354
				}
322 355

  
323
			public void run() {
324
				// TODO Auto-generated method stub
356
				public void cancel() {
357
					((DefaultCancellableMonitorable)cancelMonitor).
358
					setCanceled(true);
359
				}
360

  
361
				public void run() {
362
					try {
363
						
364
						BufferComputeStrategy bufferStrategy = 
365
							createBufferStrategy();
366
						bufferStrategy.setCancelMonitor(cancelMonitor);
367
						bufferStrategy.computeBuffers();
368
						finished = true;
369
					} catch (GeoprocessException e) {
370
						e.printStackTrace();
371
					}
372
				}
325 373
				
326
			}
374
				public boolean isDefined(){
375
					return cancelMonitor.isDeterminatedProcess();
376
				}
327 377

  
328
			public boolean isCanceled() {
329
				// TODO Auto-generated method stub
330
				return false;
331
			}
378
				public boolean isCanceled() {
379
					return cancelMonitor.isCanceled();
380
				}
332 381

  
333
			public boolean isFinished() {
334
				// TODO Auto-generated method stub
335
				return false;
336
			}};
337
	}
338
	*/
382
				public boolean isFinished() {
383
					return finished;
384
				}};
385
		}
339 386
}
340 387

  
341 388

  

Also available in: Unified diff