Search in sources :

Example 21 with BezierCurve

use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.

the class TestParsingPSbezier method testParse9Coordinates.

@Test
public void testParse9Coordinates() {
    parser("\\psbezier(1,2)(3,4)(5,6)(7,8)(9,10)(11,12)(13,14)(15,16)(17,18)");
    final BezierCurve bc = getShapeAt(0);
    assertEquals(4, bc.getNbPoints());
    assertEquals(0d, bc.getPtAt(0).getX(), 0.0001);
    assertEquals(0d, bc.getPtAt(0).getY(), 0.0001);
    assertEquals(5d * Shape.PPC, bc.getPtAt(1).getX(), 0.0001);
    assertEquals(-6d * Shape.PPC, bc.getPtAt(1).getY(), 0.0001);
    assertEquals(11d * Shape.PPC, bc.getPtAt(2).getX(), 0.0001);
    assertEquals(-12d * Shape.PPC, bc.getPtAt(2).getY(), 0.0001);
    assertEquals(17d * Shape.PPC, bc.getPtAt(3).getX(), 0.0001);
    assertEquals(-18d * Shape.PPC, bc.getPtAt(3).getY(), 0.0001);
    assertEquals(-1d * Shape.PPC, bc.getSecondCtrlPtAt(0).getX(), 0.0001);
    assertEquals(2d * Shape.PPC, bc.getSecondCtrlPtAt(0).getY(), 0.0001);
    assertEquals(7d * Shape.PPC, bc.getSecondCtrlPtAt(1).getX(), 0.0001);
    assertEquals(-8d * Shape.PPC, bc.getSecondCtrlPtAt(1).getY(), 0.0001);
    assertEquals(13d * Shape.PPC, bc.getSecondCtrlPtAt(2).getX(), 0.0001);
    assertEquals(-14d * Shape.PPC, bc.getSecondCtrlPtAt(2).getY(), 0.0001);
    assertEquals(3d * Shape.PPC, bc.getFirstCtrlPtAt(1).getX(), 0.0001);
    assertEquals(-4d * Shape.PPC, bc.getFirstCtrlPtAt(1).getY(), 0.0001);
    assertEquals(9d * Shape.PPC, bc.getFirstCtrlPtAt(2).getX(), 0.0001);
    assertEquals(-10d * Shape.PPC, bc.getFirstCtrlPtAt(2).getY(), 0.0001);
    assertEquals(15d * Shape.PPC, bc.getFirstCtrlPtAt(3).getX(), 0.0001);
    assertEquals(-16d * Shape.PPC, bc.getFirstCtrlPtAt(3).getY(), 0.0001);
}
Also used : BezierCurve(net.sf.latexdraw.model.api.shape.BezierCurve) Test(org.junit.jupiter.api.Test)

Example 22 with BezierCurve

use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.

the class TestParsingPSbezier method testParse4Coordinates.

@Test
public void testParse4Coordinates() {
    parser("\\psbezier(5,10)(1,2)(3,4)(5,6)");
    final BezierCurve bc = getShapeAt(0);
    assertEquals(2, bc.getNbPoints());
    assertEquals(5d * Shape.PPC, bc.getPtAt(0).getX(), 0.0001);
    assertEquals(-10d * Shape.PPC, bc.getPtAt(0).getY(), 0.0001);
    assertEquals(5d * Shape.PPC, bc.getPtAt(1).getX(), 0.0001);
    assertEquals(-6d * Shape.PPC, bc.getPtAt(1).getY(), 0.0001);
    assertEquals(9d * Shape.PPC, bc.getSecondCtrlPtAt(0).getX(), 0.0001);
    assertEquals(-18d * Shape.PPC, bc.getSecondCtrlPtAt(0).getY(), 0.0001);
    assertEquals(3d * Shape.PPC, bc.getFirstCtrlPtAt(1).getX(), 0.0001);
    assertEquals(-4d * Shape.PPC, bc.getFirstCtrlPtAt(1).getY(), 0.0001);
}
Also used : BezierCurve(net.sf.latexdraw.model.api.shape.BezierCurve) Test(org.junit.jupiter.api.Test)

Example 23 with BezierCurve

use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.

the class TestParsingPSbezier method testParse3Coordinates.

@Test
public void testParse3Coordinates() {
    parser("\\psbezier(1,2)(3,4)(5,6)");
    final BezierCurve bc = getShapeAt(0);
    assertEquals(2, bc.getNbPoints());
    assertEquals(0d, bc.getPtAt(0).getX(), 0.0001);
    assertEquals(0d, bc.getPtAt(0).getY(), 0.0001);
    assertEquals(5d * Shape.PPC, bc.getPtAt(1).getX(), 0.0001);
    assertEquals(-6d * Shape.PPC, bc.getPtAt(1).getY(), 0.0001);
    assertEquals(-1d * Shape.PPC, bc.getSecondCtrlPtAt(0).getX(), 0.0001);
    assertEquals(2d * Shape.PPC, bc.getSecondCtrlPtAt(0).getY(), 0.0001);
    assertEquals(3d * Shape.PPC, bc.getFirstCtrlPtAt(1).getX(), 0.0001);
    assertEquals(-4d * Shape.PPC, bc.getFirstCtrlPtAt(1).getY(), 0.0001);
}
Also used : BezierCurve(net.sf.latexdraw.model.api.shape.BezierCurve) Test(org.junit.jupiter.api.Test)

Example 24 with BezierCurve

use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.

the class TestBezierCurve method testConstructors2.

@Test
public void testConstructors2() {
    final BezierCurve curve = ShapeFactory.INST.createBezierCurve(Arrays.asList(ShapeFactory.INST.createPoint(100, 200), ShapeFactory.INST.createPoint(300, 400)));
    assertEquals(2, curve.getPoints().size());
    assertEqualsDouble(100., curve.getPoints().get(0).getX());
    assertEqualsDouble(200., curve.getPoints().get(0).getY());
    assertEqualsDouble(300., curve.getPoints().get(1).getX());
    assertEqualsDouble(400., curve.getPoints().get(1).getY());
    assertEquals(2, curve.getFirstCtrlPts().size());
    assertEquals(2, curve.getSecondCtrlPts().size());
    assertEquals(2, curve.getNbArrows());
}
Also used : BezierCurve(net.sf.latexdraw.model.api.shape.BezierCurve) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 25 with BezierCurve

use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.

the class TestShapeFactory method testCreateBezierCurveFromSameNewPoint.

@Test
void testCreateBezierCurveFromSameNewPoint() {
    BezierCurve bc = ShapeFactory.INST.createBezierCurve(Collections.singletonList(ShapeFactory.INST.createPoint()));
    bc = ShapeFactory.INST.createBezierCurveFrom(bc, ShapeFactory.INST.createPoint(1d, 2d));
    assertEqualsDouble(1d, bc.getPtAt(1).getX());
    assertEqualsDouble(2d, bc.getPtAt(1).getY());
}
Also used : BezierCurve(net.sf.latexdraw.model.api.shape.BezierCurve) Test(org.junit.jupiter.api.Test) HelperTest(net.sf.latexdraw.HelperTest)

Aggregations

BezierCurve (net.sf.latexdraw.model.api.shape.BezierCurve)26 Test (org.junit.jupiter.api.Test)16 HelperTest (net.sf.latexdraw.HelperTest)6 Point (net.sf.latexdraw.model.api.shape.Point)4 Test (org.junit.Test)4 Polygon (net.sf.latexdraw.model.api.shape.Polygon)3 ArrayList (java.util.ArrayList)2 Freehand (net.sf.latexdraw.model.api.shape.Freehand)2 Polyline (net.sf.latexdraw.model.api.shape.Polyline)2 Shape (net.sf.latexdraw.model.api.shape.Shape)2 NotNull (org.jetbrains.annotations.NotNull)2 Click (io.github.interacto.jfx.interaction.library.Click)1 DnD (io.github.interacto.jfx.interaction.library.DnD)1 MultiClick (io.github.interacto.jfx.interaction.library.MultiClick)1 PointsData (io.github.interacto.jfx.interaction.library.PointsData)1 Press (io.github.interacto.jfx.interaction.library.Press)1 Point2D (java.awt.geom.Point2D)1 Arrays (java.util.Arrays)1 Objects (java.util.Objects)1 Function (java.util.function.Function)1