RFR: 8255572: Axis does not compute preferred height properly when autoRanging is off [v6]

Jeanette Winzenburg fastegal at openjdk.java.net
Wed Feb 3 17:10:44 UTC 2021


On Tue, 2 Feb 2021 12:02:17 GMT, Jeanette Winzenburg <fastegal at openjdk.org> wrote:

> 
> 
> wondering about the system test - what stands in the way to add a simple "normal" unit test?

looks like there might be a bug in StubFontLoader that makes a normal unit test fail w/out the fix: Axis uses a Text field (measure) for measuring size requirements for the tick labels - its font has no nativeFont set in the stub context such that all fields of the bounds of text are always 0, consequently the change in autoRange never kicks in. Hacking around with explicitly setting a tickLabelFont gives us a test that fails before and passes after the fix:

    @Test
    public void testRotatedStandAlone() {
        Pane root = new Pane();
        Scene scene = new Scene(root);
        Stage stage = new Stage();
        stage.setScene(scene);
        CategoryAxis xAxis = new CategoryAxis(FXCollections.observableArrayList(categories));
        // hack around stubFontLoader bug (?feature)
        xAxis.setTickLabelFont(new Font(8));
        BarChart<String, Number> chart = new BarChart<>(xAxis, new NumberAxis());
        chart.setPrefWidth(400);
        root.getChildren().add(chart);
        stage.show();
        assertEquals(90, xAxis.getTickLabelRotation(), 0.1);
    }
    
Question is why the stubFontLoader fails: its load implementation looks like it should always set the nativeFont fiel to a fitting test font, but it doesn't if the name is a plain "Amble" (vs. a more specialized like "Amble Regular").

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

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


More information about the openjfx-dev mailing list