use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class TestBorder method testMoveCtrl1PtHandlerMovePt.
@Test
public void testMoveCtrl1PtHandlerMovePt() {
Cmds.of(addBezier, selectAllShapes).execute();
final Point point = ShapeFactory.INST.createPoint(addedBezier.getFirstCtrlPtAt(1));
point.translate(100d, 20d);
Cmds.of(() -> drag(border.ctrlPt1Handlers.get(1)).dropBy(100d, 20d)).execute();
assertEquals(point.getX(), addedBezier.getFirstCtrlPtAt(1).getX(), 1d);
assertEquals(point.getY(), addedBezier.getFirstCtrlPtAt(1).getY(), 1d);
}
use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class TestBorder method testArcEndHandlerRotated.
@Test
public void testArcEndHandlerRotated() {
Cmds.of(addArc, selectAllShapes, () -> addedArc.setRotationAngle(0.5)).execute();
final Point gc = addedArc.getGravityCentre();
final Point point = addedArc.getEndPoint().rotatePoint(addedArc.getGravityCentre(), addedArc.getRotationAngle());
final Point newpoint = point.rotatePoint(gc, Math.PI / 3d).rotatePoint(addedArc.getGravityCentre(), addedArc.getRotationAngle());
Cmds.of(() -> drag(border.arcHandlerEnd).dropBy(newpoint.getX() - point.getX(), newpoint.getY() - point.getY())).execute();
final Line l1 = ShapeFactory.INST.createLine(gc, addedArc.getEndPoint().rotatePoint(addedArc.getGravityCentre(), addedArc.getRotationAngle()));
final Line l2 = ShapeFactory.INST.createLine(gc, newpoint);
assertEquals(l1.getA(), l2.getA(), 0.02);
}
use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class TestBorder method testScaleERectangle.
@Test
public void testScaleERectangle() {
Cmds.of(addRec, selectAllShapes).execute();
final double width = addedRec.getWidth();
final double height = addedRec.getHeight();
final Point tr = addedRec.getTopRightPoint();
final CmdFXVoid trCmd = () -> tr.translate(50d, 0d);
Cmds.of(trCmd, () -> drag(border.scaleHandlers.get(4)).dropBy(50d, 10d)).execute();
assertEquals(height, addedRec.getHeight(), 0.001);
assertEquals(width + 50d, addedRec.getWidth(), 3d);
assertEquals(tr.getX(), addedRec.getTopRightPoint().getX(), 2d);
assertEquals(tr.getY(), addedRec.getTopRightPoint().getY(), 2d);
}
use of net.sf.latexdraw.model.api.shape.Point 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);
}
use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class TestBorder method testArcStartHandler.
@Test
public void testArcStartHandler() {
Cmds.of(addArc, selectAllShapes).execute();
final Point gc = addedArc.getGravityCentre();
final Point point = ShapeFactory.INST.createPoint(addedArc.getStartPoint());
final Point newpoint = point.rotatePoint(gc, -Math.PI / 4d);
Cmds.of(() -> drag(border.arcHandlerStart).dropBy(newpoint.getX() - point.getX(), newpoint.getY() - point.getY())).execute();
final Line l1 = ShapeFactory.INST.createLine(gc, ShapeFactory.INST.createPoint(addedArc.getStartPoint()));
final Line l2 = ShapeFactory.INST.createLine(gc, newpoint);
assertEquals(l1.getA(), l2.getA(), 0.02);
}
Aggregations