package java.awt;
-import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.io.Serializable;
* ArrayIndexOutOfBoundsException, or invalid results. Also, this class is
* not threadsafe.
*
- * @author Warren Levy <warrenl@cygnus.com>
- * @author Aaron M. Renn <arenn@urbanophile.com>
- * @author Eric Blake <ebb9@email.byu.edu>
+ * @author Warren Levy (warrenl@cygnus.com)
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Eric Blake (ebb9@email.byu.edu)
* @since 1.0
* @status updated to 1.4
*/
*/
public void setBounds(Rectangle r)
{
- x = r.x;
- y = r.y;
- width = r.width;
- height = r.height;
+ setBounds (r.x, r.y, r.width, r.height);
}
/**
*/
public void setBounds(int x, int y, int width, int height)
{
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
+ reshape (x, y, width, height);
}
/**
*/
public void reshape(int x, int y, int width, int height)
{
- setBounds(x, y, width, height);
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
}
/**
* its upper left corner.
*
* @return the point where this rectangle is located
- * @see setLocation(Point)
+ * @see #setLocation(Point)
* @since 1.1
*/
public Point getLocation()
*/
public void setLocation(Point p)
{
- this.x = p.x;
- this.y = p.y;
+ setLocation (p.x, p.y);
}
/**
*/
public void setLocation(int x, int y)
{
- this.x = x;
- this.y = y;
+ move (x, y);
}
/**
*/
public void move(int x, int y)
{
- setLocation(x, y);
+ this.x = x;
+ this.y = y;
}
/**
*/
public void setSize(Dimension d)
{
- width = d.width;
- height = d.height;
+ setSize (d.width, d.height);
}
/**
*/
public void setSize(int width, int height)
{
- this.width = width;
- this.height = height;
+ resize (width, height);
}
/**
*/
public void resize(int width, int height)
{
- setSize(width, height);
+ this.width = width;
+ this.height = height;
}
/**
*/
public boolean contains(Point p)
{
- return width > 0 && height > 0
- && p.x >= x && p.x < x + width
- && p.y >= y && p.y < y + height;
+ return contains (p.x, p.y);
}
/**
*/
public boolean contains(int x, int y)
{
- return width > 0 && height > 0
- && x >= this.x && x < this.x + width
- && y >= this.y && y < this.y + height;
+ return inside (x, y);
}
/**
*/
public boolean contains(Rectangle r)
{
- return width > 0 && height > 0 && r.width > 0 && r.height > 0
- && r.x >= x && r.x + r.width <= x + width
- && r.y >= y && r.y + r.height <= y + height;
+ return contains (r.x, r.y, r.width, r.height);
}
/**
*/
public boolean inside(int x, int y)
{
- return contains(x, y);
+ return width > 0 && height > 0
+ && x >= this.x && x < this.x + width
+ && y >= this.y && y < this.y + height;
}
/**
*/
public boolean intersects(Rectangle r)
{
- return width > 0 && height > 0 && r.width > 0 && r.height > 0
+ return r.width > 0 && r.height > 0 && width > 0 && height > 0
&& r.x < x + width && r.x + r.width > x
&& r.y < y + height && r.y + r.height > y;
}