Package com.adobe.xfa.ut
Class Rect
java.lang.Object
com.adobe.xfa.ut.Rect
A class to describe a rectangle. It consists of left, top, right, and, bottom
extents.
Instances of this class are immutable. All change operations
return a new instance of this Rect
class.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRect()
Instantiates aRect
of zero extents.Instantiates aRect
specified by the givenCoordPair
.Deprecated.Rect is immutable, so there is no need to copy an instance.Instantiates aRect
specified by the givenUnitSpan
extents. -
Method Summary
Modifier and TypeMethodDescriptionReturns aRect
representing the shift of this object by the givenCoordPair
.bottom()
Gets this object's bottommost extent.bottomHeight
(UnitSpan newBottom, UnitSpan newHeight) Returns aRect
representing the change in height of this object by the givenUnitSpan
extents.Gets this object's bottom left coordinate.bottomLeft
(CoordPair newBottomLeft) Returns aRect
representing the extention of this object using the given bottom leftCoordPair
.Gets this object's bottom right coordinate.bottomRight
(CoordPair newBottomRight) Returns aRect
representing the extention of this object using the given bottom rightCoordPair
.centre()
Gets this object's centre coordinate.changeUnits
(int eNewUnits) Returns aRect
representing the change of this object's unit span units to the given unit code.boolean
Determines if this object contains the givenCoordPair
.boolean
Determines if this object contains the givenRect
.boolean
Determines if this object is disjoint from the givenRect
.boolean
Determines if this object is equal to the givenObject
.int
hashCode()
height()
Gets this object's height.Returns aRect
representing the stretch in height of this object by the givenUnitSpan
.intersection
(Rect intersect) Returns aRect
representing the intersection of this object with the givenRect
.boolean
Determines if this object is degenerate.left()
Gets this object's leftmost extent.Returns aRect
representing the change in width of this object by the givenUnitSpan
extents.Returns aRect
representing the change in width of this object by the givenUnitSpan
extents.boolean
Determines if this object is not equal to the givenObject
.boolean
Determines if this object overlaps the givenRect
.right()
Gets this object's rightmost extent.rightWidth
(UnitSpan newRight, UnitSpan newWidth) Returns aRect
representing the change in width of this object by the givenUnitSpan
extents.Returns aRect
representing the rotation of this object about the givenCoordPair
andAngle
of rotation.Returns aRect
representing the shift of this object and the givenCoordPair
.top()
Gets this object's topmost extent.Returns aRect
representing the change in height of this object by the givenUnitSpan
extents.Returns aRect
representing the change in height of this object by the givenUnitSpan
extents.topLeft()
Gets this object's top left coordinate.Returns aRect
representing the extention of this object using the given top leftCoordPair
.topRight()
Gets this object's top right coordinate.Returns aRect
representing the extention of this object using the given top rightCoordPair
.Returns aRect
representing the union of this object with the givenRect
.width()
Gets this object's width.Returns aRect
representing the stretch in width of this object by the givenUnitSpan
.static Rect
zero()
The zero rectangle.
-
Field Details
-
ZERO
-
-
Constructor Details
-
Rect
public Rect()Instantiates aRect
of zero extents. -
Rect
Deprecated.Rect is immutable, so there is no need to copy an instance.Instantiates aRect
from the givenRect
.- Parameters:
source
- theRect
to copy to this object.
-
Rect
Instantiates aRect
specified by the givenCoordPair
.- Parameters:
topLeft
- the top left coordinate of the rectangle.bottomRight
- the bottom right coordinate of the rectangle.
-
Rect
Instantiates aRect
specified by the givenUnitSpan
extents. The rectangle's extents are normalized such that:- the leftmost extent is set to
min(oLeft, oRight)
, - the rightmost extent is set to
max(oLeft, oRight)
, - the topmost extent is set to
min(oTop, oBottom)
, - the bottommost extent is set to
max(oTop, oBottom)
, - the width is set to
|oLeft - oRight|
, and, - the height is set to
|oTop - oBottom|
.
- Parameters:
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.
- the leftmost extent is set to
-
-
Method Details
-
left
Gets this object's leftmost extent.- Returns:
- the leftmost extent.
-
top
Gets this object's topmost extent.- Returns:
- the topmost extent.
-
right
Gets this object's rightmost extent.- Returns:
- the rightmost extent.
-
bottom
Gets this object's bottommost extent.- Returns:
- the bottommost extent.
-
leftRight
Returns aRect
representing the change in width of this object by the givenUnitSpan
extents. The left/right extends are normalized.- Parameters:
newLeft
- the new left extent.newRight
- the new right extent.- Returns:
- a rectangle of the changed width.
-
topBottom
Returns aRect
representing the change in height of this object by the givenUnitSpan
extents.- Parameters:
newTop
- the new left extent.newBottom
- the new bottom extent.- Returns:
- a rectangle of the changed height.
-
leftWidth
Returns aRect
representing the change in width of this object by the givenUnitSpan
extents.- Parameters:
newLeft
- the new left extent.newWidth
- the new width.- Returns:
- a rectangle of the changed width.
-
rightWidth
Returns aRect
representing the change in width of this object by the givenUnitSpan
extents.- Parameters:
newRight
- the new right extent.newWidth
- the new width.- Returns:
- a rectangle of the changed width.
-
topHeight
Returns aRect
representing the change in height of this object by the givenUnitSpan
extents.- Parameters:
newTop
- the new top extent.newHeight
- the new height.- Returns:
- a rectangle of the changed height.
-
bottomHeight
Returns aRect
representing the change in height of this object by the givenUnitSpan
extents.- Parameters:
newBottom
- the new bottom extent.newHeight
- the new height.- Returns:
- a rectangle of the changed height.
-
topLeft
Gets this object's top left coordinate.- Returns:
- the top left coordinate.
-
topRight
Gets this object's top right coordinate.- Returns:
- the top right coordinate.
-
bottomLeft
Gets this object's bottom left coordinate.- Returns:
- the bottom left coordinate.
-
bottomRight
Gets this object's bottom right coordinate.- Returns:
- the bottom right coordinate.
-
changeUnits
Returns aRect
representing the change of this object's unit span units to the given unit code.- Parameters:
eNewUnits
- the new unit code.- Returns:
- a rectangle of the change.
-
topLeft
Returns aRect
representing the extention of this object using the given top leftCoordPair
.- Parameters:
newTopLeft
- the new top left coordinate.- Returns:
- a rectangle of the extention.
-
topRight
Returns aRect
representing the extention of this object using the given top rightCoordPair
.- Parameters:
newTopRight
- the new top right coordinate.- Returns:
- a rectangle of the extention.
-
bottomLeft
Returns aRect
representing the extention of this object using the given bottom leftCoordPair
.- Parameters:
newBottomLeft
- the new bottom left coordinate.- Returns:
- a rectangle of the extention.
-
bottomRight
Returns aRect
representing the extention of this object using the given bottom rightCoordPair
.- Parameters:
newBottomRight
- the new bottom right coordinate.- Returns:
- a rectangle of the extention.
-
height
Gets this object's height.- Returns:
- the height.
-
width
Gets this object's width.- Returns:
- the width.
-
height
Returns aRect
representing the stretch in height of this object by the givenUnitSpan
.- Parameters:
newHeight
- the new height.bStretchTop
- stretch from the top when set; stretch from the bottom when not set.- Returns:
- a rectangle of the stretched height.
-
width
Returns aRect
representing the stretch in width of this object by the givenUnitSpan
.- Parameters:
newWidth
- the new width.bStretchLeft
- stretch from the left when set; stretch from the right when not set.- Returns:
- a rectangle of the stretched width.
-
centre
Gets this object's centre coordinate.- Returns:
- the center of the rectangle.
-
contains
Determines if this object contains the givenCoordPair
.- Parameters:
point
- a coordinate.- Returns:
- true if the coordinate is contained, false otherwise
-
contains
Determines if this object contains the givenRect
.- Parameters:
rect
- a rectangle.- Returns:
- true if given the rectangle is contained, false otherwise
-
overlaps
Determines if this object overlaps the givenRect
.- Parameters:
rect
- a rectangle.- Returns:
- true if the rectangle overlaps, false otherwise
-
disjoint
Determines if this object is disjoint from the givenRect
. This is slightly different than the result of! overlaps()
in that, if the rectangles share an edge, this will return true.- Parameters:
rect
- a rectangle.- Returns:
- true if the rectangle is disjoint, false otherwise
- See Also:
-
isDegenerate
public boolean isDegenerate()Determines if this object is degenerate. Only the zero rectangle is degenerate.- Returns:
- true if this rectangle is degenerate, false otherwise
- See Also:
-
rotate
Returns aRect
representing the rotation of this object about the givenCoordPair
andAngle
of rotation.- Parameters:
point
- the point of rotation.angle
- the angle of rotation.- Returns:
- a rectangle of the rotation.
-
equals
Determines if this object is equal to the givenObject
. Comparisons with instances of non-Rect
objects are never equal. -
hashCode
public int hashCode() -
notEquals
Determines if this object is not equal to the givenObject
. Comparisons with instances of non-Rect
objects are always not equal.- Parameters:
compare
- theObject
to compare.- Returns:
- true if not equal, false otherwise
-
add
Returns aRect
representing the shift of this object by the givenCoordPair
.- Parameters:
add
- theCoordPair
to add.- Returns:
- a rectangle of the shift.
-
subtract
Returns aRect
representing the shift of this object and the givenCoordPair
.- Parameters:
subtract
- theCoordPair
to subtract.- Returns:
- a rectangle of the shift.
-
union
Returns aRect
representing the union of this object with the givenRect
.- Parameters:
union
- theRect
to unite with.- Returns:
- a rectangle of the union.
-
intersection
Returns aRect
representing the intersection of this object with the givenRect
.- Parameters:
intersect
- theRect
to intersect with.- Returns:
- a rectangle of the intersection.
-
zero
The zero rectangle.- Returns:
- the rectangle equal to zero.
-