Examples of MapMouseEvent


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

     * 'net.refMapMouseEvent.BUTTON1ractions.udig.tools.edit.behaviour.MoveGeometryBehaviour.isValid(EditToolHandler,
     * MapMouseEvent, EventType)'
     */
    @Test
    public void testIsValid() {
        MapMouseEvent event = new MapMouseEvent(null, 100, 100, MapMouseEvent.ALT_DOWN_MASK
                | MapMouseEvent.CTRL_DOWN_MASK, MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertFalse(moveGeometryBehaviour.isValid(handler, event, EventType.DRAGGED));

        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.ALT_DOWN_MASK
                | MapMouseEvent.CTRL_DOWN_MASK, MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertTrue(moveGeometryBehaviour.isValid(handler, event, EventType.DRAGGED));

        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.ALT_DOWN_MASK
                | MapMouseEvent.CTRL_DOWN_MASK, MapMouseEvent.BUTTON1 | MapMouseEvent.BUTTON2,
                MapMouseEvent.BUTTON1);
        assertFalse(moveGeometryBehaviour.isValid(handler, event, EventType.DRAGGED));

        handler.getEditBlackboard().selectionAdd(Point.valueOf(0, 0));
        handler.getEditBlackboard().selectionAdd(Point.valueOf(50, 0));
        handler.getEditBlackboard().selectionAdd(Point.valueOf(50, 50));
        handler.getEditBlackboard().selectionAdd(Point.valueOf(0, 50));

        // now all vertices are selected so if the mouse is within the geom or on a
        // vertex the behaviour should be valid.
        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.ALT_DOWN_MASK
                | MapMouseEvent.CTRL_DOWN_MASK, MapMouseEvent.BUTTON1, MapMouseEvent.BUTTON1);
        assertTrue(moveGeometryBehaviour.isValid(handler, event, EventType.DRAGGED));

        event = new MapMouseEvent(null, 10, 10, MapMouseEvent.NONE, MapMouseEvent.BUTTON1,
                MapMouseEvent.BUTTON1);

        handler.getMouseTracker().setDragStarted(Point.valueOf(-10, 10));
        assertFalse(moveGeometryBehaviour.isValid(handler, event, EventType.DRAGGED));

View Full Code Here

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

        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);

        assertEquals(2, handler.getEditBlackboard().getCoords(10, 0).size());
        assertEquals(1, handler.getEditBlackboard().getCoords(60, 0).size());
View Full Code Here

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

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

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

        AcceptWhenOverFirstVertexBehaviour behavior=new AcceptWhenOverFirstVertexBehaviour();

        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());
        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 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));

        // not valid if not over first point
        event = new MapMouseEvent(null, 20,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));
      
        // not valid if over a different vertex (IE not 1st vertex
        handler.getEditBlackboard().addPoint(20,10, handler.getCurrentShape());
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));
View Full Code Here

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

        StartHoleCuttingBehaviour behavior=new StartHoleCuttingBehaviour();

        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());
       
        event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        // mouse must be within a shell
        assertFalse(behavior.isValid(handler, event, EventType.RELEASED));

        handler.getEditBlackboard().addPoint(100,0, handler.getCurrentShape());
        handler.getEditBlackboard().addPoint(100,100, handler.getCurrentShape());
        handler.getEditBlackboard().addPoint(0,100, handler.getCurrentShape());
        handler.getEditBlackboard().addPoint(0,0, handler.getCurrentShape());
       
        // now we have something
        assertTrue(behavior.isValid(handler, event, EventType.RELEASED));
       
        PrimitiveShape hole = handler.getCurrentGeom().newHole();
        handler.getEditBlackboard().addPoint(30,30, hole);
        handler.getEditBlackboard().addPoint(60,30, hole);
        handler.getEditBlackboard().addPoint(60,60, hole);
        handler.getEditBlackboard().addPoint(30,60, hole);
        handler.getEditBlackboard().addPoint(30,30, hole);
       
        //mouse is in another hole
        event = new MapMouseEvent(null, 40,40, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        assertFalse(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));

        // 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

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

        TestHandler handler=new TestHandler();
        ((RenderManager)handler.getContext().getRenderManager()).setMapDisplay(new TestViewportPane(new Dimension(500,500)));
        handler.getTestEditBlackboard().util.setVertexRadius(4);
       
        StartHoleCuttingBehaviour behavior=new StartHoleCuttingBehaviour();
        MapMouseEvent event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);

        try {
            behavior.getCommand(handler,event, EventType.RELEASED );
            fail();
        } catch (Exception e) {
View Full Code Here

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

    }
   
    @Override
    public void handleEvent( MapMouseEvent e, EventType eventType ) {
        if( e==null )
            e=new MapMouseEvent(null, 0,0,0,0,0);
        if( eventType==null)
            eventType=EventType.MOVED;
        super.handleEvent(e, eventType);
    }
View Full Code Here

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

   
    @Test
    public void testSelect1FeatureThenAnother() throws Exception{
       
        Point p=handler.getEditBlackboard().toPoint(new Coordinate(0,10));
        tool.mouseReleased(new MapMouseEvent(handler.getContext().getMapDisplay(), p.getX(), p.getY(), 0,0,MapMouseEvent.BUTTON1));
       
        assertEquals("feature0", handler.getContext().getEditManager().getEditFeature().getAttribute("name"))//$NON-NLS-1$//$NON-NLS-2$

        p=handler.getEditBlackboard().toPoint(new Coordinate(10,15));
        tool.mouseReleased(new MapMouseEvent(handler.getContext().getMapDisplay(), p.getX(), p.getY(), 0,0,MapMouseEvent.BUTTON1));
       
        assertEquals("feature1", handler.getContext().getEditManager().getEditFeature().getAttribute("name")); //$NON-NLS-1$ //$NON-NLS-2$

        p=handler.getEditBlackboard().toPoint(new Coordinate(30,30));
        tool.mouseReleased(new MapMouseEvent(handler.getContext().getMapDisplay(), p.getX(), p.getY(), 0,0,MapMouseEvent.BUTTON1));
       
        assertEquals("feature2", handler.getContext().getEditManager().getEditFeature().getAttribute("name")); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

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

     * Test method for 'org.locationtech.udig.tools.edit.commands.StartEditingCommand.run(IProgressMonitor)'
     */
    @Test
    public void testRun() throws Exception {
       
        MapMouseEvent event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        StartEditingCommand command=new StartEditingCommand(handler, event, ShapeType.POLYGON);
        command.setMap((Map) handler.getContext().getMap());       
       
        DeselectEditGeomCommand command2 = new DeselectEditGeomCommand(handler, handler.getEditBlackboard().getGeoms());
        command2.setMap((Map) handler.getContext().getMap());
View Full Code Here

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

        handler=new TestHandler();

        handler.getTestEditBlackboard().util.setVertexRadius(4);
        handler.getTestEditBlackboard().util.setSnappingRadius(0);

        MapMouseEvent event=new MapMouseEvent( DISPLAY, 10,10,NONE,BUTTON1, BUTTON1 );
        assertFalse(mode.isValid(handler, event, EventType.DRAGGED));
       
        editBlackboard = handler.getEditBlackboard();
        EditGeom currentGeom = editBlackboard.getGeoms().get(0);
        editBlackboard.addPoint(10,10, currentGeom.getShell());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.