/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* <CODE>Arc2D</CODE> is the abstract superclass for all objects that
* store a 2D arc defined by a framing rectangle,
* start angle, angular extent (length of the arc), and a closure type
* (<CODE>OPEN</CODE>, <CODE>CHORD</CODE>, or <CODE>PIE</CODE>).
* <p>
* <a name="inscribes">
* The arc is a partial section of a full ellipse which
* inscribes the framing rectangle of its parent {@link RectangularShape}.
* </a>
* <a name="angles">
* The angles are specified relative to the non-square
* framing rectangle such that 45 degrees always falls on the line from
* the center of the ellipse to the upper right corner of the framing
* rectangle.
* As a result, if the framing rectangle is noticeably longer along one
* axis than the other, the angles to the start and end of the arc segment
* will be skewed farther along the longer axis of the frame.
* </a>
* <p>
* The actual storage representation of the coordinates is left to
* the subclass.
*
* @author Jim Graham
* @since 1.2
*/
/**
* The closure type for an open arc with no path segments
* connecting the two ends of the arc segment.
* @since 1.2
*/
/**
* The closure type for an arc closed by drawing a straight
* line segment from the start of the arc segment to the end of the
* arc segment.
* @since 1.2
*/
/**
* The closure type for an arc closed by drawing straight line
* segments from the start of the arc segment to the center
* of the full ellipse and from that point to the end of the arc segment.
* @since 1.2
*/
/**
* This class defines an arc specified in {@code float} precision.
* @since 1.2
*/
/**
* The X coordinate of the upper-left corner of the framing
* rectangle of the arc.
* @since 1.2
* @serial
*/
public float x;
/**
* The Y coordinate of the upper-left corner of the framing
* rectangle of the arc.
* @since 1.2
* @serial
*/
public float y;
/**
* The overall width of the full ellipse of which this arc is
* a partial section (not considering the
* angular extents).
* @since 1.2
* @serial
*/
public float width;
/**
* The overall height of the full ellipse of which this arc is
* a partial section (not considering the
* angular extents).
* @since 1.2
* @serial
*/
public float height;
/**
* The starting angle of the arc in degrees.
* @since 1.2
* @serial
*/
public float start;
/**
* The angular extent of the arc in degrees.
* @since 1.2
* @serial
*/
public float extent;
/**
* Constructs a new OPEN arc, initialized to location (0, 0),
* size (0, 0), angular extents (start = 0, extent = 0).
* @since 1.2
*/
public Float() {
super(OPEN);
}
/**
* Constructs a new arc, initialized to location (0, 0),
* size (0, 0), angular extents (start = 0, extent = 0), and
* the specified closure type.
*
* @param type The closure type for the arc:
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* @since 1.2
*/
super(type);
}
/**
* Constructs a new arc, initialized to the specified location,
* size, angular extents, and closure type.
*
* @param x The X coordinate of the upper-left corner of
* the arc's framing rectangle.
* @param y The Y coordinate of the upper-left corner of
* the arc's framing rectangle.
* @param w The overall width of the full ellipse of which
* this arc is a partial section.
* @param h The overall height of the full ellipse of which this
* arc is a partial section.
* @param start The starting angle of the arc in degrees.
* @param extent The angular extent of the arc in degrees.
* @param type The closure type for the arc:
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* @since 1.2
*/
public Float(float x, float y, float w, float h,
super(type);
this.x = x;
this.y = y;
this.width = w;
this.height = h;
}
/**
* Constructs a new arc, initialized to the specified location,
* size, angular extents, and closure type.
*
* @param ellipseBounds The framing rectangle that defines the
* outer boundary of the full ellipse of which this arc is a
* partial section.
* @param start The starting angle of the arc in degrees.
* @param extent The angular extent of the arc in degrees.
* @param type The closure type for the arc:
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* @since 1.2
*/
super(type);
this.x = (float) ellipseBounds.getX();
this.y = (float) ellipseBounds.getY();
}
/**
* {@inheritDoc}
* Note that the arc
* <a href="Arc2D.html#inscribes">partially inscribes</a>
* the framing rectangle of this {@code RectangularShape}.
*
* @since 1.2
*/
public double getX() {
return (double) x;
}
/**
* {@inheritDoc}
* Note that the arc
* <a href="Arc2D.html#inscribes">partially inscribes</a>
* the framing rectangle of this {@code RectangularShape}.
*
* @since 1.2
*/
public double getY() {
return (double) y;
}
/**
* {@inheritDoc}
* Note that the arc
* <a href="Arc2D.html#inscribes">partially inscribes</a>
* the framing rectangle of this {@code RectangularShape}.
*
* @since 1.2
*/
public double getWidth() {
return (double) width;
}
/**
* {@inheritDoc}
* Note that the arc
* <a href="Arc2D.html#inscribes">partially inscribes</a>
* the framing rectangle of this {@code RectangularShape}.
*
* @since 1.2
*/
public double getHeight() {
return (double) height;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getAngleStart() {
return (double) start;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getAngleExtent() {
return (double) extent;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public boolean isEmpty() {
}
/**
* {@inheritDoc}
* @since 1.2
*/
public void setArc(double x, double y, double w, double h,
this.setArcType(closure);
this.x = (float) x;
this.y = (float) y;
this.width = (float) w;
this.height = (float) h;
}
/**
* {@inheritDoc}
* @since 1.2
*/
}
/**
* {@inheritDoc}
* @since 1.2
*/
}
/**
* {@inheritDoc}
* @since 1.2
*/
double w, double h) {
return new Rectangle2D.Float((float) x, (float) y,
(float) w, (float) h);
}
/*
* JDK 1.6 serialVersionUID
*/
/**
* Writes the default serializable fields to the
* <code>ObjectOutputStream</code> followed by a byte
* indicating the arc type of this <code>Arc2D</code>
* instance.
*
* @serialData
* <ol>
* <li>The default serializable fields.
* <li>
* followed by a <code>byte</code> indicating the arc type
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* </ol>
*/
{
s.defaultWriteObject();
s.writeByte(getArcType());
}
/**
* Reads the default serializable fields from the
* <code>ObjectInputStream</code> followed by a byte
* indicating the arc type of this <code>Arc2D</code>
* instance.
*
* @serialData
* <ol>
* <li>The default serializable fields.
* <li>
* followed by a <code>byte</code> indicating the arc type
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* </ol>
*/
{
s.defaultReadObject();
try {
setArcType(s.readByte());
} catch (IllegalArgumentException iae) {
}
}
}
/**
* This class defines an arc specified in {@code double} precision.
* @since 1.2
*/
/**
* The X coordinate of the upper-left corner of the framing
* rectangle of the arc.
* @since 1.2
* @serial
*/
public double x;
/**
* The Y coordinate of the upper-left corner of the framing
* rectangle of the arc.
* @since 1.2
* @serial
*/
public double y;
/**
* The overall width of the full ellipse of which this arc is
* a partial section (not considering the angular extents).
* @since 1.2
* @serial
*/
public double width;
/**
* The overall height of the full ellipse of which this arc is
* a partial section (not considering the angular extents).
* @since 1.2
* @serial
*/
public double height;
/**
* The starting angle of the arc in degrees.
* @since 1.2
* @serial
*/
public double start;
/**
* The angular extent of the arc in degrees.
* @since 1.2
* @serial
*/
public double extent;
/**
* Constructs a new OPEN arc, initialized to location (0, 0),
* size (0, 0), angular extents (start = 0, extent = 0).
* @since 1.2
*/
public Double() {
super(OPEN);
}
/**
* Constructs a new arc, initialized to location (0, 0),
* size (0, 0), angular extents (start = 0, extent = 0), and
* the specified closure type.
*
* @param type The closure type for the arc:
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* @since 1.2
*/
super(type);
}
/**
* Constructs a new arc, initialized to the specified location,
* size, angular extents, and closure type.
*
* @param x The X coordinate of the upper-left corner
* of the arc's framing rectangle.
* @param y The Y coordinate of the upper-left corner
* of the arc's framing rectangle.
* @param w The overall width of the full ellipse of which this
* arc is a partial section.
* @param h The overall height of the full ellipse of which this
* arc is a partial section.
* @param start The starting angle of the arc in degrees.
* @param extent The angular extent of the arc in degrees.
* @param type The closure type for the arc:
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* @since 1.2
*/
public Double(double x, double y, double w, double h,
super(type);
this.x = x;
this.y = y;
this.width = w;
this.height = h;
}
/**
* Constructs a new arc, initialized to the specified location,
* size, angular extents, and closure type.
*
* @param ellipseBounds The framing rectangle that defines the
* outer boundary of the full ellipse of which this arc is a
* partial section.
* @param start The starting angle of the arc in degrees.
* @param extent The angular extent of the arc in degrees.
* @param type The closure type for the arc:
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* @since 1.2
*/
super(type);
this.x = ellipseBounds.getX();
this.y = ellipseBounds.getY();
}
/**
* {@inheritDoc}
* Note that the arc
* <a href="Arc2D.html#inscribes">partially inscribes</a>
* the framing rectangle of this {@code RectangularShape}.
*
* @since 1.2
*/
public double getX() {
return x;
}
/**
* {@inheritDoc}
* Note that the arc
* <a href="Arc2D.html#inscribes">partially inscribes</a>
* the framing rectangle of this {@code RectangularShape}.
*
* @since 1.2
*/
public double getY() {
return y;
}
/**
* {@inheritDoc}
* Note that the arc
* <a href="Arc2D.html#inscribes">partially inscribes</a>
* the framing rectangle of this {@code RectangularShape}.
*
* @since 1.2
*/
public double getWidth() {
return width;
}
/**
* {@inheritDoc}
* Note that the arc
* <a href="Arc2D.html#inscribes">partially inscribes</a>
* the framing rectangle of this {@code RectangularShape}.
*
* @since 1.2
*/
public double getHeight() {
return height;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getAngleStart() {
return start;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getAngleExtent() {
return extent;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public boolean isEmpty() {
}
/**
* {@inheritDoc}
* @since 1.2
*/
public void setArc(double x, double y, double w, double h,
this.setArcType(closure);
this.x = x;
this.y = y;
this.width = w;
this.height = h;
}
/**
* {@inheritDoc}
* @since 1.2
*/
}
/**
* {@inheritDoc}
* @since 1.2
*/
}
/**
* {@inheritDoc}
* @since 1.2
*/
double w, double h) {
return new Rectangle2D.Double(x, y, w, h);
}
/*
* JDK 1.6 serialVersionUID
*/
/**
* Writes the default serializable fields to the
* <code>ObjectOutputStream</code> followed by a byte
* indicating the arc type of this <code>Arc2D</code>
* instance.
*
* @serialData
* <ol>
* <li>The default serializable fields.
* <li>
* followed by a <code>byte</code> indicating the arc type
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* </ol>
*/
{
s.defaultWriteObject();
s.writeByte(getArcType());
}
/**
* Reads the default serializable fields from the
* <code>ObjectInputStream</code> followed by a byte
* indicating the arc type of this <code>Arc2D</code>
* instance.
*
* @serialData
* <ol>
* <li>The default serializable fields.
* <li>
* followed by a <code>byte</code> indicating the arc type
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* </ol>
*/
{
s.defaultReadObject();
try {
setArcType(s.readByte());
} catch (IllegalArgumentException iae) {
}
}
}
private int type;
/**
* This is an abstract class that cannot be instantiated directly.
* Type-specific implementation subclasses are available for
* instantiation and provide a number of formats for storing
* the information necessary to satisfy the various accessor
* methods below.
* <p>
* This constructor creates an object with a default closure
* type of {@link #OPEN}. It is provided only to enable
* serialization of subclasses.
*
* @see java.awt.geom.Arc2D.Float
* @see java.awt.geom.Arc2D.Double
*/
protected Arc2D() {
this(OPEN);
}
/**
* This is an abstract class that cannot be instantiated directly.
* Type-specific implementation subclasses are available for
* instantiation and provide a number of formats for storing
* the information necessary to satisfy the various accessor
* methods below.
*
* @param type The closure type of this arc:
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* @see java.awt.geom.Arc2D.Float
* @see java.awt.geom.Arc2D.Double
* @since 1.2
*/
}
/**
* Returns the starting angle of the arc.
*
* @return A double value that represents the starting angle
* of the arc in degrees.
* @see #setAngleStart
* @since 1.2
*/
public abstract double getAngleStart();
/**
* Returns the angular extent of the arc.
*
* @return A double value that represents the angular extent
* of the arc in degrees.
* @see #setAngleExtent
* @since 1.2
*/
public abstract double getAngleExtent();
/**
* Returns the arc closure type of the arc: {@link #OPEN},
* {@link #CHORD}, or {@link #PIE}.
* @return One of the integer constant closure types defined
* in this class.
* @see #setArcType
* @since 1.2
*/
public int getArcType() {
return type;
}
/**
* Returns the starting point of the arc. This point is the
* intersection of the ray from the center defined by the
* starting angle and the elliptical boundary of the arc.
*
* @return A <CODE>Point2D</CODE> object representing the
* x,y coordinates of the starting point of the arc.
* @since 1.2
*/
}
/**
* Returns the ending point of the arc. This point is the
* intersection of the ray from the center defined by the
* starting angle plus the angular extent of the arc and the
* elliptical boundary of the arc.
*
* @return A <CODE>Point2D</CODE> object representing the
* x,y coordinates of the ending point of the arc.
* @since 1.2
*/
}
/**
* Sets the location, size, angular extents, and closure type of
* this arc to the specified double values.
*
* @param x The X coordinate of the upper-left corner of the arc.
* @param y The Y coordinate of the upper-left corner of the arc.
* @param w The overall width of the full ellipse of which
* this arc is a partial section.
* @param h The overall height of the full ellipse of which
* this arc is a partial section.
* @param angSt The starting angle of the arc in degrees.
* @param angExt The angular extent of the arc in degrees.
* @param closure The closure type for the arc:
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* @since 1.2
*/
public abstract void setArc(double x, double y, double w, double h,
/**
* Sets the location, size, angular extents, and closure type of
* this arc to the specified values.
*
* @param loc The <CODE>Point2D</CODE> representing the coordinates of
* the upper-left corner of the arc.
* @param size The <CODE>Dimension2D</CODE> representing the width
* and height of the full ellipse of which this arc is
* a partial section.
* @param angSt The starting angle of the arc in degrees.
* @param angExt The angular extent of the arc in degrees.
* @param closure The closure type for the arc:
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* @since 1.2
*/
}
/**
* Sets the location, size, angular extents, and closure type of
* this arc to the specified values.
*
* @param rect The framing rectangle that defines the
* outer boundary of the full ellipse of which this arc is a
* partial section.
* @param angSt The starting angle of the arc in degrees.
* @param angExt The angular extent of the arc in degrees.
* @param closure The closure type for the arc:
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* @since 1.2
*/
int closure) {
}
/**
* Sets this arc to be the same as the specified arc.
*
* @param a The <CODE>Arc2D</CODE> to use to set the arc's values.
* @since 1.2
*/
}
/**
* Sets the position, bounds, angular extents, and closure type of
* this arc to the specified values. The arc is defined by a center
* point and a radius rather than a framing rectangle for the full ellipse.
*
* @param x The X coordinate of the center of the arc.
* @param y The Y coordinate of the center of the arc.
* @param radius The radius of the arc.
* @param angSt The starting angle of the arc in degrees.
* @param angExt The angular extent of the arc in degrees.
* @param closure The closure type for the arc:
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* @since 1.2
*/
}
/**
* Sets the position, bounds, and angular extents of this arc to the
* specified value. The starting angle of the arc is tangent to the
* line specified by points (p1, p2), the ending angle is tangent to
* the line specified by points (p2, p3), and the arc has the
* specified radius.
*
* @param p1 The first point that defines the arc. The starting
* angle of the arc is tangent to the line specified by points (p1, p2).
* @param p2 The second point that defines the arc. The starting
* angle of the arc is tangent to the line specified by points (p1, p2).
* The ending angle of the arc is tangent to the line specified by
* points (p2, p3).
* @param p3 The third point that defines the arc. The ending angle
* of the arc is tangent to the line specified by points (p2, p3).
* @param radius The radius of the arc.
* @since 1.2
*/
double radius) {
}
// REMIND: This needs some work...
} else {
}
if (diff < 0) {
diff += 360;
} else {
diff -= 360;
}
}
/**
* Sets the starting angle of this arc to the specified double
* value.
*
* @param angSt The starting angle of the arc in degrees.
* @see #getAngleStart
* @since 1.2
*/
/**
* Sets the angular extent of this arc to the specified double
* value.
*
* @param angExt The angular extent of the arc in degrees.
* @see #getAngleExtent
* @since 1.2
*/
/**
* Sets the starting angle of this arc to the angle that the
* specified point defines relative to the center of this arc.
* The angular extent of the arc will remain the same.
*
* @param p The <CODE>Point2D</CODE> that defines the starting angle.
* @see #getAngleStart
* @since 1.2
*/
// Bias the dx and dy by the height and width of the oval.
}
/**
* Sets the starting angle and angular extent of this arc using two
* sets of coordinates. The first set of coordinates is used to
* determine the angle of the starting point relative to the arc's
* center. The second set of coordinates is used to determine the
* angle of the end point relative to the arc's center.
* The arc will always be non-empty and extend counterclockwise
* from the first point around to the second point.
*
* @param x1 The X coordinate of the arc's starting point.
* @param y1 The Y coordinate of the arc's starting point.
* @param x2 The X coordinate of the arc's ending point.
* @param y2 The Y coordinate of the arc's ending point.
* @since 1.2
*/
double x = getCenterX();
double y = getCenterY();
double w = getWidth();
double h = getHeight();
// Note: reversing the Y equations negates the angle to adjust
// for the upside down coordinate system.
// Also we should bias atans by the height and width of the oval.
if (ang2 <= 0.0) {
}
}
/**
* Sets the starting angle and angular extent of this arc using
* two points. The first point is used to determine the angle of
* the starting point relative to the arc's center.
* The second point is used to determine the angle of the end point
* relative to the arc's center.
* The arc will always be non-empty and extend counterclockwise
* from the first point around to the second point.
*
* @param p1 The <CODE>Point2D</CODE> that defines the arc's
* starting point.
* @param p2 The <CODE>Point2D</CODE> that defines the arc's
* ending point.
* @since 1.2
*/
}
/**
* Sets the closure type of this arc to the specified value:
* <CODE>OPEN</CODE>, <CODE>CHORD</CODE>, or <CODE>PIE</CODE>.
*
* @param type The integer constant that represents the closure
* type of this arc: {@link #OPEN}, {@link #CHORD}, or
* {@link #PIE}.
*
* @throws IllegalArgumentException if <code>type</code> is not
* 0, 1, or 2.+
* @see #getArcType
* @since 1.2
*/
}
}
/**
* {@inheritDoc}
* Note that the arc
* <a href="Arc2D.html#inscribes">partially inscribes</a>
* the framing rectangle of this {@code RectangularShape}.
*
* @since 1.2
*/
public void setFrame(double x, double y, double w, double h) {
}
/**
* Returns the high-precision framing rectangle of the arc. The framing
* rectangle contains only the part of this <code>Arc2D</code> that is
* in between the starting and ending angles and contains the pie
* wedge, if this <code>Arc2D</code> has a <code>PIE</code> closure type.
* <p>
* This method differs from the
* {@link RectangularShape#getBounds() getBounds} in that the
* <code>getBounds</code> method only returns the bounds of the
* enclosing ellipse of this <code>Arc2D</code> without considering
* the starting and ending angles of this <code>Arc2D</code>.
*
* @return the <CODE>Rectangle2D</CODE> that represents the arc's
* framing rectangle.
* @since 1.2
*/
if (isEmpty()) {
}
if (getArcType() == PIE) {
} else {
}
double angle = 0.0;
for (int i = 0; i < 6; i++) {
if (i < 4) {
// 0-3 are the four quadrants
angle += 90.0;
if (!containsAngle(angle)) {
continue;
}
} else if (i == 4) {
// 4 is start angle
angle = getAngleStart();
} else {
// 5 is end angle
angle += getAngleExtent();
}
}
double w = getWidth();
double h = getHeight();
}
/**
* Constructs a <code>Rectangle2D</code> of the appropriate precision
* to hold the parameters calculated to be the framing rectangle
* of this arc.
*
* @param x The X coordinate of the upper-left corner of the
* framing rectangle.
* @param y The Y coordinate of the upper-left corner of the
* framing rectangle.
* @param w The width of the framing rectangle.
* @param h The height of the framing rectangle.
* @return a <code>Rectangle2D</code> that is the framing rectangle
* of this arc.
* @since 1.2
*/
double w, double h);
/*
* Normalizes the specified angle into the range -180 to 180.
*/
if (angle > 180.0) {
} else {
// IEEEremainder can return -180 here for some input values...
if (angle == -180.0) {
angle = 180.0;
}
}
} else if (angle <= -180.0) {
} else {
// IEEEremainder can return -180 here for some input values...
if (angle == -180.0) {
angle = 180.0;
}
}
}
return angle;
}
/**
* Determines whether or not the specified angle is within the
* angular extents of the arc.
*
* @param angle The angle to test.
*
* @return <CODE>true</CODE> if the arc contains the angle,
* <CODE>false</CODE> if the arc doesn't contain the angle.
* @since 1.2
*/
double angExt = getAngleExtent();
if (backwards) {
}
if (angExt >= 360.0) {
return true;
}
if (backwards) {
}
if (angle < 0.0) {
angle += 360.0;
}
}
/**
* Determines whether or not the specified point is inside the boundary
* of the arc.
*
* @param x The X coordinate of the point to test.
* @param y The Y coordinate of the point to test.
*
* @return <CODE>true</CODE> if the point lies within the bound of
* the arc, <CODE>false</CODE> if the point lies outside of the
* arc's bounds.
* @since 1.2
*/
public boolean contains(double x, double y) {
// Normalize the coordinates compared to the ellipse
// having a center at 0,0 and a radius of 0.5.
if (ellw <= 0.0) {
return false;
}
if (ellh <= 0.0) {
return false;
}
if (distSq >= 0.25) {
return false;
}
if (angExt >= 360.0) {
return true;
}
normx)));
return inarc;
}
// CHORD and OPEN behave the same way
if (inarc) {
if (angExt >= 180.0) {
return true;
}
// point must be outside the "pie triangle"
} else {
if (angExt <= 180.0) {
return false;
}
// point must be inside the "pie triangle"
}
// The point is inside the pie triangle iff it is on the same
// side of the line connecting the ends of the arc as the center.
}
/**
* Determines whether or not the interior of the arc intersects
* the interior of the specified rectangle.
*
* @param x The X coordinate of the rectangle's upper-left corner.
* @param y The Y coordinate of the rectangle's upper-left corner.
* @param w The width of the rectangle.
* @param h The height of the rectangle.
*
* @return <CODE>true</CODE> if the arc intersects the rectangle,
* <CODE>false</CODE> if the arc doesn't intersect the rectangle.
* @since 1.2
*/
public boolean intersects(double x, double y, double w, double h) {
return false;
}
double ext = getAngleExtent();
if (ext == 0) {
return false;
}
double xw = x + w;
double yh = y + h;
// check bbox
return false;
}
// extract necessary data
double axc = getCenterX();
double ayc = getCenterY();
/*
* Try to catch rectangles that intersect arc in areas
* outside of rectagle with left top corner coordinates
* (min(center x, start point x, end point x),
* min(center y, start point y, end point y))
* and rigth bottom corner coordinates
* (max(center x, start point x, end point x),
* max(center y, start point y, end point y)).
* So we'll check axis segments outside of rectangle above.
*/
return true;
}
}
return true;
}
}
/*
* For PIE we should check intersection with pie slices;
* also we should do the same for arcs with extent is greater
* than 180, because we should cover case of rectangle, which
* situated between center of arc and chord, but does not
* intersect the chord.
*/
// for PIE: try to find intersections with pie slices
return true;
}
} else {
// for CHORD and OPEN: try to find intersections with chord
return true;
}
}
// finally check the rectangle corners inside the arc
return true;
}
return false;
}
/**
* Determines whether or not the interior of the arc entirely contains
* the specified rectangle.
*
* @param x The X coordinate of the rectangle's upper-left corner.
* @param y The Y coordinate of the rectangle's upper-left corner.
* @param w The width of the rectangle.
* @param h The height of the rectangle.
*
* @return <CODE>true</CODE> if the arc contains the rectangle,
* <CODE>false</CODE> if the arc doesn't contain the rectangle.
* @since 1.2
*/
public boolean contains(double x, double y, double w, double h) {
}
/**
* Determines whether or not the interior of the arc entirely contains
* the specified rectangle.
*
* @param r The <CODE>Rectangle2D</CODE> to test.
*
* @return <CODE>true</CODE> if the arc contains the rectangle,
* <CODE>false</CODE> if the arc doesn't contain the rectangle.
* @since 1.2
*/
}
private boolean contains(double x, double y, double w, double h,
if (!(contains(x, y) &&
contains(x + w, y) &&
contains(x, y + h) &&
contains(x + w, y + h))) {
return false;
}
// If the shape is convex then we have done all the testing
// we need. Only PIE arcs can be concave and then only if
// the angular extents are greater than 180 degrees.
return true;
}
// For a PIE shape we have an additional test for the case where
// the angular extents are greater than 180 degrees and all four
// rectangular corners are inside the shape but one of the
// rectangle edges spans across the "missing wedge" of the arc.
// We can test for this case by checking if the rectangle intersects
// either of the pie angle segments.
}
return false;
}
}
/**
* Returns an iteration object that defines the boundary of the
* arc.
* This iterator is multithread safe.
* <code>Arc2D</code> guarantees that
* modifications to the geometry of the arc
* do not affect any iterations of that geometry that
* are already in process.
*
* @param at an optional <CODE>AffineTransform</CODE> to be applied
* to the coordinates as they are returned in the iteration, or null
* if the untransformed coordinates are desired.
*
* @return A <CODE>PathIterator</CODE> that defines the arc's boundary.
* @since 1.2
*/
return new ArcIterator(this, at);
}
/**
* Returns the hashcode for this <code>Arc2D</code>.
* @return the hashcode for this <code>Arc2D</code>.
* @since 1.6
*/
public int hashCode() {
}
/**
* Determines whether or not the specified <code>Object</code> is
* equal to this <code>Arc2D</code>. The specified
* <code>Object</code> is equal to this <code>Arc2D</code>
* if it is an instance of <code>Arc2D</code> and if its
* location, size, arc extents and type are the same as this
* <code>Arc2D</code>.
* @param obj an <code>Object</code> to be compared with this
* <code>Arc2D</code>.
* @return <code>true</code> if <code>obj</code> is an instance
* of <code>Arc2D</code> and has the same values;
* <code>false</code> otherwise.
* @since 1.6
*/
if (obj == this) {
return true;
}
}
return false;
}
}