Package org.locationtech.udig.tools.edit.commands

Examples of org.locationtech.udig.tools.edit.commands.AddVertexCommand


        List<UndoableMapCommand> commands=new ArrayList<UndoableMapCommand>();
        commands.add(new StartBatchingCommand(bb));
        float[] coords=new float[6];
        boolean started=false;
        float[] start=new float[2];
        AddVertexCommand addVertexCommand=null;
        while( !iter.isDone() ){
            int type=iter.currentSegment(coords);
            switch(type){
            case PathIterator.SEG_MOVETO:
                if( !started ){
                    started=true;
                } else {
                    if( shapeType!=ShapeType.POLYGON  )
                        throw new IllegalArgumentException("Holes can not to shapes that are not Polygons.  Current shape is a "+shapeType); //$NON-NLS-1$
                    CreateAndSelectHoleCommand command = new CreateAndSelectHoleCommand(currentProvider);
                    currentProvider=command.getHoleProvider();
                    commands.add(command);
                }
                start[0]=coords[0];
                start[1]=coords[1];
                // no break is intentional.  It has to fall through and add a vertext to the shape
            case PathIterator.SEG_LINETO:           
                addVertexCommand = new AddVertexCommand(handler, bb, currentProvider, Point.valueOf((int)coords[0], (int)coords[1]), false);
                addVertexCommand.setShowAnimation(false);
                commands.add( addVertexCommand);
                break;
            case PathIterator.SEG_CLOSE:
                if (!Point.valueOf((int) coords[0], (int) coords[1]).equals(
                        Point.valueOf((int) start[0], (int) start[1]))) {
                    addVertexCommand = new AddVertexCommand(handler, bb, currentProvider, Point
                            .valueOf((int) start[0], (int) start[1]), false);
                    addVertexCommand.setShowAnimation(false);
                    commands.add(addVertexCommand);
                }
                break;
            default:
                throw new UnsupportedOperationException("not supported"); //$NON-NLS-1$
           
            }
            iter.next();
        }
       
        if (shapeType==ShapeType.POLYGON && addVertexCommand!=null && !addVertexCommand.getPointToAdd().equals(Point.valueOf((int)start[0], (int)start[1]))){
            commands.add( new AddVertexCommand(handler, bb, currentProvider, Point.valueOf((int)start[0], (int)start[1]), false));           
        }
       

        UndoableComposite undoableComposite = new UndoableComposite(commands);
        undoableComposite.getFinalizerCommands().add(new FireEventsCommand(bb));
View Full Code Here


            EditBlackboard editBlackboard = handler.getEditBlackboard(handler.getEditLayer());
           
            Point destination = editBlackboard.overVertex(clickPoint, PreferenceUtil.instance().getVertexRadius());
            if( destination==null ){
               
                AddVertexCommand addVertexCommand = new AddVertexCommand(handler, editBlackboard, clickPoint);

                try {
                    addVertexCommand.setMap(handler.getContext().getMap());
                    addVertexCommand.run(new NullProgressMonitor());
                } catch (Exception e1) {
                    throw (RuntimeException) new RuntimeException( ).initCause( e1 );
                }
                commands.add(new UndoRedoCommand(addVertexCommand));
            }
View Full Code Here

        if (handler.getCurrentGeom() == editGeom) {
            if (Polygon.class.isAssignableFrom(geomToCreate)) {
                for( PrimitiveShape shape : editGeom ) {
                    if (shape.getNumPoints() > 0
                            && !shape.getPoint(0).equals(shape.getPoint(shape.getNumPoints() - 1)))
                        commands.add(new AddVertexCommand(handler, editGeom.getEditBlackboard(),
                                shape.getPoint(0)));
                }
            }
        } else {
            if (editGeom.getShapeType() == ShapeType.POLYGON
                    || (editGeom.getShapeType() == ShapeType.UNKNOWN && Polygon.class
                            .isAssignableFrom(geomToCreate))) {
                for( PrimitiveShape shape : editGeom ) {
                    if (shape.getNumPoints() > 0
                            && !shape.getPoint(0).equals(shape.getPoint(shape.getNumPoints() - 1)))
                        commands.add(new AddVertexCommand(handler, editGeom.getEditBlackboard(),
                                shape.getPoint(0)));
                }
            }
        }
    }
View Full Code Here

            throw new IllegalStateException("Current state is illegal this method should not be called"); //$NON-NLS-1$
       
        List<UndoableMapCommand> commands=new ArrayList<UndoableMapCommand>();
        commands.add(new SetEditStateCommand(handler, EditState.CREATING));
        commands.add(new CreateAndSelectHoleCommand(handler));
        commands.add(new AddVertexCommand(handler, handler.getEditBlackboard(handler.getEditLayer()),
                Point.valueOf(e.x, e.y)));
        return new UndoableComposite(commands);
    }
View Full Code Here

                // 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 )
View Full Code Here

        EditBlackboard editBlackboard = handler.getEditBlackboard(handler.getEditLayer());
        Point destination = handler.getEditBlackboard(handler.getEditLayer()).overVertex(valueOf, PreferenceUtil.instance().getVertexRadius());
        if( destination==null )
            destination=valueOf;
       
        AddVertexCommand addVertexCommand = new AddVertexCommand(handler, editBlackboard, destination);
        try {
            addVertexCommand.setMap(handler.getContext().getMap());
            addVertexCommand.run(new NullProgressMonitor());
        } catch (Exception e1) {
            throw (RuntimeException) new RuntimeException( ).initCause( e1 );
        }
        return new UndoRedoCommand(addVertexCommand);
    }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.tools.edit.commands.AddVertexCommand

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.