TextBoundsInfo.Builder
public
static
final
class
TextBoundsInfo.Builder
extends Object
The builder class to create a TextBoundsInfo
object.
Summary
Inherited methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted.
|
|
Public constructors
Builder
public Builder (int start,
int end)
Create a builder for TextBoundsInfo
.
Public methods
build
public TextBoundsInfo build ()
Create the TextBoundsInfo
using the parameters in this Builder
.
Throws |
IllegalStateException |
in the following conditions:
- if the
start or end is not set.
- if the
matrix is not set.
- if
characterBounds is not set or its length doesn't equal to
4 * (end - start ).
- if the
characterFlags is not set or its length doesn't equal to
(end - start ).
- if
graphemeSegmentFinder , wordSegmentFinder or
lineSegmentFinder is not set.
- if characters in the same line has inconsistent
TextBoundsInfo.FLAG_LINE_IS_RTL
flag.
|
setCharacterBidiLevel
public TextBoundsInfo.Builder setCharacterBidiLevel (int[] characterBidiLevels)
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 |
int : the array of the character's BiDi level.
This value cannot be null . |
setCharacterBounds
public TextBoundsInfo.Builder setCharacterBounds (float[] characterBounds)
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 |
float : the array of the flattened character bounds.
This value cannot be null . |
setCharacterFlags
public TextBoundsInfo.Builder setCharacterFlags (int[] characterFlags)
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:
Parameters |
characterFlags |
int : the array of the character's flags.
This value cannot be null . |
setGraphemeSegmentFinder
public TextBoundsInfo.Builder setGraphemeSegmentFinder (SegmentFinder graphemeSegmentFinder)
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 . |
setLineSegmentFinder
public TextBoundsInfo.Builder setLineSegmentFinder (SegmentFinder lineSegmentFinder)
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 . |
setMatrix
public TextBoundsInfo.Builder setMatrix (Matrix matrix)
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 . |
setStartAndEnd
public TextBoundsInfo.Builder setStartAndEnd (int start,
int end)
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 |
setWordSegmentFinder
public TextBoundsInfo.Builder setWordSegmentFinder (SegmentFinder wordSegmentFinder)
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 . |