List of utility methods to do Rectangle Rotate
Rectangle2D | rotateRectangleOnEllipse(Rectangle2D rect, Point2D center, double angle, double a, double b) rotate Rectangle On Ellipse double ellipseScale = b > 0 ? a / b : 0; AffineTransform trans = AffineTransform.getRotateInstance(-angle, rect.getX() + center.getX(), (rect.getY() + center.getY()) * ellipseScale); trans.scale(1.0, ellipseScale > 0 ? 1.0 / ellipseScale : 0); Point2D upperLeft = trans.transform(new Point2D.Double(rect.getMinX(), rect.getMinY() * ellipseScale), null); Point2D upperRight = trans.transform(new Point2D.Double(rect.getMaxX(), rect.getMinY() * ellipseScale), null); ... |
Rectangle2D | rotateRoundMiddlePoint(Rectangle2D rectangle) rotate Round Middle Point Rectangle2D rec = new Rectangle2D.Double(); rec.setRect(rectangle); double x = (rec.getWidth() / 2); double y = (rec.getHeight() / 2); rec = grow(rec, new Point2D.Double(-x, -y)); rec = grow(rec, new Point2D.Double(y, x)); return rec; |