Here you can find the source of intersectsOutline(Rectangle2D r, Shape s)
public static boolean intersectsOutline(Rectangle2D r, Shape s)
//package com.java2s; import java.awt.Shape; import java.awt.geom.PathIterator; import java.awt.geom.Rectangle2D; public class Main { /** Return true if the outline of the given shape intersects with the * given rectangle.// ww w . j a va2 s . c o m */ public static boolean intersectsOutline(Rectangle2D r, Shape s) { PathIterator i = s.getPathIterator(null, .01); double points[] = new double[6]; double lastX = 0, lastY = 0; double firstX = 0, firstY = 0; while (!i.isDone()) { int type = i.currentSegment(points); if (type == PathIterator.SEG_MOVETO) { firstX = points[0]; firstY = points[1]; } else if (type == PathIterator.SEG_LINETO) { if (r.intersectsLine(lastX, lastY, points[0], points[1])) return true; } else if (type == PathIterator.SEG_CLOSE) { if (r.intersectsLine(lastX, lastY, firstX, firstY)) return true; } lastX = points[0]; lastY = points[1]; i.next(); } return false; } }