Search in sources :

Example 1 with SVGPathSegCurvetoQuadratic

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

the class SVGPathParser method parseQuadraticBezierCurveto.

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

Example 2 with SVGPathSegCurvetoQuadratic

use of net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoQuadratic 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 3 with SVGPathSegCurvetoQuadratic

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

the class TestSVGPathSegCurvetoQuadratic method setUp.

@Before
public void setUp() {
    cpt = 0;
    seg = new SVGPathSegCurvetoQuadratic(3e1, 4e-1, -5e1, 6.5, true);
}
Also used : SVGPathSegCurvetoQuadratic(net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoQuadratic) Before(org.junit.Before)

Aggregations

SVGPathSegCurvetoQuadratic (net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoQuadratic)3 SVGPathParser (net.sf.latexdraw.parsers.svg.parsers.SVGPathParser)1 SVGPathSegMoveto (net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto)1 Before (org.junit.Before)1 Test (org.junit.Test)1