2005-08-09  Lillian Angel  <[EMAIL PROTECTED]>

        * javax/swing/plaf/basic/BasicLabelUI.java
        (paint): Added in code to paint background rect according to
        API. Also, formatting changes.
        * javax/swing/plaf/basic/BasicTreeUI.java
        (setCellRenderer): Fixed to changed renderer in JTree.
        (uninstallDefaults): Line taken out because not needed.
        (paintNode): Took out unneeded code because BasicLabelUI was 
        fixed.
        (paintRecursive): Fixed so lines are only drawn when parents 
        have children.

Index: javax/swing/plaf/basic/BasicLabelUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicLabelUI.java,v
retrieving revision 1.14
diff -u -r1.14 BasicLabelUI.java
--- javax/swing/plaf/basic/BasicLabelUI.java	8 Jul 2005 15:24:08 -0000	1.14
+++ javax/swing/plaf/basic/BasicLabelUI.java	9 Aug 2005 16:05:42 -0000
@@ -169,26 +170,33 @@
       vr.width = 0;
     if (vr.height < 0)
       vr.height = 0;
-      
+
     Icon icon = (b.isEnabled()) ? b.getIcon() : b.getDisabledIcon();
 
     String text = layoutCL(b, fm, b.getText(), icon, vr, ir, tr);
-    
+
     if (icon != null)
       icon.paintIcon(b, g, ir.x, ir.y);
-    if (text != null && ! text.equals(""))
-      {
-	if (b.isEnabled())
-	  paintEnabledText(b, g, text, tr.x, tr.y + fm.getAscent());
-	else
-	  paintDisabledText(b, g, text, tr.x, tr.y + fm.getAscent());
-      }
+    if (text != null && !text.equals(""))
+    {
+
+      g.setColor(b.getBackground());
+      if (b.isOpaque())
+        g.fillRect(vr.x, vr.y, vr.width, vr.height);
+      else
+        g.fillRect(tr.x, tr.y, tr.width, tr.height);
+
+      if (b.isEnabled())
+        paintEnabledText(b, g, text, tr.x, tr.y + fm.getAscent());
+      else
+        paintDisabledText(b, g, text, tr.x, tr.y + fm.getAscent());
+    }
     g.setFont(saved_font);
   }
 
   /**
    * This method is simply calls SwingUtilities's layoutCompoundLabel.
-   *
+   * 
    * @param label The label to lay out.
    * @param fontMetrics The FontMetrics for the font used.
    * @param text The text to paint.
Index: javax/swing/plaf/basic/BasicTreeUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v
retrieving revision 1.55
diff -u -r1.55 BasicTreeUI.java
--- javax/swing/plaf/basic/BasicTreeUI.java	9 Aug 2005 13:27:17 -0000	1.55
+++ javax/swing/plaf/basic/BasicTreeUI.java	9 Aug 2005 16:05:43 -0000
@@ -424,6 +424,7 @@
   protected void setCellRenderer(TreeCellRenderer tcr)
   {
     currentCellRenderer = tcr;
+    tree.setCellRenderer(tcr);
     updateRenderer();
   }
   
@@ -1201,11 +1202,9 @@
    */
   protected void uninstallDefaults(JTree tree)
   {
-    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
     tree.setFont(null);
     tree.setForeground(null);
     tree.setBackground(null);
-    tree.setCellRenderer(null);
   }
   
   /**
@@ -2571,61 +2570,27 @@
    * @param node the object to draw
    */
   void paintNode(Graphics g, int x, int y, JTree tree, Object node,
-                 boolean isLeaf)
+      boolean isLeaf)
   {
     TreePath curr = new TreePath(getPathToRoot(node, 0));
     boolean selected = tree.isPathSelected(curr);
     boolean expanded = false;
     boolean hasIcons = false;
-    
+
     if (tree.isVisible(curr))
-      {
-        DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer) 
-                createDefaultCellRenderer();
-        
-        if (!isLeaf)
-          expanded = tree.isExpanded(curr);
-        
-        Icon icon = null;
-        if (!isLeaf && expanded)
-          icon = dtcr.getOpenIcon();
-        else if (!isLeaf && !expanded)
-          icon = dtcr.getClosedIcon();
-        else
-          icon = dtcr.getLeafIcon();
-        
-        if (icon.getIconHeight() > -1 && icon.getIconWidth() > -1)
-          hasIcons = true;
-        
-        Component c = dtcr.getTreeCellRendererComponent(tree, node, selected,
-                                                        expanded, isLeaf, 0, false);
-        
-        if (hasIcons)
-          {
-            if (selected)
-              {
-                Rectangle cell = getPathBounds(tree, curr);
-                g.setColor(dtcr.getBackgroundSelectionColor());
-                g.fillRect(cell.x + icon.getIconWidth()/2, cell.y, cell.width,
-                           cell.height);
-                
-                if (curr.equals(tree.getLeadSelectionPath()))
-                  {
-                    g.setColor(UIManager.getLookAndFeelDefaults().getColor(
-                    "Tree.selectionBorderColor"));
-                    g.drawRect(cell.x + icon.getIconWidth()/2, cell.y, 
-                               cell.width, cell.height);
-                  }
-              }
-            
-            g.translate(x, y);
-            c.paint(g);
-            g.translate(-x, -y);
-          }
-        else 
-          rendererPane.paintComponent(g, c, c.getParent(), 
-                                      getCellBounds(x, y, node));
-      }
+    {
+      TreeCellRenderer dtcr = tree.getCellRenderer();
+      if (dtcr == null)
+        dtcr = createDefaultCellRenderer();
+
+      if (!isLeaf)
+        expanded = tree.isExpanded(curr);
+
+      Component c = dtcr.getTreeCellRendererComponent(tree, node, selected,
+          expanded, isLeaf, 0, false);
+      rendererPane.paintComponent(g, c, c.getParent(),
+          getCellBounds(x, y, node));
+    }
   }
   
   /**
@@ -2696,7 +2661,7 @@
       }
     
     if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0))))
-      if (y0 != heightOfLine)
+      if (y0 != heightOfLine && mod.getChildCount(curr) > 0)
         {
           g.setColor(getHashColor());
           g.drawLine(indentation + halfWidth, y0, indentation + halfWidth,
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to