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

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


    public void op( Display display, Object target, IProgressMonitor monitor ) throws Exception {
        Point[] points=(Point[]) target;
       
        IMap map = ApplicationGIS.getActiveMap();
       
        EditBlackboard editBlackboard = EditBlackboardUtil.getEditBlackboard(ApplicationGIS.createContext(map),
                map.getEditManager().getSelectedLayer());
       
        ShapeProvider shapeProvider=new ShapeProvider(map);
       
         map.sendCommandASync(new SplitLineCommand(editBlackboard, shapeProvider,
View Full Code Here


  /**
   * @param newValue
   */
  private void setCurrentGeom(SimpleFeature newValue) {
    EditBlackboard bb = handler.getEditBlackboard(handler.getContext().getSelectedLayer());
    Map<Geometry, EditGeom> editGeoms = bb.setGeometries((Geometry) newValue.getDefaultGeometry(), newValue.getID());
    if( editGeoms.isEmpty() ){
      return;
    }
   
    EditGeom firstShape = editGeoms.values().iterator().next();
View Full Code Here

        SelectFeatureBehaviour mode=new SelectFeatureBehaviour(new Class[]{Point.class}, BBOX.class);
       
        Listener l=new Listener();
        handler.getBehaviours().add(mode);
        handler.getContext().getMap().getBlackboard().addListener(l);
        handler.setEditBlackboard(new EditBlackboard(SCREEN.x,
                SCREEN.y, map.getViewportModel().worldToScreenTransform(), map.getLayersInternal().get(0).layerToMapTransform()));
        handler.setContext(ApplicationGISInternal.createContext(map));
        handler.getEditBlackboard().getListeners().add(l);
       
        handler.handleEvent(new MapMouseEvent(null, 10, 0, none, none, button1), EventType.RELEASED);
View Full Code Here

    @Test
    public void testSelectMultiGeom() throws Exception {
        SelectFeatureBehaviour mode=new SelectFeatureBehaviour(new Class[]{MultiLineString.class}, BBOX.class);

        handler.getBehaviours().add(mode);
        handler.setEditBlackboard(new EditBlackboard(500,500, map.getViewportModel().worldToScreenTransform(),
                map.getLayersInternal().get(0).layerToMapTransform()));
       
        FeatureStore<SimpleFeatureType, SimpleFeature> resource = map.getLayersInternal().get(0).getResource(FeatureStore.class, null);
        GeometryFactory factory=new GeometryFactory();
        LineString line1=factory.createLineString(new Coordinate[]{
View Full Code Here

    @Test
    public void testGetCommand() {

        EditGeom geom = handler.getCurrentGeom();
        PrimitiveShape hole = geom.newHole();
        EditBlackboard bb = handler.getEditBlackboard();

        bb.addPoint(5, 5, hole);
        bb.addPoint(25, 5, hole);
        bb.addPoint(25, 25, hole);
        bb.addPoint(5, 25, hole);
        bb.addPoint(5, 5, hole);

        handler.getMouseTracker().setDragStarted(Point.valueOf(10, 10));
        MapMouseEvent event = new MapMouseEvent(null, 20, 10, MapMouseEvent.ALT_DOWN_MASK
                | MapMouseEvent.CTRL_DOWN_MASK, MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);
View Full Code Here

       
        ViewportModel model = ((ViewportModel) handler.getContext().getMap().getViewportModel());
        model.setBounds(env);
        model.setWidth(env.getWidth()*200);
       
        handler.setEditBlackboard(new EditBlackboard(10, 10, model.worldToScreenTransform(),
                TestEditBlackboard.IDENTITY));

        EditBlackboard editBlackboard = handler.getEditBlackboard();
        editBlackboard.setGeometries(lake, "lake"); //$NON-NLS-1$
       
        handler.getAcceptBehaviours().add(new AcceptChangesBehaviour(Polygon.class, false));
        Point[] points = new Point[coords.length];
        for( int i = 0; i < coords.length; i++ ) {
            points[i] = editBlackboard.toPoint(coords[i]);
        }
       
        for( int i = 0; i < points.length; i++ ) {
            List<Coordinate> list = editBlackboard.getCoords(points[i].getX(), points[i].getY());
            System.out.println(list.size());
            assertTrue(!list.isEmpty());
        }
       
        System.out.println("Done first check"); //$NON-NLS-1$
       
        handler.getMouseTracker().setDragStarted(points[0]);
        PrimitiveShape shell = editBlackboard.getGeoms().get(0).getShell();
        handler.setCurrentShape(shell);

        Coordinate[] shellCoords=new Coordinate[coords.length];
       
        for( int i = 0; i < shellCoords.length; i++ ) {
            shellCoords[i]=shell.getCoord(i);
        }
       
        MapMouseEvent event = new MapMouseEvent(handler.getContext().getMapDisplay(), points[0]
                .getX(), points[0].getY(), MapMouseEvent.ALT_DOWN_MASK
                | MapMouseEvent.CTRL_DOWN_MASK, MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);

        event = new MapMouseEvent(handler.getContext().getMapDisplay(), points[0]
                .getX() + 1, points[0].getY(), MapMouseEvent.ALT_DOWN_MASK
                | MapMouseEvent.CTRL_DOWN_MASK, MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);
       

        event = new MapMouseEvent(handler.getContext().getMapDisplay(), points[0]
                .getX() + 2, points[0].getY(), MapMouseEvent.ALT_DOWN_MASK
                | MapMouseEvent.CTRL_DOWN_MASK, MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);

        for( int i = 0; i < points.length; i++ ) {
            List<Coordinate> list = editBlackboard.getCoords(points[i].getX()+2, points[i].getY());
            System.out.println(list.size());
            assertTrue(!list.isEmpty());
        }

        for( int i = 0; i < points.length; i++ ) {
            List<EditGeom> list = editBlackboard.getGeoms(points[i].getX()+2, points[i].getY());
            System.out.println(list.size());
            assertTrue(!list.isEmpty());
        }
       
//        for( int i = 0; i < coords.length; i++ ) {
//            assertSame(  );
//        }
       
        Coordinate deltaPart1 = editBlackboard.toCoord(Point.valueOf(points[0].getX()+2, points[0].getY()));
        Coordinate deltaPart2 = editBlackboard.toCoord(points[0]);
        double deltaX = deltaPart1.x-deltaPart2.x;
        double deltaY = deltaPart1.y-deltaPart2.y;
       
        for( int i = 0; i < coords.length; i++ ) {
            assertEquals( new Coordinate( coords[i].x+deltaX, coords[i].y+deltaY ),
View Full Code Here

    @Test
    public void testUndo() throws Exception {

        editBlackboard.selectionAdd(Point.valueOf(10,10));
        editBlackboard.selectionAdd(Point.valueOf(20,10));
        EditBlackboard bb = handler.getEditBlackboard();
        handler.getMouseTracker().setDragStarted(Point.valueOf(10,10));
        MapMouseEvent event = new MapMouseEvent( DISPLAY, 10,11,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);
        assertEquals(1, bb.getCoords(10,11).size());
        assertTrue(handler.getCurrentShape().hasVertex(Point.valueOf(10,11)));
       
        event = new MapMouseEvent( DISPLAY, 10,12,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);
        assertEquals(1, bb.getCoords(10,12).size());
        assertTrue(handler.getCurrentShape().hasVertex(Point.valueOf(10,12)));
       
        event = new MapMouseEvent( DISPLAY, 10,13,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);
        assertEquals(1, bb.getCoords(10,13).size());
        assertTrue(handler.getCurrentShape().hasVertex(Point.valueOf(10,13)));
       
        event = new MapMouseEvent( DISPLAY, 10,14,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);
        assertEquals(1, bb.getCoords(10,14).size());
        assertTrue(handler.getCurrentShape().hasVertex(Point.valueOf(10,14)));
       
        event = new MapMouseEvent( DISPLAY, 10,15,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);
        assertEquals(1, bb.getCoords(10,15).size());
        assertTrue(handler.getCurrentShape().hasVertex(Point.valueOf(10,15)));

        assertEquals(1, editBlackboard.getCoords(10,15).size());
        assertEquals(1, editBlackboard.getCoords(20,15).size());
        assertEquals(0, editBlackboard.getCoords(10,10).size());
View Full Code Here

     */
    @Test
    public void testRun() throws Exception {
        TestHandler handler=new TestHandler();
       
        EditBlackboard editBlackboard = handler.getEditBlackboard();
        PrimitiveShape shape = editBlackboard.getGeoms().get(0).getShell();
        editBlackboard.addPoint(0,0, shape);
        editBlackboard.addPoint(100,0, shape);
        editBlackboard.addPoint(100,100, shape);
        editBlackboard.addPoint(0,100, shape);
        editBlackboard.addPoint(0,0, shape);
       
        PrimitiveShape hole = shape.getEditGeom().newHole();
        editBlackboard.addPoint(5,5, hole);
        editBlackboard.addPoint(20,5, hole);
        editBlackboard.addPoint(20,20, hole);
        editBlackboard.addPoint(5,20, hole);
        editBlackboard.addPoint(5,5, hole);
       
        PrimitiveShape hole2 = shape.getEditGeom().newHole();
        editBlackboard.addPoint(30,30, hole2);
        editBlackboard.addPoint(80,30, hole2);
        editBlackboard.addPoint(80,80, hole2);
        editBlackboard.addPoint(30,80, hole2);
        editBlackboard.addPoint(30,30, hole2);
       
        handler.setCurrentShape(shape);
       
        MapMouseEvent event=new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.NONE);
        SelectHoleCommand command=new SelectHoleCommand(handler, event);
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);
       
        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,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), 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

        assertEquals(0, handler.getEditBlackboard().getSelection().size());
    }

    @Test
    public void testSelectingWhen2ShapesAreOnBB() throws Exception {
        EditBlackboard bb = handler.getEditBlackboard();
        EditGeom geom2 = bb.newGeom("new", null); //$NON-NLS-1$
        bb.addPoint(100,0,geom2.getShell());
        bb.addPoint(100,10,geom2.getShell());

        handler.getBehaviours().add( new SelectVerticesWithBoxBehaviour() );
       
        handler.setCurrentShape(shell);
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.