Here you can find the source of intersects(Rectangle2D r, Object o)
public static boolean intersects(Rectangle2D r, Object o)
//package com.java2s; //License from project: Open Source License import java.awt.Shape; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; public class Main { /**Check for intersection between a rectangle and another (presumably) geometric object.**/ public static boolean intersects(Rectangle2D r, Object o) { if (o instanceof Point2D) { return intersects(r, (Point2D) o); }/*from w w w .j a va2 s.c o m*/ if (o instanceof Shape) { return intersects(r, (Shape) o); } throw new IllegalArgumentException("Object passed must be either a shape or a point."); } public static boolean intersects(Rectangle2D r, Point2D p) { return r.contains(p); } public static boolean intersects(Rectangle2D r, Shape s) { return s.intersects(r); } }