Package com.adobe.xfa.ut
Class Rect
- java.lang.Object
-
- com.adobe.xfa.ut.Rect
-
public final class Rect extends java.lang.ObjectA 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
Rectclass.
-
-
Constructor Summary
Constructors Constructor Description Rect()Instantiates aRectof zero extents.Rect(CoordPair topLeft, CoordPair bottomRight)Instantiates aRectspecified by the givenCoordPair.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 aRectspecified by the givenUnitSpanextents.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Rectadd(CoordPair add)Returns aRectrepresenting the shift of this object by the givenCoordPair.UnitSpanbottom()Gets this object's bottommost extent.RectbottomHeight(UnitSpan newBottom, UnitSpan newHeight)Returns aRectrepresenting the change in height of this object by the givenUnitSpanextents.CoordPairbottomLeft()Gets this object's bottom left coordinate.RectbottomLeft(CoordPair newBottomLeft)Returns aRectrepresenting the extention of this object using the given bottom leftCoordPair.CoordPairbottomRight()Gets this object's bottom right coordinate.RectbottomRight(CoordPair newBottomRight)Returns aRectrepresenting the extention of this object using the given bottom rightCoordPair.CoordPaircentre()Gets this object's centre coordinate.RectchangeUnits(int eNewUnits)Returns aRectrepresenting the change of this object's unit span units to the given unit code.booleancontains(CoordPair point)Determines if this object contains the givenCoordPair.booleancontains(Rect rect)Determines if this object contains the givenRect.booleandisjoint(Rect rect)Determines if this object is disjoint from the givenRect.booleanequals(java.lang.Object object)Determines if this object is equal to the givenObject.inthashCode()UnitSpanheight()Gets this object's height.Rectheight(UnitSpan newHeight, boolean bStretchTop)Returns aRectrepresenting the stretch in height of this object by the givenUnitSpan.Rectintersection(Rect intersect)Returns aRectrepresenting the intersection of this object with the givenRect.booleanisDegenerate()Determines if this object is degenerate.UnitSpanleft()Gets this object's leftmost extent.RectleftRight(UnitSpan newLeft, UnitSpan newRight)Returns aRectrepresenting the change in width of this object by the givenUnitSpanextents.RectleftWidth(UnitSpan newLeft, UnitSpan newWidth)Returns aRectrepresenting the change in width of this object by the givenUnitSpanextents.booleannotEquals(java.lang.Object compare)Determines if this object is not equal to the givenObject.booleanoverlaps(Rect rect)Determines if this object overlaps the givenRect.UnitSpanright()Gets this object's rightmost extent.RectrightWidth(UnitSpan newRight, UnitSpan newWidth)Returns aRectrepresenting the change in width of this object by the givenUnitSpanextents.Rectrotate(CoordPair point, Angle angle)Returns aRectrepresenting the rotation of this object about the givenCoordPairandAngleof rotation.Rectsubtract(CoordPair subtract)Returns aRectrepresenting the shift of this object and the givenCoordPair.UnitSpantop()Gets this object's topmost extent.RecttopBottom(UnitSpan newTop, UnitSpan newBottom)Returns aRectrepresenting the change in height of this object by the givenUnitSpanextents.RecttopHeight(UnitSpan newTop, UnitSpan newHeight)Returns aRectrepresenting the change in height of this object by the givenUnitSpanextents.CoordPairtopLeft()Gets this object's top left coordinate.RecttopLeft(CoordPair newTopLeft)Returns aRectrepresenting the extention of this object using the given top leftCoordPair.CoordPairtopRight()Gets this object's top right coordinate.RecttopRight(CoordPair newTopRight)Returns aRectrepresenting the extention of this object using the given top rightCoordPair.Rectunion(Rect union)Returns aRectrepresenting the union of this object with the givenRect.UnitSpanwidth()Gets this object's width.Rectwidth(UnitSpan newWidth, boolean bStretchLeft)Returns aRectrepresenting the stretch in width of this object by the givenUnitSpan.static Rectzero()The zero rectangle.
-
-
-
Field Detail
-
ZERO
public static final Rect ZERO
-
-
Constructor Detail
-
Rect
public Rect()
Instantiates aRectof zero extents.
-
Rect
public Rect(Rect source)
Deprecated.Rect is immutable, so there is no need to copy an instance.Instantiates aRectfrom the givenRect.- Parameters:
source- theRectto copy to this object.
-
Rect
public Rect(CoordPair topLeft, CoordPair bottomRight)
Instantiates aRectspecified by the givenCoordPair.- Parameters:
topLeft- the top left coordinate of the rectangle.bottomRight- the bottom right coordinate of the rectangle.
-
Rect
public Rect(UnitSpan left, UnitSpan top, UnitSpan right, UnitSpan bottom)
Instantiates aRectspecified by the givenUnitSpanextents. 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 Detail
-
left
public UnitSpan left()
Gets this object's leftmost extent.- Returns:
- the leftmost extent.
-
top
public UnitSpan top()
Gets this object's topmost extent.- Returns:
- the topmost extent.
-
right
public UnitSpan right()
Gets this object's rightmost extent.- Returns:
- the rightmost extent.
-
bottom
public UnitSpan bottom()
Gets this object's bottommost extent.- Returns:
- the bottommost extent.
-
leftRight
public Rect leftRight(UnitSpan newLeft, UnitSpan newRight)
Returns aRectrepresenting the change in width of this object by the givenUnitSpanextents. 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
public Rect topBottom(UnitSpan newTop, UnitSpan newBottom)
Returns aRectrepresenting the change in height of this object by the givenUnitSpanextents.- Parameters:
newTop- the new left extent.newBottom- the new bottom extent.- Returns:
- a rectangle of the changed height.
-
leftWidth
public Rect leftWidth(UnitSpan newLeft, UnitSpan newWidth)
Returns aRectrepresenting the change in width of this object by the givenUnitSpanextents.- Parameters:
newLeft- the new left extent.newWidth- the new width.- Returns:
- a rectangle of the changed width.
-
rightWidth
public Rect rightWidth(UnitSpan newRight, UnitSpan newWidth)
Returns aRectrepresenting the change in width of this object by the givenUnitSpanextents.- Parameters:
newRight- the new right extent.newWidth- the new width.- Returns:
- a rectangle of the changed width.
-
topHeight
public Rect topHeight(UnitSpan newTop, UnitSpan newHeight)
Returns aRectrepresenting the change in height of this object by the givenUnitSpanextents.- Parameters:
newTop- the new top extent.newHeight- the new height.- Returns:
- a rectangle of the changed height.
-
bottomHeight
public Rect bottomHeight(UnitSpan newBottom, UnitSpan newHeight)
Returns aRectrepresenting the change in height of this object by the givenUnitSpanextents.- Parameters:
newBottom- the new bottom extent.newHeight- the new height.- Returns:
- a rectangle of the changed height.
-
topLeft
public CoordPair topLeft()
Gets this object's top left coordinate.- Returns:
- the top left coordinate.
-
topRight
public CoordPair topRight()
Gets this object's top right coordinate.- Returns:
- the top right coordinate.
-
bottomLeft
public CoordPair bottomLeft()
Gets this object's bottom left coordinate.- Returns:
- the bottom left coordinate.
-
bottomRight
public CoordPair bottomRight()
Gets this object's bottom right coordinate.- Returns:
- the bottom right coordinate.
-
changeUnits
public Rect changeUnits(int eNewUnits)
Returns aRectrepresenting 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
public Rect topLeft(CoordPair newTopLeft)
Returns aRectrepresenting the extention of this object using the given top leftCoordPair.- Parameters:
newTopLeft- the new top left coordinate.- Returns:
- a rectangle of the extention.
-
topRight
public Rect topRight(CoordPair newTopRight)
Returns aRectrepresenting the extention of this object using the given top rightCoordPair.- Parameters:
newTopRight- the new top right coordinate.- Returns:
- a rectangle of the extention.
-
bottomLeft
public Rect bottomLeft(CoordPair newBottomLeft)
Returns aRectrepresenting the extention of this object using the given bottom leftCoordPair.- Parameters:
newBottomLeft- the new bottom left coordinate.- Returns:
- a rectangle of the extention.
-
bottomRight
public Rect bottomRight(CoordPair newBottomRight)
Returns aRectrepresenting the extention of this object using the given bottom rightCoordPair.- Parameters:
newBottomRight- the new bottom right coordinate.- Returns:
- a rectangle of the extention.
-
height
public UnitSpan height()
Gets this object's height.- Returns:
- the height.
-
width
public UnitSpan width()
Gets this object's width.- Returns:
- the width.
-
height
public Rect height(UnitSpan newHeight, boolean bStretchTop)
Returns aRectrepresenting 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
public Rect width(UnitSpan newWidth, boolean bStretchLeft)
Returns aRectrepresenting 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
public CoordPair centre()
Gets this object's centre coordinate.- Returns:
- the center of the rectangle.
-
contains
public boolean contains(CoordPair point)
Determines if this object contains the givenCoordPair.- Parameters:
point- a coordinate.- Returns:
- true if the coordinate is contained, false otherwise
-
contains
public boolean contains(Rect rect)
Determines if this object contains the givenRect.- Parameters:
rect- a rectangle.- Returns:
- true if given the rectangle is contained, false otherwise
-
overlaps
public boolean overlaps(Rect rect)
Determines if this object overlaps the givenRect.- Parameters:
rect- a rectangle.- Returns:
- true if the rectangle overlaps, false otherwise
-
disjoint
public boolean disjoint(Rect rect)
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:
overlaps(Rect)
-
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:
zero()
-
rotate
public Rect rotate(CoordPair point, Angle angle)
Returns aRectrepresenting the rotation of this object about the givenCoordPairandAngleof rotation.- Parameters:
point- the point of rotation.angle- the angle of rotation.- Returns:
- a rectangle of the rotation.
-
equals
public boolean equals(java.lang.Object object)
Determines if this object is equal to the givenObject. Comparisons with instances of non-Rectobjects are never equal.- Overrides:
equalsin classjava.lang.Object- Parameters:
object- theObjectto compare.- Returns:
- true if equal, false otherwise.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
notEquals
public boolean notEquals(java.lang.Object compare)
Determines if this object is not equal to the givenObject. Comparisons with instances of non-Rectobjects are always not equal.- Parameters:
compare- theObjectto compare.- Returns:
- true if not equal, false otherwise
-
add
public Rect add(CoordPair add)
Returns aRectrepresenting the shift of this object by the givenCoordPair.- Parameters:
add- theCoordPairto add.- Returns:
- a rectangle of the shift.
-
subtract
public Rect subtract(CoordPair subtract)
Returns aRectrepresenting the shift of this object and the givenCoordPair.- Parameters:
subtract- theCoordPairto subtract.- Returns:
- a rectangle of the shift.
-
union
public Rect union(Rect union)
Returns aRectrepresenting the union of this object with the givenRect.- Parameters:
union- theRectto unite with.- Returns:
- a rectangle of the union.
-
intersection
public Rect intersection(Rect intersect)
Returns aRectrepresenting the intersection of this object with the givenRect.- Parameters:
intersect- theRectto intersect with.- Returns:
- a rectangle of the intersection.
-
zero
public static Rect zero()
The zero rectangle.- Returns:
- the rectangle equal to zero.
-
-