/*
* 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.
*/
/**
* The <code>RoundRectangle2D</code> class defines a rectangle with
* rounded corners defined by a location {@code (x,y)}, a
* dimension {@code (w x h)}, and the width and height of an arc
* with which to round the corners.
* <p>
* This class is the abstract superclass for all objects that
* store a 2D rounded rectangle.
* The actual storage representation of the coordinates is left to
* the subclass.
*
* @author Jim Graham
* @since 1.2
*/
/**
* The <code>Float</code> class defines a rectangle with rounded
* corners all specified in <code>float</code> coordinates.
* @since 1.2
*/
implements Serializable
{
/**
* The X coordinate of this <code>RoundRectangle2D</code>.
* @since 1.2
* @serial
*/
public float x;
/**
* The Y coordinate of this <code>RoundRectangle2D</code>.
* @since 1.2
* @serial
*/
public float y;
/**
* The width of this <code>RoundRectangle2D</code>.
* @since 1.2
* @serial
*/
public float width;
/**
* The height of this <code>RoundRectangle2D</code>.
* @since 1.2
* @serial
*/
public float height;
/**
* The width of the arc that rounds off the corners.
* @since 1.2
* @serial
*/
public float arcwidth;
/**
* The height of the arc that rounds off the corners.
* @since 1.2
* @serial
*/
public float archeight;
/**
* Constructs a new <code>RoundRectangle2D</code>, initialized to
* location (0.0, 0.0), size (0.0, 0.0), and corner arcs
* of radius 0.0.
* @since 1.2
*/
public Float() {
}
/**
* Constructs and initializes a <code>RoundRectangle2D</code>
* from the specified <code>float</code> coordinates.
*
* @param x the X coordinate of the newly
* constructed <code>RoundRectangle2D</code>
* @param y the Y coordinate of the newly
* constructed <code>RoundRectangle2D</code>
* @param w the width to which to set the newly
* constructed <code>RoundRectangle2D</code>
* @param h the height to which to set the newly
* constructed <code>RoundRectangle2D</code>
* @param arcw the width of the arc to use to round off the
* corners of the newly constructed
* <code>RoundRectangle2D</code>
* @param arch the height of the arc to use to round off the
* corners of the newly constructed
* <code>RoundRectangle2D</code>
* @since 1.2
*/
public Float(float x, float y, float w, float h,
{
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getX() {
return (double) x;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getY() {
return (double) y;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getWidth() {
return (double) width;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getHeight() {
return (double) height;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getArcWidth() {
return (double) arcwidth;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getArcHeight() {
return (double) archeight;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public boolean isEmpty() {
}
/**
* Sets the location, size, and corner radii of this
* <code>RoundRectangle2D</code> to the specified
* <code>float</code> values.
*
* @param x the X coordinate to which to set the
* location of this <code>RoundRectangle2D</code>
* @param y the Y coordinate to which to set the
* location of this <code>RoundRectangle2D</code>
* @param w the width to which to set this
* <code>RoundRectangle2D</code>
* @param h the height to which to set this
* <code>RoundRectangle2D</code>
* @param arcw the width to which to set the arc of this
* <code>RoundRectangle2D</code>
* @param arch the height to which to set the arc of this
* <code>RoundRectangle2D</code>
* @since 1.2
*/
public void setRoundRect(float x, float y, float w, float h,
{
this.x = x;
this.y = y;
this.width = w;
this.height = h;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public void setRoundRect(double x, double y, double w, double h,
{
this.x = (float) x;
this.y = (float) y;
this.width = (float) w;
this.height = (float) h;
}
/**
* {@inheritDoc}
* @since 1.2
*/
}
/**
* {@inheritDoc}
* @since 1.2
*/
}
/*
* JDK 1.6 serialVersionUID
*/
}
/**
* The <code>Double</code> class defines a rectangle with rounded
* corners all specified in <code>double</code> coordinates.
* @since 1.2
*/
implements Serializable
{
/**
* The X coordinate of this <code>RoundRectangle2D</code>.
* @since 1.2
* @serial
*/
public double x;
/**
* The Y coordinate of this <code>RoundRectangle2D</code>.
* @since 1.2
* @serial
*/
public double y;
/**
* The width of this <code>RoundRectangle2D</code>.
* @since 1.2
* @serial
*/
public double width;
/**
* The height of this <code>RoundRectangle2D</code>.
* @since 1.2
* @serial
*/
public double height;
/**
* The width of the arc that rounds off the corners.
* @since 1.2
* @serial
*/
public double arcwidth;
/**
* The height of the arc that rounds off the corners.
* @since 1.2
* @serial
*/
public double archeight;
/**
* Constructs a new <code>RoundRectangle2D</code>, initialized to
* location (0.0, 0.0), size (0.0, 0.0), and corner arcs
* of radius 0.0.
* @since 1.2
*/
public Double() {
}
/**
* Constructs and initializes a <code>RoundRectangle2D</code>
* from the specified <code>double</code> coordinates.
*
* @param x the X coordinate of the newly
* constructed <code>RoundRectangle2D</code>
* @param y the Y coordinate of the newly
* constructed <code>RoundRectangle2D</code>
* @param w the width to which to set the newly
* constructed <code>RoundRectangle2D</code>
* @param h the height to which to set the newly
* constructed <code>RoundRectangle2D</code>
* @param arcw the width of the arc to use to round off the
* corners of the newly constructed
* <code>RoundRectangle2D</code>
* @param arch the height of the arc to use to round off the
* corners of the newly constructed
* <code>RoundRectangle2D</code>
* @since 1.2
*/
public Double(double x, double y, double w, double h,
{
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getX() {
return x;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getY() {
return y;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getWidth() {
return width;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getHeight() {
return height;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getArcWidth() {
return arcwidth;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public double getArcHeight() {
return archeight;
}
/**
* {@inheritDoc}
* @since 1.2
*/
public boolean isEmpty() {
}
/**
* {@inheritDoc}
* @since 1.2
*/
public void setRoundRect(double x, double y, double w, double h,
{
this.x = x;
this.y = y;
this.width = w;
this.height = h;
}
/**
* {@inheritDoc}
* @since 1.2
*/
}
/**
* {@inheritDoc}
* @since 1.2
*/
}
/*
* JDK 1.6 serialVersionUID
*/
}
/**
* 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.
*
* @see java.awt.geom.RoundRectangle2D.Float
* @see java.awt.geom.RoundRectangle2D.Double
* @since 1.2
*/
protected RoundRectangle2D() {
}
/**
* Gets the width of the arc that rounds off the corners.
* @return the width of the arc that rounds off the corners
* of this <code>RoundRectangle2D</code>.
* @since 1.2
*/
public abstract double getArcWidth();
/**
* Gets the height of the arc that rounds off the corners.
* @return the height of the arc that rounds off the corners
* of this <code>RoundRectangle2D</code>.
* @since 1.2
*/
public abstract double getArcHeight();
/**
* Sets the location, size, and corner radii of this
* <code>RoundRectangle2D</code> to the specified
* <code>double</code> values.
*
* @param x the X coordinate to which to set the
* location of this <code>RoundRectangle2D</code>
* @param y the Y coordinate to which to set the
* location of this <code>RoundRectangle2D</code>
* @param w the width to which to set this
* <code>RoundRectangle2D</code>
* @param h the height to which to set this
* <code>RoundRectangle2D</code>
* @param arcWidth the width to which to set the arc of this
* <code>RoundRectangle2D</code>
* @param arcHeight the height to which to set the arc of this
* <code>RoundRectangle2D</code>
* @since 1.2
*/
public abstract void setRoundRect(double x, double y, double w, double h,
/**
* Sets this <code>RoundRectangle2D</code> to be the same as the
* specified <code>RoundRectangle2D</code>.
* @param rr the specified <code>RoundRectangle2D</code>
* @since 1.2
*/
}
/**
* {@inheritDoc}
* @since 1.2
*/
public void setFrame(double x, double y, double w, double h) {
}
/**
* {@inheritDoc}
* @since 1.2
*/
public boolean contains(double x, double y) {
if (isEmpty()) {
return false;
}
// Check for trivial rejection - point is outside bounding rectangle
return false;
}
// Check which corner point is in and do circular containment
// test - otherwise simple acceptance
return true;
}
return true;
}
return (x * x + y * y <= 1.0);
}
double arcsize)
{
return 0;
return 1;
return 2;
return 3;
} else {
return 4;
}
}
/**
* {@inheritDoc}
* @since 1.2
*/
public boolean intersects(double x, double y, double w, double h) {
return false;
}
// Check for trivial rejection - bounding rectangles do not intersect
return false;
}
// Trivially accept if any point is inside inner rectangle
return true;
}
// Trivially accept if either edge spans inner rectangle
return true;
}
// Since neither edge spans the center, then one of the corners
// must be in one of the rounded edges. We detect this case if
// a [xy]0class is 3 or a [xy]1class is 1. One of those two cases
// must be true for each direction.
// We now find a "nearest point" to test for being inside a rounded
// corner.
x = x / aw;
y = y / ah;
return (x * x + y * y <= 1.0);
}
/**
* {@inheritDoc}
* @since 1.2
*/
public boolean contains(double x, double y, double w, double h) {
return false;
}
return (contains(x, y) &&
contains(x + w, y) &&
contains(x, y + h) &&
contains(x + w, y + h));
}
/**
* Returns an iteration object that defines the boundary of this
* <code>RoundRectangle2D</code>.
* The iterator for this class is multi-threaded safe, which means
* that this <code>RoundRectangle2D</code> class guarantees that
* modifications to the geometry of this <code>RoundRectangle2D</code>
* object 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
* <code>null</code> if untransformed coordinates are desired
* @return the <code>PathIterator</code> object that returns the
* geometry of the outline of this
* <code>RoundRectangle2D</code>, one segment at a time.
* @since 1.2
*/
return new RoundRectIterator(this, at);
}
/**
* Returns the hashcode for this <code>RoundRectangle2D</code>.
* @return the hashcode for this <code>RoundRectangle2D</code>.
* @since 1.6
*/
public int hashCode() {
}
/**
* Determines whether or not the specified <code>Object</code> is
* equal to this <code>RoundRectangle2D</code>. The specified
* <code>Object</code> is equal to this <code>RoundRectangle2D</code>
* if it is an instance of <code>RoundRectangle2D</code> and if its
* location, size, and corner arc dimensions are the same as this
* <code>RoundRectangle2D</code>.
* @param obj an <code>Object</code> to be compared with this
* <code>RoundRectangle2D</code>.
* @return <code>true</code> if <code>obj</code> is an instance
* of <code>RoundRectangle2D</code> and has the same values;
* <code>false</code> otherwise.
* @since 1.6
*/
if (obj == this) {
return true;
}
if (obj instanceof RoundRectangle2D) {
}
return false;
}
}