Point startPoint = shape.getPoint(0);
if (!startPoint.equals(shape.getPoint(shape.getNumPoints() - 1))) {
addedEndVertex = true;
shape.getEditBlackboard().addPoint(startPoint.getX(), startPoint.getY(), shape);
}
GeometryOperationAnimation indicator = new GeometryOperationAnimation(
PrimitiveShapeIterator.getPathIterator(shape).toShape(), new IsBusyStateProvider(
handler));
try {
AnimationUpdater.runTimer(handler.getContext().getMapDisplay(), indicator);
handler.setCurrentState(EditState.BUSY);
if (writeCommand == null) {
EditBlackboard editBlackboard = handler.getEditBlackboard(layer);
this.geoms = new ArrayList<EditGeom>(editBlackboard.getGeoms());
geoms.remove(shape.getEditGeom());
editBlackboard.clear();
FeatureCollection<SimpleFeatureType, SimpleFeature> features = getFeatures(monitor);
if( features == null ){
return; // did not hit anything
}
try {
List<Geometry> geoms = new ArrayList<Geometry>();
geoms.add(createReferenceGeom());
SimpleFeature first = runDifferenceOp(features.features(), geoms);
if (first == null)
return;
createAddFeatureCommands(commands, geoms, first);
} finally {
monitor.worked(2);
}
this.writeCommand = new UndoableComposite(commands);
}
writeCommand.setMap(getMap());
handler.setCurrentState(EditState.COMMITTING);
writeCommand.execute(new SubProgressMonitor(monitor, 5));
} finally {
indicator.setValid(false);
handler.setCurrentState(endState);
monitor.done();
}
}