JDK-8144907 : Support sorted children
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: scenegraph
  • Affected Version: 8u60
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2015-12-08
  • Updated: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
I suggest adding support for the automatic sorting of a Parent's children. 
Motivation: In our app we show a map with pins marking places of interest. A pin which is lower on screenshould always be in front of a pin which is higher, creating the illusion that pins to the south are in front of pins to the north.
Since the children of a JavaFX Parent are not sorted, we have to trigger sorting by listening to changes to the list. This works, but I think our code would be a lot simpler, if we could just invoke

Comparator comparator = new Comparator() {...};
someParent.setChildrenSort(comparator);
someParent.setChildrenSortEnabled(true);

Moreover, such a default implementation could be written in a performance optimising way which would group multiple list changes into a single sort, if you added a method
Parent.setChildrenSortInterval(Duration);

For us to be able to still write list change listeners, we would also require the ability to distinguish between ordinary list changes and sorting permutations, so a method like
boolean Parent.isSorting()
might be relevant.

Comments
This isn't exactly matches the requested support. However, with the addition of viewOrder property ( JDK-8144556 ) to control the rendering and picking order of children, developer can now bind each child's viewOrder to a preferred sorting function of his/her choosing. The sorting interval can also be made as a trigger to the sorting function.
18-04-2016

This is a related request to JDK-8144556 which is targeted for JDK 9. Rather than actually sorting the children list, which can affect layout in ways that are undesirable, we are considering changing the rendering and picking algorithms to use a sorted view of the children. Chien can comment in more detail, but the likely solution for that RFE will be to add a new "priority" (or similar) property to Node that would become the primary sort key for rendering and picking. The child order would be used if the primary sort indicated that two nodes were equal. We should keep this RFE in mind when implementing JDK-8144556, so that we don't preclude adding a more general comparator in the future.
18-02-2016

We do not use issue type "New feature" so changing to Enhancement.
18-02-2016