double mw = getWidth(); double mh = getHeight(); if (mw <= 0 || mh <= 0 || w <= 0 || h <= 0)
double extent = getAngleExtent(); if (extent == 0) return false;  if (contains(x, y) || contains(x, y + h) || contains(x + w, y) || contains(x + w, y + h)) return true;  Rectangle2D rect = new Rectangle2D.Double(x, y, w, h);  double a = getWidth() / 2.0; double b = getHeight() / 2.0;  double mx = getX() + a; double my = getY() + b; double x1 = mx + a * Math.cos(Math.toRadians(getAngleStart())); double y1 = my - b * Math.sin(Math.toRadians(getAngleStart())); double x2 = mx + a * Math.cos(Math.toRadians(getAngleStart() + extent)); double y2 = my - b * Math.sin(Math.toRadians(getAngleStart() + extent));  if (getArcType() != CHORD) {  if (rect.intersectsLine(mx, my, x1, y1)) return true; if (rect.intersectsLine(mx, my, x2, y2)) return true; } else if (rect.intersectsLine(x1, y1, x2, y2)) return true;   double dx;   double dy; dy = y - my; dx = a * Math.sqrt(1 - ((dy * dy) / (b * b))); if (! java.lang.Double.isNaN(dx)) { if (mx + dx >= x && mx + dx <= x + w && containsAngle(Math.toDegrees(Math.atan2(-dy, dx)))) return true; if (mx - dx >= x && mx - dx <= x + w && containsAngle(Math.toDegrees(Math.atan2(-dy, -dx)))) return true; } dy = (y + h) - my; dx = a * Math.sqrt(1 - ((dy * dy) / (b * b))); if (! java.lang.Double.isNaN(dx)) { if (mx + dx >= x && mx + dx <= x + w && containsAngle(Math.toDegrees(Math.atan2(-dy, dx)))) return true; if (mx - dx >= x && mx - dx <= x + w && containsAngle(Math.toDegrees(Math.atan2(-dy, -dx)))) return true; } dx = x - mx; dy = b * Math.sqrt(1 - ((dx * dx) / (a * a))); if (! java.lang.Double.isNaN(dy)) { if (my + dy >= y && my + dy <= y + h && containsAngle(Math.toDegrees(Math.atan2(-dy, dx)))) return true; if (my - dy >= y && my - dy <= y + h && containsAngle(Math.toDegrees(Math.atan2(dy, dx)))) return true; }  dx = (x + w) - mx; dy = b * Math.sqrt(1 - ((dx * dx) / (a * a))); if (! java.lang.Double.isNaN(dy)) { if (my + dy >= y && my + dy <= y + h && containsAngle(Math.toDegrees(Math.atan2(-dy, dx)))) return true; if (my - dy >= y && my - dy <= y + h && containsAngle(Math.toDegrees(Math.atan2(dy, dx)))) return true; }   if (rect.contains(mx, my)) return true;
  public boolean intersects(double x, double y, double w, double h)  {		double mw = getWidth();		double mh = getHeight();		if (mw <= 0 || mh <= 0 || w <= 0 || h <= 0)			return false;		// XXX Finish implementing.		throw new Error("not implemented");	}