Search in sources :

Example 1 with IBezierCurve

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

the class Border method updateCtrlPtHandlers.

private void updateCtrlPtHandlers(final IShape selectedShape) {
    if (selectedShape instanceof IBezierCurve) {
        final IBezierCurve pts = (IBezierCurve) selectedShape;
        initialisePointHandler(ctrlPt1Handlers, pt -> new CtrlPointHandler(pt), pts.getFirstCtrlPts());
        initialisePointHandler(ctrlPt2Handlers, pt -> new CtrlPointHandler(pt), pts.getSecondCtrlPts());
    }
}
Also used : CtrlPointHandler(net.sf.latexdraw.handlers.CtrlPointHandler) IBezierCurve(net.sf.latexdraw.models.interfaces.shape.IBezierCurve)

Example 2 with IBezierCurve

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

the class TestParsingPSbezier method testParamArrowsArrows.

@Test
public void testParamArrowsArrows() {
    parser("\\psbezier[arrows=<->](1,2)(3,4)(5,6)(7,8)");
    final IBezierCurve bc = getShapeAt(0);
    assertEquals(ArrowStyle.LEFT_ARROW, bc.getArrowStyle(0));
    assertEquals(ArrowStyle.RIGHT_ARROW, bc.getArrowStyle(1));
}
Also used : IBezierCurve(net.sf.latexdraw.models.interfaces.shape.IBezierCurve) Test(org.junit.Test)

Example 3 with IBezierCurve

use of net.sf.latexdraw.models.interfaces.shape.IBezierCurve 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 IBezierCurve bc = getShapeAt(0);
    assertEquals(2, 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(9d * IShape.PPC, bc.getSecondCtrlPtAt(0).getX(), 0.0001);
    assertEquals(-18d * IShape.PPC, bc.getSecondCtrlPtAt(0).getY(), 0.0001);
    assertEquals(3d * IShape.PPC, bc.getFirstCtrlPtAt(1).getX(), 0.0001);
    assertEquals(-4d * IShape.PPC, bc.getFirstCtrlPtAt(1).getY(), 0.0001);
}
Also used : IBezierCurve(net.sf.latexdraw.models.interfaces.shape.IBezierCurve) Test(org.junit.Test)

Example 4 with IBezierCurve

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

the class TestParsingPSbezier method testParse7Coordinates.

@Test
public void testParse7Coordinates() {
    parser("\\psbezier(5,10)(1,2)(3,4)(5,6)(7,8)(9,10)(11,12)");
    final IBezierCurve bc = getShapeAt(0);
    assertEquals(3, 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(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(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);
}
Also used : IBezierCurve(net.sf.latexdraw.models.interfaces.shape.IBezierCurve) Test(org.junit.Test)

Example 5 with IBezierCurve

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

the class TestParsingPSbezier method testParamArrowsArrowsNoneNone.

@Test
public void testParamArrowsArrowsNoneNone() {
    parser("\\psbezier[arrows=<->]{-}(1,2)(3,4)(5,6)(7,8)");
    final IBezierCurve bc = getShapeAt(0);
    assertEquals(ArrowStyle.NONE, bc.getArrowStyle(0));
    assertEquals(ArrowStyle.NONE, bc.getArrowStyle(1));
}
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