新聞中心
Rect

java.lang.Object
|---ohos.agp.utils.Rect
public class Rect
extends Object
implements Sequenceable表示一個矩形區(qū)域。
該類用于在繪制或勾勒出矩形后,在屏幕上指定矩形區(qū)域。
Since:
1
嵌套類摘要
| 修飾符和類型 | 類 | 描述 |
|---|---|---|
| static class | Rect.RotationEnum | 表示旋轉(zhuǎn)角度。 |
| 從接口 ohos.utils.Sequenceable 繼承的嵌套類/接口 |
|---|
| Sequenceable.ProducerT |
字段摘要
| 修飾符和類型 | 字段 | 描述 |
|---|---|---|
| int | bottom | 指示矩形底部的 Y 坐標位置。 |
| int | left | 表示矩形左側(cè) X 坐標的位置。 |
| int | right | 表示矩形右側(cè)X坐標的位置。 |
| int | top | 指示矩形頂部的 Y 坐標位置。 |
構造函數(shù)摘要
| 構造函數(shù) | 描述 |
|---|---|
| Rect() | 用于創(chuàng)建 Rect 實例的默認構造函數(shù)。 |
| Rect(int left, int top, int right, int bottom) | 用于創(chuàng)建 Rect 實例的構造函數(shù)。 |
| Rect(Rect rect) | 用于通過使用具有整數(shù)坐標的矩形來創(chuàng)建 Rect 實例的構造函數(shù)。 |
方法總結
| 修飾符和類型 | 方法 | 描述 |
|---|---|---|
| void | clear() | 清除此矩形。 |
| boolean | contains(int left, int top, int right, int bottom) | 檢查指定的矩形是否在該矩形內(nèi)或等于該矩形。 |
| String | convertRectToValue() | 將當前矩形轉(zhuǎn)換為指定模式“左上右下”的字符串。 |
| static Rect | convertValueToRect(String str) | 將指定模式的字符串轉(zhuǎn)換為矩形。 |
| boolean | equals(Object object) | 指示其他對象是否“等于”這個對象。 |
| void | fetchParcel(Parcel parcel) | 根據(jù)包裹中存儲的數(shù)據(jù)設置矩形參數(shù)。 |
| void | fuse(int xCoor, int yCoor) | 組合這個矩形和指定的點。 |
| void | fuse(int left, int top, int right, int bottom) | 將此 Rect 與保存給定坐標的指定矩形融合。 |
| void | fuse(Rect rect) | 將此 Rect 與指定的矩形融合。 |
| int[] | getCenter() | 獲取此 Rect 對象的中心點的坐標數(shù)組。 |
| int | getCenterX() | 獲取矩形的 X 軸中心。 |
| int | getCenterY() | 獲取矩形的 Y 軸中心。 |
| int | getHeight() | 獲取矩形的高度。 |
| boolean | getIntersectRect(int left, int top, int right, int bottom) | 檢查此 Rect 是否與具有給定坐標的指定矩形相交,如果它們相交,則將此 Rect 設置為該交點。 |
| boolean | getIntersectRect(Rect rect) | 檢查此 Rect 是否與指定的矩形相交,如果相交,則將此 Rect 設置為該相交。 |
| boolean | getIntersectRect(Rect rectA, Rect rectB) | 檢查兩個指定的矩形是否相交,并將此矩形設置為該相交(如果有)。 |
| Point | getPivot() | 獲取樞軸的坐標,此 Rect 對象圍繞該坐標旋轉(zhuǎn)和縮放。 |
| int | getPivotXCoordinate() | 獲取樞軸的 X 軸坐標,此 Rect 對象圍繞該坐標旋轉(zhuǎn)和縮放。 |
| int | getPivotYCoordinate() | 獲取樞軸的 Y 軸坐標,此 Rect 對象圍繞該坐標旋轉(zhuǎn)和縮放。 |
| Point | getPreciseCenter() | 獲取此 Rect 對象的中心點坐標。 |
| float | getPreciseHorizontalCenter() | 獲取此 Rect 的精確水平中心的坐標。 |
| float | getPreciseVerticalCenter() | 獲取此 Rect 的精確垂直中心的坐標。 |
| int[] | getRectSize() | 獲取此 Rect 對象的大小。 |
| int | getWidth() | 獲取矩形的寬度。 |
| int | hashCode() | 返回對象的哈希碼值。 |
| boolean | isEmpty() | 檢查矩形是否為空。 |
| boolean | isInclude(int x, int y) | 檢查指定點是否在此 Rect 內(nèi)。 |
| boolean | isInclude(int left, int top, int right, int bottom) | 檢查由 left、top、right 和 bottom 指定的矩形是否在此 Rect 對象內(nèi)。 |
| boolean | isInclude(Point point) | 檢查指定點的坐標是否在此 Rect 對象內(nèi)。 |
| boolean | isInclude(Rect rect) | 檢查指定的矩形是否在此 Rect 內(nèi)。 |
| boolean | isIntersect(int left, int top, int right, int bottom) | 檢查此 Rect 是否與指定的矩形相交。 |
| boolean | isIntersect(Rect rect) | 檢查指定的矩形是否與此 Rect 對象相交。 |
| static boolean | isIntersect(Rect rectA, Rect rectB) | 檢查兩個指定的矩形是否相交。 |
| boolean | marshalling(Parcel out) | 將此 Sequenceable 對象編組為 Parcel。 |
| void | modify(Rect rect) | 根據(jù)指定矩形的位置修改此 Rect 的位置。 |
| Rect | obtainIntersectRect(int left, int top, int right, int bottom) | 獲取此 Rect 對象與由左、上、右、下確定的矩形的交集矩形。 |
| Rect | obtainIntersectRect(Rect rect) | 獲取指定矩形與此 Rect 對象的交集矩形。 |
| void | offset(int dx, int dy) | 將此矩形偏移指定距離。 |
| void | recordParcel(Parcel parcel) | 將矩形的參數(shù)放入包裹中。 |
| void | reorder() | 如果矩形無效,則交換上下邊界和/或左右邊界。 |
| void | rotateBy(Rect.RotationEnum rotationEnum) | 將此 Rect 對象旋轉(zhuǎn)指定的度數(shù)。 |
| void | scale(float scale) | 設置此 Rect 對象的比例。 |
| void | set(int left, int top, int right, int bottom) | 根據(jù)矩形四個邊的位置設置矩形的形狀和大小。 |
| void | setPivot(int x, int y) | 設置樞軸,此 Rect 對象基于 x 和 y 圍繞其旋轉(zhuǎn)和縮放。 |
| void | setPivot(Point point) | 設置樞軸,此 Rect 對象基于該點旋轉(zhuǎn)和縮放。 |
| void | setPivotXCoordinate(int x) | 設置樞軸的 X 軸坐標,此 Rect 對象圍繞該坐標旋轉(zhuǎn)和縮放。 |
| void | setPivotYCoordinate(int y) | 設置樞軸的 Y 軸坐標,此 Rect 對象圍繞該坐標旋轉(zhuǎn)和縮放。 |
| void | shrink(int dx, int dy) | 縮小這個矩形。 |
| void | sort() | 如果此矩形無效,則交換左上角和右下角的 x 坐標和/或左上角和右下角的 y 坐標。 |
| String | toString() | 返回對象的字符串表示形式。 |
| void | translate(int dx, int dy) | 翻譯這個矩形。 |
| void | translateCenterTo(int centerX, int centerY) | 將此 Rect 對象的中心點平移到由 centerX 和 centerY 確定的新位置。 |
| void | translateCenterTo(Point point) | 將此 Rect 對象的中心點轉(zhuǎn)換為由點標識的新位置。 |
| void | translateTo(int newLeft, int newTop) | 將此 Rect 轉(zhuǎn)換到新位置。 |
| boolean | unmarshalling(Parcel in) | 從 Parcel 中解組此 Sequenceable 對象。 |
| boolean | verifyRect() | 檢查此 Rect 對象是否有效。 |
| 從類 java.lang.Object 繼承的方法 |
|---|
| clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| 從接口 ohos.utils.Sequenceable 繼承的方法 |
|---|
| hasFileDescriptor |
字段詳細信息
bottom
public int bottom
指示矩形底部的 Y 坐標位置。
此變量定義屏幕上矩形底邊所在的垂直軸上的 Y 坐標。
left
public int left
表示矩形左側(cè) X 坐標的位置。
該變量定義了屏幕上矩形左側(cè)所在的水平軸上的 X 坐標。
right
public int right
表示矩形右側(cè)X坐標的位置。
該變量定義了屏幕上矩形右側(cè)所在的水平軸上的 X 坐標。
top
public int top
指示矩形頂部的 Y 坐標位置。
此變量定義垂直軸上的 Y 坐標,矩形的頂邊位于屏幕上。
構造函數(shù)詳細信息
Rect
public Rect()
用于創(chuàng)建 Rect 實例的默認構造函數(shù)。
該方法用于定義一個矩形對象,默認為屏幕左上角的點。
Rect
public Rect(int left, int top, int right, int bottom)
用于創(chuàng)建 Rect 實例的構造函數(shù)。
該方法用于根據(jù)坐標空間中四個邊的位置定義一個矩形對象。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| left | 指示矩形對象左側(cè) X 坐標的位置。 |
| top | 指示矩形對象頂部的 Y 坐標位置。 |
| right | 表示矩形對象右側(cè) X 坐標的位置。 |
| bottom | 指示矩形對象底部的 Y 坐標位置。 |
Rect
public Rect(Rect rect)
用于通過使用具有整數(shù)坐標的矩形來創(chuàng)建 Rect 實例的構造函數(shù)。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| rect | 表示具有整數(shù)坐標的矩形。 有關詳細信息,請參閱矩形。 |
Since:
3
方法詳情
set
public void set(int left, int top, int right, int bottom)
根據(jù)矩形四個邊的位置設置矩形的形狀和大小。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| left | 指示矩形對象左側(cè) X 坐標的位置。 |
| top | 指示矩形對象頂部的 Y 坐標位置。 |
| right | 表示矩形對象右側(cè) X 坐標的位置。 |
| bottom | 指示矩形對象底部的 Y 坐標位置。 |
isEmpty
public final boolean isEmpty()
檢查矩形是否為空。
返回:
如果矩形為空,則返回 true; 否則返回 false。
Since:
3
verifyRect
public final boolean verifyRect()
檢查此 Rect 對象是否有效。
返回:
如果矩形左上角的 X 軸和 Y 軸坐標小于矩形右下角的 X 軸和 Y 軸坐標,則返回 true; 否則返回 false。
Since:
4
getWidth
public final int getWidth()
獲取矩形的寬度。
如果矩形的右值小于左值,則返回負值。
返回:
返回矩形的寬度。
Since:
3
getHeight
public final int getHeight()
獲取矩形的高度。
如果矩形的底部值小于頂部值,則返回負值。
返回:
返回矩形的高度。
Since:
3
getCenterX
public final int getCenterX()
獲取矩形的 X 軸中心。
矩形的 X 軸中心由向下舍入的整數(shù)表示。
返回:
返回矩形的 X 軸中心。
Since:
3
getCenterY
public final int getCenterY()
獲取矩形的 Y 軸中心。
矩形的 Y 軸中心由四舍五入的整數(shù)表示。
返回:
返回矩形的 Y 軸中心。
Since:
3
getCenter
public int[] getCenter()
獲取此 Rect 對象的中心點的坐標數(shù)組。
返回:
返回包含此 Rect 對象中心點坐標的數(shù)組。 第一個值表示 X 軸上的值,第二個值表示 Y 軸上的值。
Since:
4
getRectSize
public int[] getRectSize()
獲取此 Rect 對象的大小。
返回:
返回一個整數(shù)數(shù)組。 第一個值表示寬度,第二個值表示高度。
Since:
4
equals
public boolean equals(Object object)
指示其他對象是否“等于”這個對象。
equals 方法在非空對象引用上實現(xiàn)等價關系:
- 它是自反的:對于任何非空引用值 x,x.equals(x) 應該返回 true。
- 它是對稱的:對于任何非空引用值 x 和 y,當且僅當 y.equals(x) 返回 true 時,x.equals(y) 才應該返回 true。
- 它是可傳遞的:對于任何非空引用值 x、y 和 z,如果 x.equals(y) 返回 true 并且 y.equals(z) 返回 true,則 x.equals(z) 應該返回 true。
- 它是一致的:對于任何非空引用值 x 和 y,x.equals(y) 的多次調(diào)用始終返回 true 或始終返回 false,前提是沒有修改對象上 equals 比較中使用的信息。
- 對于任何非空引用值 x,x.equals(null) 應該返回 false。
Object 類的 equals 方法實現(xiàn)了對象上最有區(qū)別的可能等價關系; 也就是說,對于任何非空引用值 x 和 y,當且僅當 x 和 y 引用同一個對象(x == y 的值為 true)時,此方法才返回 true。
請注意,每當重寫該方法時,通常都需要重寫 hashCode 方法,以維護 hashCode 方法的一般約定,即相等的對象必須具有相等的哈希碼。
覆蓋:
類 Object 中的等于
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| object | 要與之比較的參考對象。 |
返回:
如果此對象與 obj 參數(shù)相同,則為 true; 否則為 false。
hashCode
public int hashCode()
返回對象的哈希碼值。 支持這種方法是為了有利于哈希表,例如 HashMap 提供的那些。
hashCode 的一般合約是:
- 每當在 Java 應用程序執(zhí)行期間對同一對象多次調(diào)用時,hashCode 方法必須始終返回相同的整數(shù),前提是沒有修改對象上相等比較中使用的信息。 該整數(shù)不需要從應用程序的一次執(zhí)行到同一應用程序的另一次執(zhí)行保持一致。
- 如果兩個對象根據(jù) equals(Object) 方法相等,則對兩個對象中的每一個調(diào)用 hashCode 方法必須產(chǎn)生相同的整數(shù)結果。
- 如果根據(jù) Object.equals(java.lang.Object) 方法,如果兩個對象不相等,則不要求對兩個對象中的每一個調(diào)用 hashCode 方法必須產(chǎn)生不同的整數(shù)結果。 但是,程序員應該意識到,為不相等的對象生成不同的整數(shù)結果可能會提高哈希表的性能。
在合理可行的情況下,由 Object 類定義的 hashCode 方法確實為不同的對象返回不同的整數(shù)。 (這通常通過將對象的內(nèi)部地址轉(zhuǎn)換為整數(shù)來實現(xiàn),但 Java? 編程語言不需要這種實現(xiàn)技術。)
覆蓋:
類 Object 中的 hashCode
返回:
此對象的哈希碼值。
toString
public String toString()
返回對象的字符串表示形式。 通常,toString 方法返回一個“以文本方式表示”該對象的字符串。 結果應該是一個簡潔但信息豐富的表示,易于人們閱讀。 建議所有子類重寫此方法。
Object 類的 toString 方法返回一個字符串,該字符串由對象作為其實例的類的名稱、at 符號字符“@”和對象哈希碼的無符號十六進制表示形式組成。 換句話說,此方法返回一個等于以下值的字符串:
getClass().getName() + '@' + Integer.toHexString(hashCode()) 覆蓋:
類 Object 中的 toString
返回:
對象的字符串表示形式。
marshalling
public boolean marshalling(Parcel out)
從接口復制的描述:Sequenceable
將此 Sequenceable 對象編組為 Parcel。
指定者:
接口 Sequenceable 中的編組
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| out | 指示將 Sequenceable 對象編組到的 Parcel 對象。 |
返回:
如果編組成功,則返回 true; 否則返回 false。
unmarshalling
public boolean unmarshalling(Parcel in)
從接口復制的描述:Sequenceable
從 Parcel 中解組此 Sequenceable 對象。
指定者:
在接口 Sequenceable 中解組
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| in | 指示已將 Sequenceable 對象編組到的 Parcel 對象。 |
返回:
如果解組成功,則返回 true; 否則返回 false。
isInclude
public boolean isInclude(int x, int y)
檢查指定點是否在此 Rect 內(nèi)。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| x | 表示指定點的X坐標。 |
| y | 表示指定點的Y坐標。 |
返回:
如果指定點在此 Rect 內(nèi),則返回 true; 否則返回 false。
Since:
3
isInclude
public boolean isInclude(Point point)
檢查指定點的坐標是否在此 Rect 對象內(nèi)。
返回:
如果指定點的坐標在此 Rect 對象內(nèi),則返回 true; 否則返回 false。
Since:
4
isInclude
public boolean isInclude(Rect rect)
檢查指定的矩形是否在此 Rect 內(nèi)。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| rect | 表示指定的矩形。 |
返回:
如果指定的矩形在此 Rect 內(nèi),則返回 true; 否則返回 false。
Since:
3
isInclude
public boolean isInclude(int left, int top, int right, int bottom)
檢查由 left、top、right 和 bottom 指定的矩形是否在此 Rect 對象內(nèi)。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| left | 表示指定矩形的左邊界。 |
| top | 表示指定矩形的上邊界。 |
| right | 表示指定矩形的右邊界。 |
| bottom | 表示指定矩形的下邊界。 |
返回:
如果指定的矩形在此 Rect 對象內(nèi),則返回 true; 否則返回 false。
Since:
4
getPreciseHorizontalCenter
public final float getPreciseHorizontalCenter()
獲取此 Rect 的精確水平中心的坐標。
返回:
返回矩形精確水平中心的坐標。
Since:
3
getPreciseVerticalCenter
public final float getPreciseVerticalCenter()
獲取此 Rect 的精確垂直中心的坐標。
返回:
返回矩形精確垂直中心的坐標。
Since:
3
getPreciseCenter
public Point getPreciseCenter()
獲取此 Rect 對象的中心點坐標。
返回:
返回表示此 Rect 對象中心點坐標的 Point 對象。
Since:
4
setPivot
public void setPivot(int x, int y)
設置樞軸,此 Rect 對象基于 x 和 y 圍繞其旋轉(zhuǎn)和縮放。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| x | 指示要設置的樞軸的 X 軸坐標。 |
| y | 指示要設置的樞軸的 Y 軸坐標。 |
Since:
4
setPivot
public void setPivot(Point point)
設置樞軸,此 Rect 對象基于該點旋轉(zhuǎn)和縮放。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| point | 指示要設置的樞軸的坐標。 |
Since:
4
setPivotXCoordinate
public void setPivotXCoordinate(int x)
設置樞軸的 X 軸坐標,此 Rect 對象圍繞該坐標旋轉(zhuǎn)和縮放。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| x | 指示要設置的樞軸的 X 軸坐標。 |
Since:
4
setPivotYCoordinate
public void setPivotYCoordinate(int y)
設置樞軸的 Y 軸坐標,此 Rect 對象圍繞該坐標旋轉(zhuǎn)和縮放。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| y | 指示要設置的樞軸的 Y 軸坐標。 |
Since:
4
getPivot
public Point getPivot()
獲取樞軸的坐標,此 Rect 對象圍繞該坐標旋轉(zhuǎn)和縮放。
返回:
返回樞軸的坐標。
Since:
4
getPivotXCoordinate
public int getPivotXCoordinate()
獲取樞軸的 X 軸坐標,此 Rect 對象圍繞該坐標旋轉(zhuǎn)和縮放。
返回:
返回樞軸的 X 軸坐標。
Since:
4
getPivotYCoordinate
public int getPivotYCoordinate()
獲取樞軸的 Y 軸坐標,此 Rect 對象圍繞該坐標旋轉(zhuǎn)和縮放。
返回:
返回樞軸的 Y 軸坐標。
Since:
4
fetchParcel
public void fetchParcel(Parcel parcel)
根據(jù)包裹中存儲的數(shù)據(jù)設置矩形參數(shù)。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| parcel | 表示包裹。 |
recordParcel
public void recordParcel(Parcel parcel)
將矩形的參數(shù)放入包裹中。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| parcel | 表示包裹。 |
scale
public void scale(float scale)
設置此 Rect 對象的比例。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| scale | 表示要設置的比例。 |
Since:
4
rotateBy
public void rotateBy(Rect.RotationEnum rotationEnum)
將此 Rect 對象旋轉(zhuǎn)指定的度數(shù)。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| rotationEnum | 指示此 Rect 對象將旋轉(zhuǎn)的度數(shù)。 |
Since:
4
shrink
public void shrink(int dx, int dy)
縮小這個矩形。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| dx | 表示要縮小的水平長度,以像素為單位。 |
| dy | 指示要收縮的垂直長度,以像素為單位。 |
Since:
3
isIntersect
public static boolean isIntersect(Rect rectA, Rect rectB)
檢查兩個指定的矩形是否相交。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| rectA | 表示要檢查的一個矩形。 |
| rectB | 指示要檢查的另一個矩形。 |
返回:
如果兩個指定的矩形相交,則返回 true; 否則返回 false。
Since:
3
translate
public void translate(int dx, int dy)
翻譯這個矩形。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| dx | 指示要平移的水平長度,以像素為單位。 |
| dy | 指示要平移的垂直長度,以像素為單位。 |
Since:
3
translateTo
public void translateTo(int newLeft, int newTop)
將此 Rect 轉(zhuǎn)換到新位置。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| newLeft | 表示新位置矩形左上角的X坐標。 |
| newTop | 表示新位置矩形左上角的Y坐標。 |
Since:
3
translateCenterTo
public void translateCenterTo(int centerX, int centerY)
將此 Rect 對象的中心點平移到由 centerX 和 centerY 確定的新位置。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| centerX | 指示矩形新中心點的 X 軸坐標。 |
| centerY | 指示矩形新中心點的 Y 軸坐標。 |
Since:
4
translateCenterTo
public void translateCenterTo(Point point)
將此 Rect 對象的中心點轉(zhuǎn)換為由點標識的新位置。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| point | 指示矩形新中心點的坐標。 |
Since:
4
modify
public void modify(Rect rect)
根據(jù)指定矩形的位置修改此 Rect 的位置。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| rect | 表示指定的矩形。 |
Since:
3
clear
public void clear()
清除此矩形。
Since:
3
fuse
public void fuse(int left, int top, int right, int bottom)
將此 Rect 與保存給定坐標的指定矩形融合。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| left | 表示指定矩形左上角的X坐標。 |
| top | 表示指定矩形左上角的Y坐標。 |
| right | 表示指定矩形右下角的X坐標。 |
| bottom | 表示指定矩形右下角的Y坐標。 |
Since:
3
fuse
public void fuse(Rect rect)
將此 Rect 與指定的矩形融合。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| rect | 表示指定的矩形。 |
Since:
3
fuse
public void fuse(int xCoor, int yCoor)
組合這個矩形和指定的點。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| xCoor | 表示指定點的X坐標。 |
| yCoor | 表示指定點的Y坐標。 |
Since:
5
getIntersectRect
public boolean getIntersectRect(int left, int top, int right, int bottom)
檢查此 Rect 是否與具有給定坐標的指定矩形相交,如果它們相交,則將此 Rect 設置為該交點。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| left | 表示指定矩形左上角的X坐標。 |
| top | 表示指定矩形左上角的Y坐標。 |
| right | 表示指定矩形右下角的X坐標。 |
| bottom | 表示指定矩形右下角的Y坐標。 |
返回:
如果此 Rect 與指定的矩形相交,則返回 true; 否則返回 false。
Since:
3
getIntersectRect
public boolean getIntersectRect(Rect rect)
檢查此 Rect 是否與指定的矩形相交,如果相交,則將此 Rect 設置為該相交。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| rect | 表示指定的矩形。 |
返回:
如果此 Rect 與指定的矩形相交,則返回 true; 否則返回 false。
Since:
3
isIntersect
public boolean isIntersect(int left, int top, int right, int bottom)
檢查此 Rect 是否與指定的矩形相交。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| left | 表示指定矩形左上角的X坐標。 |
| top | 表示指定矩形左上角的Y坐標。 |
| right | 表示指定矩形右下角的X坐標。 |
| bottom | 表示指定矩形右下角的Y坐標。 |
返回:
如果此 Rect 與指定的矩形相交,則返回 true; 否則返回 false。
Since:
3
isIntersect
public boolean isIntersect(Rect rect)
檢查指定的矩形是否與此 Rect 對象相交。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| rect | 指示要檢查的矩形。 |
返回:
如果此 Rect 對象與指定的矩形相交,則返回 true; 否則返回 false。
Since:
4
obtainIntersectRect
public Rect obtainIntersectRect(int left, int top, int right, int bottom)
獲取此 Rect 對象與由左、上、右、下確定的矩形的交集矩形。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| left | 表示指定矩形左上角的X軸坐標。 |
| top | 表示指定矩形左上角的Y軸坐標。 |
| right | 表示指定矩形右下角的X軸坐標。 |
| bottom | 表示指定矩形右下角的Y軸坐標。 |
返回:
返回指定矩形與此 Rect 對象的相交矩形。
Since:
4
obtainIntersectRect
public Rect obtainIntersectRect(Rect rect)
獲取指定矩形與此 Rect 對象的交集矩形。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| rect | 表示指定的矩形。 |
返回:
返回指定矩形與此 Rect 對象的相交矩形。
Since:
4
reorder
public void reorder()
如果矩形無效,則交換上下邊界和/或左右邊界。
Since:
5
getIntersectRect
public boolean getIntersectRect(Rect rectA, Rect rectB)
檢查兩個指定的矩形是否相交,并將此矩形設置為該相交(如果有)。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| rectA | 表示第一個矩形。 |
| rectB | 表示第二個矩形。 |
返回:
如果兩個指定的矩形相交,則返回 true; 否則返回 false。
Since:
5
convertRectToValue
public String convertRectToValue()
將當前矩形轉(zhuǎn)換為指定模式“左上右下”的字符串。
返回:
返回矩形的字符串表示形式。
Since:
5
convertValueToRect
public static Rect convertValueToRect(String str)
將指定模式的字符串轉(zhuǎn)換為矩形。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| str | 表示指定模式“左上右下”的字符串。 |
返回:
返回一個矩形。
Since:
5
offset
public void offset(int dx, int dy)
將此矩形偏移指定距離。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| dx | 表示矩形在 x 軸上的偏移量。 |
| dy | 表示矩形在 y 軸上的偏移量。 |
Since:
5
contains
public boolean contains(int left, int top, int right, int bottom)
檢查指定的矩形是否在該矩形內(nèi)或等于該矩形。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| left | 表示指定矩形左上角的 x 坐標。 |
| top | 表示指定矩形左上角的 y 坐標。 |
| right | 表示指定矩形右下角的 x 坐標。 |
| bottom | 表示指定矩形右下角的 y 坐標。 |
返回:
如果指定的矩形在該矩形內(nèi)或等于該矩形,則返回 true; 否則返回 false。
Since:
5
sort
public void sort()
如果此矩形無效,則交換左上角和右下角的 x 坐標和/或左上角和右下角的 y 坐標。
Since:
5
網(wǎng)站名稱:創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OSRect
標題網(wǎng)址:http://m.fisionsoft.com.cn/article/dhoospi.html


咨詢
建站咨詢
