Builder
class Builder
| kotlin.Any | |
| ↳ | android.view.inputmethod.TextBoundsInfo.Builder |
The builder class to create a TextBoundsInfo object.
Summary
| Public constructors | |
|---|---|
|
Create a builder for |
|
| Public methods | |
|---|---|
| TextBoundsInfo |
build()Create the |
| TextBoundsInfo.Builder |
clear()Clear all the parameters set on this |
| TextBoundsInfo.Builder |
setCharacterBidiLevel(characterBidiLevels: IntArray)Set the BiDi levels for the character. |
| TextBoundsInfo.Builder |
setCharacterBounds(characterBounds: FloatArray)Set the characters bounds, in the coordinates of the editor. |
| TextBoundsInfo.Builder |
setCharacterFlags(characterFlags: IntArray)Set the flags of the characters. |
| TextBoundsInfo.Builder |
setGraphemeSegmentFinder(graphemeSegmentFinder: SegmentFinder)Set the |
| TextBoundsInfo.Builder |
setLineSegmentFinder(lineSegmentFinder: SegmentFinder)Set the |
| TextBoundsInfo.Builder |
Sets the matrix that transforms local coordinates into screen coordinates. |
| TextBoundsInfo.Builder |
setStartAndEnd(start: Int, end: Int)Set the start and end index of the |
| TextBoundsInfo.Builder |
setWordSegmentFinder(wordSegmentFinder: SegmentFinder)Set the |
Public constructors
Builder
Builder(
start: Int,
end: Int)
Create a builder for TextBoundsInfo.
| Parameters | |
|---|---|
start |
Int: the start index of the TextBoundsInfo, inclusive. |
end |
Int: the end index of the TextBoundsInfo, exclusive. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if the given start or end is negative, or end is smaller than the start. |
Public methods
build
fun build(): TextBoundsInfo
Create the TextBoundsInfo using the parameters in this Builder.
| Return | |
|---|---|
TextBoundsInfo |
This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalStateException |
in the following conditions:
|
clear
fun clear(): TextBoundsInfo.Builder
Clear all the parameters set on this Builder to reuse it.
| Return | |
|---|---|
TextBoundsInfo.Builder |
This value cannot be null. |
setCharacterBidiLevel
fun setCharacterBidiLevel(characterBidiLevels: IntArray): TextBoundsInfo.Builder
Set the BiDi levels for the character. The bidiLevel of the i-th character in the editor is stored at index (i - start). The length of the given array must equal to (end - start).
BiDi level is defined by the unicode bidirectional algorithm . One can determine whether a character's direction is right-to-left (RTL) or left-to-right (LTR) by checking the last bit of the BiDi level. If it's 1, the character is RTL, otherwise the character is LTR. The BiDi level of a character must be in the range of [0, 125].
| Parameters | |
|---|---|
characterBidiLevels |
IntArray: the array of the character's BiDi level. This value cannot be null. |
| Return | |
|---|---|
TextBoundsInfo.Builder |
This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if the given characterBidiLevels contains an element that's out of the range [0, 125]. |
java.lang.NullPointerException |
if the given characterBidiLevels is null. |
See Also
setCharacterBounds
fun setCharacterBounds(characterBounds: FloatArray): TextBoundsInfo.Builder
Set the characters bounds, in the coordinates of the editor.
The given array should be divided into groups of four where each element represents left, top, right and bottom of the character bounds respectively. The bounds of the i-th character in the editor should be stored at index 4 * (i - start). The length of the given array must equal to 4 * (end - start).
Sometimes multiple characters in a single grapheme are rendered as one symbol on the screen. So those characters only have one shared bounds. In this case, we recommend the editor to assign all the width to the bounds of the first character in the grapheme, and make the rest characters' bounds zero-width.
For example, the string "'0xD83D' '0xDE00'" is rendered as one grapheme - a grinning face emoji. If the bounds of the grapheme is: Rect(5, 10, 15, 20), the character bounds of the string should be: [ Rect(5, 10, 15, 20), Rect(15, 10, 15, 20) ].
| Parameters | |
|---|---|
characterBounds |
FloatArray: the array of the flattened character bounds. This value cannot be null. |
| Return | |
|---|---|
TextBoundsInfo.Builder |
This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.NullPointerException |
if the given characterBounds is null. |
setCharacterFlags
fun setCharacterFlags(characterFlags: IntArray): TextBoundsInfo.Builder
Set the flags of the characters. The flags of the i-th character in the editor is stored at index (i - start). The length of the given array must equal to (end - start). The flags contain the following information:
- The
FLAG_CHARACTER_WHITESPACEflag, indicating the character is a whitespace. - The
FLAG_CHARACTER_LINEFEEDflag, indicating the character is a linefeed. - The
FLAG_CHARACTER_PUNCTUATIONflag, indicating the character is a punctuation. - The
FLAG_LINE_IS_RTLflag, indicating the line this character belongs to is RTL. All all character in the same line must have the same line direction. CheckgetLineSegmentFinder()for more information of line boundaries.
| Parameters | |
|---|---|
characterFlags |
IntArray: the array of the character's flags. This value cannot be null. |
| Return | |
|---|---|
TextBoundsInfo.Builder |
This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if the given characterFlags contains invalid flags. |
java.lang.NullPointerException |
if the given characterFlags is null. |
See Also
setGraphemeSegmentFinder
fun setGraphemeSegmentFinder(graphemeSegmentFinder: SegmentFinder): TextBoundsInfo.Builder
Set the SegmentFinder that locates the grapheme cluster boundaries. Grapheme is defined in the unicode annex #29: unicode text segmentation. It's a user-perspective character. And it's usually the minimal unit for selection, backspace, deletion etc.
Please note that only the grapheme segments within the range from start to end will be available to the IME. The remaining information will be discarded during serialization for better performance.
| Parameters | |
|---|---|
graphemeSegmentFinder |
SegmentFinder: the SegmentFinder that locates the grapheme cluster boundaries. This value cannot be null. |
| Return | |
|---|---|
TextBoundsInfo.Builder |
This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.NullPointerException |
if the given graphemeSegmentFinder is null. |
setLineSegmentFinder
fun setLineSegmentFinder(lineSegmentFinder: SegmentFinder): TextBoundsInfo.Builder
Set the SegmentFinder that locates the line boundaries. Aside from the hard breaks in the text, it should also locate the soft line breaks added by the editor. It is expected that the characters within the same line is rendered on the same baseline. (Except for some text formatted as subscript and superscript.)
Please note that only the line segments within the range from start to end will be available to the IME. The remaining information will be discarded during serialization for better performance.
| Parameters | |
|---|---|
lineSegmentFinder |
SegmentFinder: set the SegmentFinder that locates the line boundaries. This value cannot be null. |
| Return | |
|---|---|
TextBoundsInfo.Builder |
This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.NullPointerException |
if the given lineSegmentFinder is null. |
setMatrix
fun setMatrix(matrix: Matrix): TextBoundsInfo.Builder
Sets the matrix that transforms local coordinates into screen coordinates.
| Parameters | |
|---|---|
matrix |
Matrix: transformation matrix from local coordinates into screen coordinates. This value cannot be null. |
| Return | |
|---|---|
TextBoundsInfo.Builder |
This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.NullPointerException |
if the given matrix is null. |
setStartAndEnd
fun setStartAndEnd(
start: Int,
end: Int
): TextBoundsInfo.Builder
Set the start and end index of the TextBoundsInfo. It's the range of the characters whose information is available in the TextBoundsInfo.
| Parameters | |
|---|---|
start |
Int: the start index of the TextBoundsInfo, inclusive. Value is 0 or greater |
end |
Int: the end index of the TextBoundsInfo, exclusive. Value is 0 or greater |
| Return | |
|---|---|
TextBoundsInfo.Builder |
This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if the given start or end is negative, or end is smaller than the start. |
setWordSegmentFinder
fun setWordSegmentFinder(wordSegmentFinder: SegmentFinder): TextBoundsInfo.Builder
Set the SegmentFinder that locates the word boundaries.
Please note that only the word segments within the range from start to end will be available to the IME. The remaining information will be discarded during serialization for better performance.
| Parameters | |
|---|---|
wordSegmentFinder |
SegmentFinder: set the SegmentFinder that locates the word boundaries. This value cannot be null. |
| Return | |
|---|---|
TextBoundsInfo.Builder |
This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.NullPointerException |
if the given wordSegmentFinder is null. |