@Override // from interface IArc public Point startPoint () { return startPoint(new Point()); }
@Override // from interface IArc public Point startPoint () { return startPoint(new Point()); }
@Override // from RectangularShape public Rectangle bounds (Rectangle target) { if (isEmpty()) { target.setBounds(x(), y(), width(), height()); return target; } float rx1 = x(); float ry1 = y(); float rx2 = rx1 + width(); float ry2 = ry1 + height(); Point p1 = startPoint(), p2 = endPoint(); float bx1 = containsAngle(180f) ? rx1 : Math.min(p1.x(), p2.x()); float by1 = containsAngle(90f) ? ry1 : Math.min(p1.y(), p2.y()); float bx2 = containsAngle(0f) ? rx2 : Math.max(p1.x(), p2.x()); float by2 = containsAngle(270f) ? ry2 : Math.max(p1.y(), p2.y()); if (arcType() == PIE) { float cx = centerX(); float cy = centerY(); bx1 = Math.min(bx1, cx); by1 = Math.min(by1, cy); bx2 = Math.max(bx2, cx); by2 = Math.max(by2, cy); } target.setBounds(bx1, by1, bx2 - bx1, by2 - by1); return target; }
@Override // from RectangularShape public Rectangle bounds (Rectangle target) { if (isEmpty()) { target.setBounds(x(), y(), width(), height()); return target; } float rx1 = x(); float ry1 = y(); float rx2 = rx1 + width(); float ry2 = ry1 + height(); Point p1 = startPoint(), p2 = endPoint(); float bx1 = containsAngle(180f) ? rx1 : Math.min(p1.x(), p2.x()); float by1 = containsAngle(90f) ? ry1 : Math.min(p1.y(), p2.y()); float bx2 = containsAngle(0f) ? rx2 : Math.max(p1.x(), p2.x()); float by2 = containsAngle(270f) ? ry2 : Math.max(p1.y(), p2.y()); if (arcType() == PIE) { float cx = centerX(); float cy = centerY(); bx1 = Math.min(bx1, cx); by1 = Math.min(by1, cy); bx2 = Math.max(bx2, cx); by2 = Math.max(by2, cy); } target.setBounds(bx1, by1, bx2 - bx1, by2 - by1); return target; }
@Override // from RectangularShape public boolean contains (float px, float py) { // normalize point float nx = (px - x()) / width() - 0.5f; float ny = (py - y()) / height() - 0.5f; if ((nx * nx + ny * ny) > 0.25) { return false; } float extent = angleExtent(); float absExtent = Math.abs(extent); if (absExtent >= 360f) { return true; } boolean containsAngle = containsAngle(FloatMath.toDegrees(-FloatMath.atan2(ny, nx))); if (arcType() == PIE) { return containsAngle; } if (absExtent <= 180f && !containsAngle) { return false; } Line l = new Line(startPoint(), endPoint()); int ccw1 = l.relativeCCW(px, py); int ccw2 = l.relativeCCW(centerX(), centerY()); return ccw1 == 0 || ccw2 == 0 || ((ccw1 + ccw2) == 0 ^ absExtent > 180f); }
@Override // from RectangularShape public boolean contains (float px, float py) { // normalize point float nx = (px - x()) / width() - 0.5f; float ny = (py - y()) / height() - 0.5f; if ((nx * nx + ny * ny) > 0.25) { return false; } float extent = angleExtent(); float absExtent = Math.abs(extent); if (absExtent >= 360f) { return true; } boolean containsAngle = containsAngle(FloatMath.toDegrees(-FloatMath.atan2(ny, nx))); if (arcType() == PIE) { return containsAngle; } if (absExtent <= 180f && !containsAngle) { return false; } Line l = new Line(startPoint(), endPoint()); int ccw1 = l.relativeCCW(px, py); int ccw2 = l.relativeCCW(centerX(), centerY()); return ccw1 == 0 || ccw2 == 0 || ((ccw1 + ccw2) == 0 ^ absExtent > 180f); }
@Override // from RectangularShape public boolean contains (float rx, float ry, float rw, float rh) { if (!(contains(rx, ry) && contains(rx + rw, ry) && contains(rx + rw, ry + rh) && contains(rx, ry + rh))) { return false; } float absExtent = Math.abs(angleExtent()); if (arcType() != PIE || absExtent <= 180f || absExtent >= 360f) { return true; } Rectangle r = new Rectangle(rx, ry, rw, rh); float cx = centerX(), cy = centerY(); if (r.contains(cx, cy)) { return false; } Point p1 = startPoint(), p2 = endPoint(); return !r.intersectsLine(cx, cy, p1.x(), p1.y()) && !r.intersectsLine(cx, cy, p2.x(), p2.y()); }
@Override // from RectangularShape public boolean contains (float rx, float ry, float rw, float rh) { if (!(contains(rx, ry) && contains(rx + rw, ry) && contains(rx + rw, ry + rh) && contains(rx, ry + rh))) { return false; } float absExtent = Math.abs(angleExtent()); if (arcType() != PIE || absExtent <= 180f || absExtent >= 360f) { return true; } Rectangle r = new Rectangle(rx, ry, rw, rh); float cx = centerX(), cy = centerY(); if (r.contains(cx, cy)) { return false; } Point p1 = startPoint(), p2 = endPoint(); return !r.intersectsLine(cx, cy, p1.x(), p1.y()) && !r.intersectsLine(cx, cy, p2.x(), p2.y()); }
Point p1 = startPoint(), p2 = endPoint();
Point p1 = startPoint(), p2 = endPoint();