RFR: 8255572: Axis does not compute preferred height properly when autoRanging is off [v6]
Jonathan Vusich
github.com+31666175+jonathanvusich at openjdk.java.net
Mon Apr 26 13:17:32 UTC 2021
On Fri, 23 Apr 2021 23:28:49 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:
>> Jonathan Vusich has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Add tests for vertical axis as well
>> - Improve layout calculations for rotated text
>
> modules/javafx.controls/src/main/java/javafx/scene/chart/CategoryAxis.java line 365:
>
>> 363: double requiredLengthToDisplay = calculateRequiredSize(side.isVertical(), tickLabelRotation);
>> 364: if (requiredLengthToDisplay > length) {
>> 365: if (tickLabelRotation != 90) {
>
> One difference between the new algorithm and the old is that the new doesn't take into account which side you are on. If the only two values are 0 or 90, then it wouldn't matter. But what happens when someone sets a 45 degree rotation (or 30)?
Well, it's complicated. The algorithm that calculates the required space for the tick labels does not take into account the tick label rotation. I did not look into adding this at this time because that opens up a lot of other potential pathways that seem broader in scope. Currently, if the application detects that there is not enough space to display the text at the current rotation (which is assumed to be either 90 or 0 degrees), we rotate it by 90 degrees and remeasure. If that second remeasuring shows that the tick labels can be fully displayed at that rotation, the tick label rotation is overwritten to either 0 or 90 degrees. Theoretically if a user defines a set tick label rotation, it can be overwritten under these circumstances. However, I think this is reasonable given that when `autoRanging` is disabled a number of other properties are also overwritten in a similar manner.
-------------
PR: https://git.openjdk.java.net/jfx/pull/342
More information about the openjfx-dev
mailing list