use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class RectangleTest method getPositionShouldReturnTheTransformedPosition.
@Test
public void getPositionShouldReturnTheTransformedPosition() {
Rectangle rectangle = new Rectangle(10, 20);
rectangle.setWidth(10);
rectangle.setHeight(10);
assertEquals(Double.valueOf(10), Double.valueOf(rectangle.getPosition().getX()));
assertEquals(Double.valueOf(20), Double.valueOf(rectangle.getPosition().getY()));
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class RectangleTest method rotateShouldRotateAroundRectangleCenter.
@Test
public void rotateShouldRotateAroundRectangleCenter() {
Rectangle rectangle = new Rectangle();
rectangle.setWidth(10);
rectangle.setHeight(10);
rectangle.move(new Point2D.Double(10, 10));
// Rotate 360
rectangle.rotate(90);
rectangle.rotate(90);
rectangle.rotate(90);
rectangle.rotate(90);
// Rotate additional 90 degrees
rectangle.rotate(90);
assertEquals(15, rectangle.getCenter().getX(), 0.01);
assertEquals(15, rectangle.getCenter().getY(), 0.01);
assertEquals(90, rectangle.getRotation(), 0.01);
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class RectangleTest method setSizeWithAnotherWidthShouldOnlyScaleWidth.
@Test
public void setSizeWithAnotherWidthShouldOnlyScaleWidth() {
Rectangle rectangle = new Rectangle();
rectangle.setPosition(new Point2D.Double(1, 1));
rectangle.setWidth(100);
rectangle.setHeight(100);
rectangle.setRotation(90);
assertEquals(100, rectangle.getSize().getWidth(), 0.1);
assertEquals(100, rectangle.getSize().getHeight(), 0.1);
assertEquals(1, rectangle.getPosition().getX(), 0.1);
assertEquals(1, rectangle.getPosition().getY(), 0.1);
assertEquals(90, rectangle.getRotation(), 0.1);
rectangle.setSize(new Size(200, 150));
assertEquals(200, rectangle.getSize().getWidth(), 0.1);
assertEquals(150, rectangle.getSize().getHeight(), 0.1);
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class RectangleTest method scaleShouldChangeTheSize.
@Test
public void scaleShouldChangeTheSize() {
Rectangle rectangle = new Rectangle();
rectangle.setWidth(100);
rectangle.setHeight(100);
rectangle.setPosition(new Point2D.Double(1, 1));
rectangle.scale(0.5, 0.5);
assertEquals(50, rectangle.getSize().getWidth(), 0.1);
assertEquals(50, rectangle.getSize().getHeight(), 0.1);
assertEquals(1, rectangle.getPosition().getX(), 0.1);
assertEquals(1, 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 SelectionManagerTest method setRotationShouldRotateChildrenAsWell.
@Test
public void setRotationShouldRotateChildrenAsWell() {
Rectangle rectangle1 = new Rectangle(10, 0);
rectangle1.setWidth(1);
rectangle1.setHeight(1);
target.addSelection(rectangle1);
Rectangle rectangle2 = new Rectangle(0, 0);
rectangle2.setWidth(1);
rectangle2.setHeight(1);
target.addSelection(rectangle2);
target.setRotation(90);
assertEquals(90, rectangle1.getRotation(), 0.001);
assertEquals(90, rectangle2.getRotation(), 0.001);
assertEquals(new Point2D.Double(5, -5), rectangle1.getPosition());
assertEquals(new Point2D.Double(5, 5), rectangle2.getPosition());
}
Aggregations