Example usage for javax.media.j3d BranchGroup getUserData

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

Introduction

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

Prototype

public Object getUserData() 

Source Link

Document

Retrieves the userData field from this scene graph object.

Usage

From source file:ffx.potential.MolecularAssembly.java

/**
 * <p>/*from ww  w  .  ja v  a2s.c  o m*/
 * sceneGraphChange</p>
 *
 * @param newShapes a {@link java.util.List} object.
 */
public void sceneGraphChange(List<BranchGroup> newShapes) {
    if (newShapes == null) {
        newShapes = myNewShapes;
    }

    if (newShapes.isEmpty()) {
        return;
    }

    boolean reCompile = false;
    // Check for nodes (new and/or recycled) being added to this
    // MolecularAssembly
    for (ListIterator<BranchGroup> li = newShapes.listIterator(); li.hasNext();) {
        BranchGroup group = li.next();
        li.remove();
        // This is code for cycling between two MolecularAssemblies
        if (group.getUserData() != null) {
            logger.info(group.toString() + " " + group.getUserData());
            /*
             * Object userData = group.getUserData(); if (userData!=this) {
             * // The appearance has already been set during a recursive
             * call to setView, // although we need to turn back on
             * Pickablility. TransformGroup tg = (TransformGroup)
             * group.getChild(0); Shape3D shape = (Shape3D) tg.getChild(0);
             * shape.setPickable(true); group.setUserData(this); if
             * (!reCompile) { if (childNodes.isLive()) {
             * childNodes.detach(); } reCompile = true; }
             * childNodes.moveTo(group);
             */
        } else {
            // This is a new group since it has no userData.
            // We can not query for the identity of its parent later, so
            // we will store it as a userData reference.
            group.setUserData(this);
            if (!reCompile) {
                if (childNodes.isLive()) {
                    childNodes.detach();
                }

                reCompile = true;
            }

            childNodes.addChild(group);
        }

    }
    if (reCompile) {
        childNodes.compile();
        base.addChild(childNodes);
    }

}