Example usage for java.awt Polygon getPathIterator

List of usage examples for java.awt Polygon getPathIterator

Introduction

In this page you can find the example usage for java.awt Polygon getPathIterator.

Prototype

public PathIterator getPathIterator(AffineTransform at) 

Source Link

Document

Returns an iterator object that iterates along the boundary of this Polygon and provides access to the geometry of the outline of this Polygon .

Usage

From source file:Main.java

private static ArrayList<Double> getCoords(Polygon p) {
    ArrayList<Double> vals = new ArrayList<Double>();

    for (PathIterator iter = p.getPathIterator(null); !iter.isDone();) {
        double[] coords = new double[2];
        iter.currentSegment(coords);/*from w ww. ja  va 2s. com*/
        vals.add(coords[0]);
        vals.add(coords[1]);
        iter.next();
    }
    return vals;
}