use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class TestCanvasTranslation method testShapeTranslationWithZoom50.
@Test
public void testShapeTranslationWithZoom50() {
final var sh = ShapeSupplier.createRectangle();
Cmds.of(CmdFXVoid.of(() -> {
canvas.getSelectionBorder().setFill(new Color(1d, 1d, 1d, 0.1d));
sh.setFilled(true);
sh.translate(-canvas.getOrigin().getX(), -canvas.getOrigin().getY());
canvas.getDrawing().addShape(sh);
canvas.getDrawing().setSelection(List.of(sh));
canvas.setZoom(Double.NaN, Double.NaN, 0.5);
}), requestFocusCanvas).execute();
final Point tl = sh.getTopLeftPoint();
Cmds.of(() -> drag(canvas.getSelectionBorder()).dropBy(100, 160)).execute();
assertEquals(tl.getX() + 200d, sh.getTopLeftPoint().getX(), 5d);
assertEquals(tl.getY() + 320d, sh.getTopLeftPoint().getY(), 5d);
}
use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class TestCanvasTranslation method testTranslateSeveralShapesUsingOne.
@Test
public void testTranslateSeveralShapesUsingOne() {
Cmds.of(addRec, addRec2, selectAllShapes, CmdFXVoid.of(() -> canvas.getDrawing().getShapes().forEach(sh -> sh.setFilled(true)))).execute();
final Point tl1 = canvas.getDrawing().getShapeAt(0).orElseThrow().getTopLeftPoint();
final Point tl2 = canvas.getDrawing().getShapeAt(1).orElseThrow().getTopLeftPoint();
Cmds.of(() -> drag(canvas.getViews().getChildren().get(1)), () -> dropBy(100d, 200d)).execute();
assertEquals(2, canvas.getDrawing().getSelection().size());
assertEquals(tl1.getX() + 100d, canvas.getDrawing().getShapeAt(0).orElseThrow().getTopLeftPoint().getX(), 1d);
assertEquals(tl1.getY() + 200d, canvas.getDrawing().getShapeAt(0).orElseThrow().getTopLeftPoint().getY(), 1d);
assertEquals(tl2.getX() + 100d, canvas.getDrawing().getShapeAt(1).orElseThrow().getTopLeftPoint().getX(), 1d);
assertEquals(tl2.getY() + 200d, canvas.getDrawing().getShapeAt(1).orElseThrow().getTopLeftPoint().getY(), 1d);
}
use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class TestCanvasTranslation method testShapeTranslationWithZoom120.
@Test
public void testShapeTranslationWithZoom120() {
final var sh = ShapeSupplier.createRectangle();
Cmds.of(CmdFXVoid.of(() -> {
canvas.getSelectionBorder().setFill(new Color(1d, 1d, 1d, 0.1d));
sh.setFilled(true);
sh.translate(-canvas.getOrigin().getX(), -canvas.getOrigin().getY());
canvas.getDrawing().addShape(sh);
canvas.getDrawing().setSelection(List.of(sh));
canvas.setZoom(Double.NaN, Double.NaN, 1.2);
}), requestFocusCanvas).execute();
final Point tl = sh.getTopLeftPoint();
Cmds.of(() -> drag(canvas.getSelectionBorder()).dropBy(100, 160)).execute();
assertEquals(tl.getX() + (100d / 1.2), sh.getTopLeftPoint().getX(), 5d);
assertEquals(tl.getY() + (160d / 1.2), sh.getTopLeftPoint().getY(), 5d);
}
use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class ShapeFactoryImpl method createBezierCurveFrom.
@Override
@NotNull
public BezierCurve createBezierCurveFrom(final BezierCurve bc, final Point pointToAdd) {
if (bc == null || !MathUtils.INST.isValidPt(pointToAdd)) {
throw new IllegalArgumentException();
}
final List<Point> pts = new ArrayList<>(bc.getPoints());
final List<Point> ptsCtrl = new ArrayList<>(bc.getFirstCtrlPts());
pts.add(pointToAdd);
ptsCtrl.add(createPoint(pointToAdd.getX(), pointToAdd.getY() + BezierCurve.DEFAULT_POSITION_CTRL));
final BezierCurve copy = new BezierCurveImpl(pts, ptsCtrl);
copy.copy(bc);
return copy;
}
use of net.sf.latexdraw.model.api.shape.Point in project latexdraw by arnobl.
the class SquaredShapeBase method setWidth.
@Override
public void setWidth(final double width) {
if (width > 0 && MathUtils.INST.isValidCoord(width)) {
final Point pt = points.get(points.size() - 1);
final double xPos = pt.getX() + width;
final double yPos = pt.getY() - width;
points.get(1).setX(xPos);
points.get(2).setX(xPos);
points.get(0).setY(yPos);
points.get(1).setY(yPos);
}
}
Aggregations