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

Ajit Ghaisas aghaisas at openjdk.java.net
Tue Dec 22 09:38:56 UTC 2020


On Wed, 25 Nov 2020 18:06:10 GMT, Jonathan Vusich <github.com+31666175+JonathanVusich at openjdk.org> wrote:

>> As noted in the corresponding JBS issue, `Axis` does not properly compute its preferred height when `autoRanging` is turned off. The simplest fix seems to be changing `CategoryAxis` so that `tickLabelRotation` is set to 90 degrees if there is not enough room for the category labels to layout horizontally. This fixes the fact that the axis labels are truncated and also ensures that the chart does not leave unused space from the layout calculations. `CategoryAxis` is already setting the `categorySpacing` property when `autoRanging` is off, so this seems to be an appropriate fix.
>
> Jonathan Vusich has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Unrotate labels if there is enough space for them

modules/javafx.controls/src/main/java/javafx/scene/chart/CategoryAxis.java line 381:

> 379:                 }
> 380:             }
> 381:             if (!isAutoRanging()) setTickLabelRotation(tickLabelRotation);

At first, I thought this setTickLabelRotation() call violates the method javadoc above. On a second look, I found that the javadoc is applicable only if AutoRanging() is true.
Method calls - calculateNewSpacing() and calculateNewFirstPos() also set properties if AutoRanging is false. Hence, this fix seems OK to me.

modules/javafx.controls/src/main/java/javafx/scene/chart/CategoryAxis.java line 48:

> 46: import javafx.util.Duration;
> 47: 
> 48: import com.sun.javafx.binding.Logging;

This looks unused import. Please remove it.

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

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


More information about the openjfx-dev mailing list