Liking cljdoc? Tell your friends :D

jdk.awt.font.TextHitInfo

The TextHitInfo class represents a character position in a text model, and a bias, or "side," of the character. Biases are either leading (the left edge, for a left-to-right character) or trailing (the right edge, for a left-to-right character). Instances of TextHitInfo are used to specify caret and insertion positions within text.

For example, consider the text "abc". TextHitInfo.trailing(1) corresponds to the right side of the 'b' in the text.

TextHitInfo is used primarily by TextLayout and clients of TextLayout. Clients of TextLayout query TextHitInfo instances for an insertion offset, where new text is inserted into the text model. The insertion offset is equal to the character position in the TextHitInfo if the bias is leading, and one character after if the bias is trailing. The insertion offset for TextHitInfo.trailing(1) is 2.

Sometimes it is convenient to construct a TextHitInfo with the same insertion offset as an existing one, but on the opposite character. The getOtherHit method constructs a new TextHitInfo with the same insertion offset as an existing one, with a hit on the character on the other side of the insertion offset. Calling getOtherHit on trailing(1) would return leading(2). In general, getOtherHit for trailing(n) returns leading(n+1) and getOtherHit for leading(n) returns trailing(n-1).

Example: Converting a graphical point to an insertion point within a text model

TextLayout layout = ...; Point2D.Float hitPoint = ...; TextHitInfo hitInfo = layout.hitTestChar(hitPoint.x, hitPoint.y); int insPoint = hitInfo.getInsertionIndex(); // insPoint is relative to layout; may need to adjust for use // in a text model

The TextHitInfo class represents a character position in a
text model, and a bias, or "side," of the character.  Biases are
either leading (the left edge, for a left-to-right character)
or trailing (the right edge, for a left-to-right character).
Instances of TextHitInfo are used to specify caret and
insertion positions within text.

For example, consider the text "abc".  TextHitInfo.trailing(1)
corresponds to the right side of the 'b' in the text.

TextHitInfo is used primarily by TextLayout and
clients of TextLayout.  Clients of TextLayout
query TextHitInfo instances for an insertion offset, where
new text is inserted into the text model.  The insertion offset is equal
to the character position in the TextHitInfo if the bias
is leading, and one character after if the bias is trailing.  The
insertion offset for TextHitInfo.trailing(1) is 2.

Sometimes it is convenient to construct a TextHitInfo with
the same insertion offset as an existing one, but on the opposite
character.  The getOtherHit method constructs a new
TextHitInfo with the same insertion offset as an existing
one, with a hit on the character on the other side of the insertion offset.
Calling getOtherHit on trailing(1) would return leading(2).
In general, getOtherHit for trailing(n) returns
leading(n+1) and getOtherHit for leading(n)
returns trailing(n-1).

Example:
Converting a graphical point to an insertion point within a text
model


TextLayout layout = ...;
Point2D.Float hitPoint = ...;
TextHitInfo hitInfo = layout.hitTestChar(hitPoint.x, hitPoint.y);
int insPoint = hitInfo.getInsertionIndex();
// insPoint is relative to layout;  may need to adjust for use
// in a text model
raw docstring

*after-offsetclj

(*after-offset offset)

Creates a TextHitInfo at the specified offset, associated with the character after the offset.

offset - an offset associated with the character after the offset - int

returns: a TextHitInfo at the specified offset. - java.awt.font.TextHitInfo

Creates a TextHitInfo at the specified offset,
 associated with the character after the offset.

offset - an offset associated with the character after the offset - `int`

returns: a TextHitInfo at the specified offset. - `java.awt.font.TextHitInfo`
raw docstring

*before-offsetclj

(*before-offset offset)

Creates a TextHitInfo at the specified offset, associated with the character before the offset.

offset - an offset associated with the character before the offset - int

returns: a TextHitInfo at the specified offset. - java.awt.font.TextHitInfo

Creates a TextHitInfo at the specified offset,
 associated with the character before the offset.

offset - an offset associated with the character before the offset - `int`

returns: a TextHitInfo at the specified offset. - `java.awt.font.TextHitInfo`
raw docstring

*leadingclj

(*leading char-index)

Creates a TextHitInfo on the leading edge of the character at the specified charIndex.

char-index - the index of the character hit - int

returns: a TextHitInfo on the leading edge of the character at the specified charIndex. - java.awt.font.TextHitInfo

Creates a TextHitInfo on the leading edge of the
 character at the specified charIndex.

char-index - the index of the character hit - `int`

returns: a TextHitInfo on the leading edge of the
 character at the specified charIndex. - `java.awt.font.TextHitInfo`
raw docstring

*trailingclj

(*trailing char-index)

Creates a hit on the trailing edge of the character at the specified charIndex.

char-index - the index of the character hit - int

returns: a TextHitInfo on the trailing edge of the character at the specified charIndex. - java.awt.font.TextHitInfo

Creates a hit on the trailing edge of the character at
 the specified charIndex.

char-index - the index of the character hit - `int`

returns: a TextHitInfo on the trailing edge of the
 character at the specified charIndex. - `java.awt.font.TextHitInfo`
raw docstring

equalsclj

(equals this obj)

Returns true if the specified Object is a TextHitInfo and equals this TextHitInfo.

obj - the Object to test for equality - java.lang.Object

returns: true if the specified Object equals this TextHitInfo; false otherwise. - boolean

Returns true if the specified Object is a
 TextHitInfo and equals this TextHitInfo.

obj - the Object to test for equality - `java.lang.Object`

returns: true if the specified Object
 equals this TextHitInfo; false otherwise. - `boolean`
raw docstring

get-char-indexclj

(get-char-index this)

Returns the index of the character hit.

returns: the index of the character hit. - int

Returns the index of the character hit.

returns: the index of the character hit. - `int`
raw docstring

get-insertion-indexclj

(get-insertion-index this)

Returns the insertion index. This is the character index if the leading edge of the character was hit, and one greater than the character index if the trailing edge was hit.

returns: the insertion index. - int

Returns the insertion index.  This is the character index if
 the leading edge of the character was hit, and one greater
 than the character index if the trailing edge was hit.

returns: the insertion index. - `int`
raw docstring

get-offset-hitclj

(get-offset-hit this delta)

Creates a TextHitInfo whose character index is offset by delta from the charIndex of this TextHitInfo. This TextHitInfo remains unchanged.

delta - the value to offset this charIndex - int

returns: a TextHitInfo whose charIndex is offset by delta from the charIndex of this TextHitInfo. - java.awt.font.TextHitInfo

Creates a TextHitInfo whose character index is offset
 by delta from the charIndex of this
 TextHitInfo. This TextHitInfo remains
 unchanged.

delta - the value to offset this charIndex - `int`

returns: a TextHitInfo whose charIndex is
 offset by delta from the charIndex of
 this TextHitInfo. - `java.awt.font.TextHitInfo`
raw docstring

get-other-hitclj

(get-other-hit this)

Creates a TextHitInfo on the other side of the insertion point. This TextHitInfo remains unchanged.

returns: a TextHitInfo on the other side of the insertion point. - java.awt.font.TextHitInfo

Creates a TextHitInfo on the other side of the
 insertion point.  This TextHitInfo remains unchanged.

returns: a TextHitInfo on the other side of the
 insertion point. - `java.awt.font.TextHitInfo`
raw docstring

hash-codeclj

(hash-code this)

Returns the hash code.

returns: the hash code of this TextHitInfo, which is also the charIndex of this TextHitInfo. - int

Returns the hash code.

returns: the hash code of this TextHitInfo, which is
 also the charIndex of this TextHitInfo. - `int`
raw docstring

leading-edge?clj

(leading-edge? this)

Returns true if the leading edge of the character was hit.

returns: true if the leading edge of the character was hit; false otherwise. - boolean

Returns true if the leading edge of the character was
 hit.

returns: true if the leading edge of the character was
 hit; false otherwise. - `boolean`
raw docstring

to-stringclj

(to-string this)

Returns a String representing the hit for debugging use only.

returns: a String representing this TextHitInfo. - java.lang.String

Returns a String representing the hit for debugging
 use only.

returns: a String representing this
 TextHitInfo. - `java.lang.String`
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close