/[classpath]/classpath/javax/swing/plaf/basic/BasicTreeUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicTreeUI.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.43 by langel, Tue Jul 19 18:15:35 2005 UTC revision 1.44 by langel, Wed Jul 20 13:52:04 2005 UTC
# Line 589  public class BasicTreeUI Line 589  public class BasicTreeUI
589        {        {
590           Object cell = path.getLastPathComponent();           Object cell = path.getLastPathComponent();
591           TreeModel mod = tree.getModel();           TreeModel mod = tree.getModel();
592           Point loc = getCellLocation(0, 0, tree, mod, cell, mod.getRoot());           DefaultMutableTreeNode root = (DefaultMutableTreeNode) mod.getRoot();
593           int x = (int) loc.getX();           if (!tree.isRootVisible()
594           int y = (int) loc.getY();                 && tree.isExpanded(new TreePath(((DefaultMutableTreeNode) root)
595           return getCellBounds(x, y, cell);                       .getPath())))
596                root = root.getNextNode();
597    
598             Point loc = getCellLocation(0, 0, tree, mod, cell, root);
599             return getCellBounds(loc.x, loc.y, cell);
600        }        }
601        return null;        return null;
602     }     }
# Line 610  public class BasicTreeUI Line 614  public class BasicTreeUI
614     {     {
615        DefaultMutableTreeNode node = ((DefaultMutableTreeNode) (tree.getModel())        DefaultMutableTreeNode node = ((DefaultMutableTreeNode) (tree.getModel())
616              .getRoot());              .getRoot());
617          if (!tree.isRootVisible()
618                && tree.isExpanded(new TreePath(((DefaultMutableTreeNode) node)
619                      .getPath())))
620             node = node.getNextNode();
621    
622        for (int i = 0; i < row; i++)        for (int i = 0; i < row; i++)
623           node = getNextVisibleNode(node);           node = getNextVisibleNode(node);
# Line 650  public class BasicTreeUI Line 658  public class BasicTreeUI
658     {     {
659        DefaultMutableTreeNode node = ((DefaultMutableTreeNode) (tree.getModel())        DefaultMutableTreeNode node = ((DefaultMutableTreeNode) (tree.getModel())
660              .getRoot());              .getRoot());
661          if (!tree.isRootVisible()
662                && tree.isExpanded(new TreePath(((DefaultMutableTreeNode) node)
663                      .getPath())))
664             node = node.getNextNode();
665          
666        int count = 0;        int count = 0;
667                
668        while (node != null)        while (node != null)
# Line 679  public class BasicTreeUI Line 692  public class BasicTreeUI
692                
693        int row = Math.round(y / getRowHeight());        int row = Math.round(y / getRowHeight());
694        TreePath path = getPathForRow(tree, row);        TreePath path = getPathForRow(tree, row);
695          
696        // no row is visible at this node        // no row is visible at this node
697        while (row > 0 && path == null)        while (row > 0 && path == null)
698        {        {
# Line 1220  public class BasicTreeUI Line 1233  public class BasicTreeUI
1233     {     {
1234        JTree tree = (JTree) c;        JTree tree = (JTree) c;
1235        TreeModel mod = tree.getModel();        TreeModel mod = tree.getModel();
1236        paintRecursive(g, 0, 0, 0, 0, tree, mod, mod.getRoot());        Object root = mod.getRoot();
1237          
1238          if (!tree.isRootVisible())
1239             tree.expandPath(new TreePath(((DefaultMutableTreeNode) root)
1240                   .getPath()));
1241          
1242          paintRecursive(g, 0, 0, 0, 0, tree, mod, root);
1243                
1244        if (hasControlIcons())        if (hasControlIcons())
1245           paintControlIcons(g, 0, 0, 0, 0, tree, mod, mod.getRoot());           paintControlIcons(g, 0, 0, 0, 0, tree, mod, root);
1246                
1247        TreePath lead = tree.getLeadSelectionPath();        TreePath lead = tree.getLeadSelectionPath();
1248        if (lead != null && tree.isPathSelected(lead))        if (lead != null && tree.isPathSelected(lead))
# Line 1231  public class BasicTreeUI Line 1250  public class BasicTreeUI
1250           Rectangle cell = getPathBounds(tree, lead);             Rectangle cell = getPathBounds(tree, lead);  
1251           g.setColor(UIManager.getLookAndFeelDefaults().getColor(           g.setColor(UIManager.getLookAndFeelDefaults().getColor(
1252                 "Tree.selectionBorderColor"));                 "Tree.selectionBorderColor"));
1253           g.drawRect(cell.x + rightChildIndent - 4, cell.y, cell.width + 4,           g.drawRect(cell.x + rightChildIndent - 4, cell.y,
1254                 cell.height);                 cell.width + 4, cell.height);
1255        }        }
1256     }     }
1257    
# Line 2455  public class BasicTreeUI Line 2474  public class BasicTreeUI
2474     {     {
2475        int rowHeight = getRowHeight();        int rowHeight = getRowHeight();
2476        if (startNode == null || startNode.equals(node))        if (startNode == null || startNode.equals(node))
2477           return new Point(x + ((((DefaultMutableTreeNode) node).        {
2478                 getLevel() + 1) * rightChildIndent), y);           if (!tree.isRootVisible() && tree.isExpanded(new TreePath((
2479                   (DefaultMutableTreeNode) mod.getRoot()).getPath())))
2480                return new Point(x + ((((DefaultMutableTreeNode) node).getLevel())
2481                      * rightChildIndent), y);
2482            
2483             return new Point(x + ((((DefaultMutableTreeNode) node).getLevel() + 1)
2484                   * rightChildIndent), y);
2485          }
2486    
2487        if (!mod.isLeaf(startNode)        if (!mod.isLeaf(startNode)
2488              && tree.isExpanded(new TreePath(              && tree.isExpanded(new TreePath(
# Line 2540  public class BasicTreeUI Line 2566  public class BasicTreeUI
2566        int halfWidth = rightChildIndent / 2;        int halfWidth = rightChildIndent / 2;
2567        int y0 = descent + halfHeight;        int y0 = descent + halfHeight;
2568        int heightOfLine = descent + halfHeight;        int heightOfLine = descent + halfHeight;
2569          boolean isRootVisible = tree.isRootVisible();
2570                
2571        if (mod.isLeaf(curr))        if (mod.isLeaf(curr))
2572        {        {
# Line 2548  public class BasicTreeUI Line 2575  public class BasicTreeUI
2575        }        }
2576        else        else
2577        {        {
2578           if (depth > 0 || tree.isRootVisible())           if (depth > 0 || isRootVisible)
2579           {           {
2580              paintNode(g, indentation + 4, descent, tree, curr, false);              paintNode(g, indentation + 4, descent, tree, curr, false);
2581              descent += getRowHeight();              descent += getRowHeight();
2582              y0 += halfHeight;              y0 += halfHeight;
2583           }           }
2584            
2585           int max = mod.getChildCount(curr);           int max = mod.getChildCount(curr);
2586           if (tree.isExpanded(new TreePath(((DefaultMutableTreeNode) curr)           if (tree.isExpanded(new TreePath(((DefaultMutableTreeNode) curr)
2587                 .getPath())))                 .getPath())))
2588           {           {
2589              for (int i = 0; i < max; ++i)              for (int i = 0; i < max; ++i)
2590              {              {
2591                 g.setColor(getHashColor());                 int indent = indentation + rightChildIndent;
2592                 heightOfLine = descent + halfHeight;                 if (!isRootVisible && depth == 0)
2593                 g.drawLine(indentation + halfWidth, heightOfLine,                    indent = 0;
2594                       indentation + rightChildIndent, heightOfLine);                 else if ((!isRootVisible && !curr.equals(mod.getRoot())) ||
2595                                                       isRootVisible)
2596                 descent = paintRecursive(g, indentation + rightChildIndent,                 {
2597                      g.setColor(getHashColor());
2598                      heightOfLine = descent + halfHeight;
2599                      g.drawLine(indentation + halfWidth, heightOfLine, indentation
2600                            + rightChildIndent, heightOfLine);
2601                   }
2602                      
2603                   descent = paintRecursive(g, indent,
2604                       descent, i, depth + 1, tree, mod, mod.getChild(curr, i));                       descent, i, depth + 1, tree, mod, mod.getChild(curr, i));
2605              }              }
2606           }           }
# Line 2628  public class BasicTreeUI Line 2662  public class BasicTreeUI
2662                 ei.paintIcon(tree, g, indentation - rightChildIndent - 3, h);                 ei.paintIcon(tree, g, indentation - rightChildIndent - 3, h);
2663                            
2664              for (int i = 0; i < max; ++i)              for (int i = 0; i < max; ++i)
2665              {                        {
2666                 descent = paintControlIcons(g, indentation + rightChildIndent,                 int indent = indentation + rightChildIndent;
2667                   if (depth == 0 && !tree.isRootVisible())
2668                      indent = -1;
2669                  
2670                   descent = paintControlIcons(g, indent,
2671                       descent, i, depth + 1, tree, mod, mod.getChild(node, i));                       descent, i, depth + 1, tree, mod, mod.getChild(node, i));
2672              }              }
2673           }           }

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.44

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26