java::awt::Rectangle Class Reference

Inheritance diagram for java::awt::Rectangle:

Inheritance graph
java::awt::geom::Rectangle2Djava::awt::geom::RectangularShapejava::awt::Shapejava::lang::Interfacejava::lang::Objectjava::awt::geom::Point2Djava::awt::geom::Dimension2Djava::awt::Pointjava::awt::Dimension
[legend]
Collaboration diagram for java::awt::Rectangle:

Collaboration graph
java::awt::geom::Rectangle2Djava::awt::geom::RectangularShapejava::awt::Shapejava::lang::Interfacejava::lang::Objectjava::awt::geom::Point2Djava::awt::geom::Dimension2Djava::awt::Pointjava::awt::Dimension
[legend]

List of all members.


Detailed Description

A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-left point (xy) in the coordinate space, its width, and its height.

A Rectangle object's width and height are public fields. The constructors that create a Rectangle, and the methods that can modify one, do not prevent setting a negative value for width or height.

A Rectangle whose width or height is negative is considered empty. If the Rectangle is empty, then the isEmpty method returns true. No point can be contained by or inside an empty Rectangle. The values of width and height, however, are still valid. An empty Rectangle still has a location in the coordinate space, and methods that change its size or location remain valid. The behavior of methods that operate on more than one Rectangle is undefined if any of the participating Rectangle objects has a negative width or height. These methods include intersects, intersection, and union.

Version:
1.65, 01/23/03
Author:
Sami Shaio
Since:
JDK1.0

Public Member Functions

 Rectangle ()
 Constructs a new Rectangle whose top-left corner is at (0, 0) in the coordinate space, and whose width and height are both zero.
 Rectangle (jint x, jint y, jint w, jint h)
 Constructs a new Rectangle whose top-left corner is specified as (xy) and whose width and height are specified by the arguments of the same name.
 Rectangle (jint w, jint h)
 Constructs a new Rectangle whose top-left corner is at (0, 0) in the coordinate space, and whose width and height are specified by the arguments of the same name.
 Rectangle (const Point &p, const Dimension &d)
 Constructs a new Rectangle whose top-left corner is specified by the Point argument, and whose width and height are specified by the Dimension argument.
 Rectangle (const Point &p)
 Constructs a new Rectangle whose top-left corner is the specified Point, and whose width and height are both zero.
 Rectangle (const Dimension &d)
 Constructs a new Rectangle whose top left corner is (0, 0) and whose width and height are specified by the Dimension argument.
virtual jdouble getX () const
 Returns the X coordinate of the bounding Rectangle in double precision.
virtual jdouble getY () const
 Returns the Y coordinate of the bounding Rectangle in double precision.
virtual jdouble getWidth () const
 Returns the width of the bounding Rectangle in double precision.
virtual jdouble getHeight () const
 Returns the height of the bounding Rectangle in double precision.
virtual Rectangle getBounds () const
 Gets the bounding Rectangle of this Rectangle.
virtual Ref
< geom::Rectangle2D
getBounds2D () const
 Return the high precision bounding box of this rectangle.
virtual void setBounds (const Rectangle &r)
 Sets the bounding Rectangle of this Rectangle to match the specified Rectangle.
virtual void setBounds (jint x, jint y, jint width, jint height)
 Sets the bounding Rectangle of this Rectangle to the specified x, y, width, and height.
virtual void setRect (jdouble x, jdouble y, jdouble width, jdouble height)
 Sets the bounds of this Rectangle to the specified x, y, width, and height.
virtual jboolean contains (const Point &p) const
 Checks whether or not this Rectangle contains the specified Point.
virtual jboolean contains (jint _x, jint _y) const
 Checks whether or not this Rectangle contains the point at the specified location (xy).
virtual jboolean contains (const Rectangle &r) const
 Checks whether or not this Rectangle entirely contains the specified Rectangle.
virtual jboolean contains (jint _x, jint _y, jint _w, jint _h) const
 Checks whether this Rectangle entirely contains the Rectangle at the specified location (XY) with the specified dimensions (WH).
virtual jboolean intersects (const Rectangle &r) const
 Determines whether or not this Rectangle and the specified Rectangle intersect.
virtual jboolean intersects (jint _x, jint _y, jint _w, jint _h) const
 Tests if the interior of this Rectangle intersects the interior of a specified set of rectangular coordinates.
Rectangle intersection (const Rectangle &r) const
 Computes the intersection of this Rectangle with the specified Rectangle.
Rectangle unionOf (const Rectangle &r) const
 Computes the union of this Rectangle with the specified Rectangle.
virtual void add (jint newx, jint newy)
 Adds a point, specified by the integer arguments newx and newy, to this Rectangle.
virtual void add (const Point &pt)
 Adds the specified Point to this Rectangle.
virtual void add (const Rectangle &r)
 Adds a Rectangle to this Rectangle.
virtual void grow (jint h, jint v)
 Resizes the Rectangle both horizontally and vertically.
virtual jboolean isEmpty () const
 Determines whether or not this Rectangle is empty.
virtual jint outcode (jdouble x, jdouble y) const
 Determines where the specified coordinates lie with respect to this Rectangle.
virtual Ref
< geom::Rectangle2D
createIntersection (const geom::Rectangle2D &r) const
 Returns a new Rectangle2D object representing the intersection of this Rectangle with the specified Rectangle2D.
virtual Ref
< geom::Rectangle2D
createUnion (const geom::Rectangle2D &r) const
 Returns a new Rectangle2D object representing the union of this Rectangle with the specified Rectangle2D.
virtual jint hashCode () const
 Returns the hashcode for this Rectangle2D.
virtual jboolean equals (const Object &obj) const
 Checks whether two rectangles are equal.
virtual String toString () const
 Returns a String representing this Rectangle and its values.

Constructor & Destructor Documentation

java::awt::Rectangle::Rectangle (  ) 

Constructs a new Rectangle whose top-left corner is at (0, 0) in the coordinate space, and whose width and height are both zero.

java::awt::Rectangle::Rectangle ( jint  x,
jint  y,
jint  w,
jint  h 
)

Constructs a new Rectangle whose top-left corner is specified as (xy) and whose width and height are specified by the arguments of the same name.

Parameters:
x the specified x coordinate
y the specified y coordinate
width the width of the Rectangle
height the height of the Rectangle

java::awt::Rectangle::Rectangle ( jint  w,
jint  h 
)

Constructs a new Rectangle whose top-left corner is at (0, 0) in the coordinate space, and whose width and height are specified by the arguments of the same name.

Parameters:
width the width of the Rectangle
height the height of the Rectangle

java::awt::Rectangle::Rectangle ( const Point p,
const Dimension d 
)

Constructs a new Rectangle whose top-left corner is specified by the Point argument, and whose width and height are specified by the Dimension argument.

Parameters:
p a Point that is the top-left corner of the Rectangle
d a Dimension, representing the width and height of the Rectangle

java::awt::Rectangle::Rectangle ( const Point p  ) 

Constructs a new Rectangle whose top-left corner is the specified Point, and whose width and height are both zero.

Parameters:
p a Point that is the top left corner of the Rectangle

java::awt::Rectangle::Rectangle ( const Dimension d  ) 

Constructs a new Rectangle whose top left corner is (0, 0) and whose width and height are specified by the Dimension argument.

Parameters:
d a Dimension, specifying width and height


Member Function Documentation

virtual jdouble java::awt::Rectangle::getX (  )  const [virtual]

Returns the X coordinate of the bounding Rectangle in double precision.

Returns:
the x coordinate of the bounding Rectangle.

Reimplemented from java::awt::Point.

virtual jdouble java::awt::Rectangle::getY (  )  const [virtual]

Returns the Y coordinate of the bounding Rectangle in double precision.

Returns:
the y coordinate of the bounding Rectangle.

Reimplemented from java::awt::Point.

virtual jdouble java::awt::Rectangle::getWidth (  )  const [virtual]

Returns the width of the bounding Rectangle in double precision.

Returns:
the width of the bounding Rectangle.

Reimplemented from java::awt::Dimension.

virtual jdouble java::awt::Rectangle::getHeight (  )  const [virtual]

Returns the height of the bounding Rectangle in double precision.

Returns:
the height of the bounding Rectangle.

Reimplemented from java::awt::Dimension.

virtual Rectangle java::awt::Rectangle::getBounds (  )  const [virtual]

Gets the bounding Rectangle of this Rectangle.

This method is included for completeness, to parallel the getBounds method of Component.

Returns:
a new Rectangle, equal to the bounding Rectangle for this Rectangle.
See also:
java.awt.Component::getBounds

setBounds(Rectangle)

setBounds(int, int, int, int)

Since:
JDK1.1

Reimplemented from java::awt::geom::RectangularShape.

virtual Ref<geom::Rectangle2D> java::awt::Rectangle::getBounds2D (  )  const [virtual]

Return the high precision bounding box of this rectangle.

Since:
1.2

Reimplemented from java::awt::geom::Rectangle2D.

virtual void java::awt::Rectangle::setBounds ( const Rectangle r  )  [virtual]

Sets the bounding Rectangle of this Rectangle to match the specified Rectangle.

This method is included for completeness, to parallel the setBounds method of Component.

Parameters:
r the specified Rectangle
See also:
getBounds

java.awt.Component::setBounds(java.awt.Rectangle)

Since:
JDK1.1

virtual void java::awt::Rectangle::setBounds ( jint  x,
jint  y,
jint  width,
jint  height 
) [virtual]

Sets the bounding Rectangle of this Rectangle to the specified x, y, width, and height.

This method is included for completeness, to parallel the setBounds method of Component.

Parameters:
x the new x coordinate for the top-left corner of this Rectangle
y the new y coordinate for the top-left corner of this Rectangle
width the new width for this Rectangle
height the new height for this Rectangle
See also:
getBounds

java.awt.Component::setBounds(int, int, int, int)

Since:
JDK1.1

virtual void java::awt::Rectangle::setRect ( jdouble  x,
jdouble  y,
jdouble  width,
jdouble  height 
) [virtual]

Sets the bounds of this Rectangle to the specified x, y, width, and height.

This method is included for completeness, to parallel the setBounds method of Component.

Parameters:
x the x coordinate of the upper-left corner of the specified rectangle
y the y coordinate of the upper-left corner of the specified rectangle
width the new width for the Dimension object
height the new height for the Dimension object

Implements java::awt::geom::Rectangle2D.

virtual jboolean java::awt::Rectangle::contains ( const Point p  )  const [virtual]

Checks whether or not this Rectangle contains the specified Point.

Parameters:
p the Point to test
Returns:
true if the Point (xy) is inside this Rectangle; false otherwise.
Since:
JDK1.1

virtual jboolean java::awt::Rectangle::contains ( jint  _x,
jint  _y 
) const [virtual]

Checks whether or not this Rectangle contains the point at the specified location (xy).

Parameters:
_x the specified x coordinate
_y the specified y coordinate
Returns:
true if the point (xy) is inside this Rectangle; false otherwise.
Since:
JDK1.1

virtual jboolean java::awt::Rectangle::contains ( const Rectangle r  )  const [virtual]

Checks whether or not this Rectangle entirely contains the specified Rectangle.

Parameters:
r the specified Rectangle
Returns:
true if the Rectangle is contained entirely inside this Rectangle; false otherwise.
Since:
JDK1.1

virtual jboolean java::awt::Rectangle::contains ( jint  _x,
jint  _y,
jint  _w,
jint  _h 
) const [virtual]

Checks whether this Rectangle entirely contains the Rectangle at the specified location (XY) with the specified dimensions (WH).

Parameters:
_x the specified x coordinate
_y the specified y coordinate
_w the width of the Rectangle
_h the height of the Rectangle
Returns:
true if the Rectangle specified by (XYWH) is entirely enclosed inside this Rectangle; false otherwise.
Since:
JDK1.1

virtual jboolean java::awt::Rectangle::intersects ( const Rectangle r  )  const [virtual]

Determines whether or not this Rectangle and the specified Rectangle intersect.

Two rectangles intersect if their intersection is nonempty.

Parameters:
r the specified Rectangle
Returns:
true if the specified Rectangle and this Rectangle intersect; false otherwise.

virtual jboolean java::awt::Rectangle::intersects ( jint  _x,
jint  _y,
jint  _w,
jint  _h 
) const [virtual]

Tests if the interior of this Rectangle intersects the interior of a specified set of rectangular coordinates.

Parameters:
x,&nbsp;y the coordinates of the upper left corner of the specified set of rectangular coordinates
w the width of the specified set of rectangular coordinates
h the height of the specified set of rectangular coordinates
Returns:
true if this Rectangle intersects the interior of a specified set of rectangular coordinates; false otherwise.
Since:
1.2

Rectangle java::awt::Rectangle::intersection ( const Rectangle r  )  const

Computes the intersection of this Rectangle with the specified Rectangle.

Returns a new Rectangle that represents the intersection of the two rectangles. If the two rectangles do not intersect, the result will be an empty rectangle.

Parameters:
r the specified Rectangle
Returns:
the largest Rectangle contained in both the specified Rectangle and in this Rectangle; or if the rectangles do not intersect, an empty rectangle.

Rectangle java::awt::Rectangle::unionOf ( const Rectangle r  )  const

Computes the union of this Rectangle with the specified Rectangle.

Returns a new Rectangle that represents the union of the two rectangles

Parameters:
r the specified Rectangle
Returns:
the smallest Rectangle containing both the specified Rectangle and this Rectangle.

virtual void java::awt::Rectangle::add ( jint  newx,
jint  newy 
) [virtual]

Adds a point, specified by the integer arguments newx and newy, to this Rectangle.

The resulting Rectangle is the smallest Rectangle that contains both the original Rectangle and the specified point.

After adding a point, a call to contains with the added point as an argument does not necessarily return true. The contains method does not return true for points on the right or bottom edges of a Rectangle. Therefore, if the added point falls on the right or bottom edge of the enlarged Rectangle, contains returns false for that point.

Parameters:
newx the x coordinate of the new point
newy the y coordinate of the new point

virtual void java::awt::Rectangle::add ( const Point pt  )  [virtual]

Adds the specified Point to this Rectangle.

The resulting Rectangle is the smallest Rectangle that contains both the original Rectangle and the specified Point.

After adding a Point, a call to contains with the added Point as an argument does not necessarily return true. The contains method does not return true for points on the right or bottom edges of a Rectangle. Therefore if the added Point falls on the right or bottom edge of the enlarged Rectangle, contains returns false for that Point.

Parameters:
pt the new Point to add to this Rectangle

virtual void java::awt::Rectangle::add ( const Rectangle r  )  [virtual]

Adds a Rectangle to this Rectangle.

The resulting Rectangle is the union of the two rectangles.

Parameters:
r the specified Rectangle

virtual void java::awt::Rectangle::grow ( jint  h,
jint  v 
) [virtual]

Resizes the Rectangle both horizontally and vertically.

This method modifies the Rectangle so that it is h units larger on both the left and right side, and v units larger at both the top and bottom.

The new Rectangle has (x - h, y - v) as its top-left corner, a width of width + 2h, and a height of height + 2v.

If negative values are supplied for h and v, the size of the Rectangle decreases accordingly. The grow method does not check whether the resulting values of width and height are non-negative.

Parameters:
h the horizontal expansion
v the vertical expansion

virtual jboolean java::awt::Rectangle::isEmpty (  )  const [virtual]

Determines whether or not this Rectangle is empty.

A Rectangle is empty if its width or its height is less than or equal to zero.

Returns:
true if this Rectangle is empty; false otherwise.

Implements java::awt::geom::RectangularShape.

virtual jint java::awt::Rectangle::outcode ( jdouble  x,
jdouble  y 
) const [virtual]

Determines where the specified coordinates lie with respect to this Rectangle.

This method computes a binary OR of the appropriate mask values indicating, for each side of this Rectangle, whether or not the specified coordinates are on the same side of the edge as the rest of this Rectangle.

Parameters:
x the specified x coordinate
y the specified y coordinate
Returns:
the logical OR of all appropriate out codes.
See also:
OUT_LEFT

OUT_TOP

OUT_RIGHT

OUT_BOTTOM

Since:
1.2

Implements java::awt::geom::Rectangle2D.

virtual Ref<geom::Rectangle2D> java::awt::Rectangle::createIntersection ( const geom::Rectangle2D r  )  const [virtual]

Returns a new Rectangle2D object representing the intersection of this Rectangle with the specified Rectangle2D.

Parameters:
r the Rectangle2D to be intersected with this Rectangle
Returns:
the largest Rectangle2D contained in both the specified Rectangle2D and in this Rectangle.
Since:
1.2

Implements java::awt::geom::Rectangle2D.

virtual Ref<geom::Rectangle2D> java::awt::Rectangle::createUnion ( const geom::Rectangle2D r  )  const [virtual]

Returns a new Rectangle2D object representing the union of this Rectangle with the specified Rectangle2D.

Parameters:
r the Rectangle2D to be combined with this Rectangle
Returns:
the smallest Rectangle2D containing both the specified Rectangle2D and this Rectangle.
Since:
1.2

Implements java::awt::geom::Rectangle2D.

virtual jint java::awt::Rectangle::hashCode (  )  const [virtual]

Returns the hashcode for this Rectangle2D.

Returns:
the hashcode for this Rectangle2D.

Reimplemented from java::awt::Dimension.

virtual jboolean java::awt::Rectangle::equals ( const Object obj  )  const [virtual]

Checks whether two rectangles are equal.

The result is true if and only if the argument is not null and is a Rectangle object that has the same top-left corner, width, and height as this Rectangle.

Parameters:
obj the Object to compare with this Rectangle
Returns:
true if the objects are equal; false otherwise.

Reimplemented from java::awt::Dimension.

virtual String java::awt::Rectangle::toString (  )  const [virtual]

Returns a String representing this Rectangle and its values.

Returns:
a String representing this Rectangle object's coordinate and size values.

Reimplemented from java::awt::Dimension.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:07 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3