Revision 288

View differences:

org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.buffer/src/main/java/org/gvsig/geoprocess/algorithm/buffer/BufferAlgorithm.java
172 172
            operation.setTypeOfCap(round_border ? BufferOperation.CAP_ROUND
173 173
                : BufferOperation.CAP_SQUARE);
174 174
            operation.setNumberOfRadialBuffers(rings + 1);
175

  
175
            operation.setGeoProcess(this, 100);
176
            
176 177
        	// Builds the output FeatureStore
177 178
        	FeatureStore outFeatStore =
178 179
        		buildOutPutStore(featureType,
......
198 199

  
199 200
            		outAuxFeatStore = open(file, storeLayer.getDefaultFeatureType().getDefaultSRS());
200 201
            		FuseSpatiallyAlgorithm alg = new FuseSpatiallyAlgorithm();
202
            		alg.setTaskMonitor(m_Task);
203
            		alg.setParentProcess(this);
204
            		m_Task.setProgressText(getTranslation("fuse_spatially"));
201 205
            		alg.execute(outAuxFeatStore, outFeatStore, IVectorLayer.SHAPE_TYPE_POLYGON, 
202 206
            				false, getStatus(), "FID", false);
203 207
            	} catch (ValidateDataParametersException e) {
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.buffer/src/main/resources/org/gvsig/geoprocess/algorithm/buffer/buffer.properties
40 40
area_field=?rea definida por un campo 
41 41
area_distance=?rea definida por una distancia
42 42
file_exists=El fichero de salida existe
43
Dissolve_entities=Disolver entidades
43
Dissolve_entities=Disolver entidades (solo un anillo)
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.buffer/src/main/resources/org/gvsig/geoprocess/algorithm/buffer/buffer_en.properties
40 40
area_field=Area defined by a field 
41 41
area_distance=Area defined by a distance
42 42
file_exists=The output file exists
43
Dissolve_entities=Dissolve entities
43
Dissolve_entities=Dissolve entities (only one ring)
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.base/src/main/java/org/gvsig/geoprocess/algorithm/base/core/GeometryOperation.java
35 35
import org.gvsig.fmap.dal.feature.FeatureSet;
36 36
import org.gvsig.fmap.dal.feature.FeatureStore;
37 37
import org.gvsig.geoprocess.core.IProgressModel;
38
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess;
38 39
import org.gvsig.tools.dispose.DisposableIterator;
39 40
import org.gvsig.tools.task.SimpleTaskStatus;
40 41

  
......
43 44
 *  
44 45
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
45 46
 */
47
@SuppressWarnings("deprecation")
46 48
public abstract class GeometryOperation {
47 49
	protected DALFeaturePersister              persister          = null;
48 50
	protected FeatureStore                     inFeatureStore     = null;
......
50 52
	protected boolean                          selectedGeom       = false;
51 53
	protected int                              numberOfFeatures   = 0;
52 54
	protected EditableFeature                  lastEditFeature    = null;
53
    protected SimpleTaskStatus status;
55
    protected SimpleTaskStatus                 status             = null;
56
    protected AbstractSextanteGeoProcess       process            = null;
57
    protected int                              procesSize         = 0;
54 58
	
55 59
	/**
56 60
	 * Invokes this operation and returns an EditableFeature
......
97 101
	 *        If it is true only the selected geometries will be processed
98 102
	 * @throws DataException
99 103
	 */
100
	@SuppressWarnings("unchecked")
104
	@SuppressWarnings({ "unchecked" })
101 105
	public void computesGeometryOperation(FeatureStore inFeatStore,
102 106
									FeatureStore outFeatStore,
103 107
									String[] attrNames,
......
119 123
		
120 124
		it = featuresSet.iterator();
121 125
		numberOfFeatures = (int)featuresSet.getSize();
122
        if (status != null) {
126
        if (status != null && process != null) {
123 127
            status.setRangeOfValues(0, numberOfFeatures);
128
            process.setProgress(0, numberOfFeatures);
124 129
        }
125 130
		
126 131
		int iCount = 0;
127
		while( it.hasNext() ) {
132
		while( it.hasNext() && !process.getTaskMonitor().isCanceled()) {
128 133
			Feature feature = (Feature)it.next();
129 134
			List geomList = feature.getGeometries();
130 135
			
131
            if (status != null) {
136
            if (status != null && process != null) {
132 137
                status.setCurValue(iCount);
138
                process.setProgress(iCount, numberOfFeatures);
133 139
            }
134 140
			iCount ++;
135 141
			
......
142 148
			Iterator<org.gvsig.fmap.geom.Geometry> itGeom = geomList.iterator();
143 149
			boolean first = true;
144 150
			EditableFeature editFeat = null;
145
			while(itGeom.hasNext()) {
151
			while(itGeom.hasNext() && !process.getTaskMonitor().isCanceled()) {
146 152
				org.gvsig.fmap.geom.Geometry g = itGeom.next();
147 153
				if(first) {
148 154
					editFeat = invoke(g, feature);
......
190 196
			it = featuresSet.iterator();
191 197
		numberOfFeatures = (int)featuresSet.getSize();
192 198

  
193
        if (status != null) {
199
		if (status != null && process != null) {
194 200
            status.setRangeOfValues(0, numberOfFeatures);
201
            process.setProgress(0, numberOfFeatures);
195 202
        }
196 203
		
197 204
		int iCount = 0;
198
		while( it.hasNext() ) {
205
		while( it.hasNext() && !process.getTaskMonitor().isCanceled()) {
199 206
			Feature feature = (Feature)it.next();
200 207
			invoke(null, feature);
201
            if (status != null) {
202
                status.setCurValue(iCount);
203
            }
208
			if (status != null && process != null) {
209
				status.setCurValue(iCount);
210
				process.setProgress(iCount, numberOfFeatures);
211
			}
204 212
			iCount ++;
205 213
		}
206 214
		
......
228 236
									boolean closeOutStore) throws DataException {
229 237
		this.inFeatureStoreList = inFeatStoreList;
230 238
		
231
        if (status != null) {
239
		if (status != null && process != null) {
232 240
            status.setRangeOfValues(0, inFeatStoreList.size());
233
		}
241
            process.setProgress(0, inFeatStoreList.size());
242
        }
234 243

  
235 244
		int iCount = 0;
236 245
		for (int i = 0; i < inFeatStoreList.size(); i++) {
237
            if (status != null) {
238
                status.setCurValue(iCount);
239
            }
246
			if (status != null && process != null) {
247
				status.setCurValue(iCount);
248
				process.setProgress(iCount, numberOfFeatures);
249
			}
240 250
			iCount ++;
241 251
			computesGeometryOperation(inFeatStoreList.get(i), 
242 252
										i == 0 ? outFeatStore : null, 
243 253
										attrNames, 
244 254
										selectedGeom, 
245 255
										false);
256
			if(process.getTaskMonitor().isCanceled())
257
				return;
246 258
		}
247 259
		
248 260
        if (closeOutStore && persister != null) {
......
268 280
    public void setTaskStatus(SimpleTaskStatus status) {
269 281
        this.status = status;
270 282
    }
283
    
284
    public void setGeoProcess(AbstractSextanteGeoProcess geoprocess, int size) {
285
		this.process = geoprocess;
286
		this.procesSize = size;
287
	}
271 288

  
272 289
}
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.fusespatially/src/main/java/org/gvsig/geoprocess/algorithm/fusespatially/FuseSpatiallyAlgorithm.java
63 63
 */
64 64
public class FuseSpatiallyAlgorithm extends AbstractSextanteGeoProcess {
65 65

  
66
	public static final String        RESULT            = "RESULT";
67
	public static final String        RESULT_TABLE      = "RESULT_TABLE";
68
	public static final String        LAYER             = "LAYER";
69
	public static final String        SELECTED_GEOM     = "SELECTED_GEOM";
66
	public static final String         RESULT            = "RESULT";
67
	public static final String         RESULT_TABLE      = "RESULT_TABLE";
68
	public static final String         LAYER             = "LAYER";
69
	public static final String         SELECTED_GEOM     = "SELECTED_GEOM";
70
	private AbstractSextanteGeoProcess process           = null;
70 71

  
71 72
	/*
72 73
	 * (non-Javadoc)
......
86 87
		}
87 88
	}
88 89
	
90
	public void setParentProcess(AbstractSextanteGeoProcess process) {
91
		this.process = process;
92
	}
93
	
89 94
	/*
90 95
	 * (non-Javadoc)
91 96
	 * @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm()
......
211 216
	}
212 217
	
213 218
	public boolean setProgress(int step, int size) {
214
		return super.setProgress(step, size);
219
		if(process != null)
220
			return process.setProgress(step, size);
221
		else
222
			return super.setProgress(step, size);
215 223
	}
216 224
	
217 225
	/**
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.fusespatially/src/main/java/org/gvsig/geoprocess/algorithm/fusespatially/FuseSpatiallyOperation.java
59 59
import org.gvsig.geoprocess.algorithm.base.core.DALFeaturePersister;
60 60
import org.gvsig.geoprocess.algorithm.base.core.GeometryOperation;
61 61
import org.gvsig.geoprocess.algorithm.base.util.GeometryUtil;
62
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess;
63 62

  
64 63
import com.vividsolutions.jts.geom.Geometry;
65 64
/**
......
72 71
	private List<Feature>                    featList              = null;
73 72
	private FeatureStore                     outFeatureStoreTable  = null;
74 73
	private String                           idField               = "FID";
75
	private AbstractSextanteGeoProcess       geoprocess            = null;
76
	private int                              procesSize           = 0;
77 74
	
78 75
	public FuseSpatiallyOperation(List<Feature> f, FeatureStore outFeatStoreTable, String[] fieldNames, String idField) throws DataException {
79 76
		this.featList = f;
......
86 83
		this.outFeatureStoreTable = outFeatStoreTable;
87 84
	}
88 85
	
89
	public void setGeoProcess(AbstractSextanteGeoProcess geoprocess, int size) {
90
		this.geoprocess = geoprocess;
91
		this.procesSize = size;
92
	}
93

  
94 86
	/*
95 87
	 * (non-Javadoc)
96 88
	 * @see org.gvsig.geoprocess.algorithm.base.core.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.dal.feature.Feature)
......
101 93
			insertInTable(feature);
102 94
			
103 95
			int cont = featList.size() - 1;
104
			while(cont >= 0 && !geoprocess.getTaskMonitor().isCanceled()) {
96
			while(cont >= 0 && !process.getTaskMonitor().isCanceled()) {
105 97
				Feature f = featList.get(cont);
106 98
				g = f.getDefaultGeometry();
107 99
				Geometry jtsGeom = GeometryUtil.geomToJTS(g); //Multigeometry support
108 100
				if(jtsGeom.intersects(jtsInputGeom)) {
109 101
					jtsInputGeom = jtsInputGeom.union(jtsGeom);
110 102
					featList.remove(cont);
111
					geoprocess.setProgress(procesSize - featList.size(), procesSize);
103
					process.setProgress(procesSize - featList.size(), procesSize);
112 104
					cont = featList.size();
113 105
					insertInTable(f);
114 106
				}
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.lib/org.gvsig.geoprocess.lib.sextante/src/main/java/org/gvsig/geoprocess/lib/sextante/AbstractSextanteGeoProcess.java
385 385
    public ITaskMonitor getTaskMonitor() {
386 386
    	return m_Task;
387 387
    }
388
    
389
    public void setTaskMonitor(ITaskMonitor task) {
390
    	this.m_Task = task;
391
    }
388 392
}

Also available in: Unified diff