use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class MoveControlTest method moveShouldMoveMultipleSelectedEntitiesFromSelectionManager.
@Test
public void moveShouldMoveMultipleSelectedEntitiesFromSelectionManager() {
Rectangle rectangle1 = new Rectangle();
rectangle1.setWidth(10);
rectangle1.setHeight(10);
rectangle1.move(new Point2D.Double(10, 10));
Rectangle rectangle2 = new Rectangle();
rectangle2.setWidth(10);
rectangle2.setHeight(10);
SelectionManager selectionManager = new SelectionManager();
selectionManager.addSelection(rectangle1);
selectionManager.addSelection(rectangle2);
Assert.assertEquals(0, selectionManager.getPosition().getX(), 0.1);
Assert.assertEquals(0, selectionManager.getPosition().getY(), 0.1);
Controller controller = new Controller(selectionManager, new SimpleUndoManager());
MoveControl target = new MoveControl(controller);
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_PRESSED, new Point2D.Double(10, 10), new Point2D.Double(10, 10)));
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_DRAGGED, new Point2D.Double(10, 10), new Point2D.Double(11, 11)));
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_DRAGGED, new Point2D.Double(10, 10), new Point2D.Double(12, 12)));
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_DRAGGED, new Point2D.Double(10, 10), new Point2D.Double(20, 20)));
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_RELEASED, new Point2D.Double(10, 10), new Point2D.Double(20, 20)));
Assert.assertEquals(10, selectionManager.getPosition().getX(), 0.1);
Assert.assertEquals(10, selectionManager.getPosition().getY(), 0.1);
Assert.assertEquals(20, rectangle1.getPosition().getX(), 0.1);
Assert.assertEquals(20, rectangle1.getPosition().getY(), 0.1);
Assert.assertEquals(10, rectangle2.getPosition().getX(), 0.1);
Assert.assertEquals(10, rectangle2.getPosition().getY(), 0.1);
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class RectangleTest method isWithinShouldReturnTrueIfPointIsWithin.
@Test
public void isWithinShouldReturnTrueIfPointIsWithin() {
Rectangle rectangle = new Rectangle(10, 10);
rectangle.setWidth(10);
rectangle.setHeight(10);
assertTrue(rectangle.isWithin(new Point2D.Double(11, 11)));
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class RectangleTest method setPositionShouldTranslateTheRectangle.
@Test
public void setPositionShouldTranslateTheRectangle() {
Rectangle rectangle = new Rectangle();
rectangle.setWidth(10);
rectangle.setHeight(10);
rectangle.move(new Point2D.Double(10, 0));
assertEquals(rectangle.getPosition().getX(), 10, 0.1);
assertEquals(rectangle.getPosition().getY(), 0, 0.1);
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class RectangleTest method rotateShouldRotateAroundItsCenter.
@Test
public void rotateShouldRotateAroundItsCenter() {
Rectangle rectangle = new Rectangle(10, 10);
rectangle.setWidth(10);
rectangle.setHeight(10);
assertEquals(Double.valueOf(15), Double.valueOf(rectangle.getCenter().getX()));
assertEquals(Double.valueOf(15), Double.valueOf(rectangle.getCenter().getY()));
rectangle.rotate(90);
assertEquals(Double.valueOf(10), Double.valueOf(rectangle.getPosition().getX()));
assertEquals(Double.valueOf(10), Double.valueOf(rectangle.getPosition().getY()));
assertEquals(Double.valueOf(15), Double.valueOf(rectangle.getCenter().getX()));
assertEquals(Double.valueOf(15), Double.valueOf(rectangle.getCenter().getY()));
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class RectangleTest method isWithinShouldReturnFalseIfPointIsNotWithin.
@Test
public void isWithinShouldReturnFalseIfPointIsNotWithin() {
Rectangle rectangle = new Rectangle(10, 10);
rectangle.setWidth(10);
rectangle.setHeight(10);
assertFalse(rectangle.isWithin(new Point2D.Double(9, 11)));
}
Aggregations