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

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


                    Messages.AddVertexWhileCreatingBehaviour_illegal+"\n"+reasonForFaliure, PreferenceUtil.instance().getMessageDisplayDelay())); //$NON-NLS-1$
            return null;
        }
       
        Point valueOf = Point.valueOf(e.x, e.y);
        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);
View Full Code Here


        return false;
    }

    public UndoableMapCommand getCommand( EditToolHandler handler, MapMouseEvent e,
            EventType eventType ) {
        EditBlackboard editBlackboard = handler.getCurrentShape().getEditBlackboard();
        Point point=editBlackboard.overVertex(Point.valueOf(e.x, e.y),
                PreferenceUtil.instance().getVertexRadius());
        if( point.equals(handler.getCurrentShape().getPoint(0))){
            List<UndoableMapCommand> commands=new ArrayList<UndoableMapCommand>();
            commands.add(new ReversePointsInShapeCommand(handler, handler.getCurrentShape()));
            commands.add(new SetEditStateCommand(handler, EditState.CREATING));
View Full Code Here

   * @param composite
   */
  private void delete(UndoableComposite composite) {

    List<EditGeom> list = new LinkedList<EditGeom>();
    EditBlackboard bb = handler.getCurrentEditBlackboard();
    list.addAll(bb.getGeoms());

    // Deselects the selected painted geometry
    composite.addCommand(new DeselectEditGeomCommand(handler, list));
  }
View Full Code Here

    // check if it's ready.
    if (!(parallelContext.mode == PrecisionToolsMode.READY)) {
      return;
    }

    EditBlackboard bb = handler.getEditBlackboard(handler.getEditLayer());

    List<Geometry> resultList = parallelContext.getOutputCoordinates();
    for (Geometry result : resultList) {

      Coordinate[] coordinates = result.getCoordinates();
      List<Coordinate> array = new ArrayList<Coordinate>();
      for (Coordinate coord : coordinates) {
        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;
View Full Code Here

    public String getName() {
        return "RemoveAllVerticesCommand"; //$NON-NLS-1$
    }

    public void rollback( IProgressMonitor monitor ) throws Exception {
        EditBlackboard bb = oldGeom.getEditBlackboard();
        EditGeom geom = bb.newGeom(oldGeom.getFeatureIDRef().get(), oldGeom.getShapeType());
        for( Point p : oldGeom.getShell() ) {
            bb.addPoint(p.getX(), p.getY(), geom.getShell());
        }
       
        for( PrimitiveShape shape : oldGeom.getHoles() ) {
            PrimitiveShape hole = geom.newHole();
            for( Point p : shape ) {
                bb.addPoint(p.getX(), p.getY(), hole);
            }
        }

    }
View Full Code Here

            subProgressMonitor.done();
            geom.getFeatureIDRef().set(oldID);

            getMap().getEditManagerInternal().setEditFeature(oldFeature, (Layer) oldLayer);
            if (deselectCreatedFeature) {
                EditBlackboard bb = geom.getEditBlackboard();
                EditGeom newGeom = bb.newGeom(geom.getFeatureIDRef().get(), geom.getShapeType());
                PrimitiveShape shell = geom.getShell();
                for( org.locationtech.udig.tools.edit.support.Point point : shell ) {
                    bb.addPoint(point.getX(), point.getY(), newGeom.getShell());
                }

                List<PrimitiveShape> holes = geom.getHoles();
                for( PrimitiveShape primitiveShape : holes ) {
                    PrimitiveShape newHole = newGeom.newHole();
                    for( Point point2 : primitiveShape ) {
                        bb.addPoint(point2.getX(), point2.getY(), newHole);
                    }
                }
                geom = newGeom;
            } else {
                EditUtils.instance.refreshLayer(layer, Collections.singleton(addFeatureCommand
View Full Code Here

    }

    public void rollback( IProgressMonitor monitor ) throws Exception {
        monitor.beginTask(Messages.SetGeomCommand_runTask, 30);
        handler.setCurrentShape(currentShape);
        EditBlackboard bb = handler.getEditBlackboard(selectedLayer);
        handler.setCurrentState(currentState);
        EditGeom newCurrentGeom=null;
        List<EditGeom> empty = bb.getGeoms();
       
        for( EditGeom original : removed ) {
            EditGeom inBlackboard = bb.newGeom(original.getFeatureIDRef().get(), original.getShapeType());
            inBlackboard.setChanged(original.isChanged());
            if( original == currentGeom )
                newCurrentGeom=inBlackboard;
           
            PrimitiveShape destination = inBlackboard.getShell();
            newCurrentGeom = setCurrentGeom(newCurrentGeom, destination, original.getShell());
           
            for( Iterator<Coordinate> iter=original.getShell().coordIterator(); iter.hasNext(); ) {
                bb.addCoordinate(iter.next(), destination);
            }
           
            for( PrimitiveShape shape : original.getHoles() ) {
                destination=inBlackboard.newHole();
                newCurrentGeom = setCurrentGeom(newCurrentGeom, destination, shape);
                for( Iterator<Coordinate> iter=shape.coordIterator(); iter.hasNext(); ) {
                    bb.addCoordinate(iter.next(), destination);
                }
            }
        }

        bb.removeGeometries(empty);
        monitor.worked(10);
        refreshBounds.expandToInclude(new ReferencedEnvelope(feature.getBounds()));
        EditUtils.instance.refreshLayer(selectedLayer, feature, refreshBounds, true, false);

        command.rollback(new SubProgressMonitor(monitor, 10));
View Full Code Here

    public RemoveSelectedVerticesCommand( EditToolHandler handler ) {
        this.handler = handler;
    }

    public void run( IProgressMonitor monitor ) throws Exception {
        EditBlackboard blackboard = handler.getEditBlackboard(handler.getEditLayer());
        blackboard.startBatchingEvents();
        Selection selection = blackboard.getSelection();
        undoData = new ArrayList<Bag>();
        EditState oldState = handler.getCurrentState();
        try {
            handler.setCurrentState(EditState.BUSY);
            DeleteVertexAnimation deleteVertexAnimation=null;
            if( runAnimation ){
                for( Point point : selection ) {
                    deleteVertexAnimation = new DeleteVertexAnimation(point);
                    AnimationUpdater.runTimer(handler.getContext().getMapDisplay(), deleteVertexAnimation);
                }
                if( deleteVertexAnimation!=null ){
                    final DeleteVertexAnimation finalDeleteVertexAnim=deleteVertexAnimation;
                    PlatformGIS.wait(deleteVertexAnimation.getFrameInterval(), 5000, new WaitCondition(){
   
                        public boolean isTrue()  {
                            return !finalDeleteVertexAnim.isValid();
                        }
                       
                    }, null);
                }
            }
            HashSet<Point> points = new HashSet<Point>(selection);
            HashSet<EditGeom> allAffectedGeoms = new HashSet<EditGeom>();
            for( Point point : points ) {
                allAffectedGeoms.addAll(blackboard.getGeoms(point.getX(), point.getY()));
            }
           
            Map<PrimitiveShape, Integer> deletes = new HashMap<PrimitiveShape, Integer>();
           
            for( EditGeom geom : allAffectedGeoms ) {
                for( PrimitiveShape shape : geom ) {
                    for( int i = 0; i < shape.getNumPoints(); i++ ) {
                        Point shapePoint = shape.getPoint(i);
                        if (points.contains(shapePoint)) {
                            Bag bag = new Bag();
                            bag.p = shapePoint;
                            bag.coords = shape.getCoordsAt(i);
                            bag.shape = shape;
                            bag.index = i - get(deletes, shape);
                            bag.action = Action.REMOVE;
                            increment( deletes, shape);
                            undoData.add(bag);
                        }
                    }
                }
            }
            for( Point point : points ) {
                blackboard.removeCoordsAtPoint(point.getX(), point.getY());
            }
            for( PrimitiveShape shape : deletes.keySet() ) {
                if (shape.getNumPoints()>0 && shape.getEditGeom().getShapeType() == ShapeType.POLYGON) {
                    if( !shape.getPoint(0).equals(shape.getPoint(shape.getNumPoints()-1)) ){
                        List<Coordinate> singletonList = Collections.singletonList(shape
                                .getCoord(0));
                        blackboard.addCoordinate(shape.getCoord(0), shape);
                        Bag bag = new Bag();
                        bag.p = shape.getPoint(shape.getNumPoints()-1);
                        bag.coords = singletonList;
                        bag.shape = shape;
                        bag.index = -1;
                        bag.action = Action.ADD;
                        undoData.add(bag);
                    }
                }

            }
        } finally {
            handler.setCurrentState(oldState);
            blackboard.fireBatchedEvents();
        }
    }
View Full Code Here

    public String getName() {
        return Messages.RemoveSelectedVerticesCommand_name;
    }
   
    public void rollback( IProgressMonitor monitor ) throws Exception {
        EditBlackboard blackboard = handler.getEditBlackboard(handler.getEditLayer());
        blackboard.startBatchingEvents();
       
        try {
            for( int i = undoData.size() - 1; i > -1; i-- ) {
                Bag bag = undoData.get(i);
                switch( bag.action ) {
                case ADD:
                    blackboard.removeCoordinate( bag.shape.getNumPoints()-1, bag.coords.get(0), bag.shape );
                    break;
                case REMOVE:
                    if( runAnimation )
                        AnimationUpdater.runTimer(handler.getContext().getMapDisplay(), new AddVertexAnimation(bag.p.getX(), bag.p.getY()));
                    blackboard.insertCoords(bag.index, bag.p, bag.coords, bag.shape);
                    blackboard.selectionAdd(bag.p);
                    break;

                default:
                    break;
                }
            }
        } finally {
            blackboard.fireBatchedEvents();
        }
    }
View Full Code Here

            subProgressMonitor.done();
            geom.getFeatureIDRef().set(oldID);

            getMap().getEditManagerInternal().setEditFeature(oldFeature, (Layer) oldLayer);
            if (deselectCreatedFeature) {
                EditBlackboard bb = geom.getEditBlackboard();
                EditGeom newGeom = bb.newGeom(geom.getFeatureIDRef().get(), geom.getShapeType());
                PrimitiveShape shell = geom.getShell();
                for( org.locationtech.udig.tools.edit.support.Point point : shell ) {
                    bb.addPoint(point.getX(), point.getY(), newGeom.getShell());
                }

                List<PrimitiveShape> holes = geom.getHoles();
                for( PrimitiveShape primitiveShape : holes ) {
                    PrimitiveShape newHole = newGeom.newHole();
                    for( Point point2 : primitiveShape ) {
                        bb.addPoint(point2.getX(), point2.getY(), newHole);
                    }
                }
                geom = newGeom;
            } else {
                EditUtils.instance.refreshLayer(layer, Collections.singleton(addFeatureCommand
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.