Example usage for javax.media.j3d SceneGraphObject getUserData

List of usage examples for javax.media.j3d SceneGraphObject getUserData

Introduction

In this page you can find the example usage for javax.media.j3d SceneGraphObject getUserData.

Prototype

public Object getUserData() 

Source Link

Document

Retrieves the userData field from this scene graph object.

Usage

From source file:SwingTest.java

/**
 * Removes a BranchGroup from the scene based on user data
 * //from ww w  .ja  va 2 s .c o  m
 * @param name
 *            the user data to look for
 */
protected void removeShape(String name) {
    try {
        java.util.Enumeration e = sceneBranchGroup.getAllChildren();
        int index = 0;

        while (e.hasMoreElements() != false) {
            SceneGraphObject sgObject = (SceneGraphObject) e.nextElement();
            Object userData = sgObject.getUserData();

            if (userData instanceof String && ((String) userData).compareTo(name) == 0) {
                System.out.println("Removing: " + sgObject.getUserData());
                sceneBranchGroup.removeChild(index);
            }

            index++;
        }
    } catch (Exception e) {
        // the scenegraph may not have yet been synchronized...
    }
}