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

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


    @Test
    public void testRun() throws Exception {

        handler.getEditBlackboard().selectionAdd(Point.valueOf(10,10));

        MapMouseEvent event=new MapMouseEvent( DISPLAY, 10,15,NONE,BUTTON1, BUTTON1 );
        try{
            mode.getCommand(handler, event, EventType.RELEASED);
            fail();
        }catch (Exception e) {
            // good behaviour because mode only works on EventType.DRAGGED
        }
       
        handler.getMouseTracker().setDragStarted(Point.valueOf(10,10));
        mode.getCommand(handler, event, EventType.DRAGGED);
        assertEquals(1, editBlackboard.getCoords(10,15).size());
        assertEquals(0, editBlackboard.getCoords(10,10).size());
        assertEquals(1, handler.getEditBlackboard().getSelection().size());
        assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(10,15)));

        //return to original position.
        event=new MapMouseEvent( DISPLAY, 10,10,NONE,BUTTON1, BUTTON1 );
        handler.getMouseTracker().setDragStarted(Point.valueOf(10,15));
        mode.getCommand(handler, event, EventType.DRAGGED);
        assertEquals(1, editBlackboard.getCoords(10,10).size());
        assertEquals(0, editBlackboard.getCoords(10,15).size());
       
        //move 2 points
        handler.getEditBlackboard().selectionAdd(Point.valueOf(20,10));
        assertEquals(2, handler.getEditBlackboard().getSelection().size());
       
        handler.unlock(mode);
        mode=new MoveVertexBehaviour();
       
        handler.getMouseTracker().setDragStarted(Point.valueOf(10,10));
        event=new MapMouseEvent( DISPLAY, 10,15,NONE,BUTTON1, BUTTON1 );
       
        mode.getCommand(handler, event, EventType.DRAGGED);
       
        assertEquals(1, editBlackboard.getCoords(10,15).size());
        assertEquals(0, editBlackboard.getCoords(10,10).size());
        assertEquals(1, editBlackboard.getCoords(20,15).size());
        assertEquals(0, editBlackboard.getCoords(20,10).size());
        handler.getMouseTracker().setDragStarted(Point.valueOf(10,15));
        event=new MapMouseEvent( DISPLAY, 10,10,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);
        assertEquals(1, editBlackboard.getCoords(10,10).size());
        assertEquals(0, editBlackboard.getCoords(10,15).size());
       
       
View Full Code Here


        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());
        assertEquals(0, editBlackboard.getCoords(20,10).size());
       
        //test undo first button must release so the Position tracker will execute:
        event=new MapMouseEvent( DISPLAY, 10,10,NONE,BUTTON1, BUTTON1 );
        EventBehaviour tracker = findPositionTracker();
        handler.getContext().getMap().sendCommandSync(tracker.getCommand(handler, event, EventType.RELEASED));

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

        handler.getTestEditBlackboard().util.setSnappingRadius(12);
       
        editBlackboard.selectionAdd(Point.valueOf(10,10));
       
        handler.getMouseTracker().setDragStarted(Point.valueOf(10,12));
        MapMouseEvent event = new MapMouseEvent( DISPLAY, 10,13,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);

        assertEquals(1, editBlackboard.getCoords(10,13).size());
       
        event = new MapMouseEvent( DISPLAY, 40,10,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);
        handler.handleEvent(event, EventType.RELEASED);

        assertEquals(2, editBlackboard.getCoords(30,20).size());
        assertEquals(0, editBlackboard.getCoords(10,10).size());

        handler.getEditBlackboard().removeCoordsAtPoint(20,10);

        //Testing searching through the layer for the closest point.
        assertEquals(2, editBlackboard.getCoords(30,20).size());

        ILayer editLayer = handler.getEditLayer();
        FeatureSource<SimpleFeatureType, SimpleFeature> source = editLayer.getResource(FeatureSource.class, new NullProgressMonitor());
        SimpleFeature feature = source.getFeatures().features().next();
        Coordinate coord = ((Geometry) feature.getDefaultGeometry()).getCoordinates()[1];
        Coordinate t = JTS.transform(coord, new Coordinate(), editLayer.layerToMapTransform());
        java.awt.Point pointOnScreen = handler.getContext().worldToPixel(t);
        handler.getMouseTracker().setDragStarted(Point.valueOf(30,20));
        event = new MapMouseEvent( DISPLAY, pointOnScreen.x+5,pointOnScreen.y,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);
        handler.handleEvent(event, EventType.RELEASED);
       
        assertEquals(1, editBlackboard.getCoords(pointOnScreen.x,pointOnScreen.y).size());
        assertEquals(1, editBlackboard.getCoords(30,20).size());
View Full Code Here

    public void testSnappingDuringDragging() throws Exception {
        editBlackboard.selectionAdd(Point.valueOf(10,10));
        editBlackboard.selectionAdd(Point.valueOf(20,10));
       
        handler.getMouseTracker().setDragStarted(Point.valueOf(10,12));
        MapMouseEvent event = new MapMouseEvent( DISPLAY, 10,13,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);

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

    public void testDragAcrossAnotherVertex() throws Exception {
        editBlackboard.selectionAdd(Point.valueOf(10,10));

       
        handler.getMouseTracker().setDragStarted(Point.valueOf(10,12));
        MapMouseEvent event = new MapMouseEvent( DISPLAY, 12,10,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);
       
        assertEquals(1, editBlackboard.getCoords(12,10).size());
        assertEquals(0, editBlackboard.getCoords(10,10).size());

        event = new MapMouseEvent( DISPLAY, 20,10,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);
       
        assertEquals(2, editBlackboard.getCoords(20,10).size());
        assertEquals(0, editBlackboard.getCoords(12,10).size());
       
        event = new MapMouseEvent( DISPLAY, 20,15,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);
        assertEquals(1, editBlackboard.getCoords(20,10).size());
        assertEquals(1, editBlackboard.getCoords(20,15).size());
        assertTrue( handler.getCurrentShape().hasVertex(Point.valueOf(20,10)));
        assertTrue( handler.getCurrentShape().hasVertex(Point.valueOf(20,15)));
View Full Code Here

    }
   
    @Test
    public void testSnapToVertex() throws Exception{

        MapMouseEvent event;
        //drag close to point and it should snap to a coord in point.
       
        assertEquals(1, editBlackboard.getCoords(20,10).size());
        handler.getEditBlackboard().selectionClear();
        handler.getEditBlackboard().selectionAdd(Point.valueOf(10,10));
        handler.getMouseTracker().setDragStarted(Point.valueOf(10,10));
        event=new MapMouseEvent( DISPLAY, 13,10,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);
       
        event=new MapMouseEvent( DISPLAY, 18,10,NONE,BUTTON1, BUTTON1 );
        mode.getCommand(handler, event, EventType.DRAGGED);
       
        handler.handleEvent(event, EventType.RELEASED);
       
        assertEquals(2, editBlackboard.getCoords(20,10).size());
View Full Code Here

        AcceptOnDoubleClickBehaviour behavior=new AcceptOnDoubleClickBehaviour();

        handler.setCurrentState(EditState.CREATING);

        //Current Shape must be set
        MapMouseEvent event = new MapMouseEvent(null, 10,10, MapMouseEvent.BUTTON1, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.DOUBLE_CLICK));
       
        EditGeom editGeom = handler.getEditBlackboard().getGeoms().get(0);
        handler.setCurrentShape(editGeom.getShell());
        editGeom.setChanged(true);
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertTrue(behavior.isValid(handler, event, EventType.DOUBLE_CLICK));
        // only button1 should be down
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.BUTTON2, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.DOUBLE_CLICK));
        // button2 isn't legal
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON2);
        assertFalse(behavior.isValid(handler, event, EventType.DOUBLE_CLICK));

        // no modifiers only
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.ALT_DOWN_MASK, MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.DOUBLE_CLICK));

        // MODIFYING is legal
        handler.setCurrentState(EditState.MODIFYING);
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertTrue(behavior.isValid(handler, event, EventType.DOUBLE_CLICK));
       
        // not a legal state
        handler.setCurrentState(EditState.NONE);
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.DOUBLE_CLICK));
       
        // should work, just checking state is still good;
        handler.setCurrentState(EditState.CREATING);
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertTrue(behavior.isValid(handler, event, EventType.DOUBLE_CLICK));
       
        // doesn't work with event pressed
        assertFalse(behavior.isValid(handler, event, EventType.PRESSED));       
    }
View Full Code Here

        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);
       
        command.setMap((Map) handler.getContext().getMap());
        NullProgressMonitor nullProgressMonitor = new NullProgressMonitor();
        command.run(nullProgressMonitor);

        assertEquals(hole, handler.getCurrentShape());
       
        command.rollback(nullProgressMonitor);
        assertEquals(shape, handler.getCurrentShape());

        command.run(nullProgressMonitor);
        assertEquals(hole, handler.getCurrentShape());

        event=new MapMouseEvent(null, 40,40, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.NONE);
        command=new SelectHoleCommand(handler, event);
       
        command.setMap((Map) handler.getContext().getMap());
        command.run(nullProgressMonitor);
View Full Code Here

    @Test
    public void testLegal() throws Exception {
        handler.setCurrentState(EditState.ILLEGAL);
        WithinLegalLayerBoundsBehaviour behav=new WithinLegalLayerBoundsBehaviour();
        MapMouseEvent e=new MapMouseEvent(map.getRenderManager().getMapDisplay(), 0,0, 0,0,0);
       
        assertNull( behav.isEnabled(handler, e, EventType.MOVED) );
    }
View Full Code Here

        map.getViewportModelInternal().setBounds(-300, -250, -180, -140);
       
        System.out.println(map.getViewportModel().getBounds());
       
        WithinLegalLayerBoundsBehaviour behav=new WithinLegalLayerBoundsBehaviour();
        MapMouseEvent e=new MapMouseEvent(map.getRenderManager().getMapDisplay(), 0,0, 0,0,0);
        behav.isEnabled(handler, e, EventType.MOVED);
       
        assertNotNull( behav.isEnabled(handler, e, EventType.MOVED));
    }
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.