use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class EntityGroupTest method getChildrenAtShouldReturnEntitiesWithinPoint.
@Test
public void getChildrenAtShouldReturnEntitiesWithinPoint() {
EntityGroup entityGroup = new EntityGroup();
Rectangle rectangle = new Rectangle(0, 0);
rectangle.setWidth(10);
rectangle.setHeight(10);
entityGroup.addChild(rectangle);
entityGroup.move(new Point2D.Double(10, 10));
List<Entity> childrenAt = entityGroup.getChildrenAt(new Point2D.Double(11, 11));
assertEquals(1, childrenAt.size());
assertEquals(rectangle, childrenAt.get(0));
childrenAt = entityGroup.getChildrenAt(new Point2D.Double(9, 9));
assertEquals(0, childrenAt.size());
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class EntityGroupTest method rotateShouldRotateChildrenAsWell.
@Test
public void rotateShouldRotateChildrenAsWell() {
EntityGroup entityGroup = new EntityGroup();
Rectangle rectangle1 = new Rectangle(10, 0);
rectangle1.setWidth(1);
rectangle1.setHeight(1);
entityGroup.addChild(rectangle1);
Rectangle rectangle2 = new Rectangle(0, 0);
rectangle2.setWidth(1);
rectangle2.setHeight(1);
entityGroup.addChild(rectangle2);
entityGroup.rotate(90);
assertEquals(5, rectangle1.getPosition().getX(), 0.1);
assertEquals(-5, rectangle1.getPosition().getY(), 0.1);
assertEquals(90, rectangle1.getRotation(), 0.1);
assertEquals(5, rectangle2.getPosition().getX(), 0.1);
assertEquals(5, rectangle2.getPosition().getY(), 0.1);
assertEquals(90, rectangle2.getRotation(), 0.1);
assertEquals(90, entityGroup.getRotation(), 0.1);
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class EntityGroupTest method setSizeShouldResizeChildrenRelativly.
@Test
public void setSizeShouldResizeChildrenRelativly() {
EntityGroup entityGroup = new EntityGroup();
Rectangle rectangle1 = new Rectangle(10, 10);
rectangle1.setWidth(10);
rectangle1.setHeight(10);
entityGroup.addChild(rectangle1);
Rectangle rectangle2 = new Rectangle(20, 20);
rectangle2.setWidth(10);
rectangle2.setHeight(10);
entityGroup.addChild(rectangle2);
assertEquals(20, entityGroup.getSize().getWidth(), 0.1);
assertEquals(20, entityGroup.getSize().getHeight(), 0.1);
entityGroup.setSize(new Size(40, 40));
assertEquals(10, rectangle1.getPosition().getX(), 0.1);
assertEquals(10, rectangle1.getPosition().getX(), 0.1);
assertEquals(20, rectangle1.getSize().getWidth(), 0.1);
assertEquals(20, rectangle1.getSize().getHeight(), 0.1);
assertEquals(30, rectangle2.getPosition().getX(), 0.1);
assertEquals(30, rectangle2.getPosition().getX(), 0.1);
assertEquals(20, rectangle2.getSize().getWidth(), 0.1);
assertEquals(20, rectangle2.getSize().getHeight(), 0.1);
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class EntityGroupTest method rotateShouldRotateChildAsWell.
@Test
public void rotateShouldRotateChildAsWell() {
EntityGroup entityGroup = new EntityGroup();
Rectangle rectangle = new Rectangle(10, 0);
rectangle.setWidth(1);
rectangle.setHeight(1);
entityGroup.addChild(rectangle);
entityGroup.rotate(90);
assertEquals(10, rectangle.getPosition().getX(), 0.1);
assertEquals(0, rectangle.getPosition().getY(), 0.1);
assertEquals(90, rectangle.getRotation(), 0.1);
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class EntityGroupTest method getPositionOfChildrenShouldReturnRealPosition.
@Test
public void getPositionOfChildrenShouldReturnRealPosition() {
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(20, rectangle.getPosition().getX(), 0.1);
assertEquals(20, rectangle.getPosition().getX(), 0.1);
}
Aggregations