|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.geom.RectangularShape java.awt.geom.Rectangle2D java.awt.Rectangle
public class Rectangle
A rectangle with integer coordinates.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D |
---|
Rectangle2D.Double, Rectangle2D.Float |
Field Summary | |
---|---|
int |
height
The height of the rectangle |
int |
width
The width of the rectangle |
int |
x
The x coordinate of the top left of the rectangle |
int |
y
The y coordinate of the top right of the rectangle |
Fields inherited from class java.awt.geom.Rectangle2D |
---|
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP |
Constructor Summary | |
---|---|
Rectangle()
Creates an empty rectangle at (0,0). |
|
Rectangle(int width,
int height)
Creates a rectangle with top left corner at (0,0) and with specified width and height. |
|
Rectangle(int x,
int y,
int width,
int height)
Creates a rectangle with top left corner at (x,y) and with specified width and height. |
|
Rectangle(Point p)
Create an empty rectangle at the given point |
Method Summary | |
---|---|
boolean |
contains(int x,
int y)
Test if a point given by (x,y) coordinates is within the rectangle |
boolean |
contains(Point p)
Test if a point is within the rectangle |
boolean |
contains(Rectangle r)
Test if this rectangle contains a specified rectangle |
boolean |
equals(Object obj)
Test if the Rectangle is equal to a given object |
Rectangle |
getBounds()
Get the bounds of this rectangular shape as a Rectangle |
Rectangle2D |
getBounds2D()
Get the bounding Rectangle2D for the shape |
double |
getHeight()
Get the height as a double |
Point |
getLocation()
Get the location of the rectangle |
double |
getWidth()
Get the width as a double |
double |
getX()
Get the x coordinate as a double |
double |
getY()
Get the y coordinate as a double |
boolean |
inside(int x,
int y)
Deprecated. |
boolean |
intersects(Rectangle r)
Test if this rectangle intersects a specified rectangle |
boolean |
isEmpty()
Test if the rectangle is empty |
int |
outcode(double x,
double y)
Returns a mask value that specifies where a point lies with respect to this rectangle. |
void |
reshape(int x,
int y,
int width,
int height)
Deprecated. |
void |
resize(int width,
int height)
Deprecated. |
void |
setBounds(int x,
int y,
int width,
int height)
Set the bounds of this rectangle |
void |
setBounds(Rectangle r)
Set the bounds of this rectangle to the given rectangle |
void |
setLocation(int x,
int y)
Move the rectangle to (x,y) |
void |
setLocation(Point p)
Set the location of this point to the location of a given point |
void |
setRect(double x,
double y,
double width,
double height)
Set this rectangle to a rectangle defined by double coordinates |
void |
setSize(int width,
int height)
Set the size of the rectangle |
String |
toString()
Returns a String representing this rectangle. |
Methods inherited from class java.awt.geom.Rectangle2D |
---|
contains, contains, intersects, intersectsLine, outcode, setFrame, setRect |
Methods inherited from class java.awt.geom.RectangularShape |
---|
clone, contains, contains, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.Shape |
---|
contains, contains, contains, contains, intersects, intersects |
Field Detail |
---|
public int height
public int width
public int x
public int y
Constructor Detail |
---|
public Rectangle(int x, int y, int width, int height)
x
- the x coordinate of the top left cornery
- the y coordinate of the top left cornerwidth
- the width of the rectangleheight
- the height of the rectanglepublic Rectangle(int width, int height)
width
- the width of the rectangleheight
- the height of the rectanglepublic Rectangle()
public Rectangle(Point p)
p
- trhe pointMethod Detail |
---|
public double getX()
getX
in class RectangularShape
public double getY()
getY
in class RectangularShape
public double getWidth()
getWidth
in class RectangularShape
public double getHeight()
getHeight
in class RectangularShape
public void setLocation(int x, int y)
x
- the new x coordinatey
- the new y coordinatepublic void setLocation(Point p)
p
- the given pointpublic boolean isEmpty()
isEmpty
in class RectangularShape
public boolean contains(int x, int y)
x
- the x coordinatey
- the y coordinate
public boolean contains(Point p)
p
- the point
public boolean contains(Rectangle r)
r
- the specified rectangle
public boolean intersects(Rectangle r)
r
- the given rectangle
public Rectangle getBounds()
RectangularShape
getBounds
in interface Shape
getBounds
in class RectangularShape
public Rectangle2D getBounds2D()
Shape
getBounds2D
in interface Shape
public void setBounds(int x, int y, int width, int height)
x
- the new x coordinatey
- the new y coordinatewidth
- the new widthheight
- the new heightpublic void setBounds(Rectangle r)
r
- the new rectanglepublic void setRect(double x, double y, double width, double height)
Rectangle2D
setRect
in class Rectangle2D
x
- the x coordinate of the top left cornery
- the y coordinate of the top right cornerwidth
- the width of the rectangleheight
- the height of the rectangle@Deprecated public void reshape(int x, int y, int width, int height)
public boolean equals(Object obj)
equals
in class Rectangle2D
obj
- the objectpublic Point getLocation()
public void setSize(int width, int height)
width
- the new widthheight
- the new height@Deprecated public void resize(int width, int height)
public String toString()
toString
in class Object
public int outcode(double x, double y)
Rectangle2D
outcode
in class Rectangle2D
x
- the x coordinate of the given pointy
- the y coordinate of the given point
@Deprecated public boolean inside(int x, int y)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |