コード例 #1
0
 /**
  * Determines whether or not the root node from the TreeModel is visible.
  *
  * @param rootVisible true if the root node of the tree is to be displayed
  * @see #rootVisible
  */
 public void setRootVisible(boolean rootVisible) {
   if (isRootVisible() != rootVisible) {
     super.setRootVisible(rootVisible);
     if (root != null) {
       if (rootVisible) {
         rowCount++;
         root.adjustRowBy(1);
       } else {
         rowCount--;
         root.adjustRowBy(-1);
       }
       visibleNodesChanged();
     }
   }
 }
コード例 #2
0
    /**
     * Messaged when the node has expanded. This updates all of the receivers children rows, as well
     * as the total row count.
     */
    protected void didExpand() {
      int nextRow = setRowAndChildren(row);
      FHTreeStateNode parent = (FHTreeStateNode) getParent();
      int childRowCount = nextRow - row - 1;

      if (parent != null) {
        parent.adjustRowBy(childRowCount, parent.getIndex(this) + 1);
      }
      adjustRowCountBy(childRowCount);
    }
コード例 #3
0
    /**
     * Adjusts this node, its child, and its parent starting at an index of <code>index</code> index
     * is the index of the child to start adjusting from, which is not necessarily the model index.
     */
    protected void adjustRowBy(int amount, int startIndex) {
      // Could check isVisible, but probably isn't worth it.
      if (isExpanded) {
        // children following startIndex.
        for (int counter = getChildCount() - 1; counter >= startIndex; counter--)
          ((FHTreeStateNode) getChildAt(counter)).adjustRowBy(amount);
      }
      // Parent
      FHTreeStateNode parent = (FHTreeStateNode) getParent();

      if (parent != null) {
        parent.adjustRowBy(amount, parent.getIndex(this) + 1);
      }
    }