Search in sources :

Example 1 with SVGPathSegLinetoHorizontal

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

the class SVGPathParser method parseHorizontalLineto.

/**
 * Parses an SVGPath horizontal lineto.
 * @param isRelative True if segment is relative.
 * @throws ParseException If a problem occurs.
 */
protected void parseHorizontalLineto(final boolean isRelative) throws ParseException {
    nextChar();
    skipWSP();
    do {
        final double h = parseNumber(false);
        skipWSPComma();
        handler.onPathSeg(new SVGPathSegLinetoHorizontal(h, isRelative));
    } while (!isEOC() && isNumber(false));
}
Also used : SVGPathSegLinetoHorizontal(net.sf.latexdraw.parsers.svg.path.SVGPathSegLinetoHorizontal)

Example 2 with SVGPathSegLinetoHorizontal

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

the class TestSVGPathSegLinetoHorizontal 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 SVGPathSegLinetoHorizontal);
        SVGPathSegLinetoHorizontal seg2 = (SVGPathSegLinetoHorizontal) pathSeg;
        assertEquals(seg.getX(), seg2.getX(), 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) SVGPathSegLinetoHorizontal(net.sf.latexdraw.parsers.svg.path.SVGPathSegLinetoHorizontal) Test(org.junit.Test)

Example 3 with SVGPathSegLinetoHorizontal

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

the class TestSVGPathSegLinetoHorizontal method setUp.

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

Aggregations

SVGPathSegLinetoHorizontal (net.sf.latexdraw.parsers.svg.path.SVGPathSegLinetoHorizontal)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