Package org.locationtech.udig.tools.edit.support

Examples of org.locationtech.udig.tools.edit.support.EditBlackboard


     * @param handler
     */
    private UndoableMapCommand createNewGeom( EditToolHandler handler ) {
        List<UndoableMapCommand> commands=new ArrayList<UndoableMapCommand>();
       
        EditBlackboard editBlackboard = handler.getCurrentShape().getEditBlackboard();
        final CreateEditGeomCommand createEditGeomCommand = new CreateEditGeomCommand(
                editBlackboard, "freeHandDraw"+System.currentTimeMillis(), ShapeType.LINE); //$NON-NLS-1$
        commands.add(createEditGeomCommand);
        class PrimitiveProvider implements IBlockingProvider<PrimitiveShape> {
            public PrimitiveShape get(IProgressMonitor monitor, Object... params) {
View Full Code Here


        if( !isValid(handler, e, eventType))
            throw new IllegalArgumentException("Current State is not valid for behaviour"); //$NON-NLS-1$
        List<UndoableMapCommand> commands=new ArrayList<UndoableMapCommand>();
        commands.add(handler.getContext().getEditFactory().createNullEditFeatureCommand());
        ILayer editLayer = handler.getEditLayer();
        EditBlackboard bb = handler.getEditBlackboard(editLayer);
        commands.add(new DeselectEditGeomCommand(handler, bb.getGeoms()));
        commands.add(new StartEditingCommand(handler, e, type));
       
        UndoableComposite undoableComposite = new UndoableComposite(commands);
        undoableComposite.setMap(handler.getContext().getMap());
        try {
View Full Code Here

        // if tracker!=null then the move has started so the selection is no longer
        // at the same spot as the selected point so return true
        if (tracker != null)
            return true;
        Point started = handler.getMouseTracker().getDragStarted();
        EditBlackboard editBlackboard = handler.getEditBlackboard(handler.getEditLayer());
        Point point = handler.getEditBlackboard(handler.getEditLayer())
                .overVertex(Point.valueOf(started.getX(), started.getY()),
                        PreferenceUtil.instance().getVertexRadius());
        if (point == null) {
            point = Point.valueOf(started.getX(), started.getY());
View Full Code Here

            handler.setCurrentState(EditState.MOVING);

        if (!isValid(handler, e, eventType))
            throw new IllegalArgumentException("Not valid state", new Exception()); //$NON-NLS-1$

        EditBlackboard editBlackboard2 = handler.getEditBlackboard(handler.getEditLayer());
        editBlackboard2.startBatchingEvents();
        try {
            if (tracker == null) {
                handler.lock(this);
                Point closestPoint = editBlackboard2.overVertex(Point.valueOf(e.x, e.y),
                        PreferenceUtil.instance().getVertexRadius(), false);
                Map<EditGeom, Boolean> changedStatus=new HashMap<EditGeom, Boolean>();
                for( EditGeom geom : editBlackboard2.getGeoms() ) {
                    changedStatus.put(geom, geom.isChanged());
                }
               
                IEditValidator validator = validatorFactory.get(handler, e, eventType);

                // If at the start the geometry isn't valid then who are we to complain?
                if( validator.isValid(handler, e, eventType)!=null ){
                  validator=null;
                }
               
                tracker = new PositionTracker(closestPoint, handler.getMouseTracker()
                        .getDragStarted(), getPointsToMove(handler, editBlackboard2),
                        changedStatus, validator);
                handler.getBehaviours().add(tracker);
                if (isSnappingValid() && PreferenceUtil.instance().getSnapBehaviour()!=SnapBehaviour.GRID ) {
                        drawSnapArea = new DrawSnapAreaCommand(tracker);
                    handler.getContext().getViewportPane().addDrawCommand(drawSnapArea);

                }
            }

            if (tracker.lastPoint == null) {
                tracker.lastPoint = handler.getMouseTracker().getDragStarted();
            }

            Point point = Point.valueOf(e.x, e.y);

            int deltaX = point.getX() - tracker.lastPoint.getX(), deltaY = point.getY()
                    - tracker.lastPoint.getY();

            doMove(deltaX, deltaY, handler, editBlackboard2, tracker.selection);

            tracker.lastPoint = point;
            return null;
        } finally {
            editBlackboard2.fireBatchedEvents();
            handler.repaint();
        }
    }
View Full Code Here

    private void openErrorBubble( EditToolHandler handler, MapMouseEvent e, String errorMessage ) {
            MessageBubble bubble=new MessageBubble(e.getPoint().x, e.getPoint().y, errorMessage, //$NON-NLS-1$
                    PreferenceUtil.instance().getMessageDisplayDelay());
            AnimationUpdater.runTimer(handler.getContext().getMapDisplay(), bubble);
            EditBlackboard editBlackboard = handler.getEditBlackboard(handler.getEditLayer());
            doMove(start.getX()-lastPoint.getX(), start.getY()-lastPoint.getY(),
                    handler, editBlackboard, selection);
            Set<Entry<EditGeom, Boolean>> entries = dirtyStatesBeforeMove.entrySet();
            for( Entry<EditGeom, Boolean> entry : entries ) {
                entry.getKey().setChanged(entry.getValue());
View Full Code Here

        if( !isValid(handler, e, eventType) ){
            throw new IllegalStateException("Cannot insert a vertext here"); //$NON-NLS-1$
        }
        ILayer editLayer = handler.getEditLayer();

        EditBlackboard editBlackboard = handler.getEditBlackboard( editLayer );       
        Point toInsert = Point.valueOf(e.x,e.y);
       
        return new InsertOnNearestEdgeCommand( handler, editBlackboard, toInsert );

    }
View Full Code Here

    public UndoableMapCommand getCommand( EditToolHandler handler, MapMouseEvent e, EventType eventType ) {
        if( !isValid(handler, e, eventType) )
            throw new IllegalArgumentException("Not valid state", new Exception()); //$NON-NLS-1$

        EditBlackboard editBlackboard = handler.getEditBlackboard(handler.getEditLayer());
        Point point = handler.getEditBlackboard(handler.getEditLayer()).overVertex(Point.valueOf(e.x,e.y), PreferenceUtil.instance().getVertexRadius());
        List<EditGeom> geoms = null;
        if( point != null )
            geoms= editBlackboard.getGeoms(point.getX(),point.getY());
        else{
            EditPlugin.trace(EditPlugin.SELECTION, "VertexSelectorBehaviour: Not over vertex (" //$NON-NLS-1$
                    +e.x+","+e.y+")", null); //$NON-NLS-1$ //$NON-NLS-2$
        }
        Selection selection = editBlackboard.getSelection();
        List<UndoableMapCommand> commands=new ArrayList<UndoableMapCommand>();
        if( e.isShiftDown() ){
            if( geoms!=null && geoms.contains(handler.getCurrentGeom())
                    && !editBlackboard.getSelection().contains(point) ){
                commands.add( new SelectVertexCommand(editBlackboard, point, Type.ADD ) );
            }
        } else if (e.isControlDown()) {
            if (geoms != null && geoms.contains(handler.getCurrentGeom())) {
                if( selection.contains(point) )
View Full Code Here

   
    public boolean isValid( EditToolHandler handler, MapMouseEvent e, EventType eventType ) {
        boolean currentGeomNotNull = handler.getCurrentGeom()!=null;
        boolean eventTypePressed = eventType==EventType.PRESSED;
        boolean button1Changed=e.button==MapMouseEvent.BUTTON1;
        EditBlackboard editBlackboard = handler.getEditBlackboard(handler.getEditLayer());
        boolean overPoint = editBlackboard.overVertex(Point.valueOf(e.x,e.y), PreferenceUtil.instance().getVertexRadius())!=null;

        return currentGeomNotNull && eventTypePressed && button1Changed
        && !e.modifiersDown() && e.buttons==MapMouseEvent.BUTTON1 && overPoint;
    }
View Full Code Here

    public UndoableMapCommand getCommand( EditToolHandler handler, MapMouseEvent e, EventType eventType ) {
        if( !isValid(handler, e, eventType) )
            throw new IllegalArgumentException("Not valid state", new Exception()); //$NON-NLS-1$

        EditBlackboard editBlackboard = handler.getEditBlackboard(handler.getEditLayer());
        Point point = handler.getEditBlackboard(handler.getEditLayer()).overVertex(Point.valueOf(e.x,e.y), PreferenceUtil.instance().getVertexRadius());
        List<EditGeom> geoms = null;
        if( point != null )
            geoms= editBlackboard.getGeoms(point.getX(),point.getY());
        else{
            EditPlugin.trace(EditPlugin.SELECTION, "VertexSelectorBehaviour: Not over vertex (" //$NON-NLS-1$
                    +e.x+","+e.y+")", null); //$NON-NLS-1$ //$NON-NLS-2$
            return null;
        }
        Selection selection = editBlackboard.getSelection();
        List<UndoableMapCommand> commands=new ArrayList<UndoableMapCommand>();

        if( !selection.contains(point) )
            commands.addnew SelectVertexCommand(editBlackboard, point, Type.SET) );
View Full Code Here

            return true;
        }
       
        ILayer editLayer = handler.getEditLayer();
       
        EditBlackboard editBlackboard = handler.getEditBlackboard(editLayer);
        final int vertexRadius = PreferenceUtil.instance().getVertexRadius();
       
        Point vertexOver=editBlackboard.overVertex(point, vertexRadius);
       
        if( vertexOver == null ) {
            // we are not over any points
            return true;            
        }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.tools.edit.support.EditBlackboard

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.