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 / VariableHeightLayoutCache$VisibleTreeStateNodeEnumeration.class (.txt) < prev   
Encoding:
Java Class File  |  1979-12-31  |  2.0 KB  |  94 lines

  1. package javax.swing.tree;
  2.  
  3. import java.util.Enumeration;
  4. import java.util.NoSuchElementException;
  5.  
  6. class VariableHeightLayoutCache$VisibleTreeStateNodeEnumeration implements Enumeration {
  7.    protected VariableHeightLayoutCache.TreeStateNode parent;
  8.    protected int nextIndex;
  9.    protected int childCount;
  10.    // $FF: synthetic field
  11.    private final VariableHeightLayoutCache this$0;
  12.  
  13.    protected VariableHeightLayoutCache$VisibleTreeStateNodeEnumeration(VariableHeightLayoutCache var1, VariableHeightLayoutCache.TreeStateNode var2) {
  14.       this(var1, var2, -1);
  15.    }
  16.  
  17.    protected VariableHeightLayoutCache$VisibleTreeStateNodeEnumeration(VariableHeightLayoutCache var1, VariableHeightLayoutCache.TreeStateNode var2, int var3) {
  18.       this.this$0 = var1;
  19.       this.parent = var2;
  20.       this.nextIndex = var3;
  21.       this.childCount = this.parent.getChildCount();
  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.             VariableHeightLayoutCache.TreeStateNode var2 = (VariableHeightLayoutCache.TreeStateNode)this.parent.getChildAt(this.nextIndex);
  37.             var1 = var2.getTreePath();
  38.          }
  39.  
  40.          this.updateNextObject();
  41.          return var1;
  42.       }
  43.    }
  44.  
  45.    protected void updateNextObject() {
  46.       if (!this.updateNextIndex()) {
  47.          this.findNextValidParent();
  48.       }
  49.  
  50.    }
  51.  
  52.    protected boolean findNextValidParent() {
  53.       if (this.parent == VariableHeightLayoutCache.access$200(this.this$0)) {
  54.          this.parent = null;
  55.          return false;
  56.       } else {
  57.          while(this.parent != null) {
  58.             VariableHeightLayoutCache.TreeStateNode var1 = (VariableHeightLayoutCache.TreeStateNode)this.parent.getParent();
  59.             if (var1 != null) {
  60.                this.nextIndex = ((DefaultMutableTreeNode)var1).getIndex(this.parent);
  61.                this.parent = var1;
  62.                this.childCount = this.parent.getChildCount();
  63.                if (this.updateNextIndex()) {
  64.                   return true;
  65.                }
  66.             } else {
  67.                this.parent = null;
  68.             }
  69.          }
  70.  
  71.          return false;
  72.       }
  73.    }
  74.  
  75.    protected boolean updateNextIndex() {
  76.       if (this.nextIndex == -1 && !this.parent.isExpanded()) {
  77.          return false;
  78.       } else if (this.childCount == 0) {
  79.          return false;
  80.       } else if (++this.nextIndex >= this.childCount) {
  81.          return false;
  82.       } else {
  83.          VariableHeightLayoutCache.TreeStateNode var1 = (VariableHeightLayoutCache.TreeStateNode)this.parent.getChildAt(this.nextIndex);
  84.          if (var1 != null && var1.isExpanded()) {
  85.             this.parent = var1;
  86.             this.nextIndex = -1;
  87.             this.childCount = ((DefaultMutableTreeNode)var1).getChildCount();
  88.          }
  89.  
  90.          return true;
  91.       }
  92.    }
  93. }
  94.