This patch (committed) fixes the painting of icons to respect the (possibly
overridden) getShift() method. It improves the appearance of our file chooser and
JTree components, a little bit anyway:
2006-09-26 David Gilbert <[EMAIL PROTECTED]>
* javax/swing/plaf/metal/MetalIconFactory.java
(FileIcon16.paintIcon): Apply vertical shift by the number of pixels
returned by getShift(),
(FileIcon16.getShift): Updated API docs,
(FolderIcon16.paintIcon): Apply vertical shift by the number of pixels
returned by getShift(),
(FolderIcon16.getShift): Updated API docs,
(TreeFolderIcon.getShift): Likewise,
(TreeLeafIcon.getShift): Likewise.
Regards,
Dave
Index: javax/swing/plaf/metal/MetalIconFactory.java
===================================================================
RCS file:
/sources/classpath/classpath/javax/swing/plaf/metal/MetalIconFactory.java,v
retrieving revision 1.30
diff -u -r1.30 MetalIconFactory.java
--- javax/swing/plaf/metal/MetalIconFactory.java 26 Sep 2006 10:49:51
-0000 1.30
+++ javax/swing/plaf/metal/MetalIconFactory.java 26 Sep 2006 13:23:59
-0000
@@ -568,6 +568,7 @@
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
+ y = y + getShift();
g.setColor(MetalLookAndFeel.getBlack());
g.drawLine(x, y, x + 9, y);
g.drawLine(x, y + 1, x, y + 15);
@@ -599,7 +600,9 @@
}
/**
- * Returns the shift (???).
+ * Returns the vertical shift, in pixels, applied when painting the icon.
+ * The default value is zero, but subclasses may override this (for
+ * example, see [EMAIL PROTECTED] TreeLeafIcon}).
*
* @return The shift.
*/
@@ -647,20 +650,21 @@
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
+ y = y + getShift();
g.setColor(MetalLookAndFeel.getBlack());
- g.drawLine(x, y + 3, x, y + 12);
- g.drawLine(x, y + 12, x + 15, y + 12);
- g.drawLine(x + 15, y + 12, x + 15, y + 2);
- g.drawLine(x + 14, y + 3, x + 9, y + 3);
- g.drawLine(x + 8, y + 2, x + 1, y + 2);
+ g.drawLine(x, y + 6, x, y + 15);
+ g.drawLine(x, y + 15, x + 15, y + 15);
+ g.drawLine(x + 15, y + 15, x + 15, y + 5);
+ g.drawLine(x + 14, y + 6, x + 9, y + 6);
+ g.drawLine(x + 8, y + 5, x + 1, y + 5);
g.setColor(MetalLookAndFeel.getPrimaryControl());
- g.fillRect(x + 2, y + 4, 7, 8);
- g.fillRect(x + 9, y + 5, 6, 7);
+ g.fillRect(x + 2, y + 7, 7, 8);
+ g.fillRect(x + 9, y + 8, 6, 7);
g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
- g.drawLine(x + 9, y + 2, x + 14, y + 2);
+ g.drawLine(x + 9, y + 5, x + 14, y + 5);
g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
- g.drawLine(x + 9, y + 1, x + 15, y + 1);
- g.drawLine(x + 10, y, x + 15, y);
+ g.drawLine(x + 9, y + 4, x + 15, y + 4);
+ g.drawLine(x + 10, y + 3, x + 15, y + 3);
}
/**
@@ -676,7 +680,9 @@
}
/**
- * Returns the shift (???).
+ * Returns the vertical shift, in pixels, applied when painting the icon.
+ * The default value is zero, but subclasses may override this (for
+ * example, see [EMAIL PROTECTED] TreeFolderIcon}).
*
* @return The shift.
*/
@@ -1880,7 +1886,8 @@
}
/**
- * Returns the shift (???).
+ * Returns the vertical shift, in pixels, applied when painting the icon.
+ * This overridden method returns <code>-1</code>.
*
* @return The shift.
*/
@@ -1915,7 +1922,8 @@
}
/**
- * Returns the shift (???).
+ * Returns the vertical shift, in pixels, applied when painting the icon.
+ * This overridden method returns <code>2</code>.
*
* @return The shift.
*/