Search in sources :

Example 11 with SVGPathSegList

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

Example 12 with SVGPathSegList

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

SVGPathSegList (net.sf.latexdraw.parsers.svg.path.SVGPathSegList)12 SVGPathSegMoveto (net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto)8 SVGPathSegClosePath (net.sf.latexdraw.parsers.svg.path.SVGPathSegClosePath)7 SVGPathSegLineto (net.sf.latexdraw.parsers.svg.path.SVGPathSegLineto)5 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)4 SVGPathElement (net.sf.latexdraw.parsers.svg.SVGPathElement)4 SVGElement (net.sf.latexdraw.parsers.svg.SVGElement)3 SVGGElement (net.sf.latexdraw.parsers.svg.SVGGElement)3 SVGPathSegCurvetoCubic (net.sf.latexdraw.parsers.svg.path.SVGPathSegCurvetoCubic)3 Point2D (java.awt.geom.Point2D)2 ArrayList (java.util.ArrayList)2 SVGPathSeg (net.sf.latexdraw.parsers.svg.path.SVGPathSeg)2 ParseException (java.text.ParseException)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Group (javafx.scene.Group)1 Node (javafx.scene.Node)1 Color (javafx.scene.paint.Color)1 ClosePath (javafx.scene.shape.ClosePath)1