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

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


        assertEquals(Messages.LegalShapeValidator_shellIntersection, validator.isValid(handler, null, null));
    }

    @Test
    public void testHoleSelfIntersection() throws Exception {
        EditGeom polygon = bb.newGeom("line", ShapeType.POLYGON); //$NON-NLS-1$
        PrimitiveShape shell = polygon.getShell();
       
        bb.addPoint(10, 10, shell);
        bb.addPoint(20, 10, shell);
        bb.addPoint(20, 20, shell);
        bb.addPoint(10, 20, shell);
        bb.addPoint(10, 10, shell);
       
        PrimitiveShape hole = polygon.newHole();
        bb.addPoint(12, 12, hole);
        bb.addPoint(18, 12, hole);
        bb.addPoint(18, 18, hole);
        bb.addPoint(16, 11, hole);
       
View Full Code Here


        assertEquals(Messages.LegalShapeValidator_holeIntersection, validator.isValid(handler, null, null));
    }
   
    @Test
    public void testHoleOutOfShell() throws Exception {
        EditGeom polygon = bb.newGeom("line", ShapeType.POLYGON); //$NON-NLS-1$
        PrimitiveShape shell = polygon.getShell();
       
        bb.addPoint(10, 10, shell);
        bb.addPoint(20, 10, shell);
        bb.addPoint(20, 20, shell);
        bb.addPoint(10, 20, shell);
        bb.addPoint(10, 10, shell);
       
        PrimitiveShape hole = polygon.newHole();
        bb.addPoint(12, 12, hole);
        bb.addPoint(18, 0, hole);
       
        assertEquals(Messages.LegalShapeValidator_holeOutside, validator.isValid(handler, null, null));
    }
View Full Code Here

        assertEquals(Messages.LegalShapeValidator_holeOutside, validator.isValid(handler, null, null));
    }
   
    @Test
    public void testHoleIntersections() throws Exception {
        EditGeom polygon = bb.newGeom("line", ShapeType.POLYGON); //$NON-NLS-1$
        PrimitiveShape shell = polygon.getShell();
       
        bb.addPoint(10, 10, shell);
        bb.addPoint(20, 10, shell);
        bb.addPoint(20, 20, shell);
        bb.addPoint(10, 20, shell);
        bb.addPoint(10, 10, shell);
       
        PrimitiveShape hole = polygon.newHole();
        bb.addPoint(13, 12, hole);
        bb.addPoint(18, 12, hole);
        bb.addPoint(18, 18, hole);
        bb.addPoint(13, 12, hole);
       
        PrimitiveShape hole2 = polygon.newHole();
        bb.addPoint(15, 15, hole2);
        bb.addPoint(19, 15, hole2);
        bb.addPoint(19, 19, hole2);
        bb.addPoint(15, 15, hole2);
       
View Full Code Here

  public void handleError(EditToolHandler handler, Throwable error, UndoableMapCommand command) {
    EditPlugin.log("", error); //$NON-NLS-1$
  }

  public boolean isValid(EditToolHandler handler) {
    EditGeom currentGeom = handler.getCurrentGeom();

    boolean currentGeomNotNull = currentGeom != null;
    return currentGeomNotNull;
  }
View Full Code Here

        this.geomToCreate = geomToCreate;
        this.deselectCreatedFeatures = deselectCreatedFeatures;
    }

    public boolean isValid( EditToolHandler handler ) {
        EditGeom currentGeom = handler.getCurrentGeom();

        boolean currentGeomNotNull = currentGeom != null;
        return currentGeomNotNull
                && typeCanBeAssignedToLayer(handler.getEditLayer().getSchema()
                        .getGeometryDescriptor().getType().getBinding());
View Full Code Here

        Class<Geometry> binding = (Class<Geometry>) schema.getGeometryDescriptor().getType()
                .getBinding();

        List<UndoableMapCommand> commands = new ArrayList<UndoableMapCommand>();

        EditGeom editGeom = entry.getValue().geom;
        List<Geometry> geoms = entry.getValue().jts;
        Geometry geom = GeometryCreationUtil.ceateGeometryCollection(geoms, binding);

        if (geom == null) { // null is used to mark things for delete?
            IBlockingProvider<ILayer> layerProvider = new StaticBlockingProvider<ILayer>(layer);
            FIDFeatureProvider featureProvider = new FIDFeatureProvider(entry.getKey(),
                    layerProvider);
            DeleteFeatureCommand deleteFeatureCommand = new DeleteFeatureCommand(featureProvider,
                    layerProvider);
            commands.add(deleteFeatureCommand);
        } else {
            // geometry is going to be written out
            if (updateBlackboard) {
                // mostly used to tack on an extra addVertex command
                // so the display is drawn as a closed polygon.
                updateBlackboardGeometry(handler, editGeom, geom, commands);
            }
            GeometryOperationAnimation animation = new GeometryOperationAnimation(
                    EditGeomPathIterator.getPathIterator(editGeom).toShape(),
                    new IsBusyStateProvider(handler));

            UndoableMapCommand startAnimationCommand = drawfactory.createStartAnimationCommand(
                    display, Collections.singletonList((IAnimation) animation));
            commands.add(startAnimationCommand);

            if (isCurrentGeometry(handler, editGeom)) {
                if (isCreatingNewFeature(handler)) {
                    int attributeCount = schema.getAttributeCount();
                    SimpleFeature feature;
                    try {
                        feature = SimpleFeatureBuilder.template(schema, "newFeature"
                                + new Random().nextInt());
                        // feature = SimpleFeatureBuilder.build(schema, new
                        // Object[attributeCount],"newFeature");
                        feature.setDefaultGeometry(geom);
                    } catch (IllegalAttributeException e) {
                        throw new IllegalStateException(
                                "Could not create an empty " + schema.getTypeName() + ":" + e, e); //$NON-NLS-1$//$NON-NLS-2$
                    }
                   
                    CreateFeatureCommand.runFeatureCreationInterceptors(feature);
                   
                    // FeaturePanelProcessor panels = ProjectUIPlugin.getDefault()
                    // .getFeaturePanelProcessor();
                    // List<FeaturePanelEntry> popup = panels.search(schema);
                    // if (popup.isEmpty()) {
                    CreateAndSelectNewFeature newFeatureCommand = new CreateAndSelectNewFeature(
                            handler.getCurrentGeom(), feature, layer, deselectCreatedFeatures);
                    commands.add(newFeatureCommand);
                    // } else {
                    // CreateDialogAndSelectNewFeature newFeatureCommand = new
                    // CreateDialogAndSelectNewFeature(
                    // handler.getCurrentGeom(), feature, layer, deselectCreatedFeatures,
                    // popup);
                    // commands.add(newFeatureCommand);
                    // }
                } else {
                    // not creating it so don't need to set it.
                    UndoableMapCommand setGeometryCommand = new SetGeometryCommand(editGeom
                            .getFeatureIDRef().get(), new StaticBlockingProvider<ILayer>(layer),
                            SetGeometryCommand.DEFAULT, geom);
                    commands.add(setGeometryCommand);
                }
            } else {
                commands.add(new CreateNewOrSelectExitingFeatureCommand(editGeom.getFeatureIDRef()
                        .get(), layer, geom));

            }
            commands.add(new SetEditGeomChangedStateCommand(editGeom, false));
            commands.add(drawfactory.createStopAnimationCommand(display, Collections
View Full Code Here

    }
   

    private boolean onEdge( EditToolHandler handler, MapMouseEvent e ) {
        Point point = Point.valueOf(e.x,e.y);
        EditGeom geom = handler.getCurrentGeom();
        if( geom==null )
            return false;

        ILayer selectedLayer = handler.getEditLayer();
        Class type = selectedLayer.getSchema().getGeometryDescriptor().getType().getBinding();
        boolean polygonLayer=Polygon.class.isAssignableFrom(type) || MultiPolygon.class.isAssignableFrom(type);

        ClosestEdge closestEdge = geom.getClosestEdge(point, polygonLayer);
       
        return closestEdge!=null && closestEdge.getDistanceToEdge()<PreferenceUtil.instance().getVertexRadius();
    }
View Full Code Here

            setText(Messages.DeleteGlobalActionSetterActivator_title);
            setToolTipText(Messages.DeleteGlobalActionSetterActivator_tooltip);
        }
        @Override
        public void runWithEvent( Event event ) {
            EditGeom currentGeom = handler.getCurrentGeom();
            if( currentGeom==null )
                return;
            EditBlackboard editBlackboard = currentGeom.getEditBlackboard();
            if( editBlackboard.getSelection().isEmpty() || hasNoPoints() ){
                UndoableComposite composite=new UndoableComposite();
                composite.getCommands().add(new SetEditStateCommand(handler, EditState.BUSY));
                composite.getCommands().add(new RemoveAllVerticesCommand(handler));
                composite.getCommands().add(handler.getCommand(handler.getAcceptBehaviours()));
View Full Code Here

        boolean legalEventType=eventType==EventType.RELEASED;
        boolean shapeAndGeomNotNull=handler.getCurrentShape()!=null;
        boolean button1Released=e.button==MapMouseEvent.BUTTON1;
        if( !shapeAndGeomNotNull )
            return false;
        EditGeom currentGeom = handler.getCurrentGeom();
        boolean selectedShapeIsPolygon=currentGeom.getShapeType()==ShapeType.POLYGON
            || currentGeom.getShapeType()==ShapeType.UNKNOWN;
       
        if ( !( legalState && legalEventType && shapeAndGeomNotNull && button1Released
        && !e.buttonsDown() && !e.modifiersDown() && selectedShapeIsPolygon) )
            return false;
       
        Point point=Point.valueOf(e.x, e.y);
       
        if( !currentGeom.getShell().contains(point, true) )
            return false;
       
        for( PrimitiveShape shape : currentGeom.getHoles() ) {
            if( shape.contains(point, true) )
                return false;
             }
        return true;
    }
View Full Code Here

                drawShapeCommand.setValid(false);
               
                Set<Point> points = new HashSet<Point>();
                Rectangle rect=(Rectangle) drawShapeCommand.getShape();
                EditGeom geom = handler.getCurrentGeom();
                for( int x=rect.x, maxx=(int) rect.getMaxX(); x<maxx; x++){
                    for( int y=rect.y, maxy=(int) rect.getMaxY(); y<maxy; y++){
                        Point valueOf = Point.valueOf(x,y);
                        if( geom.hasVertex(valueOf))
                            points.add(valueOf);
                    }
                }
               
                handler.unlock(this);
View Full Code Here

TOP

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

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.