SDK: remove duplicate code in AbstractSceneExplorer's constructor

One constructor with the shared logic, other constructor are just sugar
This commit is contained in:
David Bernard 2014-06-04 10:15:33 +02:00
parent 846960c28c
commit f26b53fcb7
3 changed files with 5 additions and 19 deletions

View File

@ -65,34 +65,22 @@ public abstract class AbstractSceneExplorerNode extends AbstractNode implements
private final List<Property<?>> sceneProperties = Collections.synchronizedList(new LinkedList<Property<?>>());
public AbstractSceneExplorerNode() {
super(Children.LEAF, new DynamicLookup(new InstanceContent()));
lookupContents = ((DynamicLookup) getLookup()).getInstanceContent();
this(Children.LEAF, null);
}
public AbstractSceneExplorerNode(Children children, DataObject dataObject) {
super(children, new ProxyLookup(dataObject.getLookup(), new DynamicLookup(new InstanceContent())));
super(children, new ProxyLookup(dataObject != null ? dataObject.getLookup() : Lookup.EMPTY, new DynamicLookup(new InstanceContent())));
this.dataObject = dataObject;
this.jmeChildren = children;
lookupContents = getLookup().lookup(DynamicLookup.class).getInstanceContent();
}
public AbstractSceneExplorerNode(DataObject dataObject) {
super(Children.LEAF, new ProxyLookup(dataObject != null ? dataObject.getLookup() : Lookup.EMPTY, new DynamicLookup(new InstanceContent())));
this.dataObject = dataObject;
lookupContents = getLookup().lookup(DynamicLookup.class).getInstanceContent();
this(Children.LEAF, dataObject);
}
public AbstractSceneExplorerNode(Children children) {
//TODO: OMG!
super(children, children instanceof JmeSpatialChildren
? (((JmeSpatialChildren) children).getDataObject() != null
? new ProxyLookup(((JmeSpatialChildren) children).getDataObject().getLookup(), new DynamicLookup(new InstanceContent()))
: new DynamicLookup(new InstanceContent()))
: new DynamicLookup(new InstanceContent()));
this.jmeChildren = children;
lookupContents = getLookup().lookup(DynamicLookup.class).getInstanceContent();
if (children instanceof JmeSpatialChildren) {
this.dataObject = ((JmeSpatialChildren) children).getDataObject();
}
this(children, (children instanceof JmeSpatialChildren) ? ((JmeSpatialChildren) children).getDataObject() : null);
}
public InstanceContent getLookupContents() {

View File

@ -63,7 +63,6 @@ public class JmeBone extends AbstractSceneExplorerNode {
public JmeBone(JmeSkeletonControl jmeSkeletonControl, Bone bone, JmeBoneChildren children) {
super(children);
this.jmeChildren = children;
this.jmeSkeletonControl = jmeSkeletonControl;
getLookupContents().add(bone);
getLookupContents().add(this);

View File

@ -83,7 +83,6 @@ public class JmeSpatial extends AbstractSceneExplorerNode {
public JmeSpatial(Spatial spatial, JmeSpatialChildren factory) {
super(factory);
this.jmeChildren = factory;
this.spatial = spatial;
getLookupContents().add(spatial);
getLookupContents().add(this);