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

Kevin Rushforth kcr at openjdk.java.net
Thu Dec 12 15:52:42 UTC 2019


On Thu, 12 Dec 2019 15:19:39 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> I just noticed while updating the CSR that, while I mentioned it on the mailing list, the fact that TextFlow's tabSize override that of any contained Text nodes is not documented.
>> Shall I add to the javadoc for tabSize  in TextFlow : "This value overrides the tabSize of contained Text nodes." ?
> 
> Good catch. Yes, please update it as you suggested.

The following comment from @swpalmer sent to the openjfx-dev mailing list wasn't mirrored in the PR (I have alerted the Skara team about this).

----
From: Scott Palmer

> I think a new `TextFlowTest.java` would be a good place for those tests.

My first attempt at unit tests for TextFlow are failing.  I believe the StubTextLayout is not equipped to handle TextFlow.  This may be a bigger job…

This fragment triggers a NPE:
...
        Toolkit tk = (StubToolkit) Toolkit.getToolkit();
        HBox root = new HBox();
        Scene scene = new Scene(root);
        Stage stage = new Stage();
        stage.setScene(scene);
        stage.setWidth(300);
        stage.setHeight(200);

        try {
            Text text1 = new Text("\tfirst");
            Text text2 = new Text("\tsecond");
            TextFlow textFlow = new TextFlow(text1, text2);
            root.getChildren().addAll(textFlow);
            stage.show();
...

test.javafx.scene.text.TextFlowTest > testTabSize FAILED
    java.lang.NullPointerException
        at test.com.sun.javafx.pgstub.StubTextLayout.getBounds(StubTextLayout.java:88)
        at test.com.sun.javafx.pgstub.StubTextLayout.getBounds(StubTextLayout.java:82)
        at javafx.graphics/javafx.scene.text.TextFlow.computePrefWidth(TextFlow.java:254)
        at javafx.graphics/javafx.scene.Parent.prefWidth(Parent.java:1019)
        at javafx.graphics/javafx.scene.layout.Region.prefWidth(Region.java:1543)
        at javafx.graphics/javafx.scene.layout.Region.computeChildPrefAreaWidth(Region.java:1946)
        at javafx.graphics/javafx.scene.layout.HBox.getAreaWidths(HBox.java:465)
        at javafx.graphics/javafx.scene.layout.HBox.computeContentWidth(HBox.java:540)
        at javafx.graphics/javafx.scene.layout.HBox.computePrefWidth(HBox.java:433)
        at javafx.graphics/javafx.scene.Parent.prefWidth(Parent.java:1019)
        at javafx.graphics/javafx.scene.layout.Region.prefWidth(Region.java:1543)
        at javafx.graphics/javafx.scene.Scene.getPreferredWidth(Scene.java:1799)
        at javafx.graphics/javafx.scene.Scene.resizeRootToPreferredSize(Scene.java:1779)
        at javafx.graphics/javafx.scene.Scene.preferredSize(Scene.java:1747)
        at javafx.graphics/javafx.scene.Scene$2.preferredSize(Scene.java:393)
        at javafx.graphics/com.sun.javafx.scene.SceneHelper.preferredSize(SceneHelper.java:66)
        at javafx.graphics/javafx.stage.Window$12.invalidated(Window.java:1086)
        at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
        at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
        at javafx.graphics/javafx.stage.Window.setShowing(Window.java:1174)
        at javafx.graphics/javafx.stage.Window.show(Window.java:1189)
        at javafx.graphics/javafx.stage.Stage.show(Stage.java:273)
        at test.javafx.scene.text.TextFlowTest.testTabSize(TextFlowTest.java:60)

Scott

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

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


More information about the openjfx-dev mailing list