RFR: 8314482: TextFlow: TabStopPolicy [v4]

Andy Goryachev angorya at openjdk.org
Wed Jun 18 18:54:17 UTC 2025


> # Tab Stop Policy
> 
> Andy Goryachev
> 
> <andy.goryachev at oracle.com>
> 
> 
> ## Summary
> 
> Introduce a `tabStopPolicy` property in the `TextFlow` class which, when set, overrides the existing `tabSize`
> value and provides consistent way of setting tab stops at the paragraph level, regardless of the individual text
> segments font [0].
> 
> ![Screenshot 2025-05-19 at 15 03 26](https://github.com/user-attachments/assets/32f2474d-7d2b-47b0-a22c-410d485f4e40)
> 
> 
> ## Goals
> 
> The goal of this proposal is to provide a better way for controlling tab stops in the `TextFlow` containing rich text.
> 
> 
> 
> ## Non-Goals
> 
> The following are not the goals of this proposal:
> 
> - support for tab stop types (BAR, or DECIMAL), or attributes like `alignment`
> - support the `leader` property (symbols to fill the empty space before the tab stop)
> - support for `firstLineIndent` property
> - deprecate the `TextFlow::tabsize` property
> 
> 
> 
> ## Motivation
> 
> The existing `tabSize` property in the `TextFlow` is inadequate for representing tab stops when the content
> contains text with different font sizes.
> 
> In addition to that, a rich text editor might require support for user-customizable tab stops, similar to that provided
> in RTF or MS Word documents.
> 
> 
> 
> 
> ## Description
> 
> ### TextFlow
> 
> 
>     /**
>      * {@code TabAdvancePolicy} determines the tab stop positions within this {@code TextFlow}.
>      * <p>
>      * A non-null {@code TabAdvancePolicy} overrides values set by {@link #setTabSize(int)},
>      * as well as any values set by {@link Text#setTabSize(int)} in individual {@code Text} instances within
>      * this {@code TextFlow}.
>      *
>      * @defaultValue null
>      *
>      * @since 999 TODO
>      */
>     public final ObjectProperty<TabStopPolicy> tabStopPolicyProperty() {
> 
>     public final TabStopPolicy getTabStopPolicy() {
> 
>     public final void setTabStopPolicy(TabStopPolicy policy) {
> 
>     /**
>      * The size of a tab stop in spaces.
>      * Values less than 1 are treated as 1. This value overrides the
>      * {@code tabSize} of contained {@link Text} nodes.
>      * <p>
> +     * Note that this method should not be used to control the tab placement when multiple {@code Text} nodes
> +     * with different fonts are contained within this {@code TextFlow}.
> +     * In this case, the {@link #setTabStopPolicy(TabStopPolicy)} should be used instead.
>      *
>      * @defaultValue 8
>      *
>      * @since 14
>      */
>     public final IntegerProperty tabSizeProperty() {
> 
> 
> 
> ### TabStopPolicy
> 
> 
> /**
>  * The TabStopPolicy determines the tab stop pos...

Andy Goryachev has updated the pull request incrementally with one additional commit since the last revision:

  final tab stop

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

Changes:
  - all: https://git.openjdk.org/jfx/pull/1744/files
  - new: https://git.openjdk.org/jfx/pull/1744/files/ef38166a..f873a5b9

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jfx&pr=1744&range=03
 - incr: https://webrevs.openjdk.org/?repo=jfx&pr=1744&range=02-03

  Stats: 8 lines in 2 files changed: 0 ins; 3 del; 5 mod
  Patch: https://git.openjdk.org/jfx/pull/1744.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1744/head:pull/1744

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


More information about the openjfx-dev mailing list