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

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


    }

    public void rollback( IProgressMonitor monitor ) throws Exception {
        editBlackboard.removeGeometries(Collections.singleton(first));

        EditGeom newGeom = editBlackboard.newGeom(oldshape.getEditGeom().getFeatureIDRef().get(), oldshape.getEditGeom().getShapeType());

        for( int i = 0; i < oldshape.getNumCoords(); i++ ) {
            editBlackboard.addCoordinate(oldshape.getCoord(i), newGeom.getShell());
        }

        if (currentShapeSet)
            setCurrentShape(newGeom.getShell());

        FeatureStore<SimpleFeatureType, SimpleFeature> store = layer.getResource(FeatureStore.class, new SubProgressMonitor(monitor,
                1));

        FilterFactory factory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
View Full Code Here


     * Copies the geometry back onto the editblackboard.
     *
     * @return
     */
    private void copyFeature( EditBlackboard editBlackboard, EditGeom geom ) {
        EditGeom newGeom = editBlackboard.newGeom(geom.getFeatureIDRef().get(), geom.getShapeType());
        for( PrimitiveShape shape : geom ) {
            PrimitiveShape newShape;
            if (shape == geom.getShell()) {
                newShape = newGeom.getShell();
            } else {
                newShape = newGeom.newHole();
            }
            if (shape == currentShape)
                handler.setCurrentShape(newShape);
            for( int i = 0; i < shape.getNumCoords(); i++ ) {
                editBlackboard.addCoordinate(shape.getCoord(i), newShape);
            }
            newGeom.setChanged(geom.isChanged());
        }
    }
View Full Code Here

            editLayer=(Layer) getMap().getEditManager().getSelectedLayer();
        this.added=blackboard.addGeometry((Geometry) feature.getDefaultGeometry(), feature.getID()).values();
        if( !added.isEmpty() && mouseLocation!=null ){
            Class<?> type = editLayer.getSchema().getGeometryDescriptor().getType().getBinding();
            boolean polygonLayer=Polygon.class.isAssignableFrom(type) || MultiPolygon.class.isAssignableFrom(type);
            EditGeom geom = EditUtils.instance.getGeomWithMouseOver(added, mouseLocation, polygonLayer);
            handler.setCurrentShape(geom.getShell());
            setEditFeatureCommand = new SetEditFeatureCommand(handler, mouseLocation, geom.getShell());
            setEditFeatureCommand.setMap(getMap());
            setEditFeatureCommand.run(SubMonitor.convert(monitor));
        }
       
        //make sure the display refreshes
View Full Code Here

    private Pair<PrimitiveShape, SimpleFeature> newSelection( IProgressMonitor monitor )
            throws IOException {

        EditBlackboard editBlackboard = handler.getEditBlackboard(layer);
        if (!editBlackboard.isEmpty()) {
            EditGeom newSelection = editBlackboard.getGeoms().get(0);

            FilterFactory factory = CommonFactoryFinder
                    .getFilterFactory(GeoTools.getDefaultHints());
            Id id = factory.id(Collections.singleton(factory.featureId(newSelection
                    .getFeatureIDRef().get())));

            FeatureSource<SimpleFeatureType, SimpleFeature> source = layer.getResource(FeatureSource.class, monitor);
            FeatureCollection<SimpleFeatureType, SimpleFeature>  features = source.getFeatures(id);

            FeatureIterator<SimpleFeature> iter = features.features();
            try {
                if (iter.hasNext()) {
                    return new Pair<PrimitiveShape, SimpleFeature>(newSelection.getShell(), iter
                            .next());
                }
            } finally {
                iter.close();
            }
View Full Code Here

        if (currentState != null)
            handler.setCurrentState(currentState);
        if (nullEditFeatureCommand != null)
            nullEditFeatureCommand.rollback(new SubProgressMonitor(monitor, 10));
        EditBlackboard bb = handler.getEditBlackboard(layer);
        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);
                }
            }
View Full Code Here

     * @param bb
     * @param geom
     * @return
     */
    private EditGeom addGeom( EditBlackboard bb, EditGeom geom ) {
        EditGeom newGeom = bb.newGeom(geom.getFeatureIDRef().get(), geom.getShapeType());
        newGeom.setChanged(geom.isChanged());
        for( PrimitiveShape shape : geom ) {
            PrimitiveShape newShape = newGeom.getShell();
            if (shape != geom.getShell())
                newShape = newGeom.newHole();
            Coordinate[] coords = shape.coordArray();
            for( int i = 0; i < coords.length; i++ ) {
                bb.addCoordinate(coords[i], newShape);
            }
        }
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.