Search in sources :

Example 26 with IBezierCurve

use of net.sf.latexdraw.models.interfaces.shape.IBezierCurve in project latexdraw by arnobl.

the class TestParsingPSbezier method testSimpleBezierCurveClose.

@Test
public void testSimpleBezierCurveClose() {
    parser("\\psbezier[linecolor=black, linewidth=0.04](0.10361466,-0.36860093)(0.76211923,-1.1211777)(7.561873,-1.9049373)(8.503614," + "-1.5686009216308594)(9.445356,-1.2322645)(6.693564,1.4899777)(5.7036147,1.631399)(4.713665,1.7728205)(-0.55489,0.38397577)(0.10361466," + "-0.36860093)");
    final IBezierCurve bc = getShapeAt(0);
    assertFalse(bc.isOpened());
}
Also used : IBezierCurve(net.sf.latexdraw.models.interfaces.shape.IBezierCurve) Test(org.junit.Test)

Example 27 with IBezierCurve

use of net.sf.latexdraw.models.interfaces.shape.IBezierCurve in project latexdraw by arnobl.

the class TestParsingPSbezier method testParse10Coordinates.

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

Example 28 with IBezierCurve

use of net.sf.latexdraw.models.interfaces.shape.IBezierCurve 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 IBezierCurve 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 * IShape.PPC, bc.getPtAt(1).getX(), 0.0001);
    assertEquals(-6d * IShape.PPC, bc.getPtAt(1).getY(), 0.0001);
    assertEquals(11d * IShape.PPC, bc.getPtAt(2).getX(), 0.0001);
    assertEquals(-12d * IShape.PPC, bc.getPtAt(2).getY(), 0.0001);
    assertEquals(17d * IShape.PPC, bc.getPtAt(3).getX(), 0.0001);
    assertEquals(-18d * IShape.PPC, bc.getPtAt(3).getY(), 0.0001);
    assertEquals(-1d * IShape.PPC, bc.getSecondCtrlPtAt(0).getX(), 0.0001);
    assertEquals(2d * IShape.PPC, bc.getSecondCtrlPtAt(0).getY(), 0.0001);
    assertEquals(7d * IShape.PPC, bc.getSecondCtrlPtAt(1).getX(), 0.0001);
    assertEquals(-8d * IShape.PPC, bc.getSecondCtrlPtAt(1).getY(), 0.0001);
    assertEquals(13d * IShape.PPC, bc.getSecondCtrlPtAt(2).getX(), 0.0001);
    assertEquals(-14d * IShape.PPC, bc.getSecondCtrlPtAt(2).getY(), 0.0001);
    assertEquals(3d * IShape.PPC, bc.getFirstCtrlPtAt(1).getX(), 0.0001);
    assertEquals(-4d * IShape.PPC, bc.getFirstCtrlPtAt(1).getY(), 0.0001);
    assertEquals(9d * IShape.PPC, bc.getFirstCtrlPtAt(2).getX(), 0.0001);
    assertEquals(-10d * IShape.PPC, bc.getFirstCtrlPtAt(2).getY(), 0.0001);
    assertEquals(15d * IShape.PPC, bc.getFirstCtrlPtAt(3).getX(), 0.0001);
    assertEquals(-16d * IShape.PPC, bc.getFirstCtrlPtAt(3).getY(), 0.0001);
}
Also used : IBezierCurve(net.sf.latexdraw.models.interfaces.shape.IBezierCurve) Test(org.junit.Test)

Aggregations

IBezierCurve (net.sf.latexdraw.models.interfaces.shape.IBezierCurve)28 Test (org.junit.Test)20 HelperTest (net.sf.latexdraw.HelperTest)6 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)5 IFreehand (net.sf.latexdraw.models.interfaces.shape.IFreehand)3 IPolygon (net.sf.latexdraw.models.interfaces.shape.IPolygon)3 IPolyline (net.sf.latexdraw.models.interfaces.shape.IPolyline)3 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 Point2D (javafx.geometry.Point2D)2 MathUtils (net.sf.latexdraw.models.MathUtils)2 ShapeFactory (net.sf.latexdraw.models.ShapeFactory)2 BorderPos (net.sf.latexdraw.models.interfaces.shape.BorderPos)2 IAxes (net.sf.latexdraw.models.interfaces.shape.IAxes)2 ICircle (net.sf.latexdraw.models.interfaces.shape.ICircle)2 ICircleArc (net.sf.latexdraw.models.interfaces.shape.ICircleArc)2 IDot (net.sf.latexdraw.models.interfaces.shape.IDot)2 IEllipse (net.sf.latexdraw.models.interfaces.shape.IEllipse)2 IGrid (net.sf.latexdraw.models.interfaces.shape.IGrid)2