use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class RectangleTest method setPositionOnRotateRectangleShouldMoveToCorrectPosition.
@Test
public void setPositionOnRotateRectangleShouldMoveToCorrectPosition() {
Rectangle rectangle = new Rectangle();
rectangle.setWidth(200);
rectangle.setHeight(50);
rectangle.setRotation(270);
rectangle.setPosition(new Point2D.Double(0.1, 0.1));
assertEquals(0.1, rectangle.getPosition().getX(), 0.1);
assertEquals(0.1, rectangle.getPosition().getY(), 0.1);
assertEquals(270, 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 getShapeShouldNotReturnATransformedShapeIfAddedAfterTransform.
@Test
public void getShapeShouldNotReturnATransformedShapeIfAddedAfterTransform() {
AffineTransform transform = new AffineTransform();
transform.translate(10, 10);
Rectangle rectangle = new Rectangle();
rectangle.setWidth(10);
rectangle.setHeight(10);
rectangle.setTransform(transform);
transform = new AffineTransform();
transform.translate(10, 10);
EntityGroup entityGroup = new EntityGroup();
entityGroup.setTransform(transform);
entityGroup.addChild(rectangle);
assertEquals(10d, rectangle.getShape().getBounds2D().getX(), 0.01);
assertEquals(10d, rectangle.getShape().getBounds2D().getY(), 0.01);
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class RectangleTest method getCenterShouldReturnTheTransformedCenterPosition.
@Test
public void getCenterShouldReturnTheTransformedCenterPosition() {
Rectangle rectangle = new Rectangle(10, 20);
rectangle.setWidth(10);
rectangle.setHeight(10);
assertEquals(Double.valueOf(15), Double.valueOf(rectangle.getCenter().getX()));
assertEquals(Double.valueOf(25), 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 moveShouldTranslateTheEntity.
@Test
public void moveShouldTranslateTheEntity() {
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.move(new Point2D.Double(-5, -5));
assertEquals(Double.valueOf(10), Double.valueOf(rectangle.getCenter().getX()));
assertEquals(Double.valueOf(10), Double.valueOf(rectangle.getCenter().getY()));
assertEquals(Double.valueOf(5), Double.valueOf(rectangle.getPosition().getX()));
assertEquals(Double.valueOf(5), 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 rotateAroundPointShouldRotateFromRectangleCenter.
@Test
public void rotateAroundPointShouldRotateFromRectangleCenter() {
Rectangle rectangle = new Rectangle();
rectangle.setWidth(10);
rectangle.setHeight(10);
rectangle.setCenter(new Point2D.Double(10, 0));
assertEquals(5, rectangle.getPosition().getX(), 0.01);
assertEquals(-5, rectangle.getPosition().getY(), 0.01);
rectangle.rotate(new Point2D.Double(0, 0), -90);
assertEquals(-5, rectangle.getPosition().getX(), 0.01);
assertEquals(5, rectangle.getPosition().getY(), 0.01);
assertEquals(270, rectangle.getRotation(), 0.01);
}
Aggregations