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

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


    public void testMultiLine() 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());
       
        // test create LineString
        behaviour=new AcceptChangesBehaviour(LineString.class, false);
        UndoableMapCommand command = behaviour.getCommand(handler);
        command.setMap(handler.getContext().getMap());
View Full Code Here


    @Ignore
    @Test
    public void testPoint() throws Exception {
        AcceptChangesBehaviour behaviour=new AcceptChangesBehaviour(Point.class, false);

        EditBlackboard bb = handler.getEditBlackboard();
        EditGeom editGeom = bb.getGeoms().get(0);

        bb.addPoint(10,10,editGeom.getShell());
       
        try{
            behaviour.getCommand(handler);
            fail();
        }catch (IllegalArgumentException e) {
            // good
        }
       
        handler.setCurrentShape(editGeom.getShell());
       
        // test create point
        UndoableMapCommand command = behaviour.getCommand(handler);
        command.setMap(handler.getContext().getMap());
        command.run(new NullProgressMonitor());
       
        assertEquals(toCoord(bb,10,10), ((Geometry) feature.getDefaultGeometry()).getCoordinates()[0]);
        FeatureIterator<SimpleFeature> features = layer.getResource(FeatureSource.class, null).getFeatures().features();
        SimpleFeature next = features.next();
        assertEquals( toCoord(bb,10,10), ((Geometry) next.getDefaultGeometry()).getCoordinates()[0] );
        assertEquals(Point.class, feature.getDefaultGeometry().getClass());
       
        bb.addPoint(40,10,bb.newGeom(null, null).getShell());
        handler.getCurrentGeom().setChanged(true);

        SimpleFeatureType type = DataUtilities.createType("MultiPoint", "*geom:MultiPoint"); //$NON-NLS-1$ //$NON-NLS-2$
        feature = SimpleFeatureBuilder.template(type, feature.getID());
        ((TestLayer)handler.getContext().getMap().getMapLayers().get(0)).setSchema(type);
View Full Code Here

        NullProgressMonitor nullProgressMonitor = new NullProgressMonitor();
        FeatureSource<SimpleFeatureType, SimpleFeature> source = layer.getResource(FeatureSource.class, nullProgressMonitor);
        int count=source.getCount(Query.ALL);
       
        EditBlackboard bb = handler.getEditBlackboard();
        EditGeom editGeom = bb.getGeoms().get(0);

        bb.addPoint(10,10,editGeom.getShell());

        handler.setCurrentShape(editGeom.getShell());
       UndoableMapCommand command = behaviour.getCommand(handler);
       command.setMap((Map) handler.getContext().getMap());
       nullProgressMonitor = new NullProgressMonitor();
View Full Code Here

     * @throws Exception
     */
    @Ignore
    @Test
    public void testMultiPointOnBlackboard() throws Exception {
        EditBlackboard bb = handler.getEditBlackboard();
        EditGeom geom = bb.newGeom(feature.getID(), ShapeType.POINT);
        bb.addPoint(10,10,geom.getShell());
        handler.setCurrentShape(geom.getShell());
       
        EditGeom geom2 = bb.newGeom(feature.getID(), ShapeType.POINT);
        bb.addPoint(20,20, geom2.getShell());
       
        AcceptChangesBehaviour behaviour = new AcceptChangesBehaviour(Point.class, false);
        UndoableMapCommand command = behaviour.getCommand(handler);
        command.setMap((Map) handler.getContext().getMap());
        command.run(new NullProgressMonitor());
View Full Code Here

     *
     * @throws Exception
     */
    @Test
    public void testTwoChangedFeaturesOnBlackboard() throws Exception {
        EditBlackboard bb = handler.getEditBlackboard();
        EditGeom geom1 = bb.newGeom(feature.getID(), null);
        bb.addPoint(10,10, geom1.getShell());
        bb.addPoint(20,10, geom1.getShell());
        bb.addPoint(20,20, geom1.getShell());
        bb.addPoint(10,10, geom1.getShell());
        handler.setCurrentShape(geom1.getShell());
       
        EditGeom geom2 = bb.newGeom(feature2.getID(), null);
       
        bb.addPoint(100,100, geom2.getShell());
        bb.addPoint(200,100, geom2.getShell());
        bb.addPoint(200,200, geom2.getShell());
        bb.addPoint(100,100, geom2.getShell());
       
        AcceptChangesBehaviour behaviour=new AcceptChangesBehaviour(LineString.class, false);
        UndoableMapCommand command = behaviour.getCommand(handler);
        command.setMap((Map) handler.getContext().getMap());
        command.run(new NullProgressMonitor());
View Full Code Here

     *
     * @throws Exception
     */
    @Test
    public void testCreateFeature() throws Exception {
        EditBlackboard bb = handler.getEditBlackboard();
       
        EditGeom geom1 = bb.newGeom("newOne", ShapeType.LINE); //$NON-NLS-1$
        bb.addPoint(10,10, geom1.getShell());
        bb.addPoint(20,10, geom1.getShell());
        bb.addPoint(20,20, geom1.getShell());
        bb.addPoint(10,10, geom1.getShell());
       
       
        EditGeom geom2 = bb.newGeom(feature.getID(), null);
        bb.addPoint(100,100, geom2.getShell());
        bb.addPoint(200,100, geom2.getShell());
        bb.addPoint(200,200, geom2.getShell());
        bb.addPoint(100,100, geom2.getShell());
        handler.setCurrentShape(geom2.getShell());
       
        AcceptChangesBehaviour behaviour=new AcceptChangesBehaviour(LineString.class, false);
        UndoableMapCommand command = behaviour.getCommand(handler);
        command.setMap((Map) handler.getContext().getMap());
View Full Code Here

    }
   
    @Ignore
    @Test
    public void testCutHole() throws Exception {
        EditBlackboard editBlackboard = handler.getEditBlackboard();
        EditGeom geom = editBlackboard.getGeoms().get(0);
        editBlackboard.addPoint(0,0,geom.getShell());
        editBlackboard.addPoint(40,0,geom.getShell());
        editBlackboard.addPoint(40,40,geom.getShell());
        editBlackboard.addPoint(0,40,geom.getShell());
        editBlackboard.addPoint(0,0,geom.getShell());
        handler.setCurrentShape(geom.getShell());
       
        handler.getMouseTracker().setDragStarted(Point.valueOf(10,10));
       
        MapMouseEvent event=new MapMouseEvent(null, 20,10,MapMouseEvent.NONE,MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
View Full Code Here

        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();
        AddVertexCommand command1=new AddVertexCommand(new TestHandler(), map, new StaticBlockingProvider<PrimitiveShape>(hole), Point.valueOf(10,10), true );
        AddVertexCommand command2=new AddVertexCommand(new TestHandler(), map, new StaticBlockingProvider<PrimitiveShape>(hole), Point.valueOf(10,15), 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());
       
        command2.rollback(new NullProgressMonitor());
        assertTrue(map.getCoords(10,15)==null || 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(map.getCoords(10,10)==null || 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

        ILayer layer = handler.getContext().getMapLayers().get(0);
        FeatureSource<SimpleFeatureType, SimpleFeature> resource = layer.getResource(FeatureSource.class, null);
        SimpleFeature feature = resource.getFeatures().features().next();
        ((EditManager)handler.getContext().getEditManager()).setEditFeature(feature, (Layer) layer);
       
        final 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$
       
        CreateShapeBehaviour behav=new CreateShapeBehaviour(new ShapeFactory(){
            @Override
            public GeneralPath create( int width, int height ) {
                GeneralPath path=new GeneralPath();
                path.append(new Rectangle(width, height), false);
                return path;
            }
        });
       
        handler.getBehaviours().add(behav);
       
        assertNotNull( handler.getContext().getEditManager().getEditFeature());

        handler.getAcceptBehaviours().add(new AcceptChangesBehaviour(Polygon.class, false));
        handler.getMouseTracker().setDragStarted(Point.valueOf(10,0));
        MapMouseEvent event=new MapMouseEvent( null, 20, 20, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);
       
        assertTrue( handler.isLocked() );
        assertTrue( handler.isLockOwner(behav) );

        event=new MapMouseEvent( null, 20, 20, MapMouseEvent.NONE,
                MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        handler.setTesting(false);
        handler.handleEvent(event, EventType.RELEASED);

        UDIGTestUtil.inDisplayThreadWait(1000, new WaitCondition(){

            public boolean isTrue() {
                return handler.getCurrentState()==EditState.NONE && editBlackboard.getGeoms().size()==1
                && 2==editBlackboard.getCoords(10,0).size();
            }
        }, false);
       
        assertNotSame( feature, handler.getContext().getEditManager().getEditFeature());
        assertFalse( handler.isLocked() );
        assertEquals( 1, editBlackboard.getGeoms().size());
        assertEquals( 2, editBlackboard.getCoords(10,0).size() );
        assertEquals( 1, editBlackboard.getCoords(20,0).size() );
        assertEquals( 1, editBlackboard.getCoords(20,20).size() );
        assertEquals( 1, editBlackboard.getCoords(10,20).size() );
        assertEquals(ShapeType.POLYGON, editBlackboard.getGeoms().get(0).getShapeType());
       
        ((CommandManager)((Map)handler.getContext().getMap()).getCommandStack()).undo(false);
       
        assertNotSame(feature, handler.getContext().getEditManager().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

        layerToWorld=CRS.findMathTransform(DefaultGeographicCRS.WGS84, DefaultGeographicCRS.WGS84);   
    }
   
    @Test
    public void testRunAndUndo() throws Exception {
        EditBlackboard map=new EditBlackboard(SCREEN.x, SCREEN.y, transform, layerToWorld);
       
        InsertVertexCommand command1=new InsertVertexCommand(new TestHandler(), map, new TestViewportPane(new Dimension(500,500)),
                new EditUtils.StaticShapeProvider(map.getGeoms().get(0).getShell()), Point.valueOf(10,10), 0, true );
        InsertVertexCommand command2=new InsertVertexCommand(new TestHandler(), map, new TestViewportPane(new Dimension(500,500)),
                new EditUtils.StaticShapeProvider(map.getGeoms().get(0).getShell()), 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), map.getGeoms().get(0).getShell().getPoint(0));
        assertEquals( Point.valueOf(10,10), map.getGeoms().get(0).getShell().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), 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(map.getCoords(10,10)==null || 0==map.getCoords(10,10).size());
        assertTrue(map.getGeoms(10,10)==null || 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

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.