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

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


    public void testMouseDoubleClick() {
        Event e=new Event();
        e.button=1;
        e.stateMask=SWT.ALT;
        handler.mouseDoubleClick(e);
        MapMouseEvent event=(MapMouseEvent) eventJob.event;
        assertEquals(MapMouseEvent.ALT_DOWN_MASK, event.modifiers);
        assertEquals(MapMouseEvent.BUTTON1, event.button);
        assertEquals(MapMouseEvent.BUTTON1, event.buttons);
    }
View Full Code Here


        Event e=new Event();
        e.button=1;
        e.stateMask=SWT.ALT|SWT.BUTTON1;

        handler.mouseDown(e);
        MapMouseEvent event=(MapMouseEvent) eventJob.event;
        assertEquals(MapMouseEvent.ALT_DOWN_MASK, event.modifiers);
        assertEquals(MapMouseEvent.BUTTON1, event.button);
        assertEquals(MapMouseEvent.BUTTON1, event.buttons);
       
        e.button=2;
View Full Code Here

        e.button=2;
        e.stateMask=SWT.ALT;
       
        handler.mouseUp( e );
       
        MapMouseEvent event = (MapMouseEvent) eventJob.event;
       
        assertEquals(MapMouseEvent.BUTTON2, event.button);
        assertEquals(MapMouseEvent.NONE, event.buttons);
       
View Full Code Here

       
        l.type.clear();
        l.events.clear();
       
        for( int i=0; i<700; i++){
            MapMouseEvent event=new MapMouseEvent(null, i,0,MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
            job.fire(EventJob.PRESSED, event);
        }

        Thread.sleep(200);
View Full Code Here

     */
    @Test
    public void testIsValid() throws Exception {
        SelectFeatureBehaviour mode=new SelectFeatureBehaviour(new Class[]{Polygon.class, MultiPolygon.class}, BBOX.class);

        assertFalse(mode.isValid(handler, new MapMouseEvent(null, 0, 0, none, none, 0), EventType.DOUBLE_CLICK));

        assertTrue(mode.isValid(handler,  new MapMouseEvent(null, 10, 0, none, none, button1), EventType.RELEASED));
        // not valid for drag events
        assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button1), EventType.DRAGGED));
        // not valid for exit events
        assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button1), EventType.EXITED));
        // not valid for moved events
        assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button1), EventType.MOVED));
        // not valid for pressed events
        assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button1), EventType.PRESSED));

        // ctl down is legal
        assertTrue(mode.isValid(handler, new MapMouseEvent(null, 10,0, ctrl,none, button1), EventType.RELEASED));
        // shift down is legal
        assertTrue(mode.isValid(handler, new MapMouseEvent(null, 10,0, shift, none, button1), EventType.RELEASED));

        // ctl down is not legal
        assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10,0, alt, none, button1), EventType.RELEASED));
        // only 1 modifier is legal
        assertFalse(mode.isValid(handler, new MapMouseEvent(null,
                0, 0, shift|ctrl, none, button1), EventType.RELEASED));
       
        // button2 is not legal
        assertFalse(mode.isValid(handler,  new MapMouseEvent(null, 10, 0, none, none, button2), EventType.RELEASED));
       
        List<EditGeom> geoms = handler.getEditBlackboard().getGeoms();
        handler.getEditBlackboard().addPoint(10,0, geoms.get(0).getShell());
        handler.setCurrentShape(handler.getEditBlackboard().getGeoms().get(0).getShell());
    }
View Full Code Here

        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);
        assertEquals( org.locationtech.udig.tools.edit.support.Point.valueOf(10,0), handler.getCurrentGeom().getShell().getPoint(0));
        assertTrue( l.set  );
        assertNull(l.old);
        assertEquals( handler.getCurrentGeom(), l.current);

        EditGeom geom=l.added.get(l.added.size()-1);
        handler.handleEvent(new MapMouseEvent(null, 20, 0, none, none, button1), EventType.RELEASED);
        assertEquals( org.locationtech.udig.tools.edit.support.Point.valueOf(20,0), handler.getCurrentGeom().getShell().getPoint(0));
        assertTrue( l.set  );
        assertEquals(geom,l.old);
        assertEquals( handler.getCurrentGeom(), l.current);
        assertEquals( 1, handler.getEditBlackboard().getGeoms().size());
       
        // add using shift
        handler.handleEvent(new MapMouseEvent(null, 10, 0, shift, none, button1), EventType.RELEASED);
        geom=l.added.get(l.added.size()-1);
        assertEquals(1, handler.getEditBlackboard().getGeoms(20,0).size());
        assertFalse( l.set  );
        assertEquals(geom,l.current);
        assertEquals( geom, handler.getCurrentGeom());
        assertEquals( 2, handler.getEditBlackboard().getGeoms().size());
       
        // add using ctrl
        handler.handleEvent(new MapMouseEvent(null, 30, 0, ctrl, none, button1), EventType.RELEASED);
        geom=l.added.get(l.added.size()-1);
        assertEquals(1, handler.getEditBlackboard().getGeoms(30,0).size());
        assertFalse( l.set  );
        assertEquals( geom, handler.getCurrentGeom());
        assertEquals( 3, handler.getEditBlackboard().getGeoms().size());
       
        // remove using ctrl
        handler.handleEvent(new MapMouseEvent(null, 30, 0, ctrl, none, button1), EventType.RELEASED);
        assertEquals(0, handler.getEditBlackboard().getGeoms(30,0).size());
        assertEquals( 2, handler.getEditBlackboard().getGeoms().size());
       
        // click on nothing and all should be deselected
        handler.handleEvent( new MapMouseEvent(null, 0, 0, none, none, button1), EventType.RELEASED);
        assertEquals(0, handler.getEditBlackboard().getGeoms(20,0).size());
        assertEquals( 1, handler.getEditBlackboard().getGeoms().size());
        assertTrue(l.set);
        assertNull( handler.getCurrentGeom() );
       
View Full Code Here

        ids.add(filterFactory.featureId(features.features().next().getID()));
    resource.modifyFeatures(feature.getFeatureType().getGeometryDescriptor(), multiline,
                filterFactory.id(ids));
   
       
        handler.handleEvent(new MapMouseEvent(null, 20, 15, none, none, button1), EventType.RELEASED);
       
        assertTrue(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(20,10)));
        assertTrue(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(20,20)));
        assertFalse(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(10,10)));
        assertFalse(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(10,20)));

        handler.handleEvent(new MapMouseEvent(null, 10, 15, none, none, button1), EventType.RELEASED);
       
        assertTrue(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(10,10)));
        assertTrue(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(10,20)));
        assertFalse(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(20,10)));
        assertFalse(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(20,20)));
View Full Code Here

        InsertVertexOnEdgeBehaviour behaviour = new InsertVertexOnEdgeBehaviour();

        handler.setCurrentState(EditState.MODIFYING);

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

        handler.setCurrentShape(shell);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        // close enough to edge
        event = new MapMouseEvent(null, 10, 8, MapMouseEvent.NONE, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1);
        assertTrue(behaviour.isValid(handler, event, EventType.RELEASED));

        // not close enough to edge
        event = new MapMouseEvent(null, 0, -10, MapMouseEvent.NONE, MapMouseEvent.NONE,
                MapMouseEvent.BUTTON1);
        assertFalse(behaviour.isValid(handler, event, EventType.RELEASED));

    }
View Full Code Here

     */
    @Test
    public void testGetCommand() {
        int x = 10;
        int y = 8;
        MapMouseEvent event = new MapMouseEvent(null, x, y, MapMouseEvent.NONE,
                MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        handler.getBehaviours().add(new InsertVertexOnEdgeBehaviour());

        handler.setCurrentState(EditState.MODIFYING);
        handler.setCurrentShape(shell);
View Full Code Here

     * '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

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.