RFR: 8341670: [Text, TextFlow] Public API for Text Layout Info [v6]

Andy Goryachev angorya at openjdk.org
Fri Oct 11 22:33:59 UTC 2024


> The RichTextArea control ([JDK-8301121](https://bugs.openjdk.org/browse/JDK-8301121)), or any custom control that needs non-trivial navigation within complex or wrapped text needs a public API to get information about text layout.
> 
> This change fixes the missing functionality by adding a new public method to the `Text` and `TextFlow` classes.:
> 
> 
>     /**
>      * Obtains the snapshot of the current text layout information.
>      * @return the layout information
>      * @since 24
>      */
>     public final LayoutInfo getLayoutInfo()
> 
> 
> The `LayoutInfo` provides a view into the text layout within `Text`/`TextFlow` nodes such as:
> 
> - text lines: offsets and bounds
> - overall layout bounds
> - text selection geometry
> - strike-through geometry
> - underline geometry
> 
> This PR also adds the missing `strikeThroughShape()` method to complement existing `underlineShape()` and `rangeShape()` for consistency sake:
> 
> 
>     /**
>      * Returns the shape for the strike-through in local coordinates.
>      *
>      * @param start the beginning character index for the range
>      * @param end the end character index (non-inclusive) for the range
>      * @return an array of {@code PathElement} which can be used to create a {@code Shape}
>      * @since 24
>      */
>     public final PathElement[] strikeThroughShape(int start, int end)

Andy Goryachev has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains eight additional commits since the last revision:

 - text line info
 - Merge remote-tracking branch 'origin/master' into ag.text.layout.api
 - convert to wrapper
 - clarify
 - javadoc
 - review comments
 - bounds
 - draft api

-------------

Changes:
  - all: https://git.openjdk.org/jfx/pull/1596/files
  - new: https://git.openjdk.org/jfx/pull/1596/files/2009a7eb..c2e26d5e

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jfx&pr=1596&range=05
 - incr: https://webrevs.openjdk.org/?repo=jfx&pr=1596&range=04-05

  Stats: 903 lines in 41 files changed: 664 ins; 138 del; 101 mod
  Patch: https://git.openjdk.org/jfx/pull/1596.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1596/head:pull/1596

PR: https://git.openjdk.org/jfx/pull/1596


More information about the openjfx-dev mailing list