get Max in Polygon - Java 2D Graphics

Java examples for 2D Graphics:Polygon

Description

get Max in Polygon

Demo Code


//package com.java2s;
import java.awt.Point;
import java.awt.Polygon;

public class Main {
    public static Point getMax(Polygon poly) {
        Point p = new Point(poly.xpoints[0], poly.ypoints[0]);
        for (int i = 0; i < poly.npoints; i++) {
            if (poly.xpoints[i] > p.x) {
                p.x = poly.xpoints[i];/*from   w ww  .  j  a  v a2 s .c o  m*/
            }
            if (poly.ypoints[i] > p.y) {
                p.y = poly.ypoints[i];
            }
        }
        return p;
    }
}

Related Tutorials