* @return the Point that is the closest vertex.
*/
public Coordinate getClosestSnapPoint( EditToolHandler handler, EditBlackboard editBlackboard, Point centerPoint, boolean includeVerticesInCurrent,
SnapBehaviour snapBehaviour, EditState stateAfterSearch ) {
IToolContext context = handler.getContext();
MinFinder minFinder = new MinFinder(editBlackboard.toCoord(centerPoint));
SearchBoxAnimation anim = new SearchBoxAnimation(centerPoint, new IsBusyStateProvider(
handler));
try {
handler.setCurrentState(EditState.BUSY);
if (snapBehaviour != SnapBehaviour.OFF && snapBehaviour != SnapBehaviour.GRID)
AnimationUpdater.runTimer(context.getMapDisplay(), anim);
switch( snapBehaviour ) {
case OFF:
return null;
case SELECTED:
searchSelection(handler, editBlackboard, centerPoint, includeVerticesInCurrent,
minFinder);
return minFinder.getMinCoord();
case CURRENT_LAYER:
searchSelection(handler, editBlackboard, centerPoint, includeVerticesInCurrent,
minFinder);
minFinder.add(searchLayer(handler.getEditLayer(), context, centerPoint));
break;
case ALL_LAYERS:
searchSelection(handler, editBlackboard, centerPoint, includeVerticesInCurrent,
minFinder);
for( ILayer layer : context.getMapLayers() ) {
minFinder.add(searchLayer(layer, context, centerPoint));
}
break;
case GRID:
Coordinate worldCoord = snapToGrid(centerPoint, context.getMap());
try {
return JTS.transform(worldCoord, null,
editBlackboard.pointCoordCalculator.mapToLayer);
} catch (TransformException e) {
return null;