2362N/A * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * NOTE: This will become more open in a future release. 0N/A * <strong>Warning:</strong> 0N/A * Serialized objects of this class will not be compatible with 0N/A * future Swing releases. The current serialization support is 0N/A * appropriate for short term storage or RMI between applications running 0N/A * the same version of Swing. As of 1.4, support for long term storage 0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup> 0N/A * has been added to the <code>java.beans</code> package. 0N/A * @author Scott Violet 0N/A /** Number of rows currently visible. */ 0N/A * Used in getting sizes for nodes to avoid creating a new Rectangle 0N/A * every time a size is needed. 0N/A * Maps from TreePath to a FHTreeStateNode. 0N/A * Sets the TreeModel that will provide the data. 0N/A * @param newModel the TreeModel that is to provide the data 0N/A * Determines whether or not the root node from 0N/A * the TreeModel is visible. 0N/A * @param rootVisible true if the root node of the tree is to be displayed 0N/A * Sets the height of each cell. If rowHeight is less than or equal to 0N/A * 0 this will throw an IllegalArgumentException. 0N/A * @param rowHeight the height of each cell, in pixels 0N/A * Returns the number of visible rows. 0N/A * Does nothing, FixedHeightLayoutCache doesn't cache width, and that 0N/A * is all that could change. 0N/A * Informs the TreeState that it needs to recalculate all the sizes 0N/A * it is referencing. 0N/A // Nothing to do here, rowHeight still same, which is all 0N/A // this is interested in, visible region may have changed though. 0N/A * Returns true if the value identified by row is currently expanded. 0N/A * Returns a rectangle giving the bounds needed to draw path. 0N/A * @param path a TreePath specifying a node 0N/A * @param placeIn a Rectangle object giving the available space 0N/A * @return a Rectangle object specifying the space to be used 0N/A // node hasn't been created yet. 0N/A * Returns the path for passed in row. If row is not visible 0N/A * Returns the row that the last item identified in path is visible 0N/A * at. Will return -1 if any of the elements in path are not 0N/A * currently visible. 0N/A * Returns the path to the node that is closest to x,y. If 0N/A * there is nothing currently visible this will return null, otherwise 0N/A * it'll always return a valid path. If you need to test if the 0N/A * returned object is exactly at x, y you should get the bounds for 0N/A * the returned path and test x, y against that. 0N/A * Returns the number of visible children for row. 0N/A * Returns an Enumerator that increments over the visible paths 0N/A * starting at the passed in location. The ordering of the enumeration 0N/A * is based on how the paths are displayed. 0N/A * Marks the path <code>path</code> expanded state to 0N/A * <code>isExpanded</code>. 0N/A // YECK! Make the parent expanded. 0N/A // And collapse the child. 0N/A * Returns true if the path is expanded, and visible. 0N/A // TreeModelListener methods 0N/A * <p>Invoked after a node (or a set of siblings) has changed in some 0N/A * way. The node(s) have not changed locations in the tree or 0N/A * altered their children arrays, but other attributes have 0N/A * changed and may affect presentation. Example: the name of a 0N/A * file has changed, but it is in the same location in the file 0N/A * <p>e.path() returns the path the parent of the changed node(s).</p> 0N/A * <p>e.childIndices() returns the index(es) of the changed node(s).</p> 0N/A /* Only need to update the children if the node has been 0N/A // PENDING(scott): make sure childIndexs is sorted! 0N/A // Null for root indicates it changed. 0N/A * <p>Invoked after nodes have been inserted into the tree.</p> 0N/A * <p>e.path() returns the parent of the new nodes 0N/A * <p>e.childIndices() returns the indices of the new nodes in 0N/A /* Only need to update the children if the node has been 0N/A // PENDING(scott): make sure childIndexs is sorted! 0N/A * <p>Invoked after nodes have been removed from the tree. Note that 0N/A * if a subtree is removed from the tree, this method may only be 0N/A * invoked once for the root of the removed subtree, not once for 0N/A * each individual set of siblings removed.</p> 0N/A * <p>e.path() returns the former parent of the deleted nodes.</p> 0N/A * <p>e.childIndices() returns the indices the nodes had before they were deleted in ascending order.</p> 0N/A // PENDING(scott): make sure that changedIndexs are sorted in 0N/A // Node has become a leaf, collapse it. 0N/A * <p>Invoked after the tree has drastically changed structure from a 0N/A * given node down. If the path returned by e.getPath() is of length 0N/A * one and the first element does not identify the current root node 0N/A * the first element should become the new root of the tree.<p> 0N/A * <p>e.path() holds the path to the node.</p> 0N/A * <p>e.childIndices() returns null.</p> 0N/A // Check if root has changed, either to a null root, or 0N/A // to an entirely new root. 0N/A * Returns the bounds for the given node. If <code>childIndex</code> 0N/A * is -1, the bounds of <code>parent</code> are returned, otherwise 0N/A * the bounds of the node at <code>childIndex</code> are returned. 0N/A // Getting bounds for parent 0N/A // No node dimensions, bail. 0N/A * Adjust the large row count of the AbstractTreeUI the receiver was 0N/A * Adds a mapping for node. 0N/A * Removes the mapping for a previously added node. 0N/A * Returns the node previously added for <code>path</code>. This may 0N/A * return null, if you to create a node use getNodeForPath. 0N/A * Sent to completely rebuild the visible tree. All nodes are collapsed. 0N/A * Returns the index of the row containing location. If there 0N/A * are no rows, -1 is returned. If location is beyond the last 0N/A * row index, the last row index is returned. 0N/A * Ensures that all the path components in path are expanded, accept 0N/A * for the last component which will only be expanded if expandLast 0N/A * Returns true if succesful in finding the path. 0N/A // Make sure the last entry isn't a leaf. 0N/A * Creates and returns an instance of FHTreeStateNode. 0N/A * Messages getTreeNodeForPage(path, onlyIfVisible, shouldCreate, 0N/A * path.length) as long as path is non-null and the length is > 0. 0N/A * Otherwise returns null. 0N/A // Check all the parent paths, until a match is found. 0N/A // Found a match, create entries for all paths in 0N/A // If we get here it means they share a different root! 0N/A * FHTreeStateNode is used to track what has been expanded. 0N/A * FHTreeStateNode differs from VariableHeightTreeState.TreeStateNode 0N/A * in that it is highly model intensive. That is almost all queries to a 0N/A * FHTreeStateNode result in the TreeModel being queried. And it 0N/A * obviously does not support variable sized row heights. 0N/A /** Is this node expanded? */ 0N/A /** Index of this node from the model. */ 0N/A /** Child count of the receiver. */ 0N/A /** Row of the receiver. This is only valid if the row is expanded. 0N/A /** Path of this node. */ 0N/A // Overriden DefaultMutableTreeNode methods 0N/A * Messaged when this node is added somewhere, resets the path 0N/A * and adds a mapping from path to this node. 0N/A * Messaged when this node is removed from its parent, this messages 0N/A * <code>removedFromMapping</code> to remove all the children. 0N/A * Messaged to set the user object. This resets the path. 0N/A * Returns the index of the receiver in the model. 0N/A * Returns the <code>TreePath</code> of the receiver. 0N/A * Returns the child for the passed in model index, this will 0N/A * return <code>null</code> if the child for <code>index</code> 0N/A * has not yet been created (expanded). 0N/A // PENDING: Make this a binary search! 0N/A * Returns true if this node is visible. This is determined by 0N/A * asking all the parents if they are expanded. 0N/A * Returns the row of the receiver. 0N/A * Returns the row of the child with a model index of 0N/A * <code>index</code>. 0N/A // This too could be a binary search! 0N/A * Returns the number of children in the receiver by descending all 0N/A * expanded nodes and messaging them with getTotalChildCount. 0N/A // This node has a created sibling, to calc total 0N/A // child count directly from that! 0N/A * Returns true if this node is expanded. 0N/A * The highest visible nodes have a depth of 0. 0N/A * Recreates the receivers path, and all its childrens paths. 0N/A * Removes the receiver, and all its children, from the mapping 0N/A * Creates a new node to represent <code>userObject</code>. 0N/A * This does NOT check to ensure there isn't already a child node 0N/A * to manage <code>userObject</code>. 0N/A * Adjusts the receiver, and all its children rows by 0N/A * <code>amount</code>. 0N/A * Adjusts this node, its child, and its parent starting at 0N/A * an index of <code>index</code> index is the index of the child 0N/A * to start adjusting from, which is not necessarily the model 0N/A // Could check isVisible, but probably isn't worth it. 0N/A // children following startIndex. 0N/A * Messaged when the node has expanded. This updates all of 0N/A * the receivers children rows, as well as the total row count. 0N/A * Sets the receivers row to <code>nextRow</code> and recursively 0N/A * updates all the children of the receivers rows. The index the 0N/A * next row is to be placed as is returned. 0N/A * Resets the receivers childrens rows. Starting with the child 0N/A * at <code>childIndex</code> (and <code>modelIndex</code>) to 0N/A * <code>newRow</code>. This uses <code>setRowAndChildren</code> 0N/A * to recursively descend children, and uses 0N/A * <code>resetRowSelection</code> to ascend parents. 0N/A // This can be rather expensive, but is needed for the collapse 0N/A // case this is resulting from a remove (although I could fix 0N/A // that by having instances of FHTreeStateNode hold a ref to 0N/A // the number of children). I prefer this though, making determing 0N/A // the row of a particular node fast is very nice! 0N/A else {
// This is the root, reset total ROWCOUNT! 0N/A * Makes the receiver visible, but invoking 0N/A * <code>expandParentAndReceiver</code> on the superclass. 0N/A * Invokes <code>expandParentAndReceiver</code> on the parent, 0N/A * and expands the receiver. 0N/A * Expands the receiver. 0N/A // Update the selection model. 0N/A * Collapses the receiver. If <code>adjustRows</code> is true, 0N/A * the rows of nodes after the receiver are adjusted. 0N/A // We can do this because adjustRowBy won't descend 0N/A * Returns true if the receiver is a leaf. 0N/A * Adds newChild to this nodes children at the appropriate location. 0N/A * The location is determined from the childIndex of newChild. 0N/A * Removes the child at <code>modelIndex</code>. 0N/A * <code>isChildVisible</code> should be true if the receiver 0N/A * is visible and expanded. 0N/A // Since matched and children are always sorted by 0N/A // index, no need to continue testing with the 0N/A // No children to adjust, but it was a child, so we still need 0N/A // to adjust nodes after this one. 0N/A * Adjusts the child indexs of the receivers children by 0N/A * <code>amount</code>, starting at <code>index</code>. 0N/A * Messaged when a child has been inserted at index. For all the 0N/A * children that have a childIndex >= index their index is incremented 0N/A /* Since matched and children are always sorted by 0N/A index, no need to continue testing with the above. */ 0N/A // No children to adjust, but it was a child, so we still need 0N/A // to adjust nodes after this one. 0N/A * Returns true if there is a row for <code>row</code>. 0N/A * <code>nextRow</code> gives the bounds of the receiver. 0N/A * Information about the found row is returned in <code>info</code>. 0N/A * This should be invoked on root with <code>nextRow</code> set 0N/A * to <code>getRowCount</code>(). 0N/A // No node exists for it, and is first. 0N/A // May have been in last childs bounds. 0N/A // Between last child and child, but not in last child 0N/A // Not in children, but we should have it, offset from 0N/A // Between last child and child, but not in last child 0N/A * Asks all the children of the receiver for their totalChildCount 0N/A * and returns this value (plus stopIndex). 0N/A * Returns the number of children that are expanded to 0N/A * <code>stopIndex</code>. This does not include the number 0N/A * of children that the child at <code>stopIndex</code> might 0N/A * Messaged when this node either expands or collapses. 0N/A }
// FixedHeightLayoutCache.FHTreeStateNode 0N/A * Used as a placeholder when getting the path in FHTreeStateNodes. 0N/A }
// FixedHeightLayoutCache.SearchInfo 0N/A * An enumerator to iterate through visible nodes. 0N/A // This is very similiar to 0N/A // VariableHeightTreeState.VisibleTreeStateNodeEnumeration 0N/A /** Parent thats children are being enumerated. */ 0N/A /** Index of next child. An index of -1 signifies parent should be 0N/A /** Number of children in parent. */ 0N/A * @return true if more visible nodes. 0N/A * @return next visible TreePath. 0N/A * Determines the next object by invoking <code>updateNextIndex</code> 0N/A * and if not succesful <code>findNextValidParent</code>. 0N/A * Finds the next valid parent, this should be called when nextIndex 0N/A * is beyond the number of children of the current parent. 0N/A * Updates <code>nextIndex</code> returning false if it is beyond 0N/A * the number of children of parent. 0N/A // nextIndex == -1 identifies receiver, make sure is expanded 0N/A // Check that it can have kids 0N/A // Make sure next index not beyond child count. 0N/A }
// FixedHeightLayoutCache.VisibleFHTreeStateNodeEnumeration