public final class Rect extends Object
Instances of this class are immutable. All change operations
return a new instance of this Rect
class.
Constructor and Description |
---|
Rect()
Instantiates a
Rect of zero extents. |
Rect(CoordPair topLeft,
CoordPair bottomRight)
Instantiates a
Rect
specified by the given CoordPair . |
Rect(Rect source)
Deprecated.
Rect is immutable, so there is no need to copy an instance.
|
Rect(UnitSpan left,
UnitSpan top,
UnitSpan right,
UnitSpan bottom)
Instantiates a
Rect
specified by the given UnitSpan extents. |
Modifier and Type | Method and Description |
---|---|
Rect |
add(CoordPair add)
Returns a
Rect representing the
shift of this object by the given CoordPair . |
UnitSpan |
bottom()
Gets this object's bottommost extent.
|
Rect |
bottomHeight(UnitSpan newBottom,
UnitSpan newHeight)
Returns a
Rect representing the
change in height of this object by the given UnitSpan extents. |
CoordPair |
bottomLeft()
Gets this object's bottom left coordinate.
|
Rect |
bottomLeft(CoordPair newBottomLeft)
Returns a
Rect representing the
extention of this object using the given bottom left CoordPair . |
CoordPair |
bottomRight()
Gets this object's bottom right coordinate.
|
Rect |
bottomRight(CoordPair newBottomRight)
Returns a
Rect representing the
extention of this object using the given bottom right CoordPair . |
CoordPair |
centre()
Gets this object's centre coordinate.
|
Rect |
changeUnits(int eNewUnits)
Returns a
Rect representing the
change of this object's unit span units to the given unit code. |
boolean |
contains(CoordPair point)
Determines if this object contains the given
CoordPair . |
boolean |
contains(Rect rect)
Determines if this object contains the given
Rect . |
boolean |
disjoint(Rect rect)
Determines if this object is disjoint from the given
Rect . |
boolean |
equals(Object object)
Determines if this object is equal to the given
Object . |
int |
hashCode() |
UnitSpan |
height()
Gets this object's height.
|
Rect |
height(UnitSpan newHeight,
boolean bStretchTop)
Returns a
Rect representing the
stretch in height of this object by the given UnitSpan . |
Rect |
intersection(Rect intersect)
Returns a
Rect representing the
intersection of this object with the given Rect . |
boolean |
isDegenerate()
Determines if this object is degenerate.
|
UnitSpan |
left()
Gets this object's leftmost extent.
|
Rect |
leftRight(UnitSpan newLeft,
UnitSpan newRight)
Returns a
Rect representing the
change in width of this object by the given UnitSpan extents. |
Rect |
leftWidth(UnitSpan newLeft,
UnitSpan newWidth)
Returns a
Rect representing the
change in width of this object by the given UnitSpan extents. |
boolean |
notEquals(Object compare)
Determines if this object is not equal to the given
Object . |
boolean |
overlaps(Rect rect)
Determines if this object overlaps the given
Rect . |
UnitSpan |
right()
Gets this object's rightmost extent.
|
Rect |
rightWidth(UnitSpan newRight,
UnitSpan newWidth)
Returns a
Rect representing the
change in width of this object by the given UnitSpan extents. |
Rect |
rotate(CoordPair point,
Angle angle)
Returns a
Rect representing the rotation
of this object about the given CoordPair
and Angle of rotation. |
Rect |
subtract(CoordPair subtract)
Returns a
Rect representing the
shift of this object and the given CoordPair . |
UnitSpan |
top()
Gets this object's topmost extent.
|
Rect |
topBottom(UnitSpan newTop,
UnitSpan newBottom)
Returns a
Rect representing the
change in height of this object by the given UnitSpan extents. |
Rect |
topHeight(UnitSpan newTop,
UnitSpan newHeight)
Returns a
Rect representing the
change in height of this object by the given UnitSpan extents. |
CoordPair |
topLeft()
Gets this object's top left coordinate.
|
Rect |
topLeft(CoordPair newTopLeft)
Returns a
Rect representing the
extention of this object using the given top left CoordPair . |
CoordPair |
topRight()
Gets this object's top right coordinate.
|
Rect |
topRight(CoordPair newTopRight)
Returns a
Rect representing the
extention of this object using the given top right CoordPair . |
Rect |
union(Rect union)
Returns a
Rect representing the
union of this object with the given Rect . |
UnitSpan |
width()
Gets this object's width.
|
Rect |
width(UnitSpan newWidth,
boolean bStretchLeft)
Returns a
Rect representing the
stretch in width of this object by the given UnitSpan . |
static Rect |
zero()
The zero rectangle.
|
public static final Rect ZERO
public Rect()
Rect
of zero extents.public Rect(Rect source)
Rect
from the
given Rect
.source
- the Rect
to copy to this object.public Rect(CoordPair topLeft, CoordPair bottomRight)
Rect
specified by the given CoordPair
.topLeft
- the top left coordinate of the rectangle.bottomRight
- the bottom right coordinate of the rectangle.public Rect(UnitSpan left, UnitSpan top, UnitSpan right, UnitSpan bottom)
Rect
specified by the given UnitSpan
extents.
The rectangle's extents are normalized such that:
min(oLeft, oRight)
,
max(oLeft, oRight)
,
min(oTop, oBottom)
,
max(oTop, oBottom)
,
|oLeft - oRight|
, and,
|oTop - oBottom|
.
left
- the left extent of the rectangle.top
- the top extent of the rectangle.right
- the right extent of the rectangle.bottom
- the bottom extent of the rectangle.public UnitSpan left()
public UnitSpan top()
public UnitSpan right()
public UnitSpan bottom()
public Rect leftRight(UnitSpan newLeft, UnitSpan newRight)
Rect
representing the
change in width of this object by the given UnitSpan
extents.
The left/right extends are normalized.newLeft
- the new left extent.newRight
- the new right extent.public Rect topBottom(UnitSpan newTop, UnitSpan newBottom)
Rect
representing the
change in height of this object by the given UnitSpan
extents.newTop
- the new left extent.newBottom
- the new bottom extent.public Rect leftWidth(UnitSpan newLeft, UnitSpan newWidth)
Rect
representing the
change in width of this object by the given UnitSpan
extents.newLeft
- the new left extent.newWidth
- the new width.public Rect rightWidth(UnitSpan newRight, UnitSpan newWidth)
Rect
representing the
change in width of this object by the given UnitSpan
extents.newRight
- the new right extent.newWidth
- the new width.public Rect topHeight(UnitSpan newTop, UnitSpan newHeight)
Rect
representing the
change in height of this object by the given UnitSpan
extents.newTop
- the new top extent.newHeight
- the new height.public Rect bottomHeight(UnitSpan newBottom, UnitSpan newHeight)
Rect
representing the
change in height of this object by the given UnitSpan
extents.newBottom
- the new bottom extent.newHeight
- the new height.public CoordPair topLeft()
public CoordPair topRight()
public CoordPair bottomLeft()
public CoordPair bottomRight()
public Rect changeUnits(int eNewUnits)
Rect
representing the
change of this object's unit span units to the given unit code.eNewUnits
- the new unit code.public Rect topLeft(CoordPair newTopLeft)
Rect
representing the
extention of this object using the given top left CoordPair
.newTopLeft
- the new top left coordinate.public Rect topRight(CoordPair newTopRight)
Rect
representing the
extention of this object using the given top right CoordPair
.newTopRight
- the new top right coordinate.public Rect bottomLeft(CoordPair newBottomLeft)
Rect
representing the
extention of this object using the given bottom left CoordPair
.newBottomLeft
- the new bottom left coordinate.public Rect bottomRight(CoordPair newBottomRight)
Rect
representing the
extention of this object using the given bottom right CoordPair
.newBottomRight
- the new bottom right coordinate.public UnitSpan height()
public UnitSpan width()
public Rect height(UnitSpan newHeight, boolean bStretchTop)
Rect
representing the
stretch in height of this object by the given UnitSpan
.newHeight
- the new height.bStretchTop
- stretch from the top when set; stretch from the bottom when not set.public Rect width(UnitSpan newWidth, boolean bStretchLeft)
Rect
representing the
stretch in width of this object by the given UnitSpan
.newWidth
- the new width.bStretchLeft
- stretch from the left when set; stretch from the right when not set.public CoordPair centre()
public boolean contains(CoordPair point)
CoordPair
.point
- a coordinate.public boolean contains(Rect rect)
Rect
.rect
- a rectangle.public boolean overlaps(Rect rect)
Rect
.rect
- a rectangle.public boolean disjoint(Rect rect)
Rect
.
This is slightly different than the result of ! overlaps()
in that, if the rectangles share an edge, this will return true.rect
- a rectangle.overlaps(Rect)
public boolean isDegenerate()
zero()
public Rect rotate(CoordPair point, Angle angle)
Rect
representing the rotation
of this object about the given CoordPair
and Angle
of rotation.point
- the point of rotation.angle
- the angle of rotation.public boolean equals(Object object)
Object
.
Comparisons with instances of non-Rect
objects are never equal.public boolean notEquals(Object compare)
Object
.
Comparisons with instances of non-Rect
objects are always not equal.compare
- the Object
to compare.public Rect add(CoordPair add)
Rect
representing the
shift of this object by the given CoordPair
.add
- the CoordPair
to add.public Rect subtract(CoordPair subtract)
Rect
representing the
shift of this object and the given CoordPair
.subtract
- the CoordPair
to subtract.public Rect union(Rect union)
Rect
representing the
union of this object with the given Rect
.union
- the Rect
to unite with.public Rect intersection(Rect intersect)
Rect
representing the
intersection of this object with the given Rect
.intersect
- the Rect
to intersect with.public static Rect zero()
Copyright © 2010 - 2020 Adobe. All Rights Reserved