home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &… the Search for Life CD 3 / 0_CD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / tree / FixedHeightLayoutCache$VisibleFHTreeStateNodeEnumeration.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.4 KB  |  98 lines

  1. package javax.swing.tree;
  2.  
  3. import java.util.Enumeration;
  4. import java.util.NoSuchElementException;
  5.  
  6. class FixedHeightLayoutCache$VisibleFHTreeStateNodeEnumeration implements Enumeration {
  7.    protected FixedHeightLayoutCache.FHTreeStateNode parent;
  8.    protected int nextIndex;
  9.    protected int childCount;
  10.    // $FF: synthetic field
  11.    private final FixedHeightLayoutCache this$0;
  12.  
  13.    protected FixedHeightLayoutCache$VisibleFHTreeStateNodeEnumeration(FixedHeightLayoutCache var1, FixedHeightLayoutCache.FHTreeStateNode var2) {
  14.       this(var1, var2, -1);
  15.    }
  16.  
  17.    protected FixedHeightLayoutCache$VisibleFHTreeStateNodeEnumeration(FixedHeightLayoutCache var1, FixedHeightLayoutCache.FHTreeStateNode var2, int var3) {
  18.       this.this$0 = var1;
  19.       this.parent = var2;
  20.       this.nextIndex = var3;
  21.       this.childCount = var1.treeModel.getChildCount(this.parent.getUserObject());
  22.    }
  23.  
  24.    public boolean hasMoreElements() {
  25.       return this.parent != null;
  26.    }
  27.  
  28.    public Object nextElement() {
  29.       if (!this.hasMoreElements()) {
  30.          throw new NoSuchElementException("No more visible paths");
  31.       } else {
  32.          TreePath var1;
  33.          if (this.nextIndex == -1) {
  34.             var1 = this.parent.getTreePath();
  35.          } else {
  36.             FixedHeightLayoutCache.FHTreeStateNode var2 = this.parent.getChildAtModelIndex(this.nextIndex);
  37.             if (var2 == null) {
  38.                var1 = this.parent.getTreePath().pathByAddingChild(this.this$0.treeModel.getChild(this.parent.getUserObject(), this.nextIndex));
  39.             } else {
  40.                var1 = var2.getTreePath();
  41.             }
  42.          }
  43.  
  44.          this.updateNextObject();
  45.          return var1;
  46.       }
  47.    }
  48.  
  49.    protected void updateNextObject() {
  50.       if (!this.updateNextIndex()) {
  51.          this.findNextValidParent();
  52.       }
  53.  
  54.    }
  55.  
  56.    protected boolean findNextValidParent() {
  57.       if (this.parent == FixedHeightLayoutCache.access$600(this.this$0)) {
  58.          this.parent = null;
  59.          return false;
  60.       } else {
  61.          while(this.parent != null) {
  62.             FixedHeightLayoutCache.FHTreeStateNode var1 = (FixedHeightLayoutCache.FHTreeStateNode)this.parent.getParent();
  63.             if (var1 != null) {
  64.                this.nextIndex = this.parent.childIndex;
  65.                this.parent = var1;
  66.                this.childCount = this.this$0.treeModel.getChildCount(this.parent.getUserObject());
  67.                if (this.updateNextIndex()) {
  68.                   return true;
  69.                }
  70.             } else {
  71.                this.parent = null;
  72.             }
  73.          }
  74.  
  75.          return false;
  76.       }
  77.    }
  78.  
  79.    protected boolean updateNextIndex() {
  80.       if (this.nextIndex == -1 && !this.parent.isExpanded()) {
  81.          return false;
  82.       } else if (this.childCount == 0) {
  83.          return false;
  84.       } else if (++this.nextIndex >= this.childCount) {
  85.          return false;
  86.       } else {
  87.          FixedHeightLayoutCache.FHTreeStateNode var1 = this.parent.getChildAtModelIndex(this.nextIndex);
  88.          if (var1 != null && var1.isExpanded()) {
  89.             this.parent = var1;
  90.             this.nextIndex = -1;
  91.             this.childCount = this.this$0.treeModel.getChildCount(((DefaultMutableTreeNode)var1).getUserObject());
  92.          }
  93.  
  94.          return true;
  95.       }
  96.    }
  97. }
  98.