Package net.anzix.fsz

Source Code of net.anzix.fsz.NodeRepository

/*
* 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);
    }
}
TOP

Related Classes of net.anzix.fsz.NodeRepository

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.