Package org.locationtech.udig.tools.edit.support

Examples of org.locationtech.udig.tools.edit.support.TestHandler


    private TestHandler handler;
    private PrimitiveShape shell;
   
    @Before
    public void setUp() throws Exception {
        handler=new TestHandler();
        shell = handler.getEditBlackboard().getGeoms().get(0).getShell();
        handler.getEditBlackboard().addPoint(10,10, shell);
        handler.getEditBlackboard().addPoint(20,10, shell);
        handler.getEditBlackboard().addPoint(20,20, shell);
        handler.getEditBlackboard().addPoint(10,20, shell);
View Full Code Here


    private EditBlackboard editBlackboard;
   
    @Before
    public void setUp() throws Exception {
        mode=new MoveVertexBehaviour();
        handler=new TestHandler();

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

        MapMouseEvent event=new MapMouseEvent( DISPLAY, 10,10,NONE,BUTTON1, BUTTON1 );
View Full Code Here

    private SimpleFeature feature;
    private SimpleFeature feature2;

    @Before
    public void setUp() throws Exception {
        handler=new TestHandler(2);
        bb= handler.getEditBlackboard();
        editGeom = bb.newGeom("testing", null); //$NON-NLS-1$
        bb.addPoint(10,10, editGeom.getShell());
        bb.addPoint(20,10, editGeom.getShell());
        bb.addPoint(30,10, editGeom.getShell());
View Full Code Here

    /*
     * Test method for 'org.locationtech.udig.tools.edit.behaviour.StartEditingBehaviour.isValid(EditToolHandler, MapMouseEvent, EventType)'
     */
    @Test
    public void testIsValid() throws Exception {
        TestHandler handler=new TestHandler();
       
        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

    /*
     * Test method for 'org.locationtech.udig.tools.edit.behaviour.StartEditingBehaviour.isValid(EditToolHandler, MapMouseEvent, EventType)'
     */
    @Test
    public void testIsValid() throws Exception {
        TestHandler handler=new TestHandler();
        handler.getTestEditBlackboard().util.setVertexRadius(4);
       
        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

    private TestHandler handler;
    private PrimitiveShape shell;
   
    @Before
    public void setUp() throws Exception {
        handler = new TestHandler();
        shell = handler.getEditBlackboard().getGeoms().get(0).getShell();
        handler.getEditBlackboard().addPoint(0, 10, shell);
        handler.getEditBlackboard().addPoint(20, 10, shell);
        handler.getEditBlackboard().addPoint(20, 20, shell);
        handler.getEditBlackboard().addPoint(10, 20, shell);
View Full Code Here

    /*
     * Test method for 'org.locationtech.udig.tools.edit.behaviour.ExtendLineBehaviour.isValid(EditToolHandler, MapMouseEvent, EventType)'
     */
    @Test
    public void testIsValid() throws Exception {
        TestHandler handler=new TestHandler();
        handler.getTestEditBlackboard().util.setVertexRadius(4);
       
        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));
View Full Code Here

    /*
     * Test method for 'org.locationtech.udig.tools.edit.behaviour.ExtendLineBehaviour.getCommand(EditToolHandler, MapMouseEvent, EventType)'
     */
    @Test
    public void testGetCommand() throws Exception {
        TestHandler handler=new TestHandler();
        handler.getTestEditBlackboard().util.setVertexRadius(4);
       
        StartExtendLineBehaviour behavior=new StartExtendLineBehaviour();
        handler.getBehaviours().add(behavior);
        handler.setCurrentState(EditState.MODIFYING);

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

        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());
       
        handler.setCurrentState(EditState.NONE);
       
        handler.handleEvent(event, EventType.RELEASED);
        assertEquals(Point.valueOf(0,0), handler.getCurrentShape().getPoint(0));
        assertEquals(EditState.CREATING, handler.getCurrentState());
    }
View Full Code Here

   
    @Test
    public void testRunAndUndo() throws Exception {
        EditBlackboard map=new EditBlackboard(SCREEN.x, SCREEN.y, transform, layerToWorld);
       
        AddVertexCommand command1=new AddVertexCommand(new TestHandler(), map, new StaticBlockingProvider<PrimitiveShape>(map.getGeoms().get(0).getShell()), Point.valueOf(10,10), true );
        AddVertexCommand command2=new AddVertexCommand(new TestHandler(), map, new StaticBlockingProvider<PrimitiveShape>(map.getGeoms().get(0).getShell()), Point.valueOf(10,15), true );

        assertEquals(0, map.getCoords(10,10).size());
        assertEquals(0, map.getCoords(10,15).size());       
       
        command1.run(new NullProgressMonitor());
View Full Code Here

    @Test
    public void testRunAndUndoWhenVerticesAreSnappedIntoOne() throws Exception {
        EditBlackboard map=new EditBlackboard(SCREEN.x, SCREEN.y, transform, layerToWorld);
       
        AddVertexCommand command1=new AddVertexCommand(new TestHandler(), map, new StaticBlockingProvider<PrimitiveShape>(map.getGeoms().get(0).getShell()), Point.valueOf(10,10), true );
        AddVertexCommand command2=new AddVertexCommand(new TestHandler(), map, new StaticBlockingProvider<PrimitiveShape>(map.getGeoms().get(0).getShell()), Point.valueOf(10,11), true );

        assertEquals(0, map.getCoords(10,10).size());
        assertEquals(0, map.getCoords(10,11).size());       
       
        command1.run(new NullProgressMonitor());
View Full Code Here

TOP

Related Classes of org.locationtech.udig.tools.edit.support.TestHandler

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.