Revision 9555
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/GenerateNetworkExtension.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
import java.awt.Component; |
44 | 44 |
import java.io.File; |
45 |
import java.io.FileNotFoundException; |
|
46 | 45 |
import java.util.HashMap; |
47 | 46 |
|
48 | 47 |
import javax.swing.ImageIcon; |
... | ... | |
73 | 72 |
import com.iver.cit.gvsig.fmap.layers.SingleLayerIterator; |
74 | 73 |
import com.iver.cit.gvsig.geoprocess.core.fmap.GeoprocessException; |
75 | 74 |
import com.iver.cit.gvsig.geoprocess.core.fmap.XTypes; |
75 |
import com.iver.cit.gvsig.geoprocess.impl.topology.lineclean.fmap.LineCleanGeoprocess; |
|
76 | 76 |
import com.iver.cit.gvsig.graph.core.writers.NetworkFileRedWriter; |
77 | 77 |
import com.iver.cit.gvsig.graph.core.writers.NetworkGvTableWriter; |
78 | 78 |
import com.iver.cit.gvsig.graph.gui.wizard.NetWizard; |
... | ... | |
80 | 80 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
81 | 81 |
import com.iver.cit.gvsig.project.documents.view.gui.IView; |
82 | 82 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
83 |
import com.iver.cit.gvsig.topology.lineclean.fmap.LineCleanGeoprocess; |
|
84 | 83 |
import com.iver.utiles.SimpleFileFilter; |
85 | 84 |
import com.iver.utiles.swing.threads.AbstractMonitorableTask; |
86 |
import com.iver.utiles.swing.threads.IMonitorableTask; |
|
87 | 85 |
import com.iver.utiles.swing.threads.IPipedTask; |
88 | 86 |
import com.iver.utiles.swing.threads.PipeTask; |
89 | 87 |
|
... | ... | |
160 | 158 |
JOptionPane.showMessageDialog(null, PluginServices |
161 | 159 |
.getText(this, "done")); |
162 | 160 |
} |
163 |
|
|
164 |
class GenerateRedNetworkAfterCleanTask
|
|
161 |
|
|
162 |
class GenerateRedNetworkAfterCleanTask |
|
165 | 163 |
extends AbstractMonitorableTask implements IPipedTask{ |
166 |
|
|
164 |
|
|
167 | 165 |
File redFile; |
168 | 166 |
NetworkFileRedWriter netBuilder; |
169 |
|
|
167 |
|
|
170 | 168 |
FLyrVect inputLayer; |
171 | 169 |
FLyrVect pseudonodes; |
172 | 170 |
FLayers tocLyrs; |
173 |
|
|
171 |
|
|
174 | 172 |
/** |
175 | 173 |
* Constructor |
176 | 174 |
* @param tocLyrs |
... | ... | |
186 | 184 |
|
187 | 185 |
public void run() throws Exception { |
188 | 186 |
int numShapes; |
189 |
try {
|
|
187 |
try { |
|
190 | 188 |
numShapes = inputLayer.getSource().getShapeCount(); |
191 |
// lo del 10 es para que termine despu?s de
|
|
189 |
// lo del 10 es para que termine despu?s de |
|
192 | 190 |
// escribir los puntos |
193 | 191 |
setFinalStep(numShapes + 10); |
194 |
|
|
195 |
|
|
192 |
|
|
193 |
|
|
196 | 194 |
} catch (DriverIOException e) { |
197 | 195 |
// TODO Auto-generated catch block |
198 | 196 |
e.printStackTrace(); |
... | ... | |
216 | 214 |
public void cancel() { |
217 | 215 |
setCanceled(true); |
218 | 216 |
} |
219 |
|
|
217 |
|
|
220 | 218 |
public boolean isFinished() { |
221 | 219 |
return (getCurrentStep() >= getFinalStep()); |
222 | 220 |
} |
... | ... | |
244 | 242 |
this.pseudonodes = (FLyrVect) layers.getLayer(1); |
245 | 243 |
} |
246 | 244 |
} |
247 |
|
|
245 |
|
|
248 | 246 |
public void enableControls(){ |
249 | 247 |
PluginServices.backgroundExecution(new Runnable(){ |
250 | 248 |
public void run() { |
251 | 249 |
PluginServices.getMainFrame().enableControls(); |
252 |
|
|
250 |
|
|
253 | 251 |
}}); |
254 | 252 |
} |
255 |
|
|
256 | 253 |
|
254 |
|
|
257 | 255 |
class GenerateRedNetworkTask extends AbstractMonitorableTask { |
258 | 256 |
FLyrVect layer; |
259 | 257 |
|
260 | 258 |
File redFile; |
261 | 259 |
|
262 | 260 |
NetworkFileRedWriter netBuilder; |
263 |
|
|
264 |
|
|
265 | 261 |
|
262 |
|
|
263 |
|
|
266 | 264 |
/** |
267 | 265 |
* Constructor |
268 | 266 |
*/ |
... | ... | |
271 | 269 |
this.layer = layer; |
272 | 270 |
if(! layer.isSpatiallyIndexed()) |
273 | 271 |
layer.createSpatialIndex(); |
274 |
|
|
272 |
|
|
275 | 273 |
this.redFile = redFile; |
276 | 274 |
this.netBuilder = netBuilder; |
277 | 275 |
setInitialStep(0); |
... | ... | |
309 | 307 |
public void cancel() { |
310 | 308 |
setCanceled(true); |
311 | 309 |
} |
312 |
|
|
310 |
|
|
313 | 311 |
public Object getResult(){ |
314 | 312 |
return null; |
315 |
|
|
313 |
|
|
316 | 314 |
} |
317 | 315 |
public void setEntry(Object object){ |
318 | 316 |
this.layer = (FLyrVect) object; |
... | ... | |
320 | 318 |
} |
321 | 319 |
|
322 | 320 |
/** |
323 |
* It returns a geoprocess to make a CLEAN of the input layer
|
|
321 |
* It returns a geoprocess to make a CLEAN of the input layer |
|
324 | 322 |
* */ |
325 | 323 |
private LineCleanGeoprocess createCleanGeoprocess(FLyrVect lineLyr) { |
326 | 324 |
File outputFile = null; |
... | ... | |
385 | 383 |
geoprocess.setParameters(params); |
386 | 384 |
geoprocess.checkPreconditions(); |
387 | 385 |
return geoprocess; |
388 |
|
|
386 |
|
|
389 | 387 |
} catch (GeoprocessException e) { |
390 | 388 |
String error = PluginServices.getText(this, "Error_ejecucion"); |
391 | 389 |
String errorDescription = PluginServices.getText(this, |
... | ... | |
431 | 429 |
if(applySnap){ |
432 | 430 |
double snapTolerance = wiz.getSnapTolerance(); |
433 | 431 |
netBuilder.setSnapTolerance(snapTolerance); |
434 |
}
|
|
432 |
} |
|
435 | 433 |
if(clean != null){ |
436 | 434 |
//we wont start the process of network creation |
437 | 435 |
//until clean geoprocess will be finished |
438 | 436 |
IPipedTask cleanTask = (IPipedTask) clean.createTask(); |
439 |
GenerateRedNetworkAfterCleanTask task =
|
|
437 |
GenerateRedNetworkAfterCleanTask task = |
|
440 | 438 |
new GenerateRedNetworkAfterCleanTask(netBuilder, tocLyrs); |
441 |
|
|
439 |
|
|
442 | 440 |
PipeTask pipe = new PipeTask(cleanTask, (IPipedTask)task); |
443 |
|
|
441 |
|
|
444 | 442 |
PluginServices.cancelableBackgroundExecution(pipe); |
445 | 443 |
// PluginServices.cancelableBackgroundExecution(task); |
446 |
|
|
444 |
|
|
447 | 445 |
}else{ |
448 | 446 |
GenerateRedNetworkTask task = new GenerateRedNetworkTask(lyr, redFile, |
449 | 447 |
netBuilder); |
Also available in: Unified diff