code: public boolean intersects(Rectangle2D r) {
  		if(np==0)return false;
  		Line2D line = new Line2D.Double(x[0],y[0],x[0],y[0]);
  		for (int i = 1; i < np; i++) {
  			line.setLine(x[i-1], y[i-1], x[i], y[i]);
  			if(line.intersects(r))return true;
  		}
  		return false;
  	}
docs: Checks if one of the lines in the polyline intersects
  with a given rectangle.
  @see java.awt.Shape#intersects(java.awt.geom.Rectangle2D)