Search in sources :

Example 1 with ViewRectangle

use of net.sf.latexdraw.view.jfx.ViewRectangle in project latexdraw by arnobl.

the class TestBorder method testRotateTwoRectangles.

@Test
public void testRotateTwoRectangles() {
    final CmdFXVoid tr = () -> canvas.getDrawing().getShapeAt(1).orElseThrow().translate(150, 60);
    Cmds.of(addRec, addRec, tr, selectAllShapes).execute();
    final Point pt1 = ShapeFactory.INST.createPoint(point(border.rotHandler).query());
    final Point gc = ShapeFactory.INST.createPoint(point(getPane().getChildren().get(0)).query());
    Cmds.of(rotateDown).execute();
    final double a1 = ShapeFactory.INST.createLine(pt1, gc).getLineAngle();
    final double a2 = 2d * Math.PI - ShapeFactory.INST.createLine(ShapeFactory.INST.createPoint(pt1.getX() + txDown, pt1.getY() + tyDown), gc).getLineAngle();
    assertFalse("No rotation", ((ViewRectangle) canvas.getSelectedViews().get(0)).getBorder().getTransforms().isEmpty());
    assertFalse("No rotation", ((ViewRectangle) canvas.getSelectedViews().get(1)).getBorder().getTransforms().isEmpty());
    assertEquals(a1 + a2, ((Shape) getPane().getChildren().get(0).getUserData()).getRotationAngle(), 0.3);
    assertEquals(Math.toDegrees(a1 + a2), ((Rotate) ((ViewRectangle) canvas.getSelectedViews().get(0)).getBorder().getTransforms().get(0)).getAngle(), 15d);
    assertEquals(Math.toDegrees(a1 + a2), ((Rotate) ((ViewRectangle) canvas.getSelectedViews().get(1)).getBorder().getTransforms().get(0)).getAngle(), 15d);
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) ViewRectangle(net.sf.latexdraw.view.jfx.ViewRectangle) Test(org.junit.Test)

Example 2 with ViewRectangle

use of net.sf.latexdraw.view.jfx.ViewRectangle in project latexdraw by arnobl.

the class TestBorder method testRotateRectangle.

@Test
public void testRotateRectangle() {
    Cmds.of(addRec, selectAllShapes).execute();
    final Point pt1 = ShapeFactory.INST.createPoint(point(border.rotHandler).query());
    final Point gc = ShapeFactory.INST.createPoint(point(getPane().getChildren().get(0)).query());
    Cmds.of(rotateDown).execute();
    final double a1 = ShapeFactory.INST.createLine(pt1, gc).getLineAngle();
    final double a2 = 2d * Math.PI - ShapeFactory.INST.createLine(ShapeFactory.INST.createPoint(pt1.getX() + txDown, pt1.getY() + tyDown), gc).getLineAngle();
    assertFalse("No rotation", ((ViewRectangle) canvas.getSelectedViews().get(0)).getBorder().getTransforms().isEmpty());
    assertEquals(a1 + a2, ((Shape) getPane().getChildren().get(0).getUserData()).getRotationAngle(), 0.01);
    assertEquals(Math.toDegrees(a1 + a2), ((Rotate) ((ViewRectangle) canvas.getSelectedViews().get(0)).getBorder().getTransforms().get(0)).getAngle(), 1d);
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) ViewRectangle(net.sf.latexdraw.view.jfx.ViewRectangle) Test(org.junit.Test)

Aggregations

Point (net.sf.latexdraw.model.api.shape.Point)2 ViewRectangle (net.sf.latexdraw.view.jfx.ViewRectangle)2 Test (org.junit.Test)2