get Rectangle Center - Java 2D Graphics

Java examples for 2D Graphics:Rectangle

Description

get Rectangle Center

Demo Code


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

public class Main {
    public static Point getCenter(Rectangle rect) {
        return new Point(rect.x + rect.width / 2, rect.y + rect.height / 2);
    }//  w w  w  .  ja  v a 2  s .  com
}

Related Tutorials