Java examples for 2D Graphics:Rectangle
Rectangle2D From Center Point
//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 }