/** * Intersects the pair of specified source <code>Rectangle2D</code> objects and puts the result * into the specified destination <code>Rectangle2D</code> object. One of the source rectangles * can also be the destination to avoid creating a third Rectangle2D object, but in this case the * original points of this source rectangle will be overwritten by this method. * * @param src1 the first of a pair of <code>Rectangle2D</code> objects to be intersected with each * other * @param src2 the second of a pair of <code>Rectangle2D</code> objects to be intersected with * each other * @param dest the <code>Rectangle2D</code> that holds the results of the intersection of <code> * src1</code> and <code>src2</code> * @since 1.2 */ public static void intersect(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest) { double x1 = Math.max(src1.getMinX(), src2.getMinX()); double y1 = Math.max(src1.getMinY(), src2.getMinY()); double x2 = Math.min(src1.getMaxX(), src2.getMaxX()); double y2 = Math.min(src1.getMaxY(), src2.getMaxY()); dest.setFrame(x1, y1, x2 - x1, y2 - y1); }