home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.awt;
-
- import java.awt.Image;
-
- public strictfp class TreeNode {
- TreeNode sibling;
- TreeNode child;
- TreeNode parent;
- String text;
- Image collapsedImage;
- Image expandedImage;
- int numberOfChildren;
- Object dataObject;
- int depth;
- boolean isExpanded;
-
- public TreeNode(String text) {
- this(text, (Image)null, (Image)null);
- }
-
- public TreeNode(String text, Image collapsedImage, Image expandedImage) {
- this.depth = -1;
- this.isExpanded = false;
- this.text = text;
- this.sibling = null;
- this.child = null;
- this.collapsedImage = collapsedImage;
- this.expandedImage = expandedImage;
- this.numberOfChildren = 0;
- this.dataObject = null;
- }
-
- void setDepth(int depth) {
- this.depth = depth;
- }
-
- public int getDepth() {
- return this.depth;
- }
-
- public boolean isExpanded() {
- return this.isExpanded;
- }
-
- public boolean isExpandable() {
- return this.child != null;
- }
-
- public void expand() {
- if (this.isExpandable()) {
- this.isExpanded = true;
- }
-
- }
-
- public void collapse() {
- this.isExpanded = false;
- }
-
- public void toggle() {
- if (this.isExpanded) {
- this.collapse();
- } else {
- if (this.isExpandable()) {
- this.expand();
- }
-
- }
- }
-
- public Image getImage() {
- return this.isExpanded && this.expandedImage != null ? this.expandedImage : this.collapsedImage;
- }
-
- public void setExpandedImage(Image image) {
- this.expandedImage = image;
- }
-
- public void setCollapsedImage(Image image) {
- this.collapsedImage = image;
- }
-
- public String getText() {
- return this.text;
- }
-
- public void setText(String s) {
- this.text = new String(s);
- }
-
- public Object getDataObject() {
- return this.dataObject;
- }
-
- public void setDataObject(Object theObject) {
- this.dataObject = theObject;
- }
-
- public TreeNode getParent() {
- return this.parent;
- }
-
- public TreeNode getChild() {
- return this.child;
- }
-
- public TreeNode getSibling() {
- return this.sibling;
- }
- }
-