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

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


       
        if( !legalState || !legalEventType || !shapeAndGeomNotNull || !button1Released
        || e.buttonsDown() || e.modifiersDown() )
            return false;
       
        PrimitiveShape currentShape = handler.getCurrentShape();
        Point point=currentShape.getEditBlackboard().overVertex(Point.valueOf(e.x, e.y),
                PreferenceUtil.instance().getVertexRadius());
        if( currentShape.getPoint(0).equals(point) || currentShape.getPoint(currentShape.getNumPoints()-1).equals(point))
            return true;
       
        return false;
    }
View Full Code Here


        if( type==ShapeType.POLYGON && EditPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_FILL_POLYGONS) ){
            drawShapeCommand.setFill(PreferenceUtil.instance().getDrawGeomsFill());
        }
       
        EditBlackboard blackboard = editBlackboard;
        PrimitiveShape currentShape = handler.getCurrentShape();
        if (currentShape == null) {
            UndoableComposite undoableComposite = startNewShape(handler, blackboard);
            return undoableComposite;
        }

        currentShape=currentShape.getEditGeom().getShell();
       
        //if current shape is a line and point matches up with one of the end points then
        // continue line.
        if( currentShape.getEditGeom().getShapeType()==ShapeType.LINE ){
            if( currentShape.getNumPoints()>0 && nearestPoint.equals(currentShape.getPoint(0)) ){
                // over the first end point so reverse order and return;
                EditUtils.instance.reverseOrder(currentShape);
                return null;
            }
           
            if( currentShape.getNumPoints()>1 && !nearestPoint.equals(currentShape.getPoint(currentShape.getNumPoints()-1)) ){
                // not over one of the end points
                return createNewGeom(handler);
            }
            return null;
        }
       
       
        if (currentShape.getEditGeom().getShapeType()==ShapeType.POINT) {
            // it's a point create a new point.
            return createNewGeom(handler);
        }else{
            if (currentShape.contains(nearestPoint, true)) {
                if (handler.getCurrentGeom().getShell() == currentShape) {
                    for( PrimitiveShape hole : handler.getCurrentGeom().getHoles() ) {
                        if (hole.contains(nearestPoint, true)) {
                            return createNewGeom(handler);   
                        }
View Full Code Here

        return  altDown && ( handler.isLockOwner(this) ||
                handler.getCurrentShape().contains(Point.valueOf(e.x, e.y), true) );
    }

    private boolean allVerticesSelectedAndWithinGeom( EditToolHandler handler ) {
        PrimitiveShape currentShape = handler.getCurrentShape();
        Selection selection = handler.getCurrentGeom().getEditBlackboard().getSelection();

        Point dragStarted = handler.getMouseTracker().getDragStarted();
        if( dragStarted==null )
            return false;
        for( Point point : currentShape ) {
            if( ! selection.contains(point) )
                return false;
        }
       
        return currentShape.contains(dragStarted, true);
       
    }
View Full Code Here

     */
    public EditGeom getCurrentGeom() {
        Lock lock2 = getLock();
        (lock2).lock();
        try {
            PrimitiveShape currentShape = getCurrentShape();
            return currentShape == null ? null : currentShape.getEditGeom();
        } finally {
            lock2.unlock();
        }
    }
View Full Code Here

        public UndoableMapCommand getCommand( EditToolHandler handler, MapMouseEvent e,
                EventType eventType ) {

            try {

                PrimitiveShape shape = handler.getCurrentShape();
                int vertexRadius = PreferenceUtil.instance().getVertexRadius();
                if (type == ShapeType.UNKNOWN) {
                    if (isOverEndPoint(e, vertexRadius, start))
                        shape.getEditGeom().setShapeType(ShapeType.POLYGON);
                    else {
                        shape.getEditGeom().setShapeType(ShapeType.LINE);
                    }
                } else {
                    shape.getEditGeom().setShapeType(type);
                }
               
                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());
View Full Code Here

     * @param handler
     * @param e
     * @return true If this point is allowed
     */
    protected boolean isNotDuplicated(EditToolHandler handler, Point point) {
        PrimitiveShape currentShape = handler.getCurrentShape();
        if (currentShape.getNumPoints() == 0 ) {
            // no points to be over           
            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;            
        }
        if( currentShape.getNumPoints() > 2 && vertexOver.equals( currentShape.getPoint(0) )) {
            // forms a closed linestring or polygon
            return true;
        }
        return !currentShape.hasVertex( vertexOver ) ;       
    }
View Full Code Here

        bb.addPoint(10,10,editGeom.getShell());
        bb.addPoint(40,10,editGeom.getShell());
        bb.addPoint(40,40,editGeom.getShell());
        bb.addPoint(10,10,editGeom.getShell());
       
        PrimitiveShape hole = editGeom.newHole();
        bb.addPoint(20,20,hole);
        bb.addPoint(30,30,hole);
        bb.addPoint(30,20,hole);
        bb.addPoint(20,20,hole);
       
View Full Code Here

        bb.addPoint(10,10,editGeom.getShell());
        bb.addPoint(40,10,editGeom.getShell());
        bb.addPoint(40,40,editGeom.getShell());
        bb.addPoint(10,10,editGeom.getShell());
       
        PrimitiveShape hole = editGeom.newHole();
        bb.addPoint(20,20,hole);
        bb.addPoint(30,20,hole);
        bb.addPoint(30,30,hole);
        bb.addPoint(20,20,hole);
       
View Full Code Here

        boolean releasedEvent = eventType == EventType.RELEASED;
        boolean noModifiers = !(e.modifiersDown());
        boolean button1 = e.button == MapMouseEvent.BUTTON1;
        boolean onlyButton1Down = e.buttons - (e.buttons & MapMouseEvent.BUTTON1) == 0;

        PrimitiveShape currentShape = handler.getCurrentShape();
        boolean shapeIsSet = currentShape != null;

        if (!(shapeIsSet && goodState && releasedEvent && noModifiers && button1 && onlyButton1Down))
            return false;

        int numPoints = currentShape.getNumPoints();
        boolean ready = numPoints == numOfPointsToAccept;

        return ready;
    }
View Full Code Here

        array.add(coord);
      }
      Iterator<Coordinate> coorIt = array.iterator();

      EditGeom newEditGeom = bb.newGeom("", ShapeType.LINE); //$NON-NLS-1$
      PrimitiveShape shape = newEditGeom.getShell();
      handler.setCurrentShape(shape);
      handler.setCurrentState(EditState.MODIFYING);

      Coordinate coor = null;
      while (coorIt.hasNext()) {
View Full Code Here

TOP

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

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.