[Review Request] Support fixed cell heights in JavaFX UI controls
Jonathan Giles
jonathan.giles at oracle.com
Sun May 19 19:41:50 PDT 2013
Hi all,
https://javafx-jira.kenai.com/browse/RT-30476
In our ongoing effort to make JavaFX fast, especially on constrained
systems such as the Raspberry Pi, I'd like to propose the addition of
API to the ListView, TreeView, TreeTableView and TableView controls that
allows for developers to specify a fixed row height for all rows. Should
a developer set this, they would be explicitly telling JavaFX that their
cells will not dynamically resize. In return for giving up this
functionality, JavaFX can do two things that massively helps performance:
1) The virtualisation code can short-circuit all height measurements
(and many resizing operations). This saves JavaFX from having to perform
massive amounts of string measurement, which is a big bottleneck.
2) The TableView and TreeTableView controls can virtualise in the
horizontal direction. In other words, for all columns that are not
visible (as the width of all columns exceeds the width of the TableView
itself), the cells contained within obstructed columns will be removed
from the scenegraph (and added back in as necessary as the user scrolls
horizontally). This saves JavaFX from having to perform CSS / layout on
all of these cells. The reason why this is enabled only with fixed cell
height is because we can not know whether cells outside the visible area
have an impact on the row height.
In our tests enabling a fixed row height has massive gains in runtime
and startup performance. It won't be useful to everyone, but I would
imagine that it would be applicable for most people. However, because
enabling this by default would potentially break a lot of people, this
functionality will _not_ be enabled by default.
I'm slightly conscious of the fact that using the term 'fixed cell
_height_' is confusing in the case of a ListView which is laid out
horizontally. Therefore, my suggested API would be either a
fixedCellHeight double property or a fixedCellLength double property
(where length is the term used internally to differentiate from the cell
breadth). From an ease-of-understanding point of view I much prefer
fixedCellHeight however - most people won't be using horizontal
ListViews, so it is unlikely to be confusing. My preferred approach
would be to have the property default to Region.USE_COMPUTED_SIZE to
indicate that fixed cell height should not be used. To enable the
functionality, a positive value can be set. I'm not wed to using
Region.USE_COMPUTED_SIZE, so if that feels confusing we could just state
a negative value will disable the value.
Thoughts?
--
-- Jonathan
More information about the openjfx-dev
mailing list