Package org.locationtech.udig.tools.edit.animation

Examples of org.locationtech.udig.tools.edit.animation.SearchBoxAnimation


    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;
                }
            default:
                break;
            }

            Coordinate min = minFinder.getMinCoord();
            try {
                if (min == null)
                    return null;
                return JTS.transform(min, new Coordinate(),
                        editBlackboard.pointCoordCalculator.mapToLayer);
            } catch (Exception e) {
                EditPlugin.log("", e); //$NON-NLS-1$
                return null;
            }
        } finally {
            if (stateAfterSearch == EditState.BUSY)
                handler.setCurrentState(EditState.MODIFYING);
            else
                handler.setCurrentState(stateAfterSearch);
            anim.setValid(false);
        }

    }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.tools.edit.animation.SearchBoxAnimation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.