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

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


        AddVertexWhileCreatingBehaviour behavior=new AddVertexWhileCreatingBehaviour();

        handler.setCurrentState(EditState.CREATING);

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

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

        // works only with CREATING
        handler.setCurrentState(EditState.MODIFYING);
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));
       
        // works only with CREATING
        handler.setCurrentState(EditState.NONE);
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));
       
        // should work, just checking state is still good;
        handler.setCurrentState(EditState.CREATING);
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertTrue(behavior.isValid(handler, event, EventType.RELEASED));
       
        // doesn't work with event pressed
        assertFalse(behavior.isValid(handler, event, EventType.PRESSED));
       
        //doesn't work if the mouse is over an existing vertex in current shape
        handler.getEditBlackboard().addPoint(11,11, handler.getCurrentShape());
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));
    }
View Full Code Here


        SelectVerticesWithBoxBehaviour behaviour = new SelectVerticesWithBoxBehaviour();

        handler.setCurrentState(EditState.MODIFYING);

        // current shape is not set
        MapMouseEvent event = new MapMouseEvent(null, 10, 10, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertFalse(behaviour.isValid(handler, event, EventType.DRAGGED));

        handler.setCurrentShape(shell);

        // should work
        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        assertTrue(behaviour.isValid(handler, event, EventType.DRAGGED));

        // creating not valid state
        handler.setCurrentState(EditState.CREATING);
        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        assertFalse(behaviour.isValid(handler, event, EventType.DRAGGED));

        // make sure state is good
        handler.setCurrentState(EditState.MODIFYING);
        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        assertTrue(behaviour.isValid(handler, event, EventType.DRAGGED));

        // alt not acceptable
        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.ALT_DOWN_MASK, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        assertFalse(behaviour.isValid(handler, event, EventType.DRAGGED));

        // ctrl not acceptable
        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.CTRL_DOWN_MASK, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        assertFalse(behaviour.isValid(handler, event, EventType.DRAGGED));

        // shift is acceptable
        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.SHIFT_DOWN_MASK, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        assertTrue(behaviour.isValid(handler, event, EventType.DRAGGED));


        // DRAGGED not acceptable
        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        assertFalse(behaviour.isValid(handler, event, EventType.RELEASED));

        // DOUBLE_CLICK not acceptable
        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        assertFalse(behaviour.isValid(handler, event, EventType.DOUBLE_CLICK));

        // ENTERED not acceptable
        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        assertFalse(behaviour.isValid(handler, event, EventType.ENTERED));

        // EXITED not acceptable
        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        assertFalse(behaviour.isValid(handler, event, EventType.EXITED));

        // MOVED not acceptable
        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        assertFalse(behaviour.isValid(handler, event, EventType.MOVED));

        // WHEEL not acceptable
        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        assertFalse(behaviour.isValid(handler, event, EventType.WHEEL));


    }
View Full Code Here

       
        handler.setCurrentShape(shell);

        // should selct 1 point
        handler.getMouseTracker().setDragStarted(Point.valueOf(0,0));
        MapMouseEvent event = new MapMouseEvent(null, 11, 11, MapMouseEvent.NONE, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);
        event = new MapMouseEvent(null, 11, 11, MapMouseEvent.NONE, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.RELEASED);
       
        assertEquals(1, handler.getEditBlackboard().getSelection().size());
        assertEquals(Point.valueOf(0,10), handler.getEditBlackboard().getSelection().iterator().next());

        // should replace old selection of (0,10) with 20,20
        handler.getMouseTracker().setDragStarted(Point.valueOf(30,30));
        event = new MapMouseEvent(null, 19, 19, MapMouseEvent.NONE, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);
        event = new MapMouseEvent(null, 19, 19, MapMouseEvent.NONE, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.RELEASED);
       
        assertEquals(1, handler.getEditBlackboard().getSelection().size());
        assertEquals(Point.valueOf(20,20), handler.getEditBlackboard().getSelection().iterator().next());

        // should add (0,10) to selection
        handler.getMouseTracker().setDragStarted(Point.valueOf(0,0));
        event = new MapMouseEvent(null, 11, 11, MapMouseEvent.SHIFT_DOWN_MASK, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);
        event = new MapMouseEvent(null, 11, 11, MapMouseEvent.SHIFT_DOWN_MASK, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.RELEASED);
       
        assertEquals(2, handler.getEditBlackboard().getSelection().size());
        assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(20,20)));
        assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(0,10)));
       
        // should add all points to selection
        handler.getMouseTracker().setDragStarted(Point.valueOf(0,0));
        event = new MapMouseEvent(null, 30, 30, MapMouseEvent.SHIFT_DOWN_MASK, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);
        event = new MapMouseEvent(null, 30,30, MapMouseEvent.SHIFT_DOWN_MASK, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.RELEASED);
       
        assertEquals(4, handler.getEditBlackboard().getSelection().size());
        assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(0,10)));
        assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(20,10)));
        assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(20,20)));
        assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(10,20)));
    
        // should make no change
        handler.getMouseTracker().setDragStarted(Point.valueOf(0,0));
        event = new MapMouseEvent(null, 1, 1, MapMouseEvent.SHIFT_DOWN_MASK, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);
        event = new MapMouseEvent(null, 1,1, MapMouseEvent.SHIFT_DOWN_MASK, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.RELEASED);
       
        assertEquals(4, handler.getEditBlackboard().getSelection().size());
        assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(0,10)));
        assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(20,10)));
        assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(20,20)));
        assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(10,20)));
    
        // should clear selection
        handler.getMouseTracker().setDragStarted(Point.valueOf(0,0));
        event = new MapMouseEvent(null, 1, 1, MapMouseEvent.NONE, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);
        event = new MapMouseEvent(null, 1,1, MapMouseEvent.NONE, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.RELEASED);
       
        assertEquals(0, handler.getEditBlackboard().getSelection().size());
    }
View Full Code Here

       
        handler.setCurrentShape(shell);

        // should selct 1 point
        handler.getMouseTracker().setDragStarted(Point.valueOf(0,0));
        MapMouseEvent event = new MapMouseEvent(null, 110, 40, MapMouseEvent.NONE, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.DRAGGED);
        event = new MapMouseEvent(null, 110, 40, MapMouseEvent.NONE, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.RELEASED);
       
        assertEquals(4, handler.getEditBlackboard().getSelection().size());
        assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(0,10)));
View Full Code Here

        StartExtendLineBehaviour behavior=new StartExtendLineBehaviour();

        handler.setCurrentState(EditState.MODIFYING);

        //Current Shape must be set
        MapMouseEvent event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));
       
        EditGeom editGeom = handler.getEditBlackboard().getGeoms().get(0);
        handler.setCurrentShape(editGeom.getShell());
        handler.getEditBlackboard().addPoint(0,0, handler.getCurrentShape());
        handler.getEditBlackboard().addPoint(11,11, handler.getCurrentShape());
       
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertTrue(behavior.isValid(handler, event, EventType.RELEASED));
       
        // no buttons should be down
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.BUTTON2, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));
        // button2 isn't legal
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON2);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));

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

        // doesn't work with BUSY
        handler.setCurrentState(EditState.BUSY);
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));
       
        // doesn't work with CREATING
        handler.setCurrentState(EditState.CREATING);
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));
       
        // should work, just checking state is still good;
        handler.setCurrentState(EditState.NONE);
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertTrue(behavior.isValid(handler, event, EventType.RELEASED));
       
        // doesn't work with event pressed
        assertFalse(behavior.isValid(handler, event, EventType.PRESSED));

        // not valid if not over end point
        event = new MapMouseEvent(null, 20,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));
      
        // valid over first point
        event = new MapMouseEvent(null, 0,0, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertTrue(behavior.isValid(handler, event, EventType.RELEASED));
       
    }
View Full Code Here

        handler.setCurrentShape(editGeom.getShell());
        handler.getEditBlackboard().addPoint(0,0, handler.getCurrentShape());
        handler.getEditBlackboard().addPoint(11,11, handler.getCurrentShape());
       

        MapMouseEvent event = new MapMouseEvent(null, 0,0, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertTrue(behavior.isValid(handler, event, EventType.RELEASED));
       
        handler.handleEvent(event, EventType.RELEASED);
       
        assertEquals(Point.valueOf(11,11), handler.getCurrentShape().getPoint(0));
        assertEquals(EditState.CREATING, handler.getCurrentState());

        handler.setCurrentState(EditState.NONE);
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertTrue(behavior.isValid(handler, event, EventType.RELEASED));
       
        handler.handleEvent(event, EventType.RELEASED);
        assertEquals(Point.valueOf(0,0), handler.getCurrentShape().getPoint(0));
        assertEquals(EditState.CREATING, handler.getCurrentState());
View Full Code Here

    public void testIsValid() throws Exception {
        TestHandler handler=new TestHandler();
       
        StartEditingBehaviour behavior=new StartEditingBehaviour(ShapeType.POLYGON);

        MapMouseEvent event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertTrue(behavior.isValid(handler, event, EventType.RELEASED));

        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.BUTTON2, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));
       
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON2);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));

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

        // works only with NONE
        handler.setCurrentState(EditState.CREATING);
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));
       
        // works only with NONE
        handler.setCurrentState(EditState.CREATING);
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);

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

        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
View Full Code Here

        SelectHoleBehaviour behavior=new SelectHoleBehaviour();

        handler.setCurrentState(EditState.MODIFYING);

        //Current Shape must be set
        MapMouseEvent event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));
       
        EditGeom editGeom = handler.getEditBlackboard().getGeoms().get(0);
        handler.setCurrentShape(editGeom.getShell());
        handler.getEditBlackboard().addPoint(11,11, handler.getCurrentShape());
       
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertTrue(behavior.isValid(handler, event, EventType.RELEASED));
       
        // no buttons should be down
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.BUTTON2, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));
       
        // button2 isn't legal
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON2);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));

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

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

    /*
     * Test method for 'org.locationtech.udig.tools.edit.behaviour.FreeHandPolygonDrawBehaviour.isValid(EditToolHandler, MapMouseEvent, EventType)'
     */
    @Test
    public void testIsValid() {
        MapMouseEvent event=new MapMouseEvent(null, 10,10,MapMouseEvent.NONE,MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertTrue(behav.isValid(handler, event, EventType.DRAGGED));
        assertFalse(behav.isValid(handler, event, EventType.RELEASED));
        assertFalse(behav.isValid(handler, event, EventType.PRESSED));
        assertFalse(behav.isValid(handler, event, EventType.MOVED));
        assertFalse(behav.isValid(handler, event, EventType.WHEEL));
        assertTrue(behav.isValid(handler, event, EventType.DRAGGED));
        event=new MapMouseEvent(null, 10,10,MapMouseEvent.NONE,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.