/** Returns an integer {@link Rectangle} that completely encloses the <code>Shape</code>. */ public Rectangle getBounds() { Rectangle2D rect = getBounds2D(); int minx = (int) Math.floor(rect.getMinX()); int miny = (int) Math.floor(rect.getMinY()); int maxx = (int) Math.ceil(rect.getMaxX()); int maxy = (int) Math.ceil(rect.getMaxY()); return new Rectangle(minx, miny, maxx - minx, maxy - miny); }
/** * Returns an integer {@link Rectangle} that completely encloses the * <code>Shape</code>. */ public Rectangle getBounds() { Rectangle2D rect = getBounds2D(); int minx = (int) Math.floor(rect.getMinX()); int miny = (int) Math.floor(rect.getMinY()); int maxx = (int) Math.ceil(rect.getMaxX()); int maxy = (int) Math.ceil(rect.getMaxY()); return new Rectangle(minx, miny, maxx - minx, maxy - miny); }