Class java.awt.Rectangle
All Packages    This Package    Previous    Next

Class java.awt.Rectangle

java.lang.Object
   |
   +----java.awt.Rectangle

public class Rectangle
extends Object
An rectangle, defined by x, y, width and height.
Version:
1.16, 10/16/95
Author:
Sami Shaio

Variable Index

 o height
The height of the rectangle.
 o width
The width of the rectangle.
 o x
The x coordinate of the rectangle.
 o y
The y coordinate of the rectangle.

Constructor Index

 o Rectangle()
Constructs a new rectangle.
 o Rectangle(int, int, int, int)
Constructs and initializes a rectangle with the specified parameters.
 o Rectangle(int, int)
Constructs a rectangle and initializes it with the specified width and height parameters.
 o Rectangle(Point, Dimension)
Constructs a rectangle and initializes it to specified point and dimension.
 o Rectangle(Point)
Constructs a rectangle and initializes it to the specified point.
 o Rectangle(Dimension)
Constructs a rectangle and initializes it to the specified width and height.

Method Index

 o add(int, int)
Add a point to a rectangle.
 o add(Point)
Add a point to a rectangle.
 o add(Rectangle)
Add a rectangle to a rectangle.
 o equals(Object)
Check if two rectangles are equal.
 o grow(int, int)
Grow the rectangle horizontally and vertically.
 o hashCode()
Hashcode
 o inside(int, int)
Checks if the specified point lies inside a rectangle.
 o intersection(Rectangle)
Compute the intersection of two rectangles.
 o intersects(Rectangle)
Check if two rectangles intersect.
 o isEmpty()
Check if the rectangle is empty.
 o move(int, int)
Move the rectangle.
 o reshape(int, int, int, int)
Reshape the rectangle.
 o resize(int, int)
Resize the rectangle.
 o toString()
Returns the String representation of this Rectangle's values.
 o translate(int, int)
Translate the rectangle.
 o union(Rectangle)
Compute the union of two rectangles.

Variables

 o x
  public int x
The x coordinate of the rectangle.
 o y
  public int y
The y coordinate of the rectangle.
 o width
  public int width
The width of the rectangle.
 o height
  public int height
The height of the rectangle.

Constructors

 o Rectangle
  public Rectangle()
Constructs a new rectangle.

 o 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

 o 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

 o Rectangle

  public Rectangle(Point p,
                   Dimension d)
Constructs a rectangle and initializes it to specified point and dimension.
Parameters:
p - the point
d - dimension

 o 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

 o 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

Methods

 o reshape
  public void reshape(int x,
                      int y,
                      int width,
                      int height)
Reshape the rectangle.

 o move

  public void move(int x,
                   int y)
Move the rectangle.

 o translate

  public void translate(int x,
                        int y)
Translate the rectangle.

 o resize

  public void resize(int width,
                     int height)
Resize the rectangle.

 o 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

 o intersects

  public boolean intersects(Rectangle r)
Check if two rectangles intersect.

 o intersection

  public Rectangle intersection(Rectangle r)
Compute the intersection of two rectangles.

 o union

  public Rectangle union(Rectangle r)
Compute the union of two rectangles.

 o add

  public void add(int x,
                  int y)
Add a point to a rectangle. This results in the smallest rectangle that contains both the rectangle and the point

 o add

  public void add(Point pt)
Add a point to a rectangle. This results in the smallest rectangle that contains both the rectangle and the point

 o add

  public void add(Rectangle r)
Add a rectangle to a rectangle. This results in the union of the two rectangles.

 o grow

  public void grow(int h,
                   int v)
Grow the rectangle horizontally and vertically.

 o isEmpty

  public boolean isEmpty()
Check if the rectangle is empty.

 o hashCode

  public int hashCode()
Hashcode
Overrides:
hashCode in class Object

 o equals

  public boolean equals(Object obj)
Check if two rectangles are equal.
Overrides:
equals in class Object

 o toString

  public String toString()
Returns the String representation of this Rectangle's values.
Overrides:
toString in class Object


All Packages    This Package    Previous    Next