/[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.47 by trebligd, Fri Jul 22 08:36:52 2005 UTC revision 1.48 by langel, Mon Jul 25 17:37:48 2005 UTC
# Line 1240  public class BasicTreeUI Line 1240  public class BasicTreeUI
1240                
1241        if (hasControlIcons())        if (hasControlIcons())
1242           paintControlIcons(g, 0, 0, 0, 0, tree, mod, root);           paintControlIcons(g, 0, 0, 0, 0, tree, mod, root);
         
       TreePath lead = tree.getLeadSelectionPath();  
       if (lead != null && tree.isPathSelected(lead))  
       {  
          Rectangle cell = getPathBounds(tree, lead);    
          g.setColor(UIManager.getLookAndFeelDefaults().getColor(  
                "Tree.selectionBorderColor"));  
          g.drawRect(cell.x + rightChildIndent - 4, cell.y,  
                cell.width + 4, cell.height);  
       }  
1243     }     }
1244    
1245     /**     /**
# Line 1928  public class BasicTreeUI Line 1918  public class BasicTreeUI
1918              boolean cntlClick = false;              boolean cntlClick = false;
1919              Rectangle bounds = BasicTreeUI.this.getPathBounds(              Rectangle bounds = BasicTreeUI.this.getPathBounds(
1920                    BasicTreeUI.this.tree, path);                    BasicTreeUI.this.tree, path);
1921              // include icon              
1922              bounds.x -= rightChildIndent - 4;              bounds.x -= rightChildIndent - 4;
1923              bounds.width += rightChildIndent + 4;              bounds.width += rightChildIndent + 4;
1924    
# Line 2517  public class BasicTreeUI Line 2507  public class BasicTreeUI
2507           Font f = tree.getFont();           Font f = tree.getFont();
2508           FontMetrics fm = tree.getToolkit().getFontMetrics(tree.getFont());           FontMetrics fm = tree.getToolkit().getFontMetrics(tree.getFont());
2509    
2510           return new Rectangle(x, y, SwingUtilities.computeStringWidth(fm, s),           return new Rectangle(x, y, SwingUtilities.computeStringWidth(fm, s) + 4,
2511                 fm.getHeight());                 fm.getHeight());
2512        }        }
2513        return null;        return null;
# Line 2581  public class BasicTreeUI Line 2571  public class BasicTreeUI
2571        TreePath curr = new TreePath(((DefaultMutableTreeNode) node).getPath());        TreePath curr = new TreePath(((DefaultMutableTreeNode) node).getPath());
2572        boolean selected = tree.isPathSelected(curr);        boolean selected = tree.isPathSelected(curr);
2573        boolean expanded = false;        boolean expanded = false;
2574          boolean hasIcons = false;
2575          
2576        if (tree.isVisible(curr))        if (tree.isVisible(curr))
2577        {        {
2578           DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer) tree           DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer) tree
# Line 2589  public class BasicTreeUI Line 2580  public class BasicTreeUI
2580    
2581           if (!isLeaf)           if (!isLeaf)
2582              expanded = tree.isExpanded(curr);              expanded = tree.isExpanded(curr);
2583            
2584             Icon icon = null;
2585             if (!isLeaf && expanded)
2586                icon = dtcr.getOpenIcon();
2587             else if (!isLeaf && !expanded)
2588                icon = dtcr.getClosedIcon();
2589             else
2590                icon = dtcr.getLeafIcon();
2591            
2592             if (icon.getIconHeight() > -1 && icon.getIconWidth() > -1)
2593                hasIcons = true;
2594            
2595           Component c = dtcr.getTreeCellRendererComponent(tree, node, selected,           Component c = dtcr.getTreeCellRendererComponent(tree, node, selected,
2596                 expanded, isLeaf, 0, false);                 expanded, isLeaf, 0, false);
2597    
2598           if (selected)           if (hasIcons)
2599           {           {
2600              Rectangle cell = getPathBounds(tree, curr);              if (selected)
2601              g.setColor(dtcr.getBackgroundSelectionColor());              {
2602              g.fillRect(cell.x + rightChildIndent - 4, cell.y, cell.width + 4,                 Rectangle cell = getPathBounds(tree, curr);
2603                    cell.height);                 g.setColor(dtcr.getBackgroundSelectionColor());
2604                   g.fillRect(cell.x + icon.getIconWidth()/2, cell.y, cell.width,
2605                         cell.height);
2606                  
2607                   if (curr.equals(tree.getLeadSelectionPath()))
2608                   {
2609                      g.setColor(UIManager.getLookAndFeelDefaults().getColor(
2610                            "Tree.selectionBorderColor"));
2611                      g.drawRect(cell.x + icon.getIconWidth()/2, cell.y,
2612                            cell.width, cell.height);
2613                   }
2614                }
2615      
2616                g.translate(x, y);
2617                c.paint(g);
2618                g.translate(-x, -y);
2619           }           }
2620             else
2621           g.translate(x, y);              rendererPane.paintComponent(g, c, c.getParent(),
2622           c.paint(g);                    getCellBounds(x, y, node));
          g.translate(-x, -y);  
2623        }        }
2624     }     }
2625    

Legend:
Removed from v.1.47  
changed lines
  Added in v.1.48

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