Java Rectangle Grow enlargeRectangle(Rectangle2D rect, double d)

Here you can find the source of enlargeRectangle(Rectangle2D rect, double d)

Description

Enlarges the passed rectangle by d in all directions.

License

Apache License

Parameter

Parameter Description
rect The rectangle to enlarge.
d The enlargement to apply.

Declaration

public static void enlargeRectangle(Rectangle2D rect, double d) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.awt.geom.*;

public class Main {
    /**/*w  w w  . j  av  a  2 s .  c  om*/
     * Enlarges the passed rectangle by d in all directions.
     * @param rect The rectangle to enlarge.
     * @param d The enlargement to apply.
     */
    public static void enlargeRectangle(Rectangle2D rect, double d) {
        if (rect == null) {
            throw new IllegalArgumentException();
        }

        rect.setRect(rect.getX() - d, rect.getY() - d, rect.getWidth() + 2 * d, rect.getHeight() + 2 * d);
    }
}

Related

  1. enlargeRectangle(Rectangle2D toEnlarge, double size)
  2. enlargeRectToGrid(Rectangle2D r)
  3. grow(java.awt.Rectangle rv, int xPad, int yPad)
  4. grow(Rectangle2D r, float amountx, float amounty)