get Points from GeneralPath - Java 2D Graphics

Java examples for 2D Graphics:Path

Description

get Points from GeneralPath

Demo Code


//package com.java2s;

import java.awt.geom.*;
import java.util.ArrayList;

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

    public static ArrayList<double[]> getPoints(GeneralPath generalPath) {

        ArrayList<double[]> list = new ArrayList<double[]>();
        PathIterator i = generalPath.getPathIterator(identity);

        while (!i.isDone()) {
            double[] coords = new double[2];
            int segType = i.currentSegment(coords);
            if (segType != PathIterator.SEG_CLOSE) {
                list.add(coords);/*from   w w  w  . j  a  va2s .c om*/
            }
            i.next();
        }

        return list;

    }
}

Related Tutorials