Search in sources :

Example 6 with SVGPathSegMoveto

use of net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto in project latexdraw by arnobl.

the class TestSVGPathSegCurvetoQuadratic method testToString.

@Test
public void testToString() throws ParseException {
    SVGPathSegMoveto m = new SVGPathSegMoveto(0d, 0d, false);
    SVGPathParser parser = new SVGPathParser(m.toString() + " " + seg.toString(), pathSeg -> {
        if (pathSeg instanceof SVGPathSegMoveto && cpt == 0) {
            cpt++;
            return;
        }
        assertTrue(pathSeg instanceof SVGPathSegCurvetoQuadratic);
        SVGPathSegCurvetoQuadratic seg2 = (SVGPathSegCurvetoQuadratic) pathSeg;
        assertEquals(seg.getX(), seg2.getX(), 0.0001);
        assertEquals(seg.getX1(), seg2.getX1(), 0.0001);
        assertEquals(seg.getY(), seg2.getY(), 0.0001);
        assertEquals(seg.getY1(), seg2.getY1(), 0.0001);
        assertEquals(seg.isRelative(), seg2.isRelative());
    });
    parser.parse();
}
Also used : SVGPathParser(net.sf.latexdraw.parsers.svg.parsers.SVGPathParser) SVGPathSegMoveto(net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto) SVGPathSegCurvetoQuadratic(net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoQuadratic) Test(org.junit.Test)

Example 7 with SVGPathSegMoveto

use of net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto in project latexdraw by arnobl.

the class TestSVGPathSegCurvetoQuadraticSmooth method testToString.

@Test
public void testToString() throws ParseException {
    SVGPathSegMoveto m = new SVGPathSegMoveto(0d, 0d, false);
    SVGPathParser parser = new SVGPathParser(m.toString() + " " + seg.toString(), pathSeg -> {
        if (pathSeg instanceof SVGPathSegMoveto && cpt == 0) {
            cpt++;
            return;
        }
        assertTrue(pathSeg instanceof SVGPathSegCurvetoQuadraticSmooth);
        SVGPathSegCurvetoQuadraticSmooth seg2 = (SVGPathSegCurvetoQuadraticSmooth) pathSeg;
        assertEquals(seg.getX(), seg2.getX(), 0.0001);
        assertEquals(seg.getY(), seg2.getY(), 0.0001);
        assertEquals(seg.isRelative(), seg2.isRelative());
    });
    parser.parse();
}
Also used : SVGPathParser(net.sf.latexdraw.parsers.svg.parsers.SVGPathParser) SVGPathSegCurvetoQuadraticSmooth(net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoQuadraticSmooth) SVGPathSegMoveto(net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto) Test(org.junit.Test)

Example 8 with SVGPathSegMoveto

use of net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto in project latexdraw by arnobl.

the class TestSVGPathSegLineto method testToString.

@Test
public void testToString() throws ParseException {
    SVGPathSegMoveto m = new SVGPathSegMoveto(0d, 0d, false);
    SVGPathParser parser = new SVGPathParser(m.toString() + " " + seg.toString(), pathSeg -> {
        if (pathSeg instanceof SVGPathSegMoveto && cpt == 0) {
            cpt++;
            return;
        }
        assertTrue(pathSeg instanceof SVGPathSegLineto);
        SVGPathSegLineto seg2 = (SVGPathSegLineto) pathSeg;
        assertEquals(seg.getX(), seg2.getX(), 0.0001);
        assertEquals(seg.getY(), seg2.getY(), 0.0001);
        assertEquals(seg.isRelative(), seg2.isRelative());
    });
    parser.parse();
}
Also used : SVGPathParser(net.sf.latexdraw.parsers.svg.parsers.SVGPathParser) SVGPathSegMoveto(net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto) SVGPathSegLineto(net.sf.latexdraw.parsers.svg.path.SVGPathSegLineto) Test(org.junit.Test)

Example 9 with SVGPathSegMoveto

use of net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto in project latexdraw by arnobl.

the class SVGArrow method createMoveTo.

@Override
public void createMoveTo(final double x, final double y) {
    createPath();
    currentPath.add(new SVGPathSegMoveto(x, y, false));
}
Also used : SVGPathSegMoveto(net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto)

Example 10 with SVGPathSegMoveto

use of net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto in project latexdraw by arnobl.

the class SVGBezierCurve method getPathSegList.

/**
 * @return The SVG segment path list of the current Bézier curve.
 * @since 2.0.0
 */
protected SVGPathSegList getPathSegList() {
    if (shape.getNbPoints() < 2) {
        return null;
    }
    final int size = shape.getNbPoints();
    int i;
    final SVGPathSegList path = new SVGPathSegList();
    path.add(new SVGPathSegMoveto(shape.getPtAt(0).getX(), shape.getPtAt(0).getY(), false));
    path.add(new SVGPathSegCurvetoCubic(shape.getPtAt(1).getX(), shape.getPtAt(1).getY(), shape.getFirstCtrlPtAt(0).getX(), shape.getFirstCtrlPtAt(0).getY(), shape.getFirstCtrlPtAt(1).getX(), shape.getFirstCtrlPtAt(1).getY(), false));
    for (i = 2; i < size; i++) {
        path.add(new SVGPathSegCurvetoCubic(shape.getPtAt(i).getX(), shape.getPtAt(i).getY(), shape.getSecondCtrlPtAt(i - 1).getX(), shape.getSecondCtrlPtAt(i - 1).getY(), shape.getFirstCtrlPtAt(i).getX(), shape.getFirstCtrlPtAt(i).getY(), false));
    }
    if (!shape.isOpened()) {
        final IPoint ctrl1b = shape.getFirstCtrlPtAt(0).centralSymmetry(shape.getPtAt(0));
        final IPoint ctrl2b = shape.getFirstCtrlPtAt(-1).centralSymmetry(shape.getPtAt(-1));
        path.add(new SVGPathSegCurvetoCubic(shape.getPtAt(0).getX(), shape.getPtAt(0).getY(), ctrl2b.getX(), ctrl2b.getY(), ctrl1b.getX(), ctrl1b.getY(), false));
        path.add(new SVGPathSegClosePath());
    }
    return path;
}
Also used : SVGPathSegMoveto(net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto) SVGPathSegCurvetoCubic(net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubic) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) SVGPathSegList(net.sf.latexdraw.parsers.svg.path.SVGPathSegList) SVGPathSegClosePath(net.sf.latexdraw.parsers.svg.path.SVGPathSegClosePath) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Aggregations

SVGPathSegMoveto (net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto)22 SVGPathParser (net.sf.latexdraw.parsers.svg.parsers.SVGPathParser)9 Test (org.junit.Test)9 SVGPathSegLineto (net.sf.latexdraw.parsers.svg.path.SVGPathSegLineto)7 SVGPathSegList (net.sf.latexdraw.parsers.svg.path.SVGPathSegList)7 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)6 SVGPathSegClosePath (net.sf.latexdraw.parsers.svg.path.SVGPathSegClosePath)5 SVGPathSegCurvetoCubic (net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubic)4 SVGPathSegArc (net.sf.latexdraw.parsers.svg.path.SVGPathSegArc)3 SVGPathElement (net.sf.latexdraw.parsers.svg.SVGPathElement)2 SVGPathSegCurvetoCubicSmooth (net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubicSmooth)2 Point2D (java.awt.geom.Point2D)1 ArrayList (java.util.ArrayList)1 ArcStyle (net.sf.latexdraw.models.interfaces.shape.ArcStyle)1 IBezierCurve (net.sf.latexdraw.models.interfaces.shape.IBezierCurve)1 SVGDefsElement (net.sf.latexdraw.parsers.svg.SVGDefsElement)1 SVGElement (net.sf.latexdraw.parsers.svg.SVGElement)1 SVGGElement (net.sf.latexdraw.parsers.svg.SVGGElement)1 CtrlPointsSeg (net.sf.latexdraw.parsers.svg.path.CtrlPointsSeg)1 SVGPathSegCurvetoQuadratic (net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoQuadratic)1