get Closed Path Length - Java 2D Graphics

Java examples for 2D Graphics:Path

Description

get Closed Path Length

Demo Code


//package com.java2s;

import java.awt.geom.*;

public class Main {
    private static final AffineTransform identity = new AffineTransform();

    public static int getClosedPathLength(GeneralPath generalPath) {
        int c = 0;

        PathIterator p = generalPath.getPathIterator(identity);
        while (!p.isDone()) {
            c++;// www  .  ja v a  2 s  .  c  o m
            p.next();
        }

        if (c > 0) // for closed paths
            c--;

        return c;
    }
}

Related Tutorials