Skip to content

Commit 7229646

Browse files
authored
Merge pull request #654 from neph1/sort_anim_clips
Sort anim clips
2 parents 9ecf510 + 4db4be8 commit 7229646

3 files changed

Lines changed: 22 additions & 11 deletions

File tree

jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/animation/JmeAnimChildren.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
*
5050
* @author nehon
5151
*/
52+
@Deprecated
5253
public class JmeAnimChildren extends Children.Keys<Object> {
5354

5455
protected JmeAnimControl jmeAnimControl;

jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/animation/JmeAnimComposerChildren.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2020 jMonkeyEngine
2+
* Copyright (c) 2009-2025 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,8 @@
3636
import com.jme3.anim.AnimLayer;
3737
import com.jme3.gde.core.scene.SceneApplication;
3838
import java.util.ArrayList;
39+
import java.util.Collections;
40+
import java.util.Comparator;
3941
import java.util.HashMap;
4042
import java.util.LinkedList;
4143
import java.util.List;
@@ -84,15 +86,18 @@ protected List<Object> createKeys() {
8486
List<Object> keys = new LinkedList<>();
8587
AnimComposer composer = jmeAnimComposer.getLookup().lookup(AnimComposer.class);
8688
if (composer != null) {
87-
keys.addAll(composer.getAnimClips());
89+
List<AnimClip> animClips = new ArrayList<>(composer.getAnimClips());
90+
Collections.sort(animClips, Comparator.comparing(AnimClip::getName));
91+
keys.addAll(animClips);
92+
8893
final Set<String> layerNames = composer.getLayerNames();
8994
final List<AnimLayer> layers = new ArrayList<>();
90-
for(String s: layerNames) {
95+
for (String s : layerNames) {
9196
layers.add(composer.getLayer(s));
9297
}
9398
keys.addAll(layers);
9499
}
95-
100+
96101
return keys;
97102
}).get();
98103
} catch (InterruptedException | ExecutionException ex) {
@@ -103,13 +108,16 @@ protected List<Object> createKeys() {
103108

104109
@Override
105110
protected Node[] createNodes(Object key) {
106-
if (key instanceof AnimClip animClip) {
107-
return new Node[]{ new JmeAnimClip(jmeAnimComposer, animClip, dataObject).setReadOnly(readOnly)};
108-
} else if (key instanceof AnimLayer animLayer) {
109-
return new Node[]{ new JmeAnimLayer(jmeAnimComposer, animLayer, dataObject).setReadOnly(readOnly)};
110-
}
111-
else {
112-
return new Node[]{ Node.EMPTY };
111+
switch (key) {
112+
case AnimClip animClip -> {
113+
return new Node[]{ new JmeAnimClip(jmeAnimComposer, animClip, dataObject).setReadOnly(readOnly)};
114+
}
115+
case AnimLayer animLayer -> {
116+
return new Node[]{ new JmeAnimLayer(jmeAnimComposer, animLayer, dataObject).setReadOnly(readOnly)};
117+
}
118+
default -> {
119+
return new Node[]{ Node.EMPTY };
120+
}
113121
}
114122
}
115123

@@ -124,4 +132,5 @@ public DataObject getDataObject() {
124132
public void setDataObject(DataObject dataObject) {
125133
this.dataObject = dataObject;
126134
}
135+
127136
}

jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/animation/JmeAnimControl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
*/
5656
@org.openide.util.lookup.ServiceProvider(service = SceneExplorerNode.class)
5757
@SuppressWarnings({"unchecked", "rawtypes"})
58+
@Deprecated
5859
public class JmeAnimControl extends JmeControl {
5960

6061
private AnimControl animControl;

0 commit comments

Comments
 (0)