Search in sources :

Example 96 with Point

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));
    });
}
Also used : Polyline(net.sf.latexdraw.model.api.shape.Polyline) Point(net.sf.latexdraw.model.api.shape.Point)

Example 97 with Point

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);
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.Test)

Example 98 with Point

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);
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.Test)

Example 99 with Point

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);
}
Also used : Line(net.sf.latexdraw.model.api.shape.Line) Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.Test)

Example 100 with Point

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);
}
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)139 Test (org.junit.Test)52 HelperTest (net.sf.latexdraw.HelperTest)27 Theory (org.junit.experimental.theories.Theory)23 NotNull (org.jetbrains.annotations.NotNull)19 Line (net.sf.latexdraw.model.api.shape.Line)10 Shape (net.sf.latexdraw.model.api.shape.Shape)9 SVGElement (net.sf.latexdraw.parser.svg.SVGElement)9 SVGGElement (net.sf.latexdraw.parser.svg.SVGGElement)9 Test (org.junit.jupiter.api.Test)8 ArrayList (java.util.ArrayList)7 Polyline (net.sf.latexdraw.model.api.shape.Polyline)5 Color (javafx.scene.paint.Color)4 MathUtils (net.sf.latexdraw.model.MathUtils)4 ShapeFactory (net.sf.latexdraw.model.ShapeFactory)4 BezierCurve (net.sf.latexdraw.model.api.shape.BezierCurve)4 Canvas (net.sf.latexdraw.view.jfx.Canvas)4 Point2D (java.awt.geom.Point2D)3 List (java.util.List)3 ShapeData (net.sf.latexdraw.data.ShapeData)3