Get Rectangle corners - Java 2D Graphics

Java examples for 2D Graphics:Rectangle

Description

Get Rectangle corners

Demo Code


//package com.java2s;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<Point> corners(Rectangle region) {
        List<Point> list = new ArrayList<Point>();
        list.add(new Point(region.x, region.y));
        list.add(new Point(region.x, region.y + region.height));
        list.add(new Point(region.x + region.width, region.y));
        list.add(new Point(region.x + region.width, region.y
                + region.height));/*from w ww . j ava2  s. c  o  m*/
        return list;
    }
}

Related Tutorials