[Rev 03] RFR: 8130738: Add tabSize property to Text and TextFlow

Nir Lisker nlisker at openjdk.java.net
Thu Dec 12 21:52:11 UTC 2019


On Thu, 12 Dec 2019 21:52:05 GMT, Scott Palmer <swpalmer at openjdk.org> wrote:

>> Added tabSize property to Text and TextFlow and -fx-tab-size CSS attribute to both.  TextFlow's tab size overrides that of contained Text nodes.
> 
> The pull request has been updated with 1 additional commit.

modules/javafx.graphics/src/main/java/javafx/scene/text/Text.java line 1273:

> 1272:     /**
> 1273:      * The size of a tab stop in spaces.
> 1274:      * Values less than 1 are treated as 1.

"tab stop" seems to be an uncommon term. Better are "horizontal tab" (used in the [JLS](https://docs.oracle.com/javase/specs/jls/se13/html/jls-3.html#jls-3.10.6)), "tab character" (used in [`Pattern`](https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/util/regex/Pattern.html), "horizontal tabulation" or the like.

modules/javafx.graphics/src/main/java/javafx/scene/text/Text.java line 1276:

> 1275:      *
> 1276:      * @defaultValue {@code 8}
> 1277:      *

No need for `@code` with numeric constants.

modules/javafx.graphics/src/main/java/javafx/scene/text/Text.java line 1450:

> 1449:         private static final CssMetaData<Text,Number> TAB_SIZE =
> 1450:                 new CssMetaData<Text,Number>("-fx-tab-size",
> 1451:                 SizeConverter.getInstance(), TextLayout.DEFAULT_TAB_SIZE) {

I think that type parameters should have space separation after a comma: `Text, Number`, though I've seen without too.

modules/javafx.graphics/src/main/java/javafx/scene/text/Text.java line 1882:

> 1881:                         return StyleableProperties.TAB_SIZE;
> 1882:                     }
> 1883:                     @Override protected void invalidated() {

The `SimpleStyleableIntegerProperty` subclass can be used instead of `StyleableIntegerProperty` to make the code cleaner:
new SimpleStyleableIntegerProperty(StyleableProperties.TAB_SIZE, Text.this, "tabSize", TextLayout.DEFAULT_TAB_SIZE);

(This can be done for many places in the library)

modules/javafx.graphics/src/main/java/javafx/scene/text/Text.java line 1883:

> 1882:                     }
> 1883:                     @Override protected void invalidated() {
> 1884:                         TextLayout layout = getTextLayout();

I think that annotations tend to go on a line above what they annotate,

modules/javafx.graphics/src/main/java/javafx/scene/text/TextFlow.java line 575:

> 574:         private static final CssMetaData<TextFlow,Number> TAB_SIZE =
> 575:                 new CssMetaData<TextFlow,Number>("-fx-tab-size",
> 576:                 SizeConverter.getInstance(), TextLayout.DEFAULT_TAB_SIZE) {

Same comment as for `Text`.

modules/javafx.graphics/src/main/java/javafx/scene/text/TextFlow.java line 517:

> 516:                 }
> 517:                 @Override protected void invalidated() {
> 518:                     TextLayout layout = getTextLayout();

Same comments as for `Text`.

modules/javafx.graphics/src/main/java/javafx/scene/text/TextFlow.java line 495:

> 494:      *
> 495:      * @defaultValue {@code 8}
> 496:      *

Same comments as for `Text`.

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

Changes requested by nlisker (Committer).

PR: https://git.openjdk.java.net/jfx/pull/32


More information about the openjfx-dev mailing list