get GeneralPath Average Direction - Java 2D Graphics

Java examples for 2D Graphics:Path

Description

get GeneralPath Average Direction

Demo Code


import java.awt.geom.PathIterator;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.awt.geom.Line2D;
import java.awt.Point;

public class Main{
    public static int getAverageDirection(GeneralPath path) {
        double seg[] = new double[6];
        PathIterator pi = path.getPathIterator(null);
        int segType = pi.currentSegment(seg);

        return GeoUtils.calculateGeneralDirection((int) seg[0],
                (int) seg[1], (int) path.getCurrentPoint().getX(),
                (int) path.getCurrentPoint().getY());
    }//from   w  w w .j av  a2s.c  o m
}

Related Tutorials