Java examples for 2D Graphics:Rectangle
expand Rectangle
//package com.java2s; import java.awt.Rectangle; import java.awt.geom.Rectangle2D; public class Main { public static Rectangle expand(Rectangle r, int dx, int dy) { return new Rectangle(r.x - dx, r.y - dy, r.width + dx * 2, r.height + dy * 2);/*from ww w . j a v a 2 s .c o m*/ } public static Rectangle2D expand(Rectangle2D r, double dw, double dh) { return new Rectangle2D.Double(r.getX() - dw, r.getY() - dh, r.getWidth() + dw * 2, r.getHeight() + dh * 2); } }