Revision 658 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

View differences:

GeometryOperation.java
41 41

  
42 42
/**
43 43
 * Each geometry operation have to inherit from this class.
44
 *  
44
 *
45 45
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
46 46
 */
47 47
@SuppressWarnings("deprecation")
......
56 56
    protected boolean                          selectedGeomInput   = false;
57 57
    protected boolean                          selectedGeomOverlay = false;
58 58
    protected int                              procesSize          = 0;
59
	
59

  
60 60
    public GeometryOperation(AbstractSextanteGeoProcess process) {
61 61
    	this.process = process;
62 62
    }
63
    
63

  
64 64
    /**
65
     * Assigns the flag to use only the selected geometries 
65
     * Assigns the flag to use only the selected geometries
66 66
     * in the overlay layer
67 67
     */
68 68
    public void setSelectedGeomOverlayLayer(boolean setSelected) {
69 69
    	this.selectedGeomOverlay = setSelected;
70 70
    }
71
    
71

  
72 72
	/**
73 73
	 * Invokes this operation and returns an EditableFeature
74 74
	 * @param g
......
76 76
	 * @return
77 77
	 */
78 78
	public abstract EditableFeature invoke(org.gvsig.fmap.geom.Geometry g, Feature featureInput);
79
	
79

  
80 80
	/**
81 81
	 * Invokes this operation
82 82
	 * @param g
83 83
	 * @param featureInput
84 84
	 */
85 85
	public abstract void invoke(org.gvsig.fmap.geom.Geometry g, EditableFeature featureInput);
86
	
86

  
87 87
	/**
88 88
	 * Sets the output FeatureType and the input attributes for this feature
89 89
	 * @param out
90
	 * @throws DataException 
90
	 * @throws DataException
91 91
	 */
92 92
	public void setFeatureStore(FeatureStore out, String[] attrNames) throws DataException {
93 93
		persister = new DALFeaturePersister(out, attrNames);
94 94
	}
95
	
95

  
96 96
	/**
97 97
	 * Gets the last result of this operation
98 98
	 * @return
......
100 100
	public Object getResult() {
101 101
		return lastEditFeature;
102 102
	}
103
	
103

  
104 104
	/**
105 105
	 * Computes a complete operation over the input FeatureStore. The result of this operation
106 106
	 * is stored in the output FeatureStore. This method will call once for each geometry.
......
134 134
		} else {
135 135
			featuresSet = inFeatStore.getFeatureSet();
136 136
		}
137
		
137

  
138 138
		it = featuresSet.iterator();
139 139
		numberOfFeatures = (int)featuresSet.getSize();
140 140
        if (status != null && process != null) {
141 141
            status.setRangeOfValues(0, numberOfFeatures);
142 142
            process.setProgress(0, numberOfFeatures);
143 143
        }
144
		
144

  
145 145
		int iCount = 0;
146 146
		while( it.hasNext() && !process.getTaskMonitor().isCanceled()) {
147 147
			Feature feature = (Feature)it.next();
148 148
			List geomList = feature.getGeometries();
149
			
149

  
150 150
            if (status != null && process != null) {
151 151
                status.setCurValue(iCount);
152 152
                process.setProgress(iCount, numberOfFeatures);
153 153
            }
154 154
			iCount ++;
155
			
155

  
156 156
			if(geomList == null) {
157 157
				org.gvsig.fmap.geom.Geometry geom = feature.getDefaultGeometry();
158 158
				invoke(geom, feature);
......
171 171
					invoke(g, editFeat);
172 172
			}
173 173
		}
174
		
174
        process.setProgress(iCount, numberOfFeatures);
175

  
175 176
		if(closeOutStore && persister != null)
176 177
			persister.end();
177 178
	}
178
	
179

  
179 180
	/**
180 181
	 * Computes a complete operation over the input FeatureStore. The result of this operation
181 182
	 * is stored in the output FeatureStore. This method will call once for each feature.
......
200 201
		featuresSet = inFeatStore.getFeatureSet();
201 202
		this.selectedGeomInput = selectedGeomInput;
202 203
		this.selectedGeomOverlay = selectedGeomOverlay;
203
		
204

  
204 205
		if(outFeatStore != null)
205 206
			setFeatureStore(outFeatStore, attrNames);
206 207
		DisposableIterator it = null;
......
216 217
            status.setRangeOfValues(0, numberOfFeatures);
217 218
            process.setProgress(0, numberOfFeatures);
218 219
        }
219
		
220

  
220 221
		int iCount = 0;
221 222
		while( it.hasNext() && !process.getTaskMonitor().isCanceled()) {
222 223
			Feature feature = (Feature)it.next();
......
227 228
			}
228 229
			iCount ++;
229 230
		}
230
		
231

  
231 232
		if(closeOutStore && persister != null)
232 233
			persister.end();
233 234
	}
234
	
235

  
235 236
	/**
236 237
	 * Computes a complete operation over the input list of FeatureStore. The result of this operation
237 238
	 * is stored in the output FeatureStore. This method will call once for each geometry.
......
254 255
		this.inFeatureStoreList = inFeatStoreList;
255 256
		this.selectedGeomInput = selectedGeomInput;
256 257
		this.selectedGeomOverlay = selectedGeomOverlay;
257
		
258

  
258 259
		if (status != null && process != null) {
259 260
            status.setRangeOfValues(0, inFeatStoreList.size());
260 261
            process.setProgress(0, inFeatStoreList.size());
......
267 268
				process.setProgress(iCount, numberOfFeatures);
268 269
			}
269 270
			iCount ++;
270
			computesGeometryOperation(inFeatStoreList.get(i), 
271
										i == 0 ? outFeatStore : null, 
272
										attrNames, 
271
			computesGeometryOperation(inFeatStoreList.get(i),
272
										i == 0 ? outFeatStore : null,
273
										attrNames,
273 274
										selectedGeomInput,
274 275
										selectedGeomOverlay,
275 276
										false);
276 277
			if(process.getTaskMonitor().isCanceled())
277 278
				return;
278 279
		}
279
		
280

  
280 281
        if (closeOutStore && persister != null) {
281 282
			persister.end();
282 283
        }
283 284
	}
284
	
285

  
285 286
	/**
286 287
	 * Ends the edition and closes the FeatureStore
287 288
	 * @deprecated
......
300 301
    public void setTaskStatus(SimpleTaskStatus status) {
301 302
        this.status = status;
302 303
    }
303
    
304

  
304 305
    public void setGeoProcess(AbstractSextanteGeoProcess geoprocess, int size) {
305 306
		this.process = geoprocess;
306 307
		this.procesSize = size;

Also available in: Unified diff