Java examples for 2D Graphics:Rectangle
expand Rectangle2D
//package com.java2s; import java.awt.geom.Rectangle2D; public class Main { public static Rectangle2D expand(Rectangle2D rect, double multiplier) { double oldWidth = rect.getWidth(); double oldHeight = rect.getHeight(); double newWidth = oldWidth * multiplier; double newHeight = oldHeight * multiplier; double newX = rect.getX() - ((newWidth - oldWidth) / 2); double newY = rect.getY() - ((newHeight - oldHeight) / 2); return new Rectangle2D.Double(newX, newY, newWidth, newHeight); }//from w w w . ja va 2 s . c o m }