RFR: 8314482: TextFlow: TabStopPolicy [v6]
Kevin Rushforth
kcr at openjdk.org
Wed Jul 9 20:47:51 UTC 2025
On Wed, 9 Jul 2025 20:27:07 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> # 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].
>>
>> 
>>
>>
>> ## 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
>> *...
>
> Andy Goryachev has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 62 commits:
>
> - since 25
> - review comments
> - Merge remote-tracking branch 'origin/master' into 8314482.tab.stops
> - Merge remote-tracking branch 'origin/master' into 8314482.tab.stops
> - final tab stop
> - review comments
> - Merge remote-tracking branch 'origin/master' into 8314482.tab.stops
> - cleanup
> - api
> - Merge remote-tracking branch 'origin/master' into 8314482.tab.stops
> - ... and 52 more: https://git.openjdk.org/jfx/compare/639a5950...00bcf4b0
APi looks good with one question and a few working suggestions.
modules/javafx.graphics/src/main/java/javafx/scene/text/TabStopPolicy.java line 54:
> 52: * @return the non-null list of tab stops
> 53: */
> 54: public final ObservableList<TabStop> tabStops() {
Did you consider also dropping "tab" from the name here? Either is fine with me, so I'll leave it up to you.
modules/javafx.graphics/src/main/java/javafx/scene/text/TabStopPolicy.java line 61:
> 59: * Specifies the default tab stop interval (beyond the last tab stop provided by {@code #tabStops()}),
> 60: * as a fixed repeating distance (in pixels) to the next tab stop computed at regular intervals
> 61: * relative to the leading edge of the {@code TextFlow} node.
This is a bit of a run-on sentence. Maybe consider breaking it up into two sentences, with the detail about "a fixed, repeating distance..." in the second sentence? Something like:
* Specifies the default tab stop interval for tabs beyond the last stop provided
* by {@code #tabStops()}. This is a fixed repeating distance (in pixels) to the
* next tab stop computed at regular intervals relative to the leading edge
* of the {@code TextFlow} node.
modules/javafx.graphics/src/main/java/javafx/scene/text/TextFlow.java line 531:
> 529: * Note that this method should not be used to control the tab placement when multiple {@code Text} nodes
> 530: * with different fonts are contained within this {@code TextFlow}.
> 531: * In this case, the {@link #setTabStopPolicy(TabStopPolicy)} should be used instead.
either drop the word "the" before "setTabStopPolicy" or add "method" after.
modules/javafx.graphics/src/main/java/javafx/scene/text/TextFlow.java line 569:
> 567:
> 568: /**
> 569: * {@code TabStopPolicy} determines the tab stop positions within this {@code TextFlow}.
I think you can remove `{@code TabStopPolicy}` since that's what this property is. Start with "Determines the ..."
-------------
PR Review: https://git.openjdk.org/jfx/pull/1744#pullrequestreview-3003009745
PR Review Comment: https://git.openjdk.org/jfx/pull/1744#discussion_r2195925106
PR Review Comment: https://git.openjdk.org/jfx/pull/1744#discussion_r2195927394
PR Review Comment: https://git.openjdk.org/jfx/pull/1744#discussion_r2195934301
PR Review Comment: https://git.openjdk.org/jfx/pull/1744#discussion_r2195937805
More information about the openjfx-dev
mailing list