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$FHTreeStateNode.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  6.3 KB  |  514 lines

  1. package javax.swing.tree;
  2.  
  3. class FixedHeightLayoutCache$FHTreeStateNode extends DefaultMutableTreeNode {
  4.    protected boolean isExpanded;
  5.    protected int childIndex;
  6.    protected int row;
  7.    protected TreePath path;
  8.    // $FF: synthetic field
  9.    private final FixedHeightLayoutCache this$0;
  10.  
  11.    public FixedHeightLayoutCache$FHTreeStateNode(FixedHeightLayoutCache var1, Object var2, int var3, int var4) {
  12.       super(var2);
  13.       this.this$0 = var1;
  14.       this.childIndex = var3;
  15.       this.row = var4;
  16.    }
  17.  
  18.    public void setParent(MutableTreeNode var1) {
  19.       super.setParent(var1);
  20.       if (var1 != null) {
  21.          this.path = ((FixedHeightLayoutCache$FHTreeStateNode)var1).getTreePath().pathByAddingChild(((DefaultMutableTreeNode)this).getUserObject());
  22.          FixedHeightLayoutCache.access$100(this.this$0, this);
  23.       }
  24.  
  25.    }
  26.  
  27.    public void remove(int var1) {
  28.       FixedHeightLayoutCache$FHTreeStateNode var2 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var1);
  29.       var2.removeFromMapping();
  30.       super.remove(var1);
  31.    }
  32.  
  33.    public void setUserObject(Object var1) {
  34.       super.setUserObject(var1);
  35.       if (this.path != null) {
  36.          FixedHeightLayoutCache$FHTreeStateNode var2 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  37.          if (var2 != null) {
  38.             this.resetChildrenPaths(var2.getTreePath());
  39.          } else {
  40.             this.resetChildrenPaths((TreePath)null);
  41.          }
  42.       }
  43.  
  44.    }
  45.  
  46.    public int getChildIndex() {
  47.       return this.childIndex;
  48.    }
  49.  
  50.    public TreePath getTreePath() {
  51.       return this.path;
  52.    }
  53.  
  54.    public FixedHeightLayoutCache$FHTreeStateNode getChildAtModelIndex(int var1) {
  55.       for(int var2 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var2 >= 0; --var2) {
  56.          if (((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var2)).childIndex == var1) {
  57.             return (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var2);
  58.          }
  59.       }
  60.  
  61.       return null;
  62.    }
  63.  
  64.    public boolean isVisible() {
  65.       FixedHeightLayoutCache$FHTreeStateNode var1 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  66.       if (var1 == null) {
  67.          return true;
  68.       } else {
  69.          return var1.isExpanded() && var1.isVisible();
  70.       }
  71.    }
  72.  
  73.    public int getRow() {
  74.       return this.row;
  75.    }
  76.  
  77.    public int getRowToModelIndex(int var1) {
  78.       int var3 = this.getRow() + 1;
  79.       int var5 = 0;
  80.  
  81.       for(int var6 = ((DefaultMutableTreeNode)this).getChildCount(); var5 < var6; ++var5) {
  82.          FixedHeightLayoutCache$FHTreeStateNode var2 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var5);
  83.          if (var2.childIndex >= var1) {
  84.             if (var2.childIndex == var1) {
  85.                return var2.row;
  86.             }
  87.  
  88.             if (var5 == 0) {
  89.                return this.getRow() + 1 + var1;
  90.             }
  91.  
  92.             return var2.row - (var2.childIndex - var1);
  93.          }
  94.       }
  95.  
  96.       return this.getRow() + 1 + this.getTotalChildCount() - (this.this$0.treeModel.getChildCount(((DefaultMutableTreeNode)this).getUserObject()) - var1);
  97.    }
  98.  
  99.    public int getTotalChildCount() {
  100.       if (!this.isExpanded()) {
  101.          return 0;
  102.       } else {
  103.          FixedHeightLayoutCache$FHTreeStateNode var1 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  104.          int var2;
  105.          if (var1 != null && (var2 = ((DefaultMutableTreeNode)var1).getIndex(this)) + 1 < ((DefaultMutableTreeNode)var1).getChildCount()) {
  106.             FixedHeightLayoutCache$FHTreeStateNode var5 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)var1).getChildAt(var2 + 1);
  107.             return var5.row - this.row - (var5.childIndex - this.childIndex);
  108.          } else {
  109.             int var3 = this.this$0.getModel().getChildCount(((DefaultMutableTreeNode)this).getUserObject());
  110.  
  111.             for(int var4 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var4 >= 0; --var4) {
  112.                var3 += ((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var4)).getTotalChildCount();
  113.             }
  114.  
  115.             return var3;
  116.          }
  117.       }
  118.    }
  119.  
  120.    public boolean isExpanded() {
  121.       return this.isExpanded;
  122.    }
  123.  
  124.    public int getVisibleLevel() {
  125.       return this.this$0.isRootVisible() ? ((DefaultMutableTreeNode)this).getLevel() : ((DefaultMutableTreeNode)this).getLevel() - 1;
  126.    }
  127.  
  128.    protected void resetChildrenPaths(TreePath var1) {
  129.       FixedHeightLayoutCache.access$200(this.this$0, this);
  130.       if (var1 == null) {
  131.          this.path = new TreePath(((DefaultMutableTreeNode)this).getUserObject());
  132.       } else {
  133.          this.path = var1.pathByAddingChild(((DefaultMutableTreeNode)this).getUserObject());
  134.       }
  135.  
  136.       FixedHeightLayoutCache.access$100(this.this$0, this);
  137.  
  138.       for(int var2 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var2 >= 0; --var2) {
  139.          ((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var2)).resetChildrenPaths(this.path);
  140.       }
  141.  
  142.    }
  143.  
  144.    protected void removeFromMapping() {
  145.       if (this.path != null) {
  146.          FixedHeightLayoutCache.access$200(this.this$0, this);
  147.  
  148.          for(int var1 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var1 >= 0; --var1) {
  149.             ((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var1)).removeFromMapping();
  150.          }
  151.       }
  152.  
  153.    }
  154.  
  155.    protected FixedHeightLayoutCache$FHTreeStateNode createChildFor(Object var1) {
  156.       int var2 = this.this$0.treeModel.getIndexOfChild(((DefaultMutableTreeNode)this).getUserObject(), var1);
  157.       if (var2 < 0) {
  158.          return null;
  159.       } else {
  160.          FixedHeightLayoutCache$FHTreeStateNode var4 = FixedHeightLayoutCache.access$300(this.this$0, var1, var2);
  161.          int var5;
  162.          if (this.isVisible()) {
  163.             var5 = this.getRowToModelIndex(var2);
  164.          } else {
  165.             var5 = -1;
  166.          }
  167.  
  168.          var4.row = var5;
  169.          int var6 = 0;
  170.  
  171.          for(int var7 = ((DefaultMutableTreeNode)this).getChildCount(); var6 < var7; ++var6) {
  172.             FixedHeightLayoutCache$FHTreeStateNode var3 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var6);
  173.             if (var3.childIndex > var2) {
  174.                ((DefaultMutableTreeNode)this).insert(var4, var6);
  175.                return var4;
  176.             }
  177.          }
  178.  
  179.          ((DefaultMutableTreeNode)this).add(var4);
  180.          return var4;
  181.       }
  182.    }
  183.  
  184.    protected void adjustRowBy(int var1) {
  185.       this.row += var1;
  186.       if (this.isExpanded) {
  187.          for(int var2 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var2 >= 0; --var2) {
  188.             ((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var2)).adjustRowBy(var1);
  189.          }
  190.       }
  191.  
  192.    }
  193.  
  194.    protected void adjustRowBy(int var1, int var2) {
  195.       if (this.isExpanded) {
  196.          for(int var3 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var3 >= var2; --var3) {
  197.             ((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var3)).adjustRowBy(var1);
  198.          }
  199.       }
  200.  
  201.       FixedHeightLayoutCache$FHTreeStateNode var4 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  202.       if (var4 != null) {
  203.          var4.adjustRowBy(var1, ((DefaultMutableTreeNode)var4).getIndex(this) + 1);
  204.       }
  205.  
  206.    }
  207.  
  208.    protected void didExpand() {
  209.       int var1 = this.setRowAndChildren(this.row);
  210.       FixedHeightLayoutCache$FHTreeStateNode var2 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  211.       int var3 = var1 - this.row - 1;
  212.       if (var2 != null) {
  213.          var2.adjustRowBy(var3, ((DefaultMutableTreeNode)var2).getIndex(this) + 1);
  214.       }
  215.  
  216.       FixedHeightLayoutCache.access$400(this.this$0, var3);
  217.    }
  218.  
  219.    protected int setRowAndChildren(int var1) {
  220.       this.row = var1;
  221.       if (!this.isExpanded()) {
  222.          return this.row + 1;
  223.       } else {
  224.          int var7 = this.row + 1;
  225.          int var3 = 0;
  226.          int var5 = ((DefaultMutableTreeNode)this).getChildCount();
  227.  
  228.          for(int var6 = 0; var6 < var5; ++var6) {
  229.             FixedHeightLayoutCache$FHTreeStateNode var4 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var6);
  230.             var7 += var4.childIndex - var3;
  231.             var3 = var4.childIndex + 1;
  232.             if (var4.isExpanded) {
  233.                var7 = var4.setRowAndChildren(var7);
  234.             } else {
  235.                var4.row = var7++;
  236.             }
  237.          }
  238.  
  239.          return var7 + this.this$0.treeModel.getChildCount(((DefaultMutableTreeNode)this).getUserObject()) - var3;
  240.       }
  241.    }
  242.  
  243.    protected void resetChildrenRowsFrom(int var1, int var2, int var3) {
  244.       int var9 = var1;
  245.       int var5 = var3;
  246.       int var7 = ((DefaultMutableTreeNode)this).getChildCount();
  247.  
  248.       for(int var8 = var2; var8 < var7; ++var8) {
  249.          FixedHeightLayoutCache$FHTreeStateNode var6 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var8);
  250.          var9 += var6.childIndex - var5;
  251.          var5 = var6.childIndex + 1;
  252.          if (var6.isExpanded) {
  253.             var9 = var6.setRowAndChildren(var9);
  254.          } else {
  255.             var6.row = var9++;
  256.          }
  257.       }
  258.  
  259.       var9 += this.this$0.treeModel.getChildCount(((DefaultMutableTreeNode)this).getUserObject()) - var5;
  260.       FixedHeightLayoutCache$FHTreeStateNode var11 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  261.       if (var11 != null) {
  262.          var11.resetChildrenRowsFrom(var9, ((DefaultMutableTreeNode)var11).getIndex(this) + 1, this.childIndex + 1);
  263.       } else {
  264.          FixedHeightLayoutCache.access$502(this.this$0, var9);
  265.       }
  266.  
  267.    }
  268.  
  269.    protected void makeVisible() {
  270.       FixedHeightLayoutCache$FHTreeStateNode var1 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  271.       if (var1 != null) {
  272.          var1.expandParentAndReceiver();
  273.       }
  274.  
  275.    }
  276.  
  277.    protected void expandParentAndReceiver() {
  278.       FixedHeightLayoutCache$FHTreeStateNode var1 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  279.       if (var1 != null) {
  280.          var1.expandParentAndReceiver();
  281.       }
  282.  
  283.       this.expand();
  284.    }
  285.  
  286.    protected void expand() {
  287.       if (!this.isExpanded) {
  288.          boolean var1 = this.isVisible();
  289.          this.isExpanded = true;
  290.          if (var1) {
  291.             this.didExpand();
  292.          }
  293.  
  294.          if (var1 && this.this$0.treeSelectionModel != null) {
  295.             this.this$0.treeSelectionModel.resetRowSelection();
  296.          }
  297.       }
  298.  
  299.    }
  300.  
  301.    protected void collapse(boolean var1) {
  302.       if (this.isExpanded) {
  303.          if (this.isVisible() && var1) {
  304.             int var2 = this.getTotalChildCount();
  305.             this.isExpanded = false;
  306.             FixedHeightLayoutCache.access$400(this.this$0, -var2);
  307.             this.adjustRowBy(-var2, 0);
  308.          } else {
  309.             this.isExpanded = false;
  310.          }
  311.  
  312.          if (var1 && this.isVisible() && this.this$0.treeSelectionModel != null) {
  313.             this.this$0.treeSelectionModel.resetRowSelection();
  314.          }
  315.       }
  316.  
  317.    }
  318.  
  319.    protected void addNode(FixedHeightLayoutCache$FHTreeStateNode var1) {
  320.       boolean var2 = false;
  321.       int var3 = var1.getChildIndex();
  322.       int var4 = 0;
  323.  
  324.       for(int var5 = ((DefaultMutableTreeNode)this).getChildCount(); var4 < var5; ++var4) {
  325.          if (((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var4)).getChildIndex() > var3) {
  326.             var2 = true;
  327.             ((DefaultMutableTreeNode)this).insert(var1, var4);
  328.             var4 = var5;
  329.          }
  330.       }
  331.  
  332.       if (!var2) {
  333.          ((DefaultMutableTreeNode)this).add(var1);
  334.       }
  335.  
  336.    }
  337.  
  338.    protected void removeChildAtModelIndex(int var1, boolean var2) {
  339.       FixedHeightLayoutCache$FHTreeStateNode var3 = this.getChildAtModelIndex(var1);
  340.       if (var3 != null) {
  341.          int var4 = var3.getRow();
  342.          int var5 = ((DefaultMutableTreeNode)this).getIndex(var3);
  343.          var3.collapse(false);
  344.          this.remove(var5);
  345.          this.adjustChildIndexs(var5, -1);
  346.          if (var2) {
  347.             this.resetChildrenRowsFrom(var4, var5, var1);
  348.          }
  349.       } else {
  350.          int var7 = ((DefaultMutableTreeNode)this).getChildCount();
  351.  
  352.          for(int var6 = 0; var6 < var7; ++var6) {
  353.             FixedHeightLayoutCache$FHTreeStateNode var8 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var6);
  354.             if (var8.childIndex >= var1) {
  355.                if (var2) {
  356.                   this.adjustRowBy(-1, var6);
  357.                   FixedHeightLayoutCache.access$400(this.this$0, -1);
  358.                }
  359.  
  360.                while(var6 < var7) {
  361.                   --((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var6)).childIndex;
  362.                   ++var6;
  363.                }
  364.  
  365.                return;
  366.             }
  367.          }
  368.  
  369.          if (var2) {
  370.             this.adjustRowBy(-1, var7);
  371.             FixedHeightLayoutCache.access$400(this.this$0, -1);
  372.          }
  373.       }
  374.  
  375.    }
  376.  
  377.    protected void adjustChildIndexs(int var1, int var2) {
  378.       int var3 = var1;
  379.  
  380.       for(int var4 = ((DefaultMutableTreeNode)this).getChildCount(); var3 < var4; ++var3) {
  381.          FixedHeightLayoutCache$FHTreeStateNode var10000 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var3);
  382.          var10000.childIndex += var2;
  383.       }
  384.  
  385.    }
  386.  
  387.    protected void childInsertedAtModelIndex(int var1, boolean var2) {
  388.       int var4 = ((DefaultMutableTreeNode)this).getChildCount();
  389.  
  390.       for(int var5 = 0; var5 < var4; ++var5) {
  391.          FixedHeightLayoutCache$FHTreeStateNode var3 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var5);
  392.          if (var3.childIndex >= var1) {
  393.             if (var2) {
  394.                this.adjustRowBy(1, var5);
  395.                FixedHeightLayoutCache.access$400(this.this$0, 1);
  396.             }
  397.  
  398.             while(var5 < var4) {
  399.                ++((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var5)).childIndex;
  400.                ++var5;
  401.             }
  402.  
  403.             return;
  404.          }
  405.       }
  406.  
  407.       if (var2) {
  408.          this.adjustRowBy(1, var4);
  409.          FixedHeightLayoutCache.access$400(this.this$0, 1);
  410.       }
  411.  
  412.    }
  413.  
  414.    protected boolean getPathForRow(int var1, int var2, FixedHeightLayoutCache.SearchInfo var3) {
  415.       if (this.row == var1) {
  416.          var3.node = this;
  417.          var3.isNodeParentNode = false;
  418.          var3.childIndex = this.childIndex;
  419.          return true;
  420.       } else {
  421.          FixedHeightLayoutCache$FHTreeStateNode var5 = null;
  422.          int var6 = 0;
  423.  
  424.          for(int var7 = ((DefaultMutableTreeNode)this).getChildCount(); var6 < var7; ++var6) {
  425.             FixedHeightLayoutCache$FHTreeStateNode var4 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var6);
  426.             if (var4.row > var1) {
  427.                if (var6 == 0) {
  428.                   var3.node = this;
  429.                   var3.isNodeParentNode = true;
  430.                   var3.childIndex = var1 - this.row - 1;
  431.                   return true;
  432.                }
  433.  
  434.                int var8 = 1 + var4.row - (var4.childIndex - var5.childIndex);
  435.                if (var1 < var8) {
  436.                   return var5.getPathForRow(var1, var8, var3);
  437.                }
  438.  
  439.                var3.node = this;
  440.                var3.isNodeParentNode = true;
  441.                var3.childIndex = var1 - var8 + var5.childIndex + 1;
  442.                return true;
  443.             }
  444.  
  445.             var5 = var4;
  446.          }
  447.  
  448.          int var10 = this.this$0.treeModel.getChildCount(((DefaultMutableTreeNode)this).getUserObject());
  449.          if (var5 != null) {
  450.             int var11 = var2 - (var10 - var5.childIndex) + 1;
  451.             if (var1 < var11) {
  452.                return var5.getPathForRow(var1, var11, var3);
  453.             } else {
  454.                var3.node = this;
  455.                var3.isNodeParentNode = true;
  456.                var3.childIndex = var1 - var11 + var5.childIndex + 1;
  457.                return true;
  458.             }
  459.          } else {
  460.             int var9 = var1 - this.row - 1;
  461.             if (var9 >= var10) {
  462.                return false;
  463.             } else {
  464.                var3.node = this;
  465.                var3.isNodeParentNode = true;
  466.                var3.childIndex = var9;
  467.                return true;
  468.             }
  469.          }
  470.       }
  471.    }
  472.  
  473.    protected int getCountTo(int var1) {
  474.       int var3 = var1 + 1;
  475.       int var4 = 0;
  476.  
  477.       for(int var5 = ((DefaultMutableTreeNode)this).getChildCount(); var4 < var5; ++var4) {
  478.          FixedHeightLayoutCache$FHTreeStateNode var2 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var4);
  479.          if (var2.childIndex >= var1) {
  480.             var4 = var5;
  481.          } else {
  482.             var3 += var2.getTotalChildCount();
  483.          }
  484.       }
  485.  
  486.       if (super.parent != null) {
  487.          return var3 + ((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent()).getCountTo(this.childIndex);
  488.       } else if (!this.this$0.isRootVisible()) {
  489.          return var3 - 1;
  490.       } else {
  491.          return var3;
  492.       }
  493.    }
  494.  
  495.    protected int getNumExpandedChildrenTo(int var1) {
  496.       int var3 = var1;
  497.       int var4 = 0;
  498.  
  499.       for(int var5 = ((DefaultMutableTreeNode)this).getChildCount(); var4 < var5; ++var4) {
  500.          FixedHeightLayoutCache$FHTreeStateNode var2 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var4);
  501.          if (var2.childIndex >= var1) {
  502.             return var3;
  503.          }
  504.  
  505.          var3 += var2.getTotalChildCount();
  506.       }
  507.  
  508.       return var3;
  509.    }
  510.  
  511.    protected void didAdjustTree() {
  512.    }
  513. }
  514.