Re: Permutation of scene graph children

2014-12-02 Thread Tomas Mikula
Hi Werner, On Tue, Dec 2, 2014 at 11:50 AM, Werner Lehmann wrote: > Tom, > > I know about Collections.swap but it looks like a bad idea to use on scene > graph children because it seems to temporarily have a duplicate element in > the list and I can't have a node twice in the scene graph. The set

Re: Permutation of scene graph children

2014-12-02 Thread Jens Kapitza
maybe this https://docs.oracle.com/javase/8/javafx/api/javafx/collections/ModifiableObservableListBase.html can help you? you can implement your swap onto a delegate and then just wrap ModifiableObservableListBase around. Jens Am 02.12.2014 um 12:23 schrieb Tom Schindl: I think the onl

Re: Permutation of scene graph children

2014-12-02 Thread Tom Schindl
I don't think adding static methods to FxCollections/Collections is the way to go in a Java8 world, they have been work arounds in a pre-default method time! Tom Von meinem iPhone gesendet > Am 02.12.2014 um 06:33 schrieb Anirvan Sarkar : > > Hi, > > java.util.List doesn't support a swap oper

Re: Permutation of scene graph children

2014-12-02 Thread Tom Schindl
I think the only really effecient way is to have the methods on the interface of observablelist because the algorithm has to have access to the internal datastructure. Tom Von meinem iPhone gesendet > Am 02.12.2014 um 12:15 schrieb Werner Lehmann : > > Hi Peter, > > didn't know about that on

Re: Permutation of scene graph children

2014-12-02 Thread Werner Lehmann
Hi Peter, didn't know about that one. It basically does what Tom suggested: makes a copy, sorts that one, then uses ObservableList.setAll to get one change event. So it is what I am doing already but still removes/adds children ;-) The remove/add approach also does work for now, it just coul

Re: Permutation of scene graph children

2014-12-02 Thread Pete Moss
You can also try using FXCollections.sort() directly on the children and see if that helps since you were wondering about a sort operation. This is intended specifically for use with ObservableList objects. This has worked well for me. I don't know how many events this will end up firing, since it

Re: Permutation of scene graph children

2014-12-02 Thread Werner Lehmann
Hi Anirvan, On 02.12.2014 06:33, Anirvan Sarkar wrote: java.util.List doesn't support a swap operation but there is Collections.swap(List, int, int) for that. thanks for the pointer. Added a comm

Re: Permutation of scene graph children

2014-12-02 Thread Werner Lehmann
Tom, I know about Collections.swap but it looks like a bad idea to use on scene graph children because it seems to temporarily have a duplicate element in the list and I can't have a node twice in the scene graph. The setAll approach is what I am using now but native permutation or swap suppo

Re: Permutation of scene graph children

2014-12-02 Thread Tom Schindl
I'd rather like to see ObservableList.move()/swap() which since we now have Java8 this could be implemented as a default methods. I think what you can do to make the swap only fire one event is to use Object[] data = l.toArray(); // reorder l.setAll(data); Tom On 02.12.14 06:33, Anirvan Sarka

Re: Permutation of scene graph children

2014-12-01 Thread Anirvan Sarkar
Hi, java.util.List doesn't support a swap operation but there is Collections.swap(List, int, int) for that. Also there exists a JIRA RT-39128 for gett

Permutation of scene graph children

2014-12-01 Thread Werner Lehmann
Hi, occasionally I need to move a child in its children list and would like to avoid a remove/add operation. For example, this could be useful to change z-order in a StackPane, or change vertical order on a VBox, or when synchronizing item order in a model with corresponding node order in a s