paintBounds.y);
Enumeration paintingEnumerator = treeState.getVisiblePathsFrom
(initialPath);
int row = treeState.getRowForPath(initialPath);
int endY = paintBounds.y + paintBounds.height;
TreeModel treeModel = tree.getModel();
SynthContext cellContext = getContext(tree, Region.TREE_CELL);
drawingCache.clear();
setHashColor(context.getStyle().getColor(context,
ColorType.FOREGROUND));
if (paintingEnumerator != null) {
// First pass, draw the rows
boolean done = false;
boolean isExpanded;
boolean hasBeenExpanded;
boolean isLeaf;
Rectangle rowBounds = new Rectangle(0, 0, tree.getWidth(),0);
Rectangle bounds;
TreePath path;
TreeCellRenderer renderer = tree.getCellRenderer();
DefaultTreeCellRenderer dtcr = (renderer instanceof
DefaultTreeCellRenderer) ? (DefaultTreeCellRenderer)
renderer : null;
configureRenderer(cellContext);
while (!done && paintingEnumerator.hasMoreElements()) {
path = (TreePath)paintingEnumerator.nextElement();
if (path != null) {
isLeaf = treeModel.isLeaf(path.getLastPathComponent());
if (isLeaf) {
isExpanded = hasBeenExpanded = false;
}
else {
isExpanded = treeState.getExpandedState(path);
hasBeenExpanded = tree.hasBeenExpanded(path);
}
bounds = getPathBounds(tree, path);
rowBounds.y = bounds.y;
rowBounds.height = bounds.height;
paintRow(renderer, dtcr, context, cellContext, g,
paintBounds, insets, bounds, rowBounds, path,
row, isExpanded, hasBeenExpanded, isLeaf);
if ((bounds.y + bounds.height) >= endY) {
done = true;
}
}
else {
done = true;
}
row++;
}
// Draw the connecting lines and controls.
// Find each parent and have them draw a line to their last child
boolean rootVisible = tree.isRootVisible();
TreePath parentPath = initialPath;
parentPath = parentPath.getParentPath();
while (parentPath != null) {
paintVerticalPartOfLeg(g, paintBounds, insets, parentPath);
drawingCache.put(parentPath, Boolean.TRUE);
parentPath = parentPath.getParentPath();
}
done = false;
paintingEnumerator = treeState.getVisiblePathsFrom(initialPath);
while (!done && paintingEnumerator.hasMoreElements()) {
path = (TreePath)paintingEnumerator.nextElement();
if (path != null) {
isLeaf = treeModel.isLeaf(path.getLastPathComponent());
if (isLeaf) {
isExpanded = hasBeenExpanded = false;
}
else {
isExpanded = treeState.getExpandedState(path);