Examples of TestHandler


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

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

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

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

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

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

   
    @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

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

    @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

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

    @Test
    public void testRunAndUndo() throws Exception {
        EditBlackboard map=new EditBlackboard(SCREEN.x, SCREEN.y, transform, layerToWorld);
       
        PrimitiveShape hole=map.getGeoms().get(0).newHole();
        InsertVertexCommand command1=new InsertVertexCommand(new TestHandler(), map, new TestViewportPane(new Dimension(500,500)), new EditUtils.StaticShapeProvider(hole), Point.valueOf(10,10), 0, true );
        InsertVertexCommand command2=new InsertVertexCommand(new TestHandler(), map, new TestViewportPane(new Dimension(500,500)), new EditUtils.StaticShapeProvider(hole), Point.valueOf(10,15), 0, true );

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

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

    /*
     * Test method for 'org.locationtech.udig.tools.edit.behaviour.StartEditingBehaviour.isValid(EditToolHandler, MapMouseEvent, EventType)'
     */
    @Test
    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

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

    }

    @Ignore
    @Test
    public void testRun() throws Exception {
        final TestHandler handler=new TestHandler();
       
        ILayer layer = handler.getContext().getMapLayers().get(0);
        FeatureSource<SimpleFeatureType, SimpleFeature> resource = layer.getResource(FeatureSource.class, null);
        SimpleFeature feature = resource.getFeatures().features().next();
        IEditManager editManager = handler.getContext().getEditManager();
    ((EditManager)editManager).setEditFeature(feature, (Layer) layer);
       
        EditBlackboard editBlackboard = handler.getEditBlackboard();
        PrimitiveShape shell = editBlackboard.getGeoms().get(0).getShell();
        editBlackboard.addPoint(100,100,shell);
        shell.getEditGeom().setShapeType(ShapeType.POINT);
        editBlackboard.newGeom("newone", null); //$NON-NLS-1$
       
        StartEditingBehaviour behav=new StartEditingBehaviour(ShapeType.POLYGON);

        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
        }
        assertEquals(1, handler.getEditBlackboard().getGeoms().size());
       
        ((CommandManager)((Map)handler.getContext().getMap()).getCommandStack()).undo(false);
       
        assertEquals("Is the feature ID equal", feature.getID(), editManager.getEditFeature().getID());       
        assertEquals("Is the feature equal", feature, editManager.getEditFeature());
        assertFalse( handler.isLocked() );
        assertEquals(2, editBlackboard.getGeoms().size());
        assertEquals(ShapeType.POINT, editBlackboard.getGeoms().get(0).getShapeType());
        assertEquals(Point.valueOf(100,100), editBlackboard.getGeoms().get(0).getShell().getPoint(0));
       
    }
View Full Code Here

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

        Polygon poly = fac.createPolygon(fac.createLinearRing(new Coordinate[]{
                new Coordinate(20,20),new Coordinate(40,20), new Coordinate(40,40),
                new Coordinate(20,40), new Coordinate(20,20)
             }), new LinearRing[0]);
   
        handler=new TestHandler();
        features=UDIGTestUtil.createTestFeatures("DifferenceFeatureTests", new Geometry[]{line, poly}, new String[]{"line", "poly"});   //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
        map = MapTests.createNonDynamicMapAndRenderer(MapTests.createGeoResource(features, true), new Dimension(500,500));
       
        Envelope env=map.getBounds(null);
        map.getRenderManagerInternal().setMapDisplay(new TestViewportPane(new Dimension((int)env.getWidth(),(int)env.getHeight())));
View Full Code Here

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

    private EditGeom editGeom;
    private PrimitiveShape hole;

    @Before
    public void setUp() throws Exception {
        handler=new TestHandler();
        bb= handler.getEditBlackboard();
        editGeom = bb.getGeoms().get(0);
        bb.addPoint(10,10, editGeom.getShell());
        bb.addPoint(20,10, editGeom.getShell());
        bb.addPoint(30,10, editGeom.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.