Search in sources :

Example 1 with SVGPathSegCurvetoCubicSmooth

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

the class SVGPathParser method parseShorthandCurveto.

/**
 * Parses an SVGPath smooth curveto.
 * @param isRelative True if segment is relative.
 * @throws ParseException If a problem occurs.
 */
protected void parseShorthandCurveto(final boolean isRelative) throws ParseException {
    nextChar();
    do {
        final Tuple<Double, Double> p2 = parsePoint();
        skipWSPComma();
        final Tuple<Double, Double> p1 = parsePoint();
        skipWSPComma();
        handler.onPathSeg(new SVGPathSegCurvetoCubicSmooth(p1.a, p1.b, p2.a, p2.b, isRelative));
    } while (!isEOC() && isNumber(false));
}
Also used : SVGPathSegCurvetoCubicSmooth(net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubicSmooth)

Example 2 with SVGPathSegCurvetoCubicSmooth

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

the class TestSVGPathSegCurvetoCubicSmooth method setUp.

@Before
public void setUp() {
    seg = new SVGPathSegCurvetoCubicSmooth(0.8E2, -2d, -5.e-1, .5, false);
    cpt = 0;
}
Also used : SVGPathSegCurvetoCubicSmooth(net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubicSmooth) Before(org.junit.Before)

Example 3 with SVGPathSegCurvetoCubicSmooth

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

the class TestSVGPathSegCurvetoCubicSmooth 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 SVGPathSegCurvetoCubicSmooth);
        SVGPathSegCurvetoCubicSmooth seg2 = (SVGPathSegCurvetoCubicSmooth) 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) SVGPathSegCurvetoCubicSmooth(net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubicSmooth) SVGPathSegMoveto(net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto) Test(org.junit.Test)

Example 4 with SVGPathSegCurvetoCubicSmooth

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

the class SVGPathElement method isBezierCurve.

public boolean isBezierCurve() {
    final SVGPathSegList segList = getSegList();
    if (segList.isEmpty() || !(segList.get(0) instanceof SVGPathSegMoveto))
        return false;
    final int size = segList.size() - 1;
    boolean ok = true;
    int i;
    for (i = 1; i < size && ok; i++) if (!(segList.get(i) instanceof SVGPathSegCurvetoCubic) && !(segList.get(i) instanceof SVGPathSegCurvetoCubicSmooth))
        ok = false;
    return ok && (segList.get(size) instanceof SVGPathSegClosePath || segList.get(size) instanceof SVGPathSegCurvetoCubic || segList.get(size) instanceof SVGPathSegCurvetoCubicSmooth);
}
Also used : SVGPathSegCurvetoCubicSmooth(net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubicSmooth) SVGPathSegMoveto(net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto) SVGPathSegCurvetoCubic(net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubic) SVGPathSegList(net.sf.latexdraw.parsers.svg.path.SVGPathSegList) SVGPathSegClosePath(net.sf.latexdraw.parsers.svg.path.SVGPathSegClosePath)

Aggregations

SVGPathSegCurvetoCubicSmooth (net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubicSmooth)4 SVGPathSegMoveto (net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto)2 SVGPathParser (net.sf.latexdraw.parsers.svg.parsers.SVGPathParser)1 SVGPathSegClosePath (net.sf.latexdraw.parsers.svg.path.SVGPathSegClosePath)1 SVGPathSegCurvetoCubic (net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubic)1 SVGPathSegList (net.sf.latexdraw.parsers.svg.path.SVGPathSegList)1 Before (org.junit.Before)1 Test (org.junit.Test)1