Permutation of scene graph children

Tom Schindl tom.schindl at bestsolution.at
Tue Dec 2 09:21:13 UTC 2014


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 Sarkar wrote:
> Hi,
> 
> java.util.List doesn't support a swap operation but there is
> Collections.swap(List,
> int, int)
> <https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#swap-java.util.List-int-int->for
> that.
> 
> Also there exists a JIRA RT-39128
> <https://javafx-jira.kenai.com/browse/RT-39128> for getting swap support on
> ObservableList.
> 
> Regards,
> Anirvan
> 
> On 1 December 2014 at 23:35, Werner Lehmann <lehmann at media-interactive.de>
> wrote:
> 
>> 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 skin.
>>
>> java.util.List does not support a move or swap operation. I had hoped a
>> sort operation with a clever comparator might do the trick, triggering a
>> permutation listchange event. However, any attempt in this direction bombs,
>> complaining about "duplicate children added". On the other hand there is
>> rudimentary support for this in Node.toFront and flags exist on Parent:
>> "childrenTriggerPermutation", "childSetModified".
>>
>> Any thoughts about getting swap support on ObservableList and/or
>> permutation support on Parent.children?
>>
>> Werner
>>
> 
> 
> 


-- 
Thomas Schindl, CTO
BestSolution.at EDV Systemhaus GmbH
Eduard-Bodem-Gasse 5-7, A-6020 Innsbruck
http://www.bestsolution.at/
Reg. Nr. FN 222302s am Firmenbuchgericht Innsbruck


More information about the openjfx-dev mailing list