Package org.locationtech.udig.project.ui.render.displayAdapter

Examples of org.locationtech.udig.project.ui.render.displayAdapter.MapMouseEvent


    @Ignore
    @Test
    public void testDrawLine() {
        handler.getMouseTracker().setDragStarted(Point.valueOf(0,10));
       
        MapMouseEvent event=new MapMouseEvent(null, 10,10,MapMouseEvent.NONE,MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);

        assertTrue(handler.isLocked());
        assertNotNull(handler.getCurrentShape());
        assertEquals(EditState.CREATING, handler.getCurrentState());
       
        event=new MapMouseEvent(null, 20,10,MapMouseEvent.NONE,MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);
        handler.handleEvent(event, EventType.RELEASED);
       
        assertFalse(handler.isLocked());
        assertEquals(Point.valueOf(0,10), handler.getCurrentShape().getPoint(0));
        assertEquals(Point.valueOf(10,10), handler.getCurrentShape().getPoint(1));
        assertEquals(Point.valueOf(20,10), handler.getCurrentShape().getPoint(2));
        assertEquals(ShapeType.LINE, handler.getCurrentGeom().getShapeType());
        assertFalse( acceptor.ran);

        //continue line
        PrimitiveShape currentShape = handler.getCurrentShape();
       
        handler.getMouseTracker().setDragStarted(Point.valueOf(20,11));
        event=new MapMouseEvent(null, 30,10,MapMouseEvent.NONE,MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);
        handler.handleEvent(event, EventType.RELEASED);

        assertEquals(currentShape, handler.getCurrentShape());
        assertEquals(Point.valueOf(0,10), handler.getCurrentShape().getPoint(0));
        assertEquals(Point.valueOf(10,10), handler.getCurrentShape().getPoint(1));
        assertEquals(Point.valueOf(20,10), handler.getCurrentShape().getPoint(2));
        assertEquals(Point.valueOf(30,10), handler.getCurrentShape().getPoint(3));
       
       
        //start a new line
        acceptor.ran=false;
        handler.getMouseTracker().setDragStarted(Point.valueOf(100,10));
        event=new MapMouseEvent(null, 100,20,MapMouseEvent.NONE,MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);
       
        handler.handleEvent(event, EventType.RELEASED);
       
        assertEquals(Point.valueOf(100,10), handler.getCurrentShape().getPoint(0));
View Full Code Here


    @Ignore
    @Test
    public void testDrawPolygon(){
        handler.getMouseTracker().setDragStarted(Point.valueOf(0,10));
       
        MapMouseEvent event=new MapMouseEvent(null, 10,10,MapMouseEvent.NONE,MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);
       
        event=new MapMouseEvent(null, 20,10,MapMouseEvent.NONE,MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);

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

        event=new MapMouseEvent(null, 10,20,MapMouseEvent.NONE,MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);

        event=new MapMouseEvent(null, 1,10,MapMouseEvent.NONE,MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);

        handler.handleEvent(event, EventType.RELEASED);
   
        assertEquals(Point.valueOf(0,10), handler.getCurrentShape().getPoint(0));
View Full Code Here

        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);
        handler.handleEvent(event, EventType.DRAGGED);
       
        event=new MapMouseEvent(null, 20,20,MapMouseEvent.NONE,MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);

        event=new MapMouseEvent(null, 10,20,MapMouseEvent.NONE,MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);

        event=new MapMouseEvent(null, 10,10,MapMouseEvent.NONE,MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);

        handler.handleEvent(event, EventType.RELEASED);
       
        assertEquals(geom, handler.getCurrentGeom());
View Full Code Here

    }
   
    @Test
    public void testStartingPolygon() throws Exception {

        MapMouseEvent event=new MapMouseEvent(null, 10,10,MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertNull(validator.isValid(handler, event, EventType.RELEASED));
       
        bb.addPoint(5, 5, shell);
       
        event=new MapMouseEvent(null, 10,10,MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertNull(validator.isValid(handler, event, EventType.RELEASED));       

        bb.addPoint(10, 10, shell);
       
        event=new MapMouseEvent(null, 10,10,MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertNull(validator.isValid(handler, event, EventType.RELEASED));
       
    }
View Full Code Here

        bb.addPoint(20, 10, shell);
        bb.addPoint(20, 20, shell);
        bb.addPoint(10, 20, shell);
       
//      just closing hole should be legal
        MapMouseEvent event=new MapMouseEvent(null, 10,10,MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertNull(validator.isValid(handler, event, EventType.RELEASED));
       
//      no intersection so should be good
        event=new MapMouseEvent(null, 5,15,MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertNull(validator.isValid(handler, event, EventType.RELEASED));
       
//      crosses 1st line so illegal
        event=new MapMouseEvent(null, 10, 5 ,MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertEquals(Messages.ValidHoleValidator_selfIntersection, validator.isValid(handler, event, EventType.RELEASED));
    }
View Full Code Here

    }
   
    @Test
    public void testStartingHoles() throws Exception {

        MapMouseEvent event=new MapMouseEvent(null, 10,10,MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertNull(validator.isValid(handler, event, EventType.RELEASED));
       
        bb.addPoint(5, 5, hole);
       
        event=new MapMouseEvent(null, 10,10,MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertNull(validator.isValid(handler, event, EventType.RELEASED));
       
    }
View Full Code Here

        bb.addPoint(20, 10, hole);
        bb.addPoint(20, 20, hole);
        bb.addPoint(10, 20, hole);
       
//      just closing hole should be legal
        MapMouseEvent event=new MapMouseEvent(null, 10,10,MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertNull(validator.isValid(handler, event, EventType.RELEASED));
       
//      no intersection so should be good
        event=new MapMouseEvent(null, 5,15,MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertNull(validator.isValid(handler, event, EventType.RELEASED));
       
//      crosses 1st line so illegal
        event=new MapMouseEvent(null, 10, 5 ,MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertEquals(Messages.ValidHoleValidator_selfIntersection, validator.isValid(handler, event, EventType.RELEASED));
    }
View Full Code Here

        bb.addPoint(10, 10, hole);
        bb.addPoint(20, 10, hole);
        bb.addPoint(20, 20, hole);
        bb.addPoint(10, 20, hole);
        MapMouseEvent event=new MapMouseEvent(null, -5,20,MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertEquals(Messages.ValidHoleValidator_outsideShell, validator.isValid(handler, event, EventType.RELEASED));
    }
View Full Code Here

        bb.addPoint(70, 50, hole2);
        bb.addPoint(70, 70, hole2);
        bb.addPoint(50, 70, hole2);
        bb.addPoint(50, 50, hole2);
       
        MapMouseEvent event=new MapMouseEvent(null, 60, 60,MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertEquals(Messages.ValidHoleValidator_holeOverlap, validator.isValid(handler, event, EventType.RELEASED));
       
    }
View Full Code Here

                path.append(new Rectangle(width, height), false);
                return path;
            }
        });
       
        MapMouseEvent event=new MapMouseEvent( null, 0,0, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertTrue(behav.isValid(handler, event, EventType.DRAGGED));
       
        //released no legal
        event=new MapMouseEvent( null, 0,0, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertFalse(behav.isValid(handler, event, EventType.RELEASED));

        // must be mouse button 1
        event=new MapMouseEvent( null, 0,0, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON2, MapMouseEvent.BUTTON1);
        assertFalse(behav.isValid(handler, event, EventType.DRAGGED));

        // cannot be Modify state
        handler.setCurrentState(EditState.MODIFYING);
        event=new MapMouseEvent( null, 0,0, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertFalse(behav.isValid(handler, event, EventType.DRAGGED));

        // cannot be creating state
        handler.setCurrentState(EditState.CREATING);
        event=new MapMouseEvent( null, 0,0, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertFalse(behav.isValid(handler, event, EventType.DRAGGED));
       
        // make sure state is good
        handler.setCurrentState(EditState.NONE);
        event=new MapMouseEvent( null, 0,0, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertTrue(behav.isValid(handler, event, EventType.DRAGGED));

        // Alt down is not legal
        handler.setCurrentState(EditState.NONE);
        event=new MapMouseEvent( null, 0,0, MapMouseEvent.ALT_DOWN_MASK,
                MapMouseEvent.BUTTON2, MapMouseEvent.BUTTON1);
        assertFalse(behav.isValid(handler, event, EventType.DRAGGED));

   
    }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.project.ui.render.displayAdapter.MapMouseEvent

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.