Search in sources :

Example 11 with SVGPathSegLineto

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

the class SVGPathParser method parseLineto.

/**
 * Parses an SVGPath lineto.
 * @param isRelative True if segment is relative.
 * @throws ParseException If a problem occurs.
 */
protected void parseLineto(final boolean isRelative) throws ParseException {
    nextChar();
    skipWSP();
    final double x = parseNumber(false);
    skipWSPComma();
    final double y = parseNumber(false);
    skipWSPComma();
    handler.onPathSeg(new SVGPathSegLineto(x, y, isRelative));
    parserPathSeg(isRelative);
}
Also used : SVGPathSegLineto(net.sf.latexdraw.parsers.svg.path.SVGPathSegLineto)

Example 12 with SVGPathSegLineto

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

the class SVGPathElement method isPolygon.

/**
 * @return True if the path is composed of lines and has a 'close path' segment at the end.
 * @since 0.1
 */
public boolean isPolygon() {
    final SVGPathSegList segList = getSegList();
    if (segList.isEmpty() || !(segList.get(0) instanceof SVGPathSegMoveto))
        return false;
    boolean ok = true;
    int i;
    final int size;
    for (i = 1, size = segList.size() - 1; i < size && ok; i++) if (!(segList.get(i) instanceof SVGPathSegLineto))
        ok = false;
    if (!(segList.get(segList.size() - 1) instanceof SVGPathSegClosePath))
        ok = false;
    return ok;
}
Also used : SVGPathSegMoveto(net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto) SVGPathSegLineto(net.sf.latexdraw.parsers.svg.path.SVGPathSegLineto) SVGPathSegList(net.sf.latexdraw.parsers.svg.path.SVGPathSegList) SVGPathSegClosePath(net.sf.latexdraw.parsers.svg.path.SVGPathSegClosePath)

Aggregations

SVGPathSegLineto (net.sf.latexdraw.parsers.svg.path.SVGPathSegLineto)12 SVGPathSegMoveto (net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto)7 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)5 SVGPathSegList (net.sf.latexdraw.parsers.svg.path.SVGPathSegList)4 SVGPathSegClosePath (net.sf.latexdraw.parsers.svg.path.SVGPathSegClosePath)3 Point2D (java.awt.geom.Point2D)1 ArrayList (java.util.ArrayList)1 ArcStyle (net.sf.latexdraw.models.interfaces.shape.ArcStyle)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 SVGPathElement (net.sf.latexdraw.parsers.svg.SVGPathElement)1 SVGPathParser (net.sf.latexdraw.parsers.svg.parsers.SVGPathParser)1 SVGPathSeg (net.sf.latexdraw.parsers.svg.path.SVGPathSeg)1 SVGPathSegArc (net.sf.latexdraw.parsers.svg.path.SVGPathSegArc)1 SVGPathSegCurvetoCubic (net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubic)1 Before (org.junit.Before)1 Test (org.junit.Test)1