From ef8761ac7a6e75743df048198363bb37f8b1cc91 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Mon, 1 Jul 2013 08:48:27 -0700 Subject: j3dcore: add type annotations to Enumerations of Nodes under a Group Signed-off-by: Harvey Harrison --- src/classes/share/javax/media/j3d/Group.java | 46 ++++++++--------- .../share/javax/media/j3d/GroupRetained.java | 59 +++++++++++----------- 2 files changed, 51 insertions(+), 54 deletions(-) (limited to 'src/classes/share') diff --git a/src/classes/share/javax/media/j3d/Group.java b/src/classes/share/javax/media/j3d/Group.java index 2457f27..b0e7ae6 100644 --- a/src/classes/share/javax/media/j3d/Group.java +++ b/src/classes/share/javax/media/j3d/Group.java @@ -222,24 +222,23 @@ public class Group extends Node { ((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 index - * must be a value - * greater than or equal to 0 and less than numChildren(). - * @exception CapabilityNotSetException if the appropriate capability is - * not set and this group node is part of live or compiled scene graph - * @exception IndexOutOfBoundsException if index 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); - } + /** + * 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 index + * must be a value + * greater than or equal to 0 and less than numChildren(). + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this group node is part of live or compiled scene graph + * @exception IndexOutOfBoundsException if index is invalid. + */ + public Node getChild(int index) { + if (isLiveOrCompiled() && !this.getCapability(ALLOW_CHILDREN_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("Group9")); + + return ((GroupRetained)this.retained).getChild(index); + } /** * Returns an Enumeration object of this group node's list of children. @@ -247,13 +246,12 @@ public class Group extends Node { * @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")); + public Enumeration getAllChildren() { + if (isLiveOrCompiled() && !this.getCapability(ALLOW_CHILDREN_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("Group9")); - return (Enumeration)((GroupRetained)this.retained).getAllChildren(); - } + return ((GroupRetained)this.retained).getAllChildren(); + } /** * Appends the specified child node to this group node's list of children. diff --git a/src/classes/share/javax/media/j3d/GroupRetained.java b/src/classes/share/javax/media/j3d/GroupRetained.java index 971fa15..5cb6ed6 100644 --- a/src/classes/share/javax/media/j3d/GroupRetained.java +++ b/src/classes/share/javax/media/j3d/GroupRetained.java @@ -424,38 +424,37 @@ ArrayList> viewLists = null; } - /** - * Returns the child specified by the index. - * @param index which child to return - * @return the children at location index - */ - Node getChild(int index) { - - NodeRetained sgo = children.get(index); - if(sgo == null) - return null; - else - return (Node) sgo.source; - } - - /** - * Returns an enumeration object of the children. - * @return an enumeration object of the children - */ - Enumeration getAllChildren() { - Vector userChildren=new Vector(children.size()); - - for(int i=0; i getAllChildren() { + Vector userChildren = new Vector(children.size()); + + for (int i = 0; i < children.size(); i++) { + NodeRetained sgo = children.get(i); + if (sgo != null) + userChildren.add((Node)sgo.source); + else + userChildren.add(null); + } + + return userChildren.elements(); } - return userChildren.elements(); - } - void checkValidChild(Node child, String s) { if ((child != null) && -- cgit v1.2.3