Examples of EditBlackboard


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

        assertEquals(0, map.getGeoms().get(0).getShell().getNumCoords());
    }

    @Test
    public void testRunAndUndoWhenVerticesAreSnappedIntoOne() throws Exception {
        EditBlackboard map=new EditBlackboard(SCREEN.x, SCREEN.y, transform, layerToWorld);
       
        AddVertexCommand command1=new AddVertexCommand(new TestHandler(), map, new StaticBlockingProvider<PrimitiveShape>(map.getGeoms().get(0).getShell()), Point.valueOf(10,10), true );
        AddVertexCommand command2=new AddVertexCommand(new TestHandler(), map, new StaticBlockingProvider<PrimitiveShape>(map.getGeoms().get(0).getShell()), Point.valueOf(10,11), true );

        assertEquals(0, map.getCoords(10,10).size());
        assertEquals(0, map.getCoords(10,11).size());       
       
        command1.run(new NullProgressMonitor());
        command2.run(new NullProgressMonitor());

        assertEquals(1, map.getCoords(10,10).size());
        assertEquals(1, map.getCoords(10,11).size());
        assertEquals(2, map.getGeoms().get(0).getShell().getNumPoints());
        assertEquals(2, map.getGeoms().get(0).getShell().getNumCoords());
       
        command2.rollback(new NullProgressMonitor());
        assertEquals(1, map.getCoords(10,10).size());
        assertEquals(0, map.getCoords(10,11).size());
        assertEquals(Point.valueOf(10,10), map.getGeoms().get(0).getShell().getPoint(0));
        assertEquals(1, map.getGeoms().get(0).getShell().getNumPoints());
        assertEquals(1, map.getGeoms().get(0).getShell().getNumCoords());
       
        command1.rollback(new NullProgressMonitor());
        assertTrue(0==map.getCoords(10,10).size());
        assertTrue( 0==map.getGeoms(10,10).size());
        assertEquals(0, map.getGeoms().get(0).getShell().getNumPoints());
        assertEquals(0, map.getGeoms().get(0).getShell().getNumCoords());
    }
View Full Code Here

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

        layerToWorld=CRS.findMathTransform(DefaultGeographicCRS.WGS84, DefaultGeographicCRS.WGS84);   
    }
   
    @Test
    public void testRunAndUndo() throws Exception {
        EditBlackboard map=new EditBlackboard(SCREEN.x, SCREEN.y, transform, layerToWorld);
       
        PrimitiveShape hole=map.getGeoms().get(0).newHole();
        InsertVertexCommand command1=new InsertVertexCommand(new TestHandler(), map, new TestViewportPane(new Dimension(500,500)), new EditUtils.StaticShapeProvider(hole), Point.valueOf(10,10), 0, true );
        InsertVertexCommand command2=new InsertVertexCommand(new TestHandler(), map, new TestViewportPane(new Dimension(500,500)), new EditUtils.StaticShapeProvider(hole), Point.valueOf(10,15), 0, true );

        assertEquals(0, map.getCoords(10,10).size());
        assertEquals(0, map.getCoords(10,15).size());
       
        command1.run(new NullProgressMonitor());
        command2.run(new NullProgressMonitor());
       
        assertEquals(1, map.getCoords(10,10).size());
        assertEquals(1, map.getCoords(10,15).size());
        assertEquals( Point.valueOf(10,15), hole.getPoint(0));
        assertEquals( Point.valueOf(10,10), hole.getPoint(1));
       
        command2.rollback(new NullProgressMonitor());
        assertTrue( 0==map.getCoords(10,15).size());
        assertTrue(0==map.getGeoms(10,15).size());
        assertEquals(Point.valueOf(10,10), hole.getPoint(0));
        assertEquals(1, hole.getNumPoints());
        assertEquals(1, hole.getNumCoords());
       
        command1.rollback(new NullProgressMonitor());
        assertTrue(0==map.getCoords(10,10).size());
        assertTrue(0==map.getGeoms(10,10).size());
        assertEquals(0, hole.getNumPoints());
        assertEquals(0, hole.getNumCoords());
       
       
    }
View Full Code Here

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

        FeatureSource<SimpleFeatureType, SimpleFeature> resource = layer.getResource(FeatureSource.class, null);
        SimpleFeature feature = resource.getFeatures().features().next();
        IEditManager editManager = handler.getContext().getEditManager();
    ((EditManager)editManager).setEditFeature(feature, (Layer) layer);
       
        EditBlackboard editBlackboard = handler.getEditBlackboard();
        PrimitiveShape shell = editBlackboard.getGeoms().get(0).getShell();
        editBlackboard.addPoint(100,100,shell);
        shell.getEditGeom().setShapeType(ShapeType.POINT);
        editBlackboard.newGeom("newone", null); //$NON-NLS-1$
       
        StartEditingBehaviour behav=new StartEditingBehaviour(ShapeType.POLYGON);

        handler.getBehaviours().add(behav);
       
        assertNotNull( editManager.getEditFeature());
       
        handler.setTesting(false);
        MapMouseEvent event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.RELEASED);
        try{
            PlatformGIS.wait(200, 200, WaitCondition.FALSE_CONDITION, null);
        }catch (Exception e) {
            // its expected
        }
        assertEquals(1, handler.getEditBlackboard().getGeoms().size());
       
        ((CommandManager)((Map)handler.getContext().getMap()).getCommandStack()).undo(false);
       
        assertEquals("Is the feature ID equal", feature.getID(), editManager.getEditFeature().getID());       
        assertEquals("Is the feature equal", feature, editManager.getEditFeature());
        assertFalse( handler.isLocked() );
        assertEquals(2, editBlackboard.getGeoms().size());
        assertEquals(ShapeType.POINT, editBlackboard.getGeoms().get(0).getShapeType());
        assertEquals(Point.valueOf(100,100), editBlackboard.getGeoms().get(0).getShell().getPoint(0));
       
    }
View Full Code Here

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

     * Test method for 'org.locationtech.udig.tools.edit.commands.SplitFeatureCommand.run(IProgressMonitor)'
     */
    @Test
    public void testDifferencePolygonOnce() throws Exception {
        handler.resetEditBlackboard();
        EditBlackboard bb = handler.getEditBlackboard();
        PrimitiveShape shell = bb.newGeom(null, null).getShell();
        handler.setCurrentShape(shell);
        bb.addPoint(25,0, shell);
        bb.addPoint(35,0, shell);
        bb.addPoint(35,60, shell);
        bb.addPoint(25,60, shell);
       
        DifferenceFeatureCommand command=new DifferenceFeatureCommand(handler, EditState.NONE);
       
        command.setMap(map);
        NullProgressMonitor nullProgressMonitor = new NullProgressMonitor();
        command.run(nullProgressMonitor);
       
        FeatureSource<SimpleFeatureType, SimpleFeature> resource = map.getEditManager().getSelectedLayer().getResource(FeatureSource.class, nullProgressMonitor);
        assertEquals(3, resource.getCount(Query.ALL));
        FeatureIterator<SimpleFeature> iter = resource.getFeatures().features();
        int found=0;
        while( iter.hasNext() ){
            SimpleFeature feature=iter.next();
            if( feature.getID().equals("new0") ){ //$NON-NLS-1$
                List<Coordinate> coords = Arrays.asList(((Geometry) feature.getDefaultGeometry()).getCoordinates());
                assertEquals(10, coords.size());
                assertTrue(coords.contains( bb.toCoord(Point.valueOf(25,0)) ) );
                assertTrue(coords.contains(new Coordinate(35.5,0.5)) );
                assertTrue(coords.contains(new Coordinate(35.5,20)) );
                assertTrue(coords.contains(new Coordinate(25.5,20)) );
                assertTrue(coords.contains(new Coordinate(25.5,40) ) );
                assertTrue(coords.contains(new Coordinate(35.5,40)) );
View Full Code Here

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

        handler.resetEditBlackboard();
        GeometryFactory fac=new GeometryFactory();
        Polygon[] polygons = new Polygon[]{ (Polygon) features[1].getDefaultGeometry()};
        MultiPolygon createMultiPolygon = fac.createMultiPolygon(polygons);
        features[1].setDefaultGeometry(createMultiPolygon);
        EditBlackboard bb = handler.getEditBlackboard();
        PrimitiveShape shell = bb.newGeom(null, null).getShell();
        handler.setCurrentShape(shell);
        bb.addPoint(25,0, shell);
        bb.addPoint(35,0, shell);
        bb.addPoint(35,60, shell);
        bb.addPoint(25,60, shell);
       
        DifferenceFeatureCommand command=new DifferenceFeatureCommand(handler, EditState.NONE);
       
        command.setMap(map);
        NullProgressMonitor nullProgressMonitor = new NullProgressMonitor();
View Full Code Here

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

        FeatureStore<SimpleFeatureType, SimpleFeature> store = map.getMapLayers().get(0).getResource(FeatureStore.class, new NullProgressMonitor());       
        FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
    store.modifyFeatures(features[0].getFeatureType().getGeometryDescriptor(), polygon,
                filterFactory.id(FeatureUtils.stringToId(filterFactory, features[0].getID())));
   
        EditBlackboard bb = handler.getEditBlackboard();
       
        PrimitiveShape shell = bb.newGeom(null, null).getShell();
        handler.setCurrentShape(shell);
        bb.addPoint(25,0, shell);
        bb.addPoint(35,0, shell);
        bb.addPoint(35,60, shell);
        bb.addPoint(25,60, shell);
       
        DifferenceFeatureCommand command=new DifferenceFeatureCommand(handler, EditState.NONE);
       
        command.setMap(map);
        NullProgressMonitor nullProgressMonitor = new NullProgressMonitor();
View Full Code Here

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

        FeatureStore<SimpleFeatureType, SimpleFeature> store = map.getMapLayers().get(0).getResource(FeatureStore.class, new NullProgressMonitor());
        FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
    store.removeFeatures(filterFactory.id(FeatureUtils.stringToId(filterFactory, features[1].getID())));
        store.modifyFeatures(features[0].getFeatureType().getGeometryDescriptor(), geom,
                filterFactory.id(FeatureUtils.stringToId(filterFactory, features[0].getID())));
        EditBlackboard bb = handler.getEditBlackboard();
       
        PrimitiveShape shell = bb.newGeom(null, null).getShell();
        handler.setCurrentShape(shell);
        bb.addPoint(25,0, shell);
        bb.addPoint(35,0, shell);
        bb.addPoint(35,65, shell);
        bb.addPoint(25,65, shell);
       
        DifferenceFeatureCommand command=new DifferenceFeatureCommand(handler, EditState.NONE);
       
        command.setMap(map);
        NullProgressMonitor nullProgressMonitor = new NullProgressMonitor();
View Full Code Here

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

    @Test
    public void testPolygon() throws Exception {
        AcceptChangesBehaviour behaviour;
        FeatureIterator<SimpleFeature> features;
        SimpleFeature next;
        EditBlackboard bb = handler.getEditBlackboard();
        EditGeom editGeom = bb.getGeoms().get(0);

        handler.setCurrentShape(editGeom.getShell());
       
           // test create Polygon
        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);
       
        behaviour=new AcceptChangesBehaviour(Polygon.class, false);       
        UndoableMapCommand command = behaviour.getCommand(handler);
        command.setMap(handler.getContext().getMap());
        command.run(new NullProgressMonitor());
View Full Code Here

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

    @Test
    public void testMultiPolygon() throws Exception {
        AcceptChangesBehaviour behaviour;
        FeatureIterator<SimpleFeature> features;
        SimpleFeature next;
        EditBlackboard bb = handler.getEditBlackboard();
        EditGeom editGeom = bb.getGeoms().get(0);

        SimpleFeatureType type = DataUtilities.createType("MultiPolygon", "*geom:MultiPolygon"); //$NON-NLS-1$ //$NON-NLS-2$
        feature = SimpleFeatureBuilder.template(type, feature.getID());
        ((TestLayer)handler.getContext().getMap().getMapLayers().get(0)).setSchema(type);
       ((Map)handler.getContext().getMap()).getEditManagerInternal().setEditFeature(feature, layer);

        handler.setCurrentShape(bb.getGeoms().get(0).getShell());
       
           // test create MultiPolygon
        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);
       
        behaviour=new AcceptChangesBehaviour(Polygon.class, false);
        UndoableMapCommand command = behaviour.getCommand(handler);
        command.setMap(handler.getContext().getMap());
        command.run(new NullProgressMonitor());
View Full Code Here

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

    public void testLines() throws Exception {
        AcceptChangesBehaviour behaviour;
        FeatureIterator<SimpleFeature> features;
        SimpleFeature next;
       
        EditBlackboard bb = handler.getEditBlackboard();
        EditGeom editGeom = bb.getGeoms().get(0);

        handler.setCurrentShape(editGeom.getShell());

        bb.addPoint(10,10,editGeom.getShell());
        bb.addPoint(40,10,editGeom.getShell());
    
        SimpleFeatureType type = DataUtilities.createType("MultiLine", "*geom:MultiLineString"); //$NON-NLS-1$ //$NON-NLS-2$
        feature = SimpleFeatureBuilder.template(type, feature.getID());
        ((TestLayer)handler.getContext().getMap().getMapLayers().get(0)).setSchema(type);
        ((Map)handler.getContext().getMap()).getEditManagerInternal().setEditFeature(feature, layer);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.