001: /*
002: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegraph/SGGroup.java,v 1.1 2005/04/20 22:20:40 paulby Exp $
003: *
004: * Sun Public License Notice
005: *
006: * The contents of this file are subject to the Sun Public License Version
007: * 1.0 (the "License"). You may not use this file except in compliance with
008: * the License. A copy of the License is available at http://www.sun.com/
009: *
010: * The Original Code is the Java 3D(tm) Scene Graph Editor.
011: * The Initial Developer of the Original Code is Paul Byrne.
012: * Portions created by Paul Byrne are Copyright (C) 2002.
013: * All Rights Reserved.
014: *
015: * Contributor(s): Paul Byrne.
016: *
017: **/
018: package org.jdesktop.j3dedit.scenegraph;
019:
020: import java.util.Properties;
021: import java.util.ArrayList;
022: import org.jdesktop.j3dedit.scenegrapheditor.NodePersistance;
023: import javax.media.j3d.Group;
024:
025: /**
026: * @author Paul Byrne
027: * @version $Id: SGGroup.java,v 1.1 2005/04/20 22:20:40 paulby Exp $
028: */
029: public class SGGroup extends SGNode {
030:
031: private boolean hideChildren = false;
032: private ArrayList children = new ArrayList();
033:
034: /**
035: * Create the ancillary SGNode representing node
036: */
037: public SGGroup(javax.media.j3d.Node node,
038: org.jdesktop.j3dedit.J3dEditContext editContext) {
039: super (node, editContext);
040: }
041:
042: /**
043: * Set the Java3D which is represented by this object
044: *
045: * Store the capability bits for the node
046: */
047: public void setJ3dNode(javax.media.j3d.Node node) {
048: super .setJ3dNode(node);
049:
050: // Set these capabilities to allow setLive to be optimised
051: node.setCapability(Group.ALLOW_CHILDREN_READ);
052: node.setCapability(Group.ALLOW_CHILDREN_WRITE);
053: node.setCapability(Group.ALLOW_CHILDREN_EXTEND);
054: node.clearCapabilityIsFrequent(Group.ALLOW_CHILDREN_READ);
055: node.clearCapabilityIsFrequent(Group.ALLOW_CHILDREN_WRITE);
056: node.clearCapabilityIsFrequent(Group.ALLOW_CHILDREN_EXTEND);
057: }
058:
059: public void hideChildren(boolean hide) {
060: hideChildren = hide;
061: }
062:
063: public boolean childrenHidden() {
064: return hideChildren;
065: }
066:
067: public void addChild(SGNode child) {
068: children.add(child);
069: child.setParent(this );
070: }
071:
072: public SGNode getChild(int index) {
073: return (SGNode) children.get(index);
074: }
075:
076: public int numChildren() {
077: return children.size();
078: }
079:
080: public void removeChild(SGNode child) {
081: children.remove(child);
082: }
083:
084: public void createPersistanceData(NodePersistance data) {
085: super .createPersistanceData(data);
086:
087: if (hideChildren)
088: data.setData("HideChildren", "T");
089: }
090:
091: public void applyPersistanceData(NodePersistance data) {
092: super .applyPersistanceData(data);
093:
094: String str;
095: str = data.getData("HideChildren");
096: if (str != null && str.equals("T"))
097: hideChildren = true;
098: }
099:
100: /**
101: * Change the live state of this node, this may change the live
102: * state of other nodes in the graph, but in general the minimum
103: * change will be made
104: */
105: public void setLive(boolean live) {
106: parent.setLive(live);
107: }
108:
109: }
|