Enlarges the passed rectangle by d in all directions. - Java java.lang

Java examples for java.lang:Math Geometry Shape

Description

Enlarges the passed rectangle by d in all directions.

Demo Code


//package com.java2s;
import java.awt.geom.*;

public class Main {
    /**/*from   w w  w .j ava 2 s  .c  o  m*/
     * 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 Tutorials