/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.anzix.fsz;
import com.ardor3d.scenegraph.Node;
import com.ardor3d.scenegraph.Spatial;
import com.google.inject.Singleton;
import java.util.HashMap;
import java.util.Map;
/**
* Common repository to store the key elements of the node hierarchy.
*
* @author elek
*/
@Singleton
public class NodeRepository {
public static final String ROOT_NODE = "ROOT";
public static final String GUI_NODE = "GUI";
private Map<String, Node> nodes = new HashMap<String, Node>();
public void addNode(String name, Node node) {
nodes.put(name, node);
}
public Node attachToParent(String name, Spatial child) {
Node node = getNode(name);
node.attachChild(child);
return node;
}
public Node dettachFromParent(String name, Spatial child) {
Node node = getNode(name);
node.detachChild(child);
return node;
}
public Node getNode(String name) {
return nodes.get(name);
}
public Node getRootNode(){
return getNode(ROOT_NODE);
}
}