@Override
    public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
        Shape ts;
        if (onStroke) {
            ts = this.transform.createTransformedShape(
                    this.stroke.createStrokedShape(s));
        } else {
            ts = this.transform.createTransformedShape(s);
        }
        if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
            return false;
        }
        Area a1 = new Area(rect);
        Area a2 = new Area(ts);
        a1.intersect(a2);
        return !a1.isEmpty();
    }
@Override
    public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
        Shape ts;
        if (onStroke) {
            ts = this.transform.createTransformedShape(
                    this.stroke.createStrokedShape(s));
        } else {
            ts = this.transform.createTransformedShape(s);
        }
        if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
            return false;
        }
        Area a1 = new Area(rect);
        Area a2 = new Area(ts);
        a1.intersect(a2);
        return !a1.isEmpty();
    }
@ Override public boolean hit ( Rectangle rect , Shape s , boolean onStroke ) { Shape ts ; if ( onStroke ) { ts = this . transform . createTransformedShape ( this . stroke . createStrokedShape ( s ) ) ; } else { ts = this . transform . createTransformedShape ( s ) ; } if ( ! rect . getBounds2D ( ) . intersects ( ts . getBounds2D ( ) ) ) { return false ; } Area a1 = new Area ( rect ) ; Area a2 = new Area ( ts ) ; a1 . intersect ( a2 ) ; return ! a1 . isEmpty ( ) ; }
Returns {@code true} if the rectangle (in device space) intersects
with the shape (the interior, if {@code onStroke} is {@code false},
otherwise the stroked outline of the shape).

@param rect  a rectangle (in device space).
@param s the shape.
@param onStroke  test the stroked outline only?

@return A boolean.
Returns { @code true } if the rectangle ( in device space ) intersects with the shape ( the interior if { @code onStroke } is { @code false } otherwise the stroked outline of the shape ) .