diff options
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java')
-rw-r--r-- | libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java | 119 |
1 files changed, 64 insertions, 55 deletions
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java b/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java index 30ec7e72b28..2817336a8f1 100644 --- a/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java +++ b/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java @@ -54,7 +54,6 @@ import javax.swing.JRadioButtonMenuItem; import javax.swing.JSlider; import javax.swing.SwingConstants; import javax.swing.UIManager; -import javax.swing.plaf.IconUIResource; import javax.swing.plaf.UIResource; @@ -569,8 +568,8 @@ public class MetalIconFactory implements Serializable */ public void paintIcon(Component c, Graphics g, int x, int y) { - // TODO: pick up appropriate UI colors - g.setColor(Color.black); + y = y + getShift(); + g.setColor(MetalLookAndFeel.getBlack()); g.drawLine(x, y, x + 9, y); g.drawLine(x, y + 1, x, y + 15); g.drawLine(x, y + 15, x + 12, y + 15); @@ -580,7 +579,7 @@ public class MetalIconFactory implements Serializable g.drawLine(x + 7, y + 2, x + 11, y + 6); g.drawLine(x + 8, y + 1, x + 9, y + 1); - g.setColor(new Color(204, 204, 255)); + g.setColor(MetalLookAndFeel.getPrimaryControl()); g.drawLine(x + 1, y + 1, x + 7, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + 14); g.drawLine(x + 1, y + 14, x + 11, y + 14); @@ -601,7 +600,9 @@ public class MetalIconFactory implements Serializable } /** - * 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 {@link TreeLeafIcon}). * * @return The shift. */ @@ -649,21 +650,21 @@ public class MetalIconFactory implements Serializable */ public void paintIcon(Component c, Graphics g, int x, int y) { - // TODO: pick up appropriate UI colors - g.setColor(Color.black); - 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.setColor(new Color(204, 204, 255)); - g.fillRect(x + 2, y + 4, 7, 8); - g.fillRect(x + 9, y + 5, 6, 7); - g.setColor(new Color(102, 102, 153)); - g.drawLine(x + 9, y + 2, x + 14, y + 2); - g.setColor(new Color(50, 50, 120)); - g.drawLine(x + 9, y + 1, x + 15, y + 1); - g.drawLine(x + 10, y, x + 15, y); + y = y + getShift(); + g.setColor(MetalLookAndFeel.getBlack()); + 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 + 7, 7, 8); + g.fillRect(x + 9, y + 8, 6, 7); + g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); + g.drawLine(x + 9, y + 5, x + 14, y + 5); + g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); + g.drawLine(x + 9, y + 4, x + 15, y + 4); + g.drawLine(x + 10, y + 3, x + 15, y + 3); } /** @@ -679,7 +680,9 @@ public class MetalIconFactory implements Serializable } /** - * 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 {@link TreeFolderIcon}). * * @return The shift. */ @@ -1036,20 +1039,22 @@ public class MetalIconFactory implements Serializable g.drawLine(x + 6, y + 14, x, y + 8); g.drawLine(x, y + 7, x, y + 1); - // Fill the icon. - if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme - && enabled) - { - String gradient; - if (focus) - gradient = "Slider.focusGradient"; - else - gradient = "Slider.gradient"; - MetalUtils.paintGradient(g, x + 1, y + 2, 12, 13, - SwingConstants.VERTICAL, gradient, - gradientMask); - } - else +// The following is commented out until the masking for the gradient painting +// is working correctly +// // Fill the icon. +// if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme +// && enabled) +// { +// String gradient; +// if (focus) +// gradient = "Slider.focusGradient"; +// else +// gradient = "Slider.gradient"; +// MetalUtils.paintGradient(g, x + 1, y + 2, 12, 13, +// SwingConstants.VERTICAL, gradient, +// gradientMask); +// } +// else { if (focus) g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); @@ -1268,23 +1273,23 @@ public class MetalIconFactory implements Serializable */ public void paintIcon(Component c, Graphics g, int x, int y) { - g.setColor(new Color(102, 102, 153)); + g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); g.fillRect(x + 1, y, 14, 2); g.fillRect(x, y + 1, 2, 14); g.fillRect(x + 1, y + 14, 14, 2); g.fillRect(x + 14, y + 1, 2, 14); g.drawLine(x + 2, y + 5, x + 14, y + 5); - g.setColor(new Color(204, 204, 255)); + g.setColor(MetalLookAndFeel.getPrimaryControl()); g.fillRect(x + 2, y + 2, 12, 3); - g.setColor(new Color(102, 102, 153)); + g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); g.drawLine(x + 3, y + 3, x + 3, y + 3); g.drawLine(x + 6, y + 3, x + 6, y + 3); g.drawLine(x + 9, y + 3, x + 9, y + 3); g.drawLine(x + 12, y + 3, x + 12, y + 3); - g.setColor(Color.white); + g.setColor(MetalLookAndFeel.getWhite()); g.fillRect(x + 2, y + 6, 12, 8); g.drawLine(x + 2, y + 2, x + 2, y + 2); g.drawLine(x + 5, y + 2, x + 5, y + 2); @@ -1697,20 +1702,22 @@ public class MetalIconFactory implements Serializable g.drawLine(x + 8, y + 14, x + 1, y + 14); g.drawLine(x, y + 13, x, y + 1); - // Fill the icon. - if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme - && enabled) - { - String gradient; - if (focus) - gradient = "Slider.focusGradient"; - else - gradient = "Slider.gradient"; - MetalUtils.paintGradient(g, x + 2, y + 1, 13, 12, - SwingConstants.HORIZONTAL, gradient, - gradientMask); - } - else +// The following is commented out until the masking for the gradient painting +// is working correctly +// // Fill the icon. +// if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme +// && enabled) +// { +// String gradient; +// if (focus) +// gradient = "Slider.focusGradient"; +// else +// gradient = "Slider.gradient"; +// MetalUtils.paintGradient(g, x + 2, y + 1, 13, 12, +// SwingConstants.HORIZONTAL, gradient, +// gradientMask); +// } +// else { if (focus) g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); @@ -1883,7 +1890,8 @@ public class MetalIconFactory implements Serializable } /** - * Returns the shift (???). + * Returns the vertical shift, in pixels, applied when painting the icon. + * This overridden method returns <code>-1</code>. * * @return The shift. */ @@ -1918,7 +1926,8 @@ public class MetalIconFactory implements Serializable } /** - * Returns the shift (???). + * Returns the vertical shift, in pixels, applied when painting the icon. + * This overridden method returns <code>2</code>. * * @return The shift. */ |