Class java.awt.Rectangle
All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.Rectangle
java.lang.Object
|
+----java.awt.Rectangle
- public class Rectangle
- extends Object
A rectangle defined by x, y, width and height.
- height
- The height of the rectangle.
- width
- The width of the rectangle.
- x
- The x coordinate of the rectangle.
- y
- The y coordinate of the rectangle.
- Rectangle()
- Constructs a new rectangle.
- Rectangle(Dimension)
- Constructs a rectangle and initializes it to the specified width and height.
- Rectangle(int, int)
- Constructs a rectangle and initializes it with the specified width and height parameters.
- Rectangle(int, int, int, int)
- Constructs and initializes a rectangle with the specified parameters.
- Rectangle(Point)
- Constructs a rectangle and initializes it to the specified point.
- Rectangle(Point, Dimension)
- Constructs a rectangle and initializes it to a specified point and dimension.
- add(int, int)
- Adds a point to a rectangle.
- add(Point)
- Adds a point to a rectangle.
- add(Rectangle)
- Adds a rectangle to a rectangle.
- equals(Object)
- Checks whether two rectangles are equal.
- grow(int, int)
- Grows the rectangle horizontally and vertically.
- hashCode()
- Returns the hashcode for this Rectangle.
- inside(int, int)
- Checks if the specified point lies inside a rectangle.
- intersection(Rectangle)
- Computes the intersection of two rectangles.
- intersects(Rectangle)
- Checks if two rectangles intersect.
- isEmpty()
- Determines whether the rectangle is empty.
- move(int, int)
- Moves the rectangle.
- reshape(int, int, int, int)
- Reshapes the rectangle.
- resize(int, int)
- Resizes the rectangle.
- toString()
- Returns the String representation of this Rectangle's values.
- translate(int, int)
- Translates the rectangle.
- union(Rectangle)
- Computes the union of two rectangles.
x
public int x
- The x coordinate of the rectangle.
y
public int y
- The y coordinate of the rectangle.
width
public int width
- The width of the rectangle.
height
public int height
- The height of the rectangle.
Rectangle
public Rectangle()
- Constructs a new rectangle.
Rectangle
public Rectangle(int x,
int y,
int width,
int height)
- Constructs and initializes a rectangle with the specified parameters.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
Rectangle
public Rectangle(int width,
int height)
- Constructs a rectangle and initializes it with the specified width and height parameters.
- Parameters:
- width - the width of the rectangle
- height - the height of the rectangle
Rectangle
public Rectangle(Point p,
Dimension d)
- Constructs a rectangle and initializes it to a specified point and dimension.
- Parameters:
- p - the point
- d - dimension
Rectangle
public Rectangle(Point p)
- Constructs a rectangle and initializes it to the specified point.
- Parameters:
- p - the value of the x and y coordinate
Rectangle
public Rectangle(Dimension d)
- Constructs a rectangle and initializes it to the specified width and height.
- Parameters:
- d - the value of the width and height
reshape
public void reshape(int x,
int y,
int width,
int height)
- Reshapes the rectangle.
move
public void move(int x,
int y)
- Moves the rectangle.
translate
public void translate(int x,
int y)
- Translates the rectangle.
resize
public void resize(int width,
int height)
- Resizes the rectangle.
inside
public boolean inside(int x,
int y)
- Checks if the specified point lies inside a rectangle.
- Parameters:
- x - the x coordinate
- y - the y coordinate
intersects
public boolean intersects(Rectangle r)
- Checks if two rectangles intersect.
intersection
public Rectangle intersection(Rectangle r)
- Computes the intersection of two rectangles.
union
public Rectangle union(Rectangle r)
- Computes the union of two rectangles.
add
public void add(int newx,
int newy)
- Adds a point to a rectangle. This results in the smallest
rectangle that contains both the rectangle and the point.
add
public void add(Point pt)
- Adds a point to a rectangle. This results in the smallest
rectangle that contains both the rectangle and the point.
add
public void add(Rectangle r)
- Adds a rectangle to a rectangle. This results in the union
of the two rectangles.
grow
public void grow(int h,
int v)
- Grows the rectangle horizontally and vertically.
isEmpty
public boolean isEmpty()
- Determines whether the rectangle is empty.
hashCode
public int hashCode()
- Returns the hashcode for this Rectangle.
- Overrides:
- hashCode in class Object
equals
public boolean equals(Object obj)
- Checks whether two rectangles are equal.
- Overrides:
- equals in class Object
toString
public String toString()
- Returns the String representation of this Rectangle's values.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index