public class RectFloat extends Object
This class describes the position, width, and height of a rectangle.
| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
RectFloat.RotationEnum |
Indicates the rotation angle.
|
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
float |
bottom |
Indicates the Y coordinate of the lower right corner of a rectangle.
|
float |
left |
Indicates the X coordinate of the upper left corner of a rectangle.
|
float |
right |
Indicates the X coordinate of the lower right corner of a rectangle.
|
float |
top |
Indicates the Y coordinate of the upper left corner of a rectangle.
|
| 构造器 | 说明 |
|---|---|
RectFloat() |
Default constructor used to create a
RectFloat instance. |
RectFloat(float left,
float top,
float right,
float bottom) |
A constructor used to create a
RectFloat instance. |
RectFloat(Rect rect) |
A constructor used to create a
RectFloat instance by using a rectangle with integer coordinates. |
RectFloat(RectFloat rectFloat) |
A constructor used to create a
RectFloat instance by using a rectangle with float coordinates. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
clear() |
Clears this
RectFloat. |
String |
convertRectToSignedValue() |
Obtains the short string that can represent the current rectangle.
|
boolean |
equals(Object o) |
Indicates whether some other object is "equal to" this one.
|
void |
fuse(float xCoor,
float yCoor) |
Fuses this
RectFloat with a specified coordinate. |
void |
fuse(float left,
float top,
float right,
float bottom) |
Fuses this
RectFloat with a specified rectangle holding given coordinates. |
void |
fuse(RectFloat rectFloat) |
Fuses this
RectFloat with a specified rectangle. |
Point |
getCenter() |
Obtains the center point of this
RectFloat. |
float |
getHeight() |
Obtains the height of this
RectFloat. |
float |
getHorizontalCenter() |
Obtains the coordinates of the horizontal center of this
RectFloat. |
boolean |
getIntersectRect(RectFloat rectFloat) |
Checks whether this
RectFloat intersects a specified rectangle and sets this RectFloat to that
intersection if they intersect. |
Point |
getPivot() |
Obtains a pivot point.
|
float |
getPivotXCoordinate() |
Obtains the x-coordinate of the pivot, around which this
RectFloat is rotated and scaled. |
float |
getPivotYCoordinate() |
Obtains the y-coordinate of the pivot, around which this
RectFloat is rotated and scaled. |
DimensFloat |
getRectSize() |
Obtains the size of this
RectFloat. |
float |
getVerticalCenter() |
Obtains the coordinates of the vertical center of this
RectFloat. |
float |
getWidth() |
Obtains the width of this
RectFloat. |
int |
hashCode() |
Returns a hash code value for the object.
|
boolean |
isEmpty() |
Checks whether this
RectFloat is empty. |
boolean |
isInclude(float x,
float y) |
Checks whether a specified point is inside this
RectFloat. |
boolean |
isInclude(float left,
float top,
float right,
float bottom) |
Checks whether a specified rectangle is inside this
RectFloat. |
boolean |
isInclude(Point point) |
Checks whether a specified point is inside this
RectFloat. |
boolean |
isInclude(RectFloat rectFloat) |
Checks whether a specified rectangle is inside this
RectFloat. |
boolean |
isIntersect(float left,
float top,
float right,
float bottom) |
Checks whether a specified rectangle intersects this
RectFloat based on left, top,
right, and bottom. |
boolean |
isIntersect(RectFloat rect) |
Checks whether a specified rectangle intersects this
RectFloat. |
static boolean |
isIntersect(RectFloat rectFloatA,
RectFloat rectFloatB) |
Checks whether two specified rectangles intersect.
|
void |
modify(float left,
float top,
float right,
float bottom) |
Modifies the position of this
RectFloat based on the position of a specified rectangle. |
void |
modify(Rect rect) |
Modifies the position of this
Rect based on the position of a specified rectangle with integer
coordinates. |
void |
modify(RectFloat rectFloat) |
Modifies the position of this
RectFloat based on the position of a specified rectangle with float
coordinates. |
RectFloat |
obtainIntersectRect(float left,
float top,
float right,
float bottom) |
Obtains the intersection rectangle of this
RectFloat and a specified rectangle based on left,
top, right, and bottom. |
RectFloat |
obtainIntersectRect(RectFloat rectFloat) |
Obtains the intersection rectangle of this
RectFloat and a specified rectangle. |
void |
reorder() |
If the rectangle is illegal, swap the left, right, or top and bottom coordinates to make the rectangle legal.
|
void |
rotateBy(RectFloat.RotationEnum rotationEnum) |
Rotates this
RectFloat around the pivot. |
void |
rounding(Rect rect) |
Rounds the float coordinates of this
RectFloat to their nearest integer coordinates and creates a
rectangle to hold the new coordinates. |
void |
scale(float scale) |
Scales this
RectFloat around the pivot. |
boolean |
setIntersect(RectFloat rectFloatA,
RectFloat rectFloatB) |
Sets this
RectFloat as an intersection for two specified rectangles that intersect one another. |
void |
setPivot(float x,
float y) |
Sets the pivot for this
RectFloat. |
void |
setPivot(Point point) |
Sets the pivot, around which this
RectFloat is rotated and scaled based on point. |
void |
setPivotXCoordinate(float x) |
Sets the x-coordinate of the pivot, around which this
RectFloat is rotated and scaled. |
void |
setPivotYCoordinate(float y) |
Sets the y-coordinate of the pivot, around which this
RectFloat is rotated and scaled. |
void |
shrink(float dx,
float dy) |
Shrinks this
RectFloat. |
String |
toString() |
Returns a string representation of the object.
|
void |
translate(float dx,
float dy) |
Translates this
RectFloat. |
void |
translateCenterTo(float centerX,
float centerY) |
Translates the center of this
RectFloat to a new position. |
void |
translateCenterTo(Point point) |
Translates the center of this
RectFloat to a new position based on point. |
void |
translateTo(float newLeft,
float newTop) |
Translates this
RectFloat to a new position. |
boolean |
verifyRectFloat() |
Checks whether this
RectFloat is valid. |
public float bottom
public float left
public float right
public float top
public RectFloat()
RectFloat instance.
The initial value is (0.0, 0.0, 0.0, 0.0).
public RectFloat(float left,
float top,
float right,
float bottom)
RectFloat instance.left - Indicates the X-coordinate of the upper left corner.top - Indicates the Y-coordinate of the upper left corner.right - Indicates the X-coordinate of the lower right corner.bottom - Indicates the Y-coordinate of the lower right corner.public RectFloat(Rect rect)
RectFloat instance by using a rectangle with integer coordinates.rect - Indicates the rectangle with integer coordinates. For details, see Rect.public final float getHorizontalCenter()
RectFloat.RectFloat.public final float getVerticalCenter()
RectFloat.RectFloat.public Point getCenter()
RectFloat.public void setPivot(float x,
float y)
RectFloat.x - Indicates the x-coordinate of the pivot to set.y - Indicates the y-coordinate of the pivot to set.setPivotXCoordinate(float),
getPivotXCoordinate(),
setPivotYCoordinate(float),
getPivotYCoordinate(),
getPivot(),
setPivot(Point)public void setPivot(Point point)
RectFloat is rotated and scaled based on point.point - Indicates the coordinates of the pivot to set.setPivotXCoordinate(float),
getPivotXCoordinate(),
setPivotYCoordinate(float),
getPivotYCoordinate(),
#getPivot(Point),
setPivot(float, float)public void setPivotXCoordinate(float x)
RectFloat is rotated and scaled.x - Indicates the x-coordinate of the pivot to set.getPivotXCoordinate(),
setPivotYCoordinate(float),
getPivotYCoordinate(),
getPivot(),
setPivot(Point),
setPivot(float, float)public void setPivotYCoordinate(float y)
RectFloat is rotated and scaled.y - Indicates the y-coordinate of the pivot to set.#setPivotXCoordinate(),
#getPivotYCoordinate(float),
getPivotYCoordinate(),
getPivot(),
setPivot(Point),
setPivot(float, float)public Point getPivot()
setPivotXCoordinate(float),
getPivotXCoordinate(),
setPivotYCoordinate(float),
getPivotYCoordinate(),
setPivot(Point),
setPivot(float, float)public float getPivotXCoordinate()
RectFloat is rotated and scaled.setPivotXCoordinate(float),
setPivotYCoordinate(float),
getPivotYCoordinate(),
getPivot(),
setPivot(Point),
setPivot(float, float)public float getPivotYCoordinate()
RectFloat is rotated and scaled.setPivotXCoordinate(float),
getPivotXCoordinate(),
setPivotYCoordinate(float),
getPivot(),
setPivot(Point),
setPivot(float, float)public void scale(float scale)
RectFloat around the pivot.scale - Indicates the scale value.public void rotateBy(RectFloat.RotationEnum rotationEnum)
RectFloat around the pivot.rotationEnum - Indicates the rotation angle, as enumerated in RotationEnum.public boolean isInclude(float x,
float y)
RectFloat.x - Indicates the X coordinate of the specified point.y - Indicates the Y coordinate of the specified point.true if the specified point is inside this RectFloat; returns false
otherwise.public boolean isInclude(Point point)
RectFloat.point - Indicates the specified point.true if the specified point is inside this RectFloat; returns false otherwise.public boolean isInclude(RectFloat rectFloat)
RectFloat.rectFloat - Indicates the specified rectangle.true if the specified rectangle is inside this RectFloat; returns false
otherwise.public boolean isInclude(float left,
float top,
float right,
float bottom)
RectFloat.left - Indicates the x-coordinate of the specified rectangle's upper left corner.top - Indicates the y-coordinate of the specified rectangle's upper left corner.right - Indicates the x-coordinate of the specified rectangle's lower right corner.bottom - Indicates the y-coordinate of the specified rectangle's lower right corner.true if the specified rectangle is inside this RectFloat; returns false otherwise.public boolean equals(Object o)
The equals method implements an equivalence relation
on non-null object references:
x, x.equals(x) should return
true.
x and y, x.equals(y)
should return true if and only if
y.equals(x) returns true.
x, y, and z, if
x.equals(y) returns true and
y.equals(z) returns true, then
x.equals(z) should return true.
x and y, multiple invocations of
x.equals(y) consistently return true
or consistently return false, provided no
information used in equals comparisons on the
objects is modified.
x,
x.equals(null) should return false.
The equals method for class Object implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x and
y, this method returns true if and only
if x and y refer to the same object
(x == y has the value true).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode method, which states
that equal objects must have equal hash codes.
equals 在类中 Objecto - the reference object with which to compare.true if this object is the same as the obj
argument; false otherwise.Object.hashCode(),
HashMappublic int hashCode()
HashMap.
The general contract of hashCode is:
hashCode method
must consistently return the same integer, provided no information
used in equals comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
Java™ programming language.)
hashCode 在类中 ObjectObject.equals(java.lang.Object),
System.identityHashCode(java.lang.Object)public final float getHeight()
RectFloat.public final float getWidth()
RectFloat.public DimensFloat getRectSize()
RectFloat.public void shrink(float dx,
float dy)
RectFloat.dx - Indicates the horizontal length to shrink.dy - Indicates the vertical length to shrink.public boolean getIntersectRect(RectFloat rectFloat)
RectFloat intersects a specified rectangle and sets this RectFloat to that
intersection if they intersect.rectFloat - Indicates the specified rectangle.true if this RectFloat intersects the specified rectangle; returns false
otherwise.public static boolean isIntersect(RectFloat rectFloatA, RectFloat rectFloatB)
rectFloatA - Indicates one rectangle to check.rectFloatB - Indicates the other rectangle to check.true if the two specified rectangles intersect; returns false otherwise.public boolean isIntersect(float left,
float top,
float right,
float bottom)
RectFloat based on left, top,
right, and bottom.left - Indicates the x-coordinate of the specified rectangle's upper left corner.top - Indicates the y-coordinate of the specified rectangle's upper left corner.right - Indicates the x-coordinate of the specified rectangle's lower right corner.bottom - Indicates the y-coordinate of the specified rectangle's lower right corner.true if the specified rectangle intersects this RectFloat; returns false otherwise.public boolean isIntersect(RectFloat rect)
RectFloat.rect - Indicates the specified rectangle.true if the specified rectangle intersects this RectFloat; returns false otherwise.public final boolean isEmpty()
RectFloat is empty.true if this RectFloat is empty; returns false otherwise.public boolean verifyRectFloat()
RectFloat is valid.
A rectangle is considered valid if left (x-coordinate of the rectangle's upper left corner) is less than
right (x-coordinate of the rectangle's lower right corner) and top (y-coordinate of the
rectangle's upper left corner) is less than bottom (y-coordinate of the rectangle's lower right corner).true if this RectFloat is valid; returns false otherwise.public void translate(float dx,
float dy)
RectFloat.dx - Indicates the horizontal length to translate.dy - Indicates the vertical length to translate.public void modify(float left,
float top,
float right,
float bottom)
RectFloat based on the position of a specified rectangle.left - Indicates the X coordinate of the upper left corner of the specified rectangle.top - Indicates the Y coordinate of the upper left corner of the specified rectangle.right - Indicates the X coordinate of the lower right corner of the specified rectangle.bottom - Indicates the Y coordinate of the lower right corner of the specified rectangle.public void modify(Rect rect)
Rect based on the position of a specified rectangle with integer
coordinates.rect - Indicates the specified rectangle with integer coordinates.public void modify(RectFloat rectFloat)
RectFloat based on the position of a specified rectangle with float
coordinates.rectFloat - Indicates the specified rectangle with float coordinates.public void clear()
RectFloat.public boolean setIntersect(RectFloat rectFloatA, RectFloat rectFloatB)
RectFloat as an intersection for two specified rectangles that intersect one another.rectFloatA - Indicates one specified rectangle.rectFloatB - Indicates another specified rectangle.true if the two specified rectangles intersect; returns false otherwise.public String toString()
toString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public void fuse(float left,
float top,
float right,
float bottom)
RectFloat with a specified rectangle holding given coordinates.left - Indicates the X coordinate of the upper left corner of the specified rectangle.top - Indicates the Y coordinate of the upper left corner of the specified rectangle.right - Indicates the X coordinate of the lower right corner of the specified rectangle.bottom - Indicates the Y coordinate of the lower right corner of the specified rectangle.public void fuse(RectFloat rectFloat)
RectFloat with a specified rectangle.rectFloat - Indicates the specified rectangle.public void fuse(float xCoor,
float yCoor)
RectFloat with a specified coordinate.xCoor - Indicates the X coordinate.yCoor - Indicates the Y coordinate.public void translateTo(float newLeft,
float newTop)
RectFloat to a new position.newLeft - Indicates the X coordinate of the upper left corner of the rectangle at the new position.newTop - Indicates the Y coordinate of the upper left corner of the rectangle at the new position.public void translateCenterTo(float centerX,
float centerY)
RectFloat to a new position.centerX - Indicates the x-coordinate of the rectangle's new center.centerY - Indicates the y-coordinate of the rectangle's new center.public void translateCenterTo(Point point)
RectFloat to a new position based on point.
param point Indicates the coordinates of the point representing the new position.public void rounding(Rect rect)
RectFloat to their nearest integer coordinates and creates a
rectangle to hold the new coordinates.
The X coordinate of the upper left corner of this RectFloat is rounded down to its nearest integer
value as the X coordinate of the upper left corner of the rectangle to create.
The Y coordinate of the upper left corner of this RectFloat is rounded down to its nearest integer
value as the Y coordinate of the upper left corner of the rectangle to create.
The X coordinate of the lower right corner of this RectFloat is rounded up to its nearest integer
value as the X coordinate of the lower right corner of the rectangle to create.
The Y coordinate of the lower right corner of this RectFloat is rounded up to its nearest integer
value as the Y coordinate of the lower right corner of the rectangle to create.
rect - Indicates the rectangle to hold new coordinates.public RectFloat obtainIntersectRect(float left, float top, float right, float bottom)
RectFloat and a specified rectangle based on left,
top, right, and bottom.left - Indicates the x-coordinate of the specified rectangle's upper left corner.top - Indicates the y-coordinate of the specified rectangle's upper left corner.right - Indicates the x-coordinate of the specified rectangle's lower right corner.bottom - indicates the y-coordinate of the specified rectangle's lower right corner.public String convertRectToSignedValue()
public void reorder()
public RectFloat obtainIntersectRect(RectFloat rectFloat)
RectFloat and a specified rectangle.rectFloat - Indicates the specified rectangle.#ObtainIntersectRect(float, float, float, float)