Example usage for javax.media.j3d Group numChildren

List of usage examples for javax.media.j3d Group numChildren

Introduction

In this page you can find the example usage for javax.media.j3d Group numChildren.

Prototype

public int numChildren() 

Source Link

Document

Returns a count of this group node's children.

Usage

From source file:TreePrinter.java

private void printNode(Object o, int indent, Set sharedGroups) {
    for (int i = 0; i < indent; i++)
        printStream.print(">");
    printStream.print(nodeString(o) + ": ");
    if (o instanceof SceneGraphObject) {
        SceneGraphObject sgo = (SceneGraphObject) o;
        int capBits = 0;
        // TODO: how to make sure we always check all the valid bits?
        for (int i = 0; i < 64; i++) {
            if (sgo.getCapability(i)) {
                capBits |= 1 << i;
            }/*from w  w  w .  ja v a2  s. com*/
        }
        printStream.print("capBits:Ox" + Integer.toHexString(capBits));
        if (o instanceof javax.media.j3d.Group) {
            javax.media.j3d.Group g = (javax.media.j3d.Group) o;
            int numChildren = 0;
            try {
                numChildren = g.numChildren();
            } catch (CapabilityNotSetException e) {
                //anyone who is using treePrinter, is debugging, so it is
                //alright to blindly allow read. you should first detach
                //browser.curScene, print the tree, then add it back to
                //browser.locale when finished.
                g.setCapability(javax.media.j3d.Group.ALLOW_CHILDREN_READ);
                numChildren = g.numChildren();
                //System.out.println("Can't read children on group");
                //return;
            }
            printStream.print(" children:" + numChildren);
            if (o instanceof TransformGroup) {
                Transform3D transform = new Transform3D();
                Transform3D identity = new Transform3D();
                TransformGroup t = (TransformGroup) o;
                t.getTransform(transform);
                // TODO: use getBestType() when implemented
                if (transform.equals(identity)) {
                    printStream.print(" xform:IDENTITY ");
                } else {
                    printStream.print(" xform:NON-IDENTITY ");
                }
            }
        } else if (o instanceof Link) {
            Link l = (Link) o;
            SharedGroup sg = l.getSharedGroup();
            printStream.print(" sg:" + nodeString(sg));
            sharedGroups.add(sg);
        } else {
            printStream.print(": leaf");
        }
    }
    printStream.println();
}