|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaclib.Rect
public class Rect
This class implements QuickDraw-like definitions for rectangles. Implements also object methods for these rectangles.
MacLib
,
Rectangle
Field Summary | |
---|---|
short |
bottom
The y coordinate of the bottom right corner. |
short |
left
The x coordinate of the top left corner. |
short |
right
The x coordinate of the bottom right corner. |
short |
top
The y coordinate of the top left corner. |
Constructor Summary | |
---|---|
Rect()
Constructs and initializes an empty rect with coordinates (0,0,0,0) . |
|
Rect(int left,
int top,
int right,
int bottom)
Constructs and initializes a rectangle with the given coordinates. |
|
Rect(Point p1,
Point p2)
Constructs and initializes a rectangle as the smallest one which encloses the two given points. |
|
Rect(Rect src1,
Rect src2)
Constructs and initializes a rectangle as the smallest one which encloses the two given rectangles. |
Method Summary | |
---|---|
Point |
botRight()
Returns the bottom right corner of this rectangle. |
boolean |
emptyRect()
Determines whether this rectangle is empty or not. |
boolean |
equalRect(Rect r)
Determines whether this rectangle and the given rectangle have the same coordinates. |
java.awt.Rectangle |
getRectangle()
Converts this rectangle as a java.awt.Rectangle object. |
int |
hashCode()
Returns a hash code for this rectangle. |
Rect |
insetRect(int dh,
int dv)
Shrinks or expands this rectangle by the specified amounts. |
Rect |
offsetRect(int dh,
int dv)
Translates this rectangle by the specified displacement. |
Rect |
pt2Rect(Point p1,
Point p2)
Sets the coordinates of this rectangle to the smallest one which encloses the two given points. |
boolean |
ptInRect(Point pt)
Determines whether the pixel below and to the right of the given point is enclosed in this rectangle. |
boolean |
sectRect(Rect src1,
Rect src2)
Sets the coordinates of this rectangle to the rectangle that is the intersection of the two given rectangles. |
Rect |
setRect(int left,
int top,
int right,
int bottom)
Sets the coordinates of this rectangle as specified. |
Rect |
setRect(Rect src)
Sets the coordinates of this rectangle as specified by the given Rect object. |
Rect |
setRect(java.awt.Rectangle rec)
Sets the coordinates of this rectangle as specified by the given java.awt.Rectangle object. |
Point |
topLeft()
Returns the top left corner of this rectangle. |
java.lang.String |
toString()
Returns a string representation for the location of this rectangle. |
Rect |
unionRect(Rect src1,
Rect src2)
Sets the coordinates of this rectangle to the smallest one which encloses the two given rectangles. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public short left
public short top
public short right
public short bottom
Constructor Detail |
---|
public Rect()
(0,0,0,0)
.
public Rect(int left, int top, int right, int bottom)
left
- the left coordinate of the new rectangle.top
- the top coordinate of the new rectangle.right
- the right coordinate of the new rectangle.bottom
- the bottom coordinate of the new rectangle.public Rect(Point p1, Point p2)
p1
- the first Point object used to specify the coordinates.p2
- the second Point object used to specify the coordinates.public Rect(Rect src1, Rect src2)
src1
- the first Rect object used to specify the
coordinates.src2
- the second Rect object used to specify the
coordinates.Method Detail |
---|
public Point topLeft()
public Point botRight()
public java.awt.Rectangle getRectangle()
java.awt.Rectangle
object.
Rectangle
public Rect setRect(int left, int top, int right, int bottom)
left
- the new left coordinate.top
- the new top coordinate.right
- the new right coordinate.bottom
- the new bottom coordinate.public Rect setRect(Rect src)
Rect
object.
src
- the Rect object used to specify the coordinates.public Rect setRect(java.awt.Rectangle rec)
java.awt.Rectangle
object.
rec
- the Rectangle object used to specify the coordinates.Rectangle
public Rect pt2Rect(Point p1, Point p2)
p1
- the first Point object used to specify the coordinates.p2
- the second Point object used to specify the coordinates.public Rect offsetRect(int dh, int dv)
dh
to each horizontal coordinate and dv
to each vertical coordinate.
dh
- the horizontal displacement.dv
- the vertical displacement.public Rect insetRect(int dh, int dv)
dh
to the left coordinate and
subtracts dh
from the right coordinate.
Adds dv
to the top coordinate and
subtracts dv
from the bottom coordinate.
dh
- the horizontal displacement.dv
- the vertical displacement.public Rect unionRect(Rect src1, Rect src2)
src1
- the first Rect object used to specify the
coordinates.src2
- the second Rect object used to specify the
coordinates.public boolean equalRect(Rect r)
r
- the Rect object to compare with.
true
if both rectangles have same coordinates;
false
otherwise.public boolean sectRect(Rect src1, Rect src2)
(0,0,0,0)
.
src1
- the first Rect object used to specify the
coordinates.src2
- the second Rect object used to specify the
coordinates.
true
if the two rectangles really intersect;
false
otherwise.public boolean ptInRect(Point pt)
pt
- the Point object to check with.
true
if so; false
otherwise.Point.inRect(Rect)
public boolean emptyRect()
true
if so; false
otherwise.public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |