use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class RectangleTest method getShapeShouldReturnATransformedShape.
@Test
public void getShapeShouldReturnATransformedShape() {
Rectangle rectangle = new Rectangle(10, 10);
rectangle.setWidth(10);
rectangle.setHeight(10);
AffineTransform transform = new AffineTransform();
transform.translate(10, 10);
rectangle.applyTransform(transform);
assertEquals(20d, rectangle.getShape().getBounds2D().getX(), 0.01);
assertEquals(20d, 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 rotateAroundPointShouldRotateRectangle.
@Test
public void rotateAroundPointShouldRotateRectangle() {
Rectangle rectangle = new Rectangle();
rectangle.setWidth(1);
rectangle.setHeight(1);
rectangle.setCenter(new Point2D.Double(10, 0));
rectangle.rotate(new Point2D.Double(5, 0), 90);
assertEquals(new Point2D.Double(4.5, -5.5), rectangle.getPosition());
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 scaleShouldChangeSizeWhenRotated.
@Test
public void scaleShouldChangeSizeWhenRotated() {
Rectangle rectangle = new Rectangle();
rectangle.setPosition(new Point2D.Double(1, 1));
rectangle.setWidth(100);
rectangle.setHeight(100);
rectangle.setRotation(90);
assertEquals(1, rectangle.getPosition().getY(), 0.1);
assertEquals(1, rectangle.getPosition().getX(), 0.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 RectangleTest method moveShouldTranslateScaledEntity.
@Test
public void moveShouldTranslateScaledEntity() {
Rectangle rectangle = new Rectangle(10, 10);
rectangle.applyTransform(AffineTransform.getScaleInstance(2, 2));
rectangle.setWidth(10);
rectangle.setHeight(10);
assertEquals(new Point2D.Double(20, 20), rectangle.getPosition());
assertEquals(new Point2D.Double(25, 25), rectangle.getCenter());
rectangle.move(new Point2D.Double(-5, -5));
assertEquals(new Point2D.Double(15, 15), rectangle.getPosition());
assertEquals(new Point2D.Double(20, 20), rectangle.getCenter());
}
use of com.willwinder.ugs.nbp.designer.entities.cuttable.Rectangle in project Universal-G-Code-Sender by winder.
the class SelectionManagerTest method setRotationShouldRotateAnEntityAroundItsCenter.
@Test
public void setRotationShouldRotateAnEntityAroundItsCenter() {
Rectangle rectangle = new Rectangle();
rectangle.setPosition(new Point2D.Double(10, 20));
rectangle.setSize(new Size(10, 10));
target.addSelection(rectangle);
assertEquals(new Point2D.Double(15, 25), target.getCenter());
target.setRotation(90);
assertEquals(new Point2D.Double(15, 25), target.getCenter());
assertEquals(new Point2D.Double(10, 20), target.getPosition());
assertEquals(90, target.getRotation(), 0.1);
assertEquals(10, rectangle.getPosition().getX(), 0.1);
assertEquals(20, rectangle.getPosition().getY(), 0.1);
assertEquals(90, rectangle.getRotation(), 0.1);
}
Aggregations