< prev index next >
src/java.desktop/share/classes/java/awt/geom/Arc2D.java
Print this page
*** 26,39 ****
package java.awt.geom;
import java.io.Serializable;
/**
! * <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</a> {@link RectangularShape}.
*
--- 26,39 ----
package java.awt.geom;
import java.io.Serializable;
/**
! * {@code Arc2D} 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 CHORD}, or {@code PIE}).
* <p>
* <a name="inscribes">
* The arc is a partial section of a full ellipse which
* inscribes the framing rectangle of its parent</a> {@link RectangularShape}.
*
*** 324,342 ****
*/
private static final long serialVersionUID = 9130893014586380278L;
/**
* 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>
*/
private void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException
--- 324,342 ----
*/
private static final long serialVersionUID = 9130893014586380278L;
/**
* Writes the default serializable fields to the
! * {@code ObjectOutputStream} followed by a byte
! * indicating the arc type of this {@code Arc2D}
* instance.
*
* @serialData
* <ol>
* <li>The default serializable fields.
* <li>
! * followed by a {@code byte} indicating the arc type
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* </ol>
*/
private void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException
*** 346,364 ****
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>
*/
private void readObject(java.io.ObjectInputStream s)
throws java.lang.ClassNotFoundException, java.io.IOException
--- 346,364 ----
s.writeByte(getArcType());
}
/**
* Reads the default serializable fields from the
! * {@code ObjectInputStream} followed by a byte
! * indicating the arc type of this {@code Arc2D}
* instance.
*
* @serialData
* <ol>
* <li>The default serializable fields.
* <li>
! * followed by a {@code byte} indicating the arc type
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* </ol>
*/
private void readObject(java.io.ObjectInputStream s)
throws java.lang.ClassNotFoundException, java.io.IOException
*** 616,634 ****
*/
private static final long serialVersionUID = 728264085846882001L;
/**
* 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>
*/
private void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException
--- 616,634 ----
*/
private static final long serialVersionUID = 728264085846882001L;
/**
* Writes the default serializable fields to the
! * {@code ObjectOutputStream} followed by a byte
! * indicating the arc type of this {@code Arc2D}
* instance.
*
* @serialData
* <ol>
* <li>The default serializable fields.
* <li>
! * followed by a {@code byte} indicating the arc type
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* </ol>
*/
private void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException
*** 638,656 ****
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>
*/
private void readObject(java.io.ObjectInputStream s)
throws java.lang.ClassNotFoundException, java.io.IOException
--- 638,656 ----
s.writeByte(getArcType());
}
/**
* Reads the default serializable fields from the
! * {@code ObjectInputStream} followed by a byte
! * indicating the arc type of this {@code Arc2D}
* instance.
*
* @serialData
* <ol>
* <li>The default serializable fields.
* <li>
! * followed by a {@code byte} indicating the arc type
* {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
* </ol>
*/
private void readObject(java.io.ObjectInputStream s)
throws java.lang.ClassNotFoundException, java.io.IOException
*** 737,747 ****
/**
* 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
*/
public Point2D getStartPoint() {
double angle = Math.toRadians(-getAngleStart());
--- 737,747 ----
/**
* 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} object representing the
* x,y coordinates of the starting point of the arc.
* @since 1.2
*/
public Point2D getStartPoint() {
double angle = Math.toRadians(-getAngleStart());
*** 754,764 ****
* 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
*/
public Point2D getEndPoint() {
double angle = Math.toRadians(-getAngleStart() - getAngleExtent());
--- 754,764 ----
* 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} object representing the
* x,y coordinates of the ending point of the arc.
* @since 1.2
*/
public Point2D getEndPoint() {
double angle = Math.toRadians(-getAngleStart() - getAngleExtent());
*** 788,800 ****
/**
* 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:
--- 788,800 ----
/**
* Sets the location, size, angular extents, and closure type of
* this arc to the specified values.
*
! * @param loc The {@code Point2D} representing the coordinates of
* the upper-left corner of the arc.
! * @param size The {@code Dimension2D} 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:
*** 827,837 ****
}
/**
* 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
*/
public void setArc(Arc2D a) {
setArc(a.getX(), a.getY(), a.getWidth(), a.getHeight(),
a.getAngleStart(), a.getAngleExtent(), a.type);
--- 827,837 ----
}
/**
* Sets this arc to be the same as the specified arc.
*
! * @param a The {@code Arc2D} to use to set the arc's values.
* @since 1.2
*/
public void setArc(Arc2D a) {
setArc(a.getX(), a.getY(), a.getWidth(), a.getHeight(),
a.getAngleStart(), a.getAngleExtent(), a.type);
*** 934,944 ****
/**
* 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
*/
public void setAngleStart(Point2D p) {
// Bias the dx and dy by the height and width of the oval.
--- 934,944 ----
/**
* 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} that defines the starting angle.
* @see #getAngleStart
* @since 1.2
*/
public void setAngleStart(Point2D p) {
// Bias the dx and dy by the height and width of the oval.
*** 987,1015 ****
* 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
*/
public void setAngles(Point2D p1, Point2D p2) {
setAngles(p1.getX(), p1.getY(), p2.getX(), p2.getY());
}
/**
* 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
*/
public void setArcType(int type) {
--- 987,1015 ----
* 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} that defines the arc's
* starting point.
! * @param p2 The {@code Point2D} that defines the arc's
* ending point.
* @since 1.2
*/
public void setAngles(Point2D p1, Point2D p2) {
setAngles(p1.getX(), p1.getY(), p2.getX(), p2.getY());
}
/**
* Sets the closure type of this arc to the specified value:
! * {@code OPEN}, {@code CHORD}, or {@code PIE}.
*
* @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} is not
* 0, 1, or 2.+
* @see #getArcType
* @since 1.2
*/
public void setArcType(int type) {
*** 1031,1051 ****
setArc(x, y, w, h, getAngleStart(), getAngleExtent(), type);
}
/**
* 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
*/
public Rectangle2D getBounds2D() {
if (isEmpty()) {
--- 1031,1051 ----
setArc(x, y, w, h, getAngleStart(), getAngleExtent(), type);
}
/**
* Returns the high-precision framing rectangle of the arc. The framing
! * rectangle contains only the part of this {@code Arc2D} that is
* in between the starting and ending angles and contains the pie
! * wedge, if this {@code Arc2D} has a {@code PIE} closure type.
* <p>
* This method differs from the
* {@link RectangularShape#getBounds() getBounds} in that the
! * {@code getBounds} method only returns the bounds of the
! * enclosing ellipse of this {@code Arc2D} without considering
! * the starting and ending angles of this {@code Arc2D}.
*
! * @return the {@code Rectangle2D} that represents the arc's
* framing rectangle.
* @since 1.2
*/
public Rectangle2D getBounds2D() {
if (isEmpty()) {
*** 1089,1109 ****
y1 = getY() + (y1 * 0.5 + 0.5) * h;
return makeBounds(x1, y1, x2, y2);
}
/**
! * 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
*/
protected abstract Rectangle2D makeBounds(double x, double y,
double w, double h);
--- 1089,1109 ----
y1 = getY() + (y1 * 0.5 + 0.5) * h;
return makeBounds(x1, y1, x2, y2);
}
/**
! * Constructs a {@code Rectangle2D} 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} that is the framing rectangle
* of this arc.
* @since 1.2
*/
protected abstract Rectangle2D makeBounds(double x, double y,
double w, double h);
*** 1140,1151 ****
* 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
*/
public boolean containsAngle(double angle) {
double angExt = getAngleExtent();
boolean backwards = (angExt < 0.0);
--- 1140,1151 ----
* Determines whether or not the specified angle is within the
* angular extents of the arc.
*
* @param angle The angle to test.
*
! * @return {@code true} if the arc contains the angle,
! * {@code false} if the arc doesn't contain the angle.
* @since 1.2
*/
public boolean containsAngle(double angle) {
double angExt = getAngleExtent();
boolean backwards = (angExt < 0.0);
*** 1172,1183 ****
* 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
--- 1172,1183 ----
* 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} if the point lies within the bound of
! * the arc, {@code false} 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
*** 1237,1248 ****
* @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) {
double aw = getWidth();
--- 1237,1248 ----
* @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} if the arc intersects the rectangle,
! * {@code false} if the arc doesn't intersect the rectangle.
* @since 1.2
*/
public boolean intersects(double x, double y, double w, double h) {
double aw = getWidth();
*** 1342,1367 ****
* @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) {
return contains(x, y, w, h, null);
}
/**
* 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
*/
public boolean contains(Rectangle2D r) {
return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight(), r);
}
--- 1342,1367 ----
* @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} if the arc contains the rectangle,
! * {@code false} if the arc doesn't contain the rectangle.
* @since 1.2
*/
public boolean contains(double x, double y, double w, double h) {
return contains(x, y, w, h, null);
}
/**
* Determines whether or not the interior of the arc entirely contains
* the specified rectangle.
*
! * @param r The {@code Rectangle2D} to test.
*
! * @return {@code true} if the arc contains the rectangle,
! * {@code false} if the arc doesn't contain the rectangle.
* @since 1.2
*/
public boolean contains(Rectangle2D r) {
return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight(), r);
}
*** 1407,1435 ****
/**
* 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
*/
public PathIterator getPathIterator(AffineTransform at) {
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() {
long bits = java.lang.Double.doubleToLongBits(getX());
bits += java.lang.Double.doubleToLongBits(getY()) * 37;
--- 1407,1435 ----
/**
* Returns an iteration object that defines the boundary of the
* arc.
* This iterator is multithread safe.
! * {@code Arc2D} 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} 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} that defines the arc's boundary.
* @since 1.2
*/
public PathIterator getPathIterator(AffineTransform at) {
return new ArcIterator(this, at);
}
/**
! * Returns the hashcode for this {@code Arc2D}.
! * @return the hashcode for this {@code Arc2D}.
* @since 1.6
*/
public int hashCode() {
long bits = java.lang.Double.doubleToLongBits(getX());
bits += java.lang.Double.doubleToLongBits(getY()) * 37;
*** 1440,1460 ****
bits += getArcType() * 61;
return (((int) bits) ^ ((int) (bits >> 32)));
}
/**
! * 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
*/
public boolean equals(Object obj) {
if (obj == this) {
return true;
--- 1440,1460 ----
bits += getArcType() * 61;
return (((int) bits) ^ ((int) (bits >> 32)));
}
/**
! * Determines whether or not the specified {@code Object} is
! * equal to this {@code Arc2D}. The specified
! * {@code Object} is equal to this {@code Arc2D}
! * if it is an instance of {@code Arc2D} and if its
* location, size, arc extents and type are the same as this
! * {@code Arc2D}.
! * @param obj an {@code Object} to be compared with this
! * {@code Arc2D}.
! * @return {@code true} if {@code obj} is an instance
! * of {@code Arc2D} and has the same values;
! * {@code false} otherwise.
* @since 1.6
*/
public boolean equals(Object obj) {
if (obj == this) {
return true;
< prev index next >