use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class EntityRectangleV1 method toInternal.
@Override
public Entity toInternal() {
Rectangle rectangle = new Rectangle();
applyCommonAttributes(rectangle);
return rectangle;
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class EntityGroupTest method moveShouldMoveChildren.
@Test
public void moveShouldMoveChildren() {
EntityGroup entityGroup = new EntityGroup();
Rectangle rectangle = new Rectangle(10, 10);
rectangle.setWidth(10);
rectangle.setHeight(10);
entityGroup.addChild(rectangle);
entityGroup.move(new Point2D.Double(-10, -10));
assertEquals(0, rectangle.getPosition().getX(), 0.1);
assertEquals(0, rectangle.getPosition().getX(), 0.1);
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class MoveControlTest method moveShouldMoveWhenDraggedAndReleasedTarget.
@Test
public void moveShouldMoveWhenDraggedAndReleasedTarget() {
Rectangle rectangle = new Rectangle();
rectangle.setWidth(10);
rectangle.setHeight(10);
rectangle.move(new Point2D.Double(10, 10));
SelectionManager selectionManager = new SelectionManager();
selectionManager.addSelection(rectangle);
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(11, 11)));
target.onEvent(new MouseEntityEvent(target, EventType.MOUSE_RELEASED, new Point2D.Double(10, 10), new Point2D.Double(11, 11)));
Assert.assertEquals(11, rectangle.getPosition().getX(), 0.1);
Assert.assertEquals(11, rectangle.getPosition().getY(), 0.1);
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class MoveControlTest method moveShouldMoveEntitiesWhenParentIsScaled.
@Test
public void moveShouldMoveEntitiesWhenParentIsScaled() {
EntityGroup entityGroup = new EntityGroup();
entityGroup.applyTransform(AffineTransform.getScaleInstance(0.1, 0.1));
Rectangle rectangle = new Rectangle();
rectangle.setWidth(10);
rectangle.setHeight(10);
entityGroup.addChild(rectangle);
SelectionManager selectionManager = new SelectionManager();
selectionManager.addSelection(rectangle);
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, rectangle.getPosition().getX(), 0.1);
Assert.assertEquals(10, rectangle.getPosition().getY(), 0.1);
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class MoveControlTest method moveShouldMoveWhenDragged.
@Test
public void moveShouldMoveWhenDragged() {
Rectangle rectangle = new Rectangle();
rectangle.setWidth(10);
rectangle.setHeight(10);
rectangle.move(new Point2D.Double(10, 10));
SelectionManager selectionManager = new SelectionManager();
selectionManager.addSelection(rectangle);
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(11, 11)));
Assert.assertEquals(11, rectangle.getPosition().getX(), 0.1);
Assert.assertEquals(11, rectangle.getPosition().getY(), 0.1);
}
Aggregations