/** * Copies the geometry back onto the editblackboard. * * @return */ private void copyFeature(EditBlackboard editBlackboard, EditGeom geom) { EditGeom newGeom = editBlackboard.newGeom(geom.getFeatureIDRef().get(), geom.getShapeType()); for (PrimitiveShape shape : geom) { PrimitiveShape newShape; if (shape == geom.getShell()) { newShape = newGeom.getShell(); } else { newShape = newGeom.newHole(); } if (shape == currentShape) handler.setCurrentShape(newShape); for (int i = 0; i < shape.getNumCoords(); i++) { editBlackboard.addCoordinate(shape.getCoord(i), newShape); } newGeom.setChanged(geom.isChanged()); } }
@Before public void setUp() throws Exception { handler = new TestHandler(); bb = handler.getEditBlackboard(); geom = bb.newGeom("id", ShapeType.POLYGON); // $NON-NLS-1$ bb.addPoint(0, 0, geom.getShell()); bb.addPoint(100, 0, geom.getShell()); bb.addPoint(100, 100, geom.getShell()); bb.addPoint(0, 100, geom.getShell()); bb.addPoint(0, 0, geom.getShell()); validator = new ValidHoleValidator(); hole = geom.newHole(); handler.setCurrentShape(hole); }
@Test public void testInOtherHole() throws Exception { bb.addPoint(10, 10, hole); bb.addPoint(20, 10, hole); PrimitiveShape hole2 = geom.newHole(); bb.addPoint(50, 50, hole2); bb.addPoint(70, 50, hole2); bb.addPoint(70, 70, hole2); bb.addPoint(50, 70, hole2); bb.addPoint(50, 50, hole2); MapMouseEvent event = new MapMouseEvent( null, 60, 60, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1); assertEquals( Messages.ValidHoleValidator_holeOverlap, validator.isValid(handler, event, EventType.RELEASED)); }