returns the number of path sections. - Java 2D Graphics

Java examples for 2D Graphics:Path

Description

returns the number of path sections.

Demo Code


//package com.java2s;
import java.awt.geom.PathIterator;
import java.awt.geom.GeneralPath;

public class Main {
    /** returns the number of path sections. */
    public static int getNumPathSections(GeneralPath path) {
        return getNumPathPoints(path) - 1;
    }/* w w w .  j a  va2 s.  c  om*/

    /** returns the number path points of "path". */
    public static int getNumPathPoints(GeneralPath path) {
        int count = 0;
        for (PathIterator i = path.getPathIterator(null); !i.isDone(); i
                .next()) {
            count++;
        }
        return count;
    }
}

Related Tutorials