Example usage for javax.media.j3d BranchGroup setUserData

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

Introduction

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

Prototype

public void setUserData(Object userData) 

Source Link

Document

Sets the userData field associated with this scene graph object.

Usage

From source file:SwingTest.java

/**
 * Create a BranchGroup that contains a Cube. The user data for the
 * BranchGroup is set so the BranchGroup can be identified.
 *//*from w w  w  . j ava 2 s. c  om*/
protected BranchGroup createCube() {
    BranchGroup bg = new BranchGroup();
    bg.setCapability(BranchGroup.ALLOW_DETACH);
    bg.addChild(new com.sun.j3d.utils.geometry.ColorCube());
    bg.setUserData("Cube");
    return bg;
}

From source file:SwingTest.java

/**
 * Create a BranchGroup that contains a Sphere. The user data for the
 * BranchGroup is set so the BranchGroup can be identified.
 *//*from   w w  w  .jav  a  2  s.  c  om*/
protected BranchGroup createSphere() {
    BranchGroup bg = new BranchGroup();
    bg.setCapability(BranchGroup.ALLOW_DETACH);

    Appearance app = new Appearance();
    Color3f objColor = new Color3f(1.0f, 0.7f, 0.8f);
    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
    app.setMaterial(new Material(objColor, black, objColor, black, 80.0f));

    bg.addChild(new com.sun.j3d.utils.geometry.Sphere(1, app));
    bg.setUserData("Sphere");
    return bg;
}

From source file:ffx.potential.MolecularAssembly.java

/**
 * <p>//w  ww  . j a v a  2 s. 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);
    }

}