home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 25 / nopv25.iso / 046A / COOBAR.ZIP / CBWNODE.CLA (.txt) < prev    next >
Encoding:
Java Class File  |  1997-07-02  |  2.5 KB  |  109 lines

  1. import java.awt.Image;
  2.  
  3. class cbwnode {
  4.    cbwnode sibling;
  5.    cbwnode child;
  6.    cbwnode parent;
  7.    String text;
  8.    Image collapsedImage;
  9.    Image expandedImage;
  10.    int numberOfChildren;
  11.    Object dataObject;
  12.    int depth;
  13.    boolean isExpanded;
  14.  
  15.    public cbwnode(String text) {
  16.       this(text, (Image)null, (Image)null);
  17.    }
  18.  
  19.    public cbwnode(String text, Image collapsedImage, Image expandedImage) {
  20.       this.depth = -1;
  21.       this.isExpanded = false;
  22.       this.text = text;
  23.       this.sibling = null;
  24.       this.child = null;
  25.       this.collapsedImage = collapsedImage;
  26.       this.expandedImage = expandedImage;
  27.       this.numberOfChildren = 0;
  28.       this.dataObject = null;
  29.    }
  30.  
  31.    void setDepth(int depth) {
  32.       this.depth = depth;
  33.    }
  34.  
  35.    public int getDepth() {
  36.       return this.depth;
  37.    }
  38.  
  39.    public boolean isExpanded() {
  40.       return this.isExpanded;
  41.    }
  42.  
  43.    public boolean isExpandable() {
  44.       return this.child != null;
  45.    }
  46.  
  47.    public void expand() {
  48.       if (this.isExpandable()) {
  49.          this.isExpanded = true;
  50.       }
  51.  
  52.    }
  53.  
  54.    public void collapse() {
  55.       this.isExpanded = false;
  56.    }
  57.  
  58.    public void toggle() {
  59.       if (this.isExpanded) {
  60.          this.collapse();
  61.       } else {
  62.          if (this.isExpandable()) {
  63.             this.expand();
  64.          }
  65.  
  66.       }
  67.    }
  68.  
  69.    public Image getImage() {
  70.       return this.isExpanded && this.expandedImage != null ? this.expandedImage : this.collapsedImage;
  71.    }
  72.  
  73.    public void setExpandedImage(Image image) {
  74.       this.expandedImage = image;
  75.    }
  76.  
  77.    public void setCollapsedImage(Image image) {
  78.       this.collapsedImage = image;
  79.    }
  80.  
  81.    public String getText() {
  82.       return this.text;
  83.    }
  84.  
  85.    public void setText(String s) {
  86.       this.text = new String(s);
  87.    }
  88.  
  89.    public Object getDataObject() {
  90.       return this.dataObject;
  91.    }
  92.  
  93.    public void setDataObject(Object theObject) {
  94.       this.dataObject = theObject;
  95.    }
  96.  
  97.    public cbwnode getParent() {
  98.       return this.parent;
  99.    }
  100.  
  101.    public cbwnode getChild() {
  102.       return this.child;
  103.    }
  104.  
  105.    public cbwnode getSibling() {
  106.       return this.sibling;
  107.    }
  108. }
  109.