src/main/java/de/javagl/geom/Rectangles.java
/**
     * Move the center of the given rectangle to the given position,
     * and store the result in the given result rectangle.<br>
     * <br>
     * If the given result rectangle is <code>null</code>, then a new 
     * rectangle will be created and returned.
     * 
     * @param r The rectangle
     * @param x The x-coordinate
     * @param y The y-coordinate
     * @param result The rectangle that will store the result
     * @return The result rectangle
     */
Move the center of the given rectangle to the given position,
and store the result in the given result rectangle.

If the given result rectangle is null, then a new
rectangle will be created and returned.


Move the center of the given rectangle to the given position and store the result in the given result rectangle . If the given result rectangle is null then a new rectangle will be created and returned .
public static Rectangle2D moveCenterTo(
        Rectangle2D r, double x, double y, Rectangle2D result)
    {
        if (result == null)
        {
            result = new Rectangle2D.Double();
        }
        result.setRect(
            x - r.getWidth() * 0.5, 
            y - r.getHeight() * 0.5,
            r.getWidth(), 
            r.getHeight());
        return result;
    }
public static Rectangle2D moveCenterTo ( Rectangle2D r , double x , double y , Rectangle2D result ) { if ( result == null ) { result = new Rectangle2D . Double ( ) ; } result . setRect ( x - r . getWidth ( ) * 0.5 , y - r . getHeight ( ) * 0.5 , r . getWidth ( ) , r . getHeight ( ) ) ; return result ; }
Move the center of the given rectangle to the given position,
 and store the result in the given result rectangle.<br>
 <br>
 If the given result rectangle is <code>null</code>, then a new
 rectangle will be created and returned.
Move the center of the given rectangle to the given position and store the result in the given result rectangle . <br > <br > If the given result rectangle is <code > null< / code > then a new rectangle will be created and returned .