}
if( shape.getEditGeom().getShapeType()==ShapeType.POLYGON )
generalPath.close();
UndoableComposite appendPathToShape;
appendPathToShape = EditUtils.instance.appendPathToShape(handler, generalPath.getPathIterator(),
shape);
// Now we need to collapse the last two vertices if they are
// within snapping distance.
if ( shape.getEditGeom().getShapeType()==ShapeType.POLYGON ){
List< ? extends MapCommand> commands = appendPathToShape.getCommands();
AddVertexCommand lastVertexCommand=(AddVertexCommand) commands.get(commands.size()-1);
AddVertexCommand previousVertexCommand=(AddVertexCommand) commands.get(commands.size()-2);
EditUtils.MinFinder finder = new EditUtils.MinFinder(lastVertexCommand.getPointToAdd());
double dist = finder.dist(previousVertexCommand.getPointToAdd());
if( dist<vertexRadius ){
commands.remove(previousVertexCommand);
}
}
if( handler.getCurrentShape()!=null )
appendPathToShape.getFinalizerCommands().add(new SetEditStateCommand( handler, EditState.MODIFYING));
else{
appendPathToShape.getFinalizerCommands().add(new SetEditStateCommand( handler, EditState.CREATING));
}
appendPathToShape.setMap(handler.getContext().getMap());
appendPathToShape.run(new NullProgressMonitor());
return new UndoRedoCommand(appendPathToShape);
} catch (Exception exception) {
throw (RuntimeException) new RuntimeException( exception );
} finally {