Search in sources :

Example 1 with SVGPathParser

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

the class SVGPathElement method getSegList.

/**
 * @return the segList.
 * @since 0.1
 */
public SVGPathSegList getSegList() {
    final String path = getPathData();
    final SVGPathSegList segList = new SVGPathSegList();
    final SVGPathParser pp = new SVGPathParser(path, segList);
    try {
        pp.parse();
    }// $NON-NLS-1$ //$NON-NLS-2$
     catch (final ParseException e) {
        throw new IllegalArgumentException(e + " But : \"" + path + "\" found.");
    }
    return segList;
}
Also used : SVGPathParser(net.sf.latexdraw.parsers.svg.parsers.SVGPathParser) ParseException(java.text.ParseException) SVGPathSegList(net.sf.latexdraw.parsers.svg.path.SVGPathSegList)

Example 2 with SVGPathParser

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

the class TestSVGPathSegArc method testToString.

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

Example 3 with SVGPathParser

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

the class TestSVGPathSegCurvetoCubic method testToString.

@Test
public void testToString() throws ParseException {
    SVGPathSegMoveto m = new SVGPathSegMoveto(0, 0, false);
    SVGPathParser parser = new SVGPathParser(m.toString() + " " + seg.toString(), pathSeg -> {
        if (pathSeg instanceof SVGPathSegMoveto && cpt == 0) {
            cpt++;
            return;
        }
        assertTrue(pathSeg instanceof SVGPathSegCurvetoCubic);
        SVGPathSegCurvetoCubic seg2 = (SVGPathSegCurvetoCubic) 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) SVGPathSegCurvetoCubic(net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubic) Test(org.junit.Test)

Example 4 with SVGPathParser

use of net.sf.latexdraw.parsers.svg.parsers.SVGPathParser 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 5 with SVGPathParser

use of net.sf.latexdraw.parsers.svg.parsers.SVGPathParser 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)

Aggregations

SVGPathParser (net.sf.latexdraw.parsers.svg.parsers.SVGPathParser)10 SVGPathSegMoveto (net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto)9 Test (org.junit.Test)9 ParseException (java.text.ParseException)1 SVGPathSegArc (net.sf.latexdraw.parsers.svg.path.SVGPathSegArc)1 SVGPathSegCurvetoCubic (net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubic)1 SVGPathSegCurvetoCubicSmooth (net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubicSmooth)1 SVGPathSegCurvetoQuadratic (net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoQuadratic)1 SVGPathSegCurvetoQuadraticSmooth (net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoQuadraticSmooth)1 SVGPathSegLineto (net.sf.latexdraw.parsers.svg.path.SVGPathSegLineto)1 SVGPathSegLinetoHorizontal (net.sf.latexdraw.parsers.svg.path.SVGPathSegLinetoHorizontal)1 SVGPathSegLinetoVertical (net.sf.latexdraw.parsers.svg.path.SVGPathSegLinetoVertical)1 SVGPathSegList (net.sf.latexdraw.parsers.svg.path.SVGPathSegList)1