charva.awt

Class Rectangle


public class Rectangle
extends java.lang.Object

The Rectangle class respresents a rectangular area of the screen; the boundaries are INCLUSIVE (i.e. the _right instance variable refers to the rightmost column that is included in the rectangular area, and the _bottom instance variable refers to the bottom row that is included in the rectangle. The width of the rectangle is given by (_right - _left +1). The height of the rectangle is given by (_bottom - _top + 1).

Constructor Summary

Rectangle(Point topleft_, Dimension size_)
Rectangle(Point topleft_, Point bottomright_)
Rectangle(Rectangle rect_)
Rectangle(int top_, int left_, int bottom_, int right_)
Construct a Rectangle with the specified boundaries.

Method Summary

Object
clone()
Returns a clone of this rectangle.
boolean
contains(Point p)
Returns true if the specified point is inside this Rectangle.
boolean
contains(int x, int y)
Returns true if the specified point is inside this Rectangle.
boolean
equals(Rectangle rect_)
Returns true if this rectangle has the same bounds as the specified rectangle.
int
getBottom()
int
getLeft()
int
getRight()
int
getTop()
Rectangle
intersection(Rectangle rect_)
Return the intersection between this Rectangle and the specified Rectangle, or null if the two rectangles don't intersect.
boolean
intersects(Rectangle rect_)
Check if the specified rectangle intersects at all with this rectangle.
String
toString()

Constructor Details

Rectangle

public Rectangle(Point topleft_,
                 Dimension size_)

Rectangle

public Rectangle(Point topleft_,
                 Point bottomright_)

Rectangle

public Rectangle(Rectangle rect_)

Rectangle

public Rectangle(int top_,
                 int left_,
                 int bottom_,
                 int right_)
Construct a Rectangle with the specified boundaries.

Method Details

clone

public Object clone()
Returns a clone of this rectangle.

contains

public boolean contains(Point p)
Returns true if the specified point is inside this Rectangle.

contains

public boolean contains(int x,
                        int y)
Returns true if the specified point is inside this Rectangle.

equals

public boolean equals(Rectangle rect_)
Returns true if this rectangle has the same bounds as the specified rectangle.

getBottom

public int getBottom()

getLeft

public int getLeft()

getRight

public int getRight()

getTop

public int getTop()

intersection

public Rectangle intersection(Rectangle rect_)
Return the intersection between this Rectangle and the specified Rectangle, or null if the two rectangles don't intersect.

intersects

public boolean intersects(Rectangle rect_)
Check if the specified rectangle intersects at all with this rectangle.

toString

public String toString()