Comments on: New to JavaFX 1.3: Cellshttp://fxexperience.com/2010/04/new-to-javafx-1-3-cells/
Sharing the Experience of JavaFXMon, 05 Dec 2016 13:59:06 +0000hourly1By: Narayan gopalhttp://fxexperience.com/2010/04/new-to-javafx-1-3-cells/comment-page-1/#comment-9015
Sun, 22 Aug 2010 16:28:41 +0000http://fxexperience.com/?p=644#comment-9015You are awesome.
The css was so fun..
It was so easy i didn’t even know.

Thanks
for the grt post!

]]>By: Richard Bairhttp://fxexperience.com/2010/04/new-to-javafx-1-3-cells/comment-page-1/#comment-8778
Mon, 09 Aug 2010 03:58:49 +0000http://fxexperience.com/?p=644#comment-8778The problem with this is that if you have, say, 2000 items in your list, then you would have 2000 HBoxes & Labels & Buttons when only 10 or so would be visible. This is a huge waste of memory and clearly doesn’t scale up (suppose you had 30,000 items in your list. Or 3 million).

Being able to have a cell factory is crucial to virtualization, which is itself crucial for virtualization.

]]>By: Richard Bairhttp://fxexperience.com/2010/04/new-to-javafx-1-3-cells/comment-page-1/#comment-8777
Mon, 09 Aug 2010 03:56:28 +0000http://fxexperience.com/?p=644#comment-8777That is the one weakness with our approach, in that the cell factory produces a cell that needs to work with every row rather than providing, say, a row index and having the developer return a different cell based on the index or item at that index. However, the reason we didn’t do that is because then you’d have to maintain a cache of cells and be notified whenever they are in use or released and manage that pool yourself, which is really complicated.

So instead, what you have to do is return a single Cell which is capable of rendering any of the items. If you have, say, 2 different types of cells you want to display, then each Cell has to have 2 different sub-scenegraphs and then choose which one to use as the “node” based on the current index. SO for example:

Or you can just have your custom cell have a variable for each type of sub-scene and lazily create them on demand, and then in the onUpdate callback do the switch there instead of using “bind” as the above code would create & throw away the subscenes pretty frequently.

My calculation here was that it was better to provide a very simple cell factory interface rather than force developers to manage a pool of cells manually, with the assumption that there would typically not be a very large number of different renderings in a single list. If you find you have a use case where you really do have a lot of different cell types in a single list, then you could go all the way if you wanted to by doing something like a ListCellComposite subclass of ListCell that would take a sequence of ListCells, or have a ListCellCreator subclass that would have cell-pool functions built into it and a shared HashMap or something of cells.

For example, suppose you had 100 different cell types to render. Under the basic API we provide, if the ListView needed 20 cells, it would end up creating 20 cells which would potentially have 100 different sub-scenes — and that 2000 different subscenes could be quite taxing on memory and such. Instead, suppose your implementation of the ListCell could refer to a pool of subscenes. When it needs one, it checks it out and assigns it to its node. When it is done with it, it puts it back. In this way you have 20 cells and only another 20 sub-scenes at first. Over time if every variation was used you could get up to all 2000 different subscenes, but it is unlikely, so you would probably save memory. Of course they could be housed in soft references so they are free’d if memory gets tight.

Are there limits to the flexibility that the cell factories support? If I have a really heterogeneous sequence of data to be rendered in a single list how would I go about creating wildly different nodes based on the type of data?

Thanks,
Keith

]]>By: rk tumulurihttp://fxexperience.com/2010/04/new-to-javafx-1-3-cells/comment-page-1/#comment-7828
Fri, 02 Jul 2010 06:53:08 +0000http://fxexperience.com/?p=644#comment-7828Awesome hidden power in these ListView controls. Very deceptive.
Good article to showcase the power.

]]>By: Ryanhttp://fxexperience.com/2010/04/new-to-javafx-1-3-cells/comment-page-1/#comment-6360
Thu, 06 May 2010 07:53:15 +0000http://fxexperience.com/?p=644#comment-6360+1 for liking the idea of having a single concept for many components. I haven’t experimented with JavaFX too much yet, but I’ve read a ton of articles like this and it’s starting to impress me.

For me, this implementation does a very good job of giving me the control I need to make a component useful while shielding me from a lot of the complexity that would normally have me over engineering things in plain old Java.

I think you guys are striking a nice balance of flexibility vs complexity. I can see JavaFX being a very productive platform.