⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 group.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $RCSfile: Group.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.5 $ * $Date: 2007/02/09 17:18:02 $ * $State: Exp $ */package javax.media.j3d;import java.util.BitSet;import java.util.Vector;import java.util.Hashtable;import java.util.Enumeration;/** * The Group node object is a general-purpose grouping node. Group * nodes have exactly one parent and an arbitrary number of children * that are rendered in an unspecified order (or in parallel).  Null * children are allowed; no operation is performed on a null child * node.  Operations on Group node objects include adding, removing, * and enumerating the children of the Group node. The subclasses of * Group node add additional semantics. */public class Group extends Node {    /**     * Specifies that this Group node allows reading its children.     */    public static final int    ALLOW_CHILDREN_READ = CapabilityBits.GROUP_ALLOW_CHILDREN_READ;    /**     * Specifies that this Group node allows writing its children.     */    public static final int    ALLOW_CHILDREN_WRITE = CapabilityBits.GROUP_ALLOW_CHILDREN_WRITE;    /**     * Specifies that this Group node allows adding new children.     */    public static final int    ALLOW_CHILDREN_EXTEND = CapabilityBits.GROUP_ALLOW_CHILDREN_EXTEND;    /**     * Specifies that this Group node allows reading its collision Bounds     */    public static final int    ALLOW_COLLISION_BOUNDS_READ =        CapabilityBits.GROUP_ALLOW_COLLISION_BOUNDS_READ;    /**     * Specifies that this Group node allows writing its collision Bounds     */    public static final int    ALLOW_COLLISION_BOUNDS_WRITE =        CapabilityBits.GROUP_ALLOW_COLLISION_BOUNDS_WRITE;    // Array for setting default read capabilities    private static final int[] readCapabilities = {        ALLOW_CHILDREN_READ,        ALLOW_COLLISION_BOUNDS_READ    };            /**     * Creates the retained mode GroupRetained object that this     * Group component object will point to.     */    void createRetained() {	retained = new GroupRetained();	retained.setSource(this);    }      /**      * Sets the collision bounds of a node.      * @param bounds the collision bounding object for a node      * @exception CapabilityNotSetException if appropriate capability is      * not set and this object is part of live or compiled scene graph      */    public void setCollisionBounds(Bounds bounds) {	if (isLiveOrCompiled())	    if(!this.getCapability(ALLOW_COLLISION_BOUNDS_WRITE))		throw new CapabilityNotSetException(J3dI18N.getString("Group0"));	((GroupRetained)this.retained).setCollisionBounds(bounds);    }    /**      * Returns the collision bounding object of this node.      * @return the node's collision bounding object      * @exception CapabilityNotSetException if appropriate capability is      * not set and this object is part of live or compiled scene graph      */    public Bounds getCollisionBounds() {	if (isLiveOrCompiled())	    if(!this.getCapability(ALLOW_COLLISION_BOUNDS_READ))		throw new CapabilityNotSetException(J3dI18N.getString("Group1"));	return ((GroupRetained)this.retained).getCollisionBounds();    }    /**     * Replaces the child node at the specified index in this     * group node's list of children with the specified child.     * @param child the new child     * @param index which child to replace.  The <code>index</code> must     * be a value     * greater than or equal to 0 and less than <code>numChildren()</code>.     * @exception CapabilityNotSetException if the appropriate capability is     * not set and this group node is part of live or compiled scene graph     * @exception RestrictedAccessException if this group node is part of     * live or compiled scene graph and the child node being set is not     * a BranchGroup node     * @exception MultipleParentException if <code>child</code> has already     * been added as a child of another group node     * @exception IndexOutOfBoundsException if <code>index</code> is invalid     */    public void setChild(Node child, int index) {	if (child instanceof SharedGroup) {	    throw new IllegalArgumentException(J3dI18N.getString("Group2"));	}	if (isLiveOrCompiled()) {	    Node oldchild =                (Node) ((GroupRetained)this.retained).getChild(index);	    if (! (child instanceof BranchGroup))		throw new RestrictedAccessException(J3dI18N.getString("Group3"));	    if (!getCapability(ALLOW_CHILDREN_WRITE))		throw new CapabilityNotSetException(J3dI18N.getString("Group13"));	    if ((oldchild != null) && 		(! ((BranchGroup)oldchild).getCapability(BranchGroup.ALLOW_DETACH))) {		throw new CapabilityNotSetException(J3dI18N.getString("Group4"));	    }	}	((GroupRetained)retained).setChild(child, index);    }      /**     * Inserts the specified child node in this group node's list of     * children at the specified index.     * @param child the new child     * @param index at which location to insert. The <code>index</code>     * must be a value     * greater than or equal to 0 and less than or equal to     * <code>numChildren()</code>.     * @exception CapabilityNotSetException if the appropriate capability is     * not set and this group node is part of live or compiled scene graph     * @exception RestrictedAccessException if this group node is part of     * live     * or compiled scene graph and the child node being inserted is not     * a BranchGroup node     * @exception MultipleParentException if <code>child</code> has already     * been added as a child of another group node.     * @exception IndexOutOfBoundsException if <code>index</code> is invalid.     */    public void insertChild(Node child, int index) {	if (child instanceof SharedGroup) {	    throw new IllegalArgumentException(J3dI18N.getString("Group2"));	}	if (isLiveOrCompiled()) {	    if (! (child instanceof BranchGroup))		throw new RestrictedAccessException(J3dI18N.getString("Group6"));	    if (!this.getCapability(ALLOW_CHILDREN_WRITE))		throw new CapabilityNotSetException(J3dI18N.getString("Group14"));	}	((GroupRetained)this.retained).insertChild(child, index);    }      /**     * Removes the child node at the specified index from this group node's     * list of children.     * @param index which child to remove.  The <code>index</code>     * must be a value     * greater than or equal to 0 and less than <code>numChildren()</code>.     * @exception CapabilityNotSetException if the appropriate capability is     * not set and this group node is part of live or compiled scene graph     * @exception RestrictedAccessException if this group node is part of     * live or compiled scene graph and the child node being removed is not     * a BranchGroup node     * @exception IndexOutOfBoundsException if <code>index</code> is invalid.     */    public void removeChild(int index) {	if (isLiveOrCompiled()) {	    Node child = ((GroupRetained)this.retained).getChild(index);	    if (!(child instanceof BranchGroup)) {		throw new RestrictedAccessException(J3dI18N.getString("Group7"));	    }	    if (!this.getCapability(ALLOW_CHILDREN_WRITE)) {		throw new CapabilityNotSetException(J3dI18N.getString("Group15"));	    }	    if (!((BranchGroup)child).getCapability(BranchGroup.ALLOW_DETACH)) {		throw new CapabilityNotSetException(J3dI18N.getString("Group4"));	    }	}	((GroupRetained)this.retained).removeChild(index);    }      /**     * Retrieves the child node at the specified index in     * this group node's list of children.     * @param index which child to return.     * @return the children at location index.  The <code>index</code>     * must be a value     * greater than or equal to 0 and less than <code>numChildren()</code>.     * @exception CapabilityNotSetException if the appropriate capability is     * not set and this group node is part of live or compiled scene graph     * @exception IndexOutOfBoundsException if <code>index</code> is invalid.     */    public Node getChild(int index) {	if (isLiveOrCompiled())	    if(!this.getCapability(ALLOW_CHILDREN_READ))		throw new CapabilityNotSetException(J3dI18N.getString("Group9"));	return (Node) ((GroupRetained)this.retained).getChild(index);    }      /**     * Returns an Enumeration object of this group node's list of children.     * @return an Enumeration object of all the children     * @exception CapabilityNotSetException if the appropriate capability is     * not set and this group node is part of live or compiled scene graph     */    public Enumeration getAllChildren() {	if (isLiveOrCompiled())	    if(!this.getCapability(ALLOW_CHILDREN_READ))		throw new CapabilityNotSetException(J3dI18N.getString("Group9"));	return (Enumeration)((GroupRetained)this.retained).getAllChildren();    }    /**     * Appends the specified child node to this group node's list of children.     * @param child the child to add to this node's list of children     * @exception CapabilityNotSetException if the appropriate capability is     * not set and this group node is part of live or compiled scene graph     * @exception RestrictedAccessException if this group node is part     * of live     * or compiled scene graph and the child node being added is not     * a BranchGroup node     * @exception MultipleParentException if <code>child</code> has already     * been added as a child of another group node.     */    public void addChild(Node child) {	if (child instanceof SharedGroup) {	    throw new IllegalArgumentException(J3dI18N.getString("Group2"));	}	if (isLiveOrCompiled()) {	    if (! (child instanceof BranchGroup))		throw new RestrictedAccessException(J3dI18N.getString("Group12"));	    if(!this.getCapability(ALLOW_CHILDREN_EXTEND))		throw new CapabilityNotSetException(J3dI18N.getString("Group16"));	}	((GroupRetained)this.retained).addChild(child);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -