use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class MovePointShapeTest method cannotDoFixtures.
@Override
protected Stream<Runnable> cannotDoFixtures() {
return Stream.of(() -> cmd = new MovePointShape(ShapeFactory.INST.createPolyline(List.of(ShapeFactory.INST.createPoint())), ShapeFactory.INST.createPoint(1, 2)), () -> cmd = new MovePointShape(ShapeFactory.INST.createPolyline(List.of(ShapeFactory.INST.createPoint())), ShapeFactory.INST.createPoint(1, 2)), () -> {
commonCanDoFixture();
point = shape.getPtAt(1);
cmd = new MovePointShape(shape, point);
cmd.setNewCoord(ShapeFactory.INST.createPoint(10, Double.NaN));
}, () -> {
final Point pt = Mockito.mock(Point.class);
final List<Point> pts = List.of(pt);
shape = Mockito.mock(Polyline.class);
Mockito.when(shape.getPoints()).thenReturn(pts);
Mockito.when(pt.getX()).thenReturn(Double.NaN);
cmd = new MovePointShape(shape, pt);
cmd.setNewCoord(ShapeFactory.INST.createPoint(10, Double.NaN));
});
}
use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class TestBorder method testScaleSORectangle.
@Test
public void testScaleSORectangle() {
Cmds.of(addRec, selectAllShapes).execute();
final double width = addedRec.getWidth();
final double height = addedRec.getHeight();
final Point bl = addedRec.getBottomLeftPoint();
final CmdFXVoid trCmd = () -> bl.translate(50d, 70d);
Cmds.of(trCmd, () -> drag(border.scaleHandlers.get(5)).dropBy(50d, 70d)).execute();
waitFXEvents.execute();
assertEquals(width - 50d, addedRec.getWidth(), 3d);
assertEquals(height + 70d, addedRec.getHeight(), 3d);
assertEquals(bl.getX(), addedRec.getBottomLeftPoint().getX(), 3d);
assertEquals(bl.getY(), addedRec.getBottomLeftPoint().getY(), 3d);
}
use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class TestBorder method testMoveCtrl2PtHandlerMovePt.
@Test
public void testMoveCtrl2PtHandlerMovePt() {
Cmds.of(addBezier, selectAllShapes).execute();
final Point point = ShapeFactory.INST.createPoint(addedBezier.getSecondCtrlPtAt(2));
point.translate(100d, 20d);
Cmds.of(() -> drag(border.ctrlPt2Handlers.get(2)).dropBy(100d, 20d)).execute();
assertEquals(point.getX(), addedBezier.getSecondCtrlPtAt(2).getX(), 1d);
assertEquals(point.getY(), addedBezier.getSecondCtrlPtAt(2).getY(), 1d);
}
use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class TestBorder method testArcEndHandler.
@Test
public void testArcEndHandler() {
Cmds.of(addArc, selectAllShapes).execute();
final Point gc = addedArc.getGravityCentre();
final Point point = ShapeFactory.INST.createPoint(addedArc.getEndPoint());
final Point newpoint = point.rotatePoint(gc, Math.PI / 3d);
Cmds.of(() -> drag(border.arcHandlerEnd).dropBy(newpoint.getX() - point.getX(), newpoint.getY() - point.getY())).execute();
final Line l1 = ShapeFactory.INST.createLine(gc, ShapeFactory.INST.createPoint(addedArc.getEndPoint()));
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 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);
}
Aggregations