Rectangle2D From Center Point - Java 2D Graphics

Java examples for 2D Graphics:Rectangle

Description

Rectangle2D From Center Point

Demo Code


//package com.java2s;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

public class Main {
    public static Rectangle2D RectFromCenterPoint(Point2D point,
            double width, double height) {
        double xOffset = width / 2;
        double yOffset = height / 2;
        return new Rectangle2D.Double(point.getX() - xOffset, point.getY()
                - yOffset, width, height);
    }//  w w  w. j  a  v a 2s.  co  m
}

Related Tutorials