aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java')
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java1386
1 files changed, 1186 insertions, 200 deletions
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java b/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
index d8c77432653..6f4feccfc37 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
@@ -43,9 +43,11 @@ import java.awt.Component;
import java.awt.Graphics;
import java.io.Serializable;
+import javax.swing.AbstractButton;
import javax.swing.Icon;
import javax.swing.JCheckBox;
import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
import javax.swing.JRadioButton;
import javax.swing.JRadioButtonMenuItem;
@@ -75,6 +77,7 @@ public class MetalIconFactory implements Serializable
*/
public CheckBoxMenuItemIcon()
{
+ // Nothing to do here.
}
/**
@@ -137,6 +140,385 @@ public class MetalIconFactory implements Serializable
}
/**
+ * An icon used for the "detail view" button on a {@link JFileChooser} under
+ * the {@link MetalLookAndFeel}.
+ *
+ * @see MetalIconFactory#getFileChooserDetailViewIcon()
+ */
+ private static class FileChooserDetailViewIcon implements Icon, Serializable
+ {
+
+ /**
+ * Creates a new icon.
+ */
+ public FileChooserDetailViewIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 18;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 18;
+ }
+
+ /**
+ * Paints the icon using colors from the {@link MetalLookAndFeel}.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ g.setColor(MetalLookAndFeel.getBlack());
+
+ // file 1 outline
+ g.drawLine(x + 2, y + 2, x + 5, y + 2);
+ g.drawLine(x + 6, y + 3, x + 6, y + 7);
+ g.drawLine(x + 2, y + 7, x + 6, y + 7);
+ g.drawLine(x + 2, y + 2, x + 2, y + 7);
+
+ // file 2 outline
+ g.drawLine(x + 2, y + 10, x + 5, y + 10);
+ g.drawLine(x + 6, y + 11, x + 6, y + 15);
+ g.drawLine(x + 2, y + 15, x + 6, y + 15);
+ g.drawLine(x + 2, y + 10, x + 2, y + 15);
+
+ // detail lines
+ g.drawLine(x + 8, y + 5, x + 15, y + 5);
+ g.drawLine(x + 8, y + 13, x + 15, y + 13);
+
+ // fill files
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 3, y + 3, 3, 4);
+ g.fillRect(x + 3, y + 11, 3, 4);
+
+ // highlight files
+ g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
+ g.drawLine(x + 4, y + 4, x + 4, y + 5);
+ g.drawLine(x + 4, y + 12, x + 4, y + 13);
+
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * An icon used for the "home folder" button on a {@link JFileChooser} under
+ * the {@link MetalLookAndFeel}.
+ *
+ * @see MetalIconFactory#getFileChooserHomeFolderIcon()
+ */
+ private static class FileChooserHomeFolderIcon implements Icon, Serializable
+ {
+
+ /**
+ * Creates a new icon.
+ */
+ public FileChooserHomeFolderIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 18;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 18;
+ }
+
+ /**
+ * Paints the icon using colors from the {@link MetalLookAndFeel}.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ g.setColor(MetalLookAndFeel.getBlack());
+
+ // roof
+ g.drawLine(x + 1, y + 8, x + 8, y + 1);
+ g.drawLine(x + 8, y + 1, x + 15, y + 8);
+
+ // base of house
+ g.drawLine(x + 3, y + 6, x + 3, y + 15);
+ g.drawLine(x + 3, y + 15, x + 13, y + 15);
+ g.drawLine(x + 13, y + 6, x + 13, y + 15);
+
+ // door frame
+ g.drawLine(x + 6, y + 9, x + 6, y + 15);
+ g.drawLine(x + 6, y + 9, x + 10, y + 9);
+ g.drawLine(x + 10, y + 9, x + 10, y + 15);
+
+ // chimney
+ g.drawLine(x + 11, y + 2, x + 11, y + 4);
+ g.drawLine(x + 12, y + 2, x + 12, y + 5);
+
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+
+ // roof paint
+ int xx = x + 8;
+ for (int i = 0; i < 4; i++)
+ g.drawLine(xx - i, y + 2 + i, xx + i, y + 2 + i);
+ g.fillRect(x + 4, y + 6, 9, 2);
+
+ // door knob
+ g.drawLine(x + 9, y + 12, x + 9, y + 12);
+
+ // house paint
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.drawLine(x + 4, y + 8, x + 12, y + 8);
+ g.fillRect(x + 4, y + 9, 2, 6);
+ g.fillRect(x + 11, y + 9, 2, 6);
+
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * An icon used for the "list view" button on a {@link JFileChooser} under
+ * the {@link MetalLookAndFeel}.
+ *
+ * @see MetalIconFactory#getFileChooserListViewIcon()
+ */
+ private static class FileChooserListViewIcon implements Icon, Serializable
+ {
+ /**
+ * Creates a new icon.
+ */
+ public FileChooserListViewIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 18;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 18;
+ }
+
+ /**
+ * Paints the icon using colors from the {@link MetalLookAndFeel}.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ g.setColor(MetalLookAndFeel.getBlack());
+
+ // file 1 outline
+ g.drawLine(x + 2, y + 2, x + 5, y + 2);
+ g.drawLine(x + 6, y + 3, x + 6, y + 7);
+ g.drawLine(x + 2, y + 7, x + 6, y + 7);
+ g.drawLine(x + 2, y + 2, x + 2, y + 7);
+
+ // file 2 outline
+ g.drawLine(x + 2, y + 10, x + 5, y + 10);
+ g.drawLine(x + 6, y + 11, x + 6, y + 15);
+ g.drawLine(x + 2, y + 15, x + 6, y + 15);
+ g.drawLine(x + 2, y + 10, x + 2, y + 15);
+
+ // file 3 outline
+ g.drawLine(x + 10, y + 2, x + 13, y + 2);
+ g.drawLine(x + 14, y + 3, x + 14, y + 7);
+ g.drawLine(x + 10, y + 7, x + 14, y + 7);
+ g.drawLine(x + 10, y + 2, x + 10, y + 7);
+
+ // file 4 outline
+ g.drawLine(x + 10, y + 10, x + 13, y + 10);
+ g.drawLine(x + 14, y + 11, x + 14, y + 15);
+ g.drawLine(x + 10, y + 15, x + 14, y + 15);
+ g.drawLine(x + 10, y + 10, x + 10, y + 15);
+
+ g.drawLine(x + 8, y + 5, x + 8, y + 5);
+ g.drawLine(x + 8, y + 13, x + 8, y + 13);
+ g.drawLine(x + 16, y + 5, x + 16, y + 5);
+ g.drawLine(x + 16, y + 13, x + 16, y + 13);
+
+ // fill files
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 3, y + 3, 3, 4);
+ g.fillRect(x + 3, y + 11, 3, 4);
+ g.fillRect(x + 11, y + 3, 3, 4);
+ g.fillRect(x + 11, y + 11, 3, 4);
+
+ // highlight files
+ g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
+ g.drawLine(x + 4, y + 4, x + 4, y + 5);
+ g.drawLine(x + 4, y + 12, x + 4, y + 13);
+ g.drawLine(x + 12, y + 4, x + 12, y + 5);
+ g.drawLine(x + 12, y + 12, x + 12, y + 13);
+
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * An icon used for the "new folder" button on a {@link JFileChooser} under
+ * the {@link MetalLookAndFeel}.
+ *
+ * @see MetalIconFactory#getFileChooserNewFolderIcon()
+ */
+ private static class FileChooserNewFolderIcon implements Icon, Serializable
+ {
+ /**
+ * Creates a new icon.
+ */
+ public FileChooserNewFolderIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 18;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 18;
+ }
+
+ /**
+ * Paints the icon using colors from the {@link MetalLookAndFeel}.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ g.setColor(MetalLookAndFeel.getBlack());
+
+ g.drawLine(x + 2, y + 5, x + 9, y + 5);
+ g.drawLine(x + 10, y + 6, x + 15, y + 6);
+ g.drawLine(x + 15, y + 5, x + 15, y + 14);
+ g.drawLine(x + 2, y + 14, x + 15, y + 14);
+ g.drawLine(x + 1, y + 6, x + 1, y + 14);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ g.drawLine(x + 11, y + 3, x + 15, y + 3);
+ g.drawLine(x + 10, y + 4, x + 15, y + 4);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 3, y + 7, 7, 7);
+ g.fillRect(x + 10, y + 8, 5, 6);
+ g.drawLine(x + 10, y + 5, x + 14, y + 5);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
+ g.drawLine(x + 10, y + 7, x + 14, y + 7);
+ g.drawLine(x + 2, y + 6, x + 9, y + 6);
+ g.drawLine(x + 2, y + 6, x + 2, y + 13);
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * An icon used for the "up folder" button on a {@link JFileChooser} under
+ * the {@link MetalLookAndFeel}.
+ *
+ * @see MetalIconFactory#getFileChooserNewFolderIcon()
+ */
+ private static class FileChooserUpFolderIcon extends FileChooserNewFolderIcon
+ implements Icon, Serializable
+ {
+ /**
+ * Creates a new icon.
+ */
+ public FileChooserUpFolderIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the icon using colors from the {@link MetalLookAndFeel}.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+
+ // draw the folder
+ super.paintIcon(c, g, x, y);
+
+ // now draw the up arrow
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 8, y + 9, x + 8, y + 16);
+ int xx = x + 8;
+ for (int i = 0; i < 4; i++)
+ g.drawLine(xx - i, y + 9 + i, xx + i, y + 9 + i);
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
* An icon representing a file (drawn as a piece of paper with the top-right
* corner turned down).
*/
@@ -153,13 +535,15 @@ public class MetalIconFactory implements Serializable
}
/**
- * Returns the height of the icon, in pixels.
+ * Returns the height of the icon, in pixels. The height returned is
+ * <code>16</code> plus the value returned by
+ * {@link #getAdditionalHeight()}.
*
* @return The height of the icon.
*/
public int getIconHeight()
{
- return 16;
+ return 16 + getAdditionalHeight();
}
/**
@@ -192,9 +576,11 @@ public class MetalIconFactory implements Serializable
}
/**
- * Returns the additional height (???).
+ * Returns the additional height for the icon. The
+ * {@link #getIconHeight()} method adds this value to the icon height it
+ * returns. Subclasses can override this method to adjust the icon height.
*
- * @return The additional height.
+ * @return The additional height (<code>0</code> unless overridden).
*/
public int getAdditionalHeight()
{
@@ -228,13 +614,15 @@ public class MetalIconFactory implements Serializable
}
/**
- * Returns the height of the icon, in pixels.
+ * Returns the height of the icon, in pixels. The height returned is
+ * <code>16</code> plus the value returned by
+ * {@link #getAdditionalHeight()}.
*
* @return The height of the icon.
*/
public int getIconHeight()
{
- return 16;
+ return 16 + getAdditionalHeight();
}
/**
@@ -265,9 +653,11 @@ public class MetalIconFactory implements Serializable
}
/**
- * Returns the additional height (???).
+ * Returns the additional height for the icon. The
+ * {@link #getIconHeight()} method adds this value to the icon height it
+ * returns. Subclasses can override this method to adjust the icon height.
*
- * @return The additional height.
+ * @return The additional height (<code>0</code> unless overridden).
*/
public int getAdditionalHeight()
{
@@ -285,29 +675,77 @@ public class MetalIconFactory implements Serializable
}
}
-
+
/**
- * An {@link Icon} implementation for {@link JCheckBox}es in the
- * Metal Look &amp; Feel.
- *
- * @author Roman Kennke (roman@kennke.org)
+ * An icon used by the {@link MetalInternalFrameUI} class when the frame
+ * is displayed as a palette.
+ *
+ * @since 1.3
*/
- static class RadioButtonIcon
- implements Icon, UIResource, Serializable
+ public static class PaletteCloseIcon
+ implements Icon, Serializable, UIResource
{
/**
- * Draws the check in the RadioButton.
- *
- * @param c the component to draw on
- * @param g the Graphics context to draw with
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
*/
- protected void drawCheck(Component c, Graphics g)
+ public int getIconWidth()
{
- g.setColor(MetalLookAndFeel.getBlack());
- g.fillRect(4, 3, 4, 6);
- g.drawLine(3, 4, 3, 7);
- g.drawLine(8, 4, 8, 7);
+ return 7;
}
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 7;
+ }
+
+ /**
+ * Paints the icon using colors from the {@link MetalLookAndFeel}.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ AbstractButton button = (AbstractButton) c;
+ if (button.getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.fillRect(x + 2, y + 2, 3, 3);
+ g.drawLine(x + 1, y, x + 1, y + 2);
+ g.drawLine(x, y + 1, x + 2, y + 1);
+ g.drawLine(x + 5, y, x + 5, y + 2);
+ g.drawLine(x + 4, y + 1, x + 6, y + 1);
+ g.drawLine(x + 1, y + 4, x + 1, y + 6);
+ g.drawLine(x, y + 5, x + 2, y + 5);
+ g.drawLine(x + 5, y + 4, x + 5, y + 6);
+ g.drawLine(x + 4, y + 5, x + 6, y + 5);
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(x + 2, y + 6, x + 3, y + 5);
+ g.drawLine(x + 5, y + 3, x + 6, y + 2);
+ g.drawLine(x + 6, y + 6, x + 6, y + 6);
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * An {@link Icon} implementation for {@link JCheckBox}es in the
+ * Metal Look &amp; Feel.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ */
+ static class RadioButtonIcon implements Icon, UIResource, Serializable
+ {
/**
* Returns the width of the icon in pixels.
@@ -330,70 +768,104 @@ public class MetalIconFactory implements Serializable
}
/**
- * Paints the icon. This first paints the border of the RadioButton and
- * if the CheckBox is selected it calls {@link #drawCheck} to draw
- * the check.
+ * Paints the icon, taking into account whether or not the component is
+ * enabled, selected and/or armed.
*
- * @param c the Component to draw on (gets casted to JCheckBox)
+ * @param c the Component to draw on (must be an instance of
+ * {@link JRadioButton})
* @param g the Graphics context to draw with
* @param x the X position
* @param y the Y position
*/
- public void paintIcon(Component c, Graphics g, int x, int y)
- {
- Color dark = MetalLookAndFeel.getControlDarkShadow();
- Color light = MetalLookAndFeel.getWhite();
- g.translate(x, y);
-
- // The light 'circle'
- g.setColor(light);
- g.drawLine(4, 1, 10, 1);
- g.drawLine(2, 2, 3, 2);
- g.drawLine(8, 2, 11, 2);
- g.drawLine(2, 3, 2, 3);
- g.drawLine(11, 2, 11, 9);
- g.drawLine(1, 4, 1, 7);
- g.drawLine(12, 4, 12, 7);
- g.drawLine(2, 8, 2, 11);
- g.drawLine(11, 8, 11, 9);
- g.drawLine(10, 10, 10, 10);
- g.drawLine(2, 11, 9, 11);
- g.drawLine(4, 12, 7, 12);
-
- // The dark 'circle'
- g.setColor(dark);
- g.drawLine(4, 0, 7, 0);
- g.drawLine(2, 1, 3, 1);
- g.drawLine(8, 1, 9, 1);
- g.drawLine(1, 2, 1, 3);
- g.drawLine(10, 2, 10, 3);
- g.drawLine(0, 4, 0, 7);
- g.drawLine(11, 4, 11, 7);
- g.drawLine(1, 8, 1, 9);
- g.drawLine(10, 8, 10, 9);
- g.drawLine(2, 10, 3, 10);
- g.drawLine(8, 10, 9, 10);
- g.drawLine(4, 11, 7, 11);
-
- JRadioButton rb = (JRadioButton) c;
- if (rb.isSelected())
- drawCheck(c, g);
-
- g.translate(-x, -y);
- }
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ JRadioButton b = (JRadioButton) c;
+
+ // draw outer circle
+ if (b.isEnabled())
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(x + 2, y + 1, x + 3, y + 1);
+ g.drawLine(x + 4, y, x + 7, y);
+ g.drawLine(x + 8, y + 1, x + 9, y + 1);
+ g.drawLine(x + 10, y + 2, x + 10, y + 3);
+ g.drawLine(x + 11, y + 4, x + 11, y + 7);
+ g.drawLine(x + 10, y + 8, x + 10, y + 9);
+ g.drawLine(x + 8, y + 10, x + 9, y + 10);
+ g.drawLine(x + 4, y + 11, x + 7, y + 11);
+ g.drawLine(x + 2, y + 10, x + 3, y + 10);
+ g.drawLine(x + 1, y + 9, x + 1, y + 8);
+ g.drawLine(x, y + 7, x, y + 4);
+ g.drawLine(x + 1, y + 2, x + 1, y + 3);
+
+ if (b.getModel().isArmed())
+ {
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(x + 4, y + 1, x + 7, y + 1);
+ g.drawLine(x + 4, y + 10, x + 7, y + 10);
+ g.drawLine(x + 1, y + 4, x + 1, y + 7);
+ g.drawLine(x + 10, y + 4, x + 10, y + 7);
+ g.fillRect(x + 2, y + 2, 8, 8);
+ }
+ else
+ {
+ // only draw inner highlight if not filled
+ if (b.isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getWhite());
+
+ g.drawLine(x + 2, y + 8, x + 2, y + 9);
+ g.drawLine(x + 1, y + 4, x + 1, y + 7);
+ g.drawLine(x + 2, y + 2, x + 2, y + 3);
+ g.drawLine(x + 3, y + 2, x + 3, y + 2);
+ g.drawLine(x + 4, y + 1, x + 7, y + 1);
+ g.drawLine(x + 8, y + 2, x + 9, y + 2);
+ }
+ }
+
+ // draw outer highlight
+ if (b.isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getWhite());
+
+ // outer
+ g.drawLine(x + 10, y + 1, x + 10, y + 1);
+ g.drawLine(x + 11, y + 2, x + 11, y + 3);
+ g.drawLine(x + 12, y + 4, x + 12, y + 7);
+ g.drawLine(x + 11, y + 8, x + 11, y + 9);
+ g.drawLine(x + 10, y + 10, x + 10, y + 10);
+ g.drawLine(x + 8, y + 11, x + 9, y + 11);
+ g.drawLine(x + 4, y + 12, x + 7, y + 12);
+ g.drawLine(x + 2, y + 11, x + 3, y + 11);
+ }
+
+ if (b.isSelected())
+ {
+ if (b.isEnabled())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(x + 4, y + 3, x + 7, y + 3);
+ g.fillRect(x + 3, y + 4, 6, 4);
+ g.drawLine(x + 4, y + 8, x + 7, y + 8);
+ }
+ g.setColor(savedColor);
+ }
}
/**
* An icon displayed for {@link JRadioButtonMenuItem} components.
*/
- private static class RadioButtonMenuItemIcon
- implements Icon, Serializable
+ private static class RadioButtonMenuItemIcon implements Icon, Serializable
{
/**
* Creates a new icon instance.
*/
public RadioButtonMenuItemIcon()
- {
+ {
+ // Nothing to do here.
}
/**
@@ -463,8 +935,7 @@ public class MetalIconFactory implements Serializable
* The icon used to display the thumb control on a horizontally oriented
* {@link JSlider} component.
*/
- private static class HorizontalSliderThumbIcon
- implements Icon, Serializable
+ private static class HorizontalSliderThumbIcon implements Icon, Serializable
{
/**
@@ -472,6 +943,7 @@ public class MetalIconFactory implements Serializable
*/
public HorizontalSliderThumbIcon()
{
+ // Nothing to do here.
}
/**
@@ -505,13 +977,19 @@ public class MetalIconFactory implements Serializable
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
+ boolean enabled = false;
boolean focus = false;
- if (c != null)
- focus = c.hasFocus();
- // TODO: pick up the colors from the look and feel
+ if (c != null)
+ {
+ enabled = c.isEnabled();
+ focus = c.hasFocus();
+ }
// draw the outline
- g.setColor(Color.black);
+ if (enabled)
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
g.drawLine(x + 1, y, x + 13, y);
g.drawLine(x + 14, y + 1, x + 14, y + 7);
g.drawLine(x + 14, y + 8, x + 7, y + 15);
@@ -519,8 +997,11 @@ public class MetalIconFactory implements Serializable
g.drawLine(x, y + 7, x, y + 1);
// fill the icon
- g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium
- g.fillRect(x + 2, y + 2, 12, 7);
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControl());
+ g.fillRect(x + 1, y + 2, 13, 7);
g.drawLine(x + 2, y + 9, x + 12, y + 9);
g.drawLine(x + 3, y + 10, x + 11, y + 10);
g.drawLine(x + 4, y + 11, x + 10, y + 11);
@@ -528,33 +1009,42 @@ public class MetalIconFactory implements Serializable
g.drawLine(x + 6, y + 13, x + 8, y + 13);
g.drawLine(x + 7, y + 14, x + 7, y + 14);
- // draw highlights
- g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light
- g.drawLine(x + 1, y + 1, x + 13, y + 1);
- g.drawLine(x + 1, y + 2, x + 1, y + 8);
- g.drawLine(x + 2, y + 2, x + 2, y + 2);
- g.drawLine(x + 6, y + 2, x + 6, y + 2);
- g.drawLine(x + 10, y + 2, x + 10, y + 2);
-
- g.drawLine(x + 4, y + 4, x + 4, y + 4);
- g.drawLine(x + 8, y + 4, x + 8, y + 4);
+ // if the slider is enabled, draw dots and highlights
+ if (c.isEnabled())
+ {
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 3, y + 3, x + 3, y + 3);
+ g.drawLine(x + 7, y + 3, x + 7, y + 3);
+ g.drawLine(x + 11, y + 3, x + 11, y + 3);
- g.drawLine(x + 2, y + 6, x + 2, y + 6);
- g.drawLine(x + 6, y + 6, x + 6, y + 6);
- g.drawLine(x + 10, y + 6, x + 10, y + 6);
+ g.drawLine(x + 5, y + 5, x + 5, y + 5);
+ g.drawLine(x + 9, y + 5, x + 9, y + 5);
- // draw dots
- g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark
- g.drawLine(x + 3, y + 3, x + 3, y + 3);
- g.drawLine(x + 7, y + 3, x + 7, y + 3);
- g.drawLine(x + 11, y + 3, x + 11, y + 3);
+ g.drawLine(x + 3, y + 7, x + 3, y + 7);
+ g.drawLine(x + 7, y + 7, x + 7, y + 7);
+ g.drawLine(x + 11, y + 7, x + 11, y + 7);
- g.drawLine(x + 5, y + 5, x + 5, y + 5);
- g.drawLine(x + 9, y + 5, x + 9, y + 5);
+ // draw highlights
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ else
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 1, y + 1, x + 13, y + 1);
+ g.drawLine(x + 1, y + 2, x + 1, y + 8);
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.drawLine(x + 6, y + 2, x + 6, y + 2);
+ g.drawLine(x + 10, y + 2, x + 10, y + 2);
+
+ g.drawLine(x + 4, y + 4, x + 4, y + 4);
+ g.drawLine(x + 8, y + 4, x + 8, y + 4);
- g.drawLine(x + 3, y + 7, x + 3, y + 7);
- g.drawLine(x + 7, y + 7, x + 7, y + 7);
- g.drawLine(x + 11, y + 7, x + 11, y + 7);
+ g.drawLine(x + 2, y + 6, x + 2, y + 6);
+ g.drawLine(x + 6, y + 6, x + 6, y + 6);
+ g.drawLine(x + 10, y + 6, x + 10, y + 6);
+ }
}
}
@@ -563,7 +1053,7 @@ public class MetalIconFactory implements Serializable
* An icon used for the 'close' button in the title frame of a
* {@link JInternalFrame}.
*/
- private static class InternalFrameCloseIcon implements Icon, Serializable
+ private static class InternalFrameCloseIcon implements Icon, Serializable
{
/** The icon size in pixels. */
private int size;
@@ -601,25 +1091,53 @@ public class MetalIconFactory implements Serializable
/**
* Paints the icon.
*
- * @param c the component.
+ * @param c the component (an {@link JInternalFrame} is expected).
* @param g the graphics device.
* @param x the x-coordinate.
* @param y the y-coordinate.
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
- // draw the gray areas first
- g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ Color savedColor = g.getColor();
+ AbstractButton b = (AbstractButton) c;
+
+ // fill the interior
+ if (b.getModel().isPressed())
+ // FIXME: also need to take into account whether the internal frame is
+ // selected
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 2, y + 2, 10, 10);
+
+ // draw the outline box and the cross
+ if (b.getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ {
+ // FIXME: also need to take into account whether the internal frame is
+ // selected
+ boolean selected = true;
+ if (selected)
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ }
g.drawLine(x + 1, y + 1, x + 13, y + 1);
g.drawLine(x + 1, y + 2, x + 1, y + 12);
g.drawLine(x + 1, y + 13, x + 13, y + 13);
g.drawLine(x + 13, y + 2, x + 13, y + 12);
+ g.drawLine(x + 2, y + 12, x + 2, y + 12);
+ g.drawLine(x + 12, y + 2, x + 12, y + 2);
g.fillRect(x + 4, y + 4, 2, 2);
- g.fillRect(x + 4, y + 9, 2, 2);
- g.fillRect(x + 9, y + 4, 2, 2);
- g.fillRect(x + 9, y + 9, 2, 2);
- g.fillRect(x + 5, y + 5, 5, 5);
+ g.fillRect(x + 5, y + 5, 4, 4);
+ g.drawLine(x + 9, y + 4, x + 10, y + 4);
+ g.drawLine(x + 9, y + 4, x + 9, y + 5);
+ g.drawLine(x + 4, y + 9, x + 4, y + 10);
+ g.drawLine(x + 4, y + 9, x + 5, y + 9);
+ g.drawLine(x + 9, y + 8, x + 9, y + 10);
+ g.drawLine(x + 8, y + 9, x + 10, y + 9);
g.setColor(MetalLookAndFeel.getBlack());
g.drawLine(x, y, x + 13, y);
@@ -635,20 +1153,24 @@ public class MetalIconFactory implements Serializable
g.drawLine(x + 1, y + 14, x + 14, y + 14);
g.drawLine(x + 14, y + 1, x + 14, y + 14);
- g.drawLine(x + 5, y + 10, x + 5, y + 10);
- g.drawLine(x + 6, y + 9, x + 7, y + 9);
- g.drawLine(x + 10, y + 5, x + 10, y + 5);
- g.drawLine(x + 9, y + 6, x + 9, y + 7);
- g.drawLine(x + 10, y + 10, x + 11, y + 10);
- g.drawLine(x + 10, y + 11, x + 10, y + 11);
+ if (!b.getModel().isPressed())
+ {
+ g.drawLine(x + 5, y + 10, x + 5, y + 10);
+ g.drawLine(x + 6, y + 9, x + 7, y + 9);
+ g.drawLine(x + 10, y + 5, x + 10, y + 5);
+ g.drawLine(x + 9, y + 6, x + 9, y + 7);
+ g.drawLine(x + 10, y + 10, x + 11, y + 10);
+ g.drawLine(x + 10, y + 11, x + 10, y + 11);
+ }
+ g.setColor(savedColor);
}
}
/**
* The icon displayed at the top-left corner of a {@link JInternalFrame}.
*/
- private static class InternalFrameDefaultMenuIcon
- implements Icon, Serializable
+ private static class InternalFrameDefaultMenuIcon
+ implements Icon, Serializable
{
/**
@@ -656,6 +1178,7 @@ public class MetalIconFactory implements Serializable
*/
public InternalFrameDefaultMenuIcon()
{
+ // Nothing to do here.
}
/**
@@ -718,8 +1241,8 @@ public class MetalIconFactory implements Serializable
* maximise an internal frame, this icon will replace the 'maximise' icon to
* provide a 'restore' option.
*/
- private static class InternalFrameAltMaximizeIcon
- implements Icon, Serializable
+ private static class InternalFrameAltMaximizeIcon
+ implements Icon, Serializable
{
/** The icon size in pixels. */
private int size;
@@ -764,14 +1287,23 @@ public class MetalIconFactory implements Serializable
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
- Color color = MetalLookAndFeel.getControlDarkShadow();
- if (c instanceof JInternalFrame)
- {
- JInternalFrame f = (JInternalFrame) c;
- if (f.isSelected())
- color = MetalLookAndFeel.getPrimaryControlShadow();
- }
- g.setColor(color);
+ Color savedColor = g.getColor();
+
+ AbstractButton b = (AbstractButton) c;
+
+ // fill the small box interior
+ if (b.getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 2, y + 6, 7, 7);
+
+
+ if (b.getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+
g.drawLine(x + 12, y + 1, x + 13, y + 1);
g.drawLine(x + 11, y + 2, x + 12, y + 2);
g.drawLine(x + 10, y + 3, x + 11, y + 3);
@@ -803,10 +1335,16 @@ public class MetalIconFactory implements Serializable
g.drawLine(x + 13, y + 6, x + 13, y + 6);
g.drawLine(x + 8, y + 7, x + 13, y + 7);
g.drawLine(x + 6, y + 5, x + 6, y + 5);
- g.drawLine(x + 2, y + 6, x + 6, y + 6);
- g.drawLine(x + 2, y + 6, x + 2, y + 11);
g.drawLine(x + 10, y + 8, x + 10, y + 13);
g.drawLine(x + 1, y + 14, x + 10, y + 14);
+
+ if (!b.getModel().isPressed())
+ {
+ g.drawLine(x + 2, y + 6, x + 6, y + 6);
+ g.drawLine(x + 2, y + 6, x + 2, y + 11);
+ }
+
+ g.setColor(savedColor);
}
}
@@ -814,8 +1352,7 @@ public class MetalIconFactory implements Serializable
* An icon used for the 'maximize' button in the title frame of a
* {@link JInternalFrame}.
*/
- private static class InternalFrameMaximizeIcon
- implements Icon, Serializable
+ private static class InternalFrameMaximizeIcon implements Icon, Serializable
{
/**
@@ -823,6 +1360,7 @@ public class MetalIconFactory implements Serializable
*/
public InternalFrameMaximizeIcon()
{
+ // Nothing to do here.
}
/**
@@ -855,14 +1393,22 @@ public class MetalIconFactory implements Serializable
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
- Color color = MetalLookAndFeel.getControlDarkShadow();
- if (c instanceof JInternalFrame)
- {
- JInternalFrame f = (JInternalFrame) c;
- if (f.isSelected())
- color = MetalLookAndFeel.getPrimaryControlShadow();
- }
- g.setColor(color);
+ Color savedColor = g.getColor();
+
+ AbstractButton b = (AbstractButton) c;
+
+ // fill the interior
+ if (b.getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 2, y + 6, 7, 7);
+
+ if (b.getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+
g.drawLine(x + 9, y + 1, x + 10, y + 1);
g.fillRect(x + 11, y + 1, 3, 3);
g.fillRect(x + 12, y + 4, 2, 2);
@@ -897,9 +1443,12 @@ public class MetalIconFactory implements Serializable
// draw white
g.setColor(MetalLookAndFeel.getWhite());
- g.drawLine(x + 2, y + 6, x + 5, y + 6);
- g.drawLine(x + 2, y + 7, x + 2, y + 9);
- g.drawLine(x + 4, y + 11, x + 7, y + 8);
+ if (!b.getModel().isPressed())
+ {
+ g.drawLine(x + 2, y + 6, x + 5, y + 6);
+ g.drawLine(x + 2, y + 7, x + 2, y + 9);
+ g.drawLine(x + 4, y + 11, x + 7, y + 8);
+ }
g.drawLine(x + 1, y + 14, x + 10, y + 14);
g.drawLine(x + 10, y + 5, x + 10, y + 13);
@@ -908,14 +1457,14 @@ public class MetalIconFactory implements Serializable
g.drawLine(x + 11, y + 4, x + 11, y + 5);
g.drawLine(x + 13, y + 6, x + 14, y + 6);
g.drawLine(x + 14, y + 1, x + 14, y + 5);
+ g.setColor(savedColor);
}
}
/**
* An icon used in the title frame of a {@link JInternalFrame}.
*/
- private static class InternalFrameMinimizeIcon
- implements Icon, Serializable
+ private static class InternalFrameMinimizeIcon implements Icon, Serializable
{
/**
@@ -923,6 +1472,7 @@ public class MetalIconFactory implements Serializable
*/
public InternalFrameMinimizeIcon()
{
+ // Nothing to do here.
}
/**
@@ -955,14 +1505,17 @@ public class MetalIconFactory implements Serializable
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
- Color color = MetalLookAndFeel.getControlDarkShadow();
- if (c instanceof JInternalFrame)
- {
- JInternalFrame f = (JInternalFrame) c;
- if (f.isSelected())
- color = MetalLookAndFeel.getPrimaryControlShadow();
- }
- g.setColor(color);
+ Color savedColor = g.getColor();
+
+ AbstractButton b = (AbstractButton) c;
+
+ if (b.getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ // FIXME: here the color depends on whether or not the internal frame
+ // is selected
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+
g.drawLine(x + 12, y + 1, x + 13, y + 1);
g.drawLine(x + 11, y + 2, x + 12, y + 2);
g.drawLine(x + 10, y + 3, x + 11, y + 3);
@@ -993,10 +1546,21 @@ public class MetalIconFactory implements Serializable
g.drawLine(x + 11, y + 4, x + 13, y + 2);
g.drawLine(x + 13, y + 6, x + 13, y + 6);
g.drawLine(x + 8, y + 7, x + 13, y + 7);
- g.drawLine(x + 2, y + 9, x + 4, y + 9);
- g.drawLine(x + 2, y + 10, x + 2, y + 11);
g.drawLine(x + 7, y + 9, x + 7, y + 13);
g.drawLine(x + 1, y + 14, x + 7, y + 14);
+
+ if (b.getModel().isPressed())
+ {
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.fillRect(x + 2, y + 9, 3, 3);
+ }
+ else
+ {
+ g.drawLine(x + 2, y + 9, x + 4, y + 9);
+ g.drawLine(x + 2, y + 10, x + 2, y + 11);
+ }
+
+ g.setColor(savedColor);
}
}
@@ -1004,13 +1568,14 @@ public class MetalIconFactory implements Serializable
* The icon used to display the thumb control on a horizontally oriented
* {@link JSlider} component.
*/
- private static class VerticalSliderThumbIcon implements Icon, Serializable
+ private static class VerticalSliderThumbIcon implements Icon, Serializable
{
/**
* Creates a new instance.
*/
public VerticalSliderThumbIcon()
{
+ // Nothing to do here.
}
/**
@@ -1045,13 +1610,19 @@ public class MetalIconFactory implements Serializable
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
+ boolean enabled = false;
boolean focus = false;
- if (c != null)
- focus = c.hasFocus();
- // TODO: pick up the colors from the look and feel
+ if (c != null)
+ {
+ enabled = c.isEnabled();
+ focus = c.hasFocus();
+ }
// draw the outline
- g.setColor(Color.black);
+ if (enabled)
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
g.drawLine(x + 1, y, x + 7, y);
g.drawLine(x + 8, y, x + 15, y + 7);
g.drawLine(x + 14, y + 8, x + 8, y + 14);
@@ -1059,8 +1630,11 @@ public class MetalIconFactory implements Serializable
g.drawLine(x, y + 13, x, y + 1);
// fill the icon
- g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium
- g.fillRect(x + 2, y + 2, 7, 12);
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControl());
+ g.fillRect(x + 2, y + 1, 7, 13);
g.drawLine(x + 9, y + 2, x + 9, y + 12);
g.drawLine(x + 10, y + 3, x + 10, y + 11);
g.drawLine(x + 11, y + 4, x + 11, y + 10);
@@ -1068,41 +1642,51 @@ public class MetalIconFactory implements Serializable
g.drawLine(x + 13, y + 6, x + 13, y + 8);
g.drawLine(x + 14, y + 7, x + 14, y + 7);
- // draw highlights
- g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light
- g.drawLine(x + 1, y + 1, x + 8, y + 1);
- g.drawLine(x + 1, y + 2, x + 1, y + 13);
- g.drawLine(x + 2, y + 2, x + 2, y + 2);
- g.drawLine(x + 2, y + 6, x + 2, y + 6);
- g.drawLine(x + 2, y + 10, x + 2, y + 10);
+ // if the slider is enabled, draw dots and highlights
+ if (enabled)
+ {
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 3, y + 3, x + 3, y + 3);
+ g.drawLine(x + 3, y + 7, x + 3, y + 7);
+ g.drawLine(x + 3, y + 11, x + 3, y + 11);
- g.drawLine(x + 4, y + 4, x + 4, y + 4);
- g.drawLine(x + 4, y + 8, x + 4, y + 8);
+ g.drawLine(x + 5, y + 5, x + 5, y + 5);
+ g.drawLine(x + 5, y + 9, x + 5, y + 9);
- g.drawLine(x + 6, y + 2, x + 6, y + 2);
- g.drawLine(x + 6, y + 6, x + 6, y + 6);
- g.drawLine(x + 6, y + 10, x + 6, y + 10);
+ g.drawLine(x + 7, y + 3, x + 7, y + 3);
+ g.drawLine(x + 7, y + 7, x + 7, y + 7);
+ g.drawLine(x + 7, y + 11, x + 7, y + 11);
- // draw dots
- g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark
- g.drawLine(x + 3, y + 3, x + 3, y + 3);
- g.drawLine(x + 3, y + 7, x + 3, y + 7);
- g.drawLine(x + 3, y + 11, x + 3, y + 11);
+ // draw highlights
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ else
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 1, y + 1, x + 8, y + 1);
+ g.drawLine(x + 1, y + 2, x + 1, y + 13);
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.drawLine(x + 2, y + 6, x + 2, y + 6);
+ g.drawLine(x + 2, y + 10, x + 2, y + 10);
- g.drawLine(x + 5, y + 5, x + 5, y + 5);
- g.drawLine(x + 5, y + 9, x + 5, y + 9);
+ g.drawLine(x + 4, y + 4, x + 4, y + 4);
+ g.drawLine(x + 4, y + 8, x + 4, y + 8);
- g.drawLine(x + 7, y + 3, x + 7, y + 3);
- g.drawLine(x + 7, y + 7, x + 7, y + 7);
- g.drawLine(x + 7, y + 11, x + 7, y + 11);
+ g.drawLine(x + 6, y + 2, x + 6, y + 2);
+ g.drawLine(x + 6, y + 6, x + 6, y + 6);
+ g.drawLine(x + 6, y + 10, x + 6, y + 10);
+
+ }
}
}
-
+
/**
* A tree control icon. This icon can be in one of two states: expanded and
* collapsed.
*/
- public static class TreeControlIcon implements Icon, Serializable
+ public static class TreeControlIcon implements Icon, Serializable
{
/** ???. */
@@ -1235,19 +1819,21 @@ public class MetalIconFactory implements Serializable
/**
* A tree folder icon.
*/
- public static class TreeFolderIcon extends FolderIcon16
+ public static class TreeFolderIcon extends FolderIcon16
{
/**
* Creates a new instance.
*/
public TreeFolderIcon()
- {
+ {
+ // Nothing to do here.
}
/**
- * Returns the additional height (???).
+ * Returns the additional height for this icon, in this case <code>2</code>
+ * pixels.
*
- * @return The additional height.
+ * @return <code>2</code>.
*/
public int getAdditionalHeight()
{
@@ -1268,19 +1854,21 @@ public class MetalIconFactory implements Serializable
/**
* A tree leaf icon.
*/
- public static class TreeLeafIcon extends FileIcon16
+ public static class TreeLeafIcon extends FileIcon16
{
/**
* Creates a new instance.
*/
public TreeLeafIcon()
{
+ // Nothing to do here.
}
/**
- * Returns the additional height (???).
+ * Returns the additional height for this icon, in this case <code>4</code>
+ * pixels.
*
- * @return The additional height.
+ * @return <code>4</code>.
*/
public int getAdditionalHeight()
{
@@ -1297,16 +1885,310 @@ public class MetalIconFactory implements Serializable
return 2;
}
}
+
+ /**
+ * An icon representing a hard disk.
+ *
+ * @see MetalIconFactory#getTreeHardDriveIcon()
+ */
+ private static class TreeHardDriveIcon implements Icon, Serializable
+ {
+
+ /**
+ * Creates a new icon instance.
+ */
+ public TreeHardDriveIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location, using colors from the
+ * current theme.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 1, y + 4, x + 1, y + 5);
+ g.drawLine(x + 14, y + 4, x + 14, y + 5);
+ g.drawLine(x + 1, y + 7, x + 1, y + 8);
+ g.drawLine(x + 14, y + 7, x + 14, y + 8);
+ g.drawLine(x + 1, y + 10, x + 1, y + 11);
+ g.drawLine(x + 14, y + 10, x + 14, y + 11);
+
+ g.drawLine(x + 2, y + 3, x + 3, y + 3);
+ g.drawLine(x + 12, y + 3, x + 13, y + 3);
+ g.drawLine(x + 2, y + 6, x + 3, y + 6);
+ g.drawLine(x + 12, y + 6, x + 13, y + 6);
+ g.drawLine(x + 2, y + 9, x + 3, y + 9);
+ g.drawLine(x + 12, y + 9, x + 13, y + 9);
+ g.drawLine(x + 2, y + 12, x + 3, y + 12);
+ g.drawLine(x + 12, y + 12, x + 13, y + 12);
+
+ g.drawLine(x + 4, y + 2, x + 11, y + 2);
+ g.drawLine(x + 4, y + 7, x + 11, y + 7);
+ g.drawLine(x + 4, y + 10, x + 11, y + 10);
+ g.drawLine(x + 4, y + 13, x + 11, y + 13);
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.fillRect(x + 4, y + 3, 2, 2);
+ g.drawLine(x + 6, y + 4, x + 6, y + 4);
+ g.drawLine(x + 7, y + 3, x + 9, y + 3);
+ g.drawLine(x + 8, y + 4, x + 8, y + 4);
+ g.drawLine(x + 11, y + 3, x + 11, y + 3);
+ g.fillRect(x + 2, y + 4, 2, 2);
+ g.fillRect(x + 2, y + 7, 2, 2);
+ g.fillRect(x + 2, y + 10, 2, 2);
+ g.drawLine(x + 4, y + 6, x + 4, y + 6);
+ g.drawLine(x + 4, y + 9, x + 4, y + 9);
+ g.drawLine(x + 4, y + 12, x + 4, y + 12);
+
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(x + 13, y + 4, x + 13, y + 4);
+ g.drawLine(x + 12, y + 5, x + 13, y + 5);
+ g.drawLine(x + 13, y + 7, x + 13, y + 7);
+ g.drawLine(x + 12, y + 8, x + 13, y + 8);
+ g.drawLine(x + 13, y + 10, x + 13, y + 10);
+ g.drawLine(x + 12, y + 11, x + 13, y + 11);
+
+ g.drawLine(x + 10, y + 5, x + 10, y + 5);
+ g.drawLine(x + 7, y + 6, x + 7, y + 6);
+ g.drawLine(x + 9, y + 6, x + 9, y + 6);
+ g.drawLine(x + 11, y + 6, x + 11, y + 6);
+
+ g.drawLine(x + 10, y + 8, x + 10, y + 8);
+ g.drawLine(x + 7, y + 9, x + 7, y + 9);
+ g.drawLine(x + 9, y + 9, x + 9, y + 9);
+ g.drawLine(x + 11, y + 9, x + 11, y + 9);
+
+ g.drawLine(x + 10, y + 11, x + 10, y + 11);
+ g.drawLine(x + 7, y + 12, x + 7, y + 12);
+ g.drawLine(x + 9, y + 12, x + 9, y + 12);
+ g.drawLine(x + 11, y + 12, x + 11, y + 12);
+
+ g.setColor(saved);
+ }
+ }
+
+ /**
+ * An icon representing a floppy disk.
+ *
+ * @see MetalIconFactory#getTreeFloppyDriveIcon()
+ */
+ private static class TreeFloppyDriveIcon implements Icon, Serializable
+ {
+
+ /**
+ * Creates a new icon instance.
+ */
+ public TreeFloppyDriveIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location, using colors from the
+ * current theme.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 1, y + 1, x + 13, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + 14);
+ g.drawLine(x + 1, y + 14, x + 14, y + 14);
+ g.drawLine(x + 14, y + 2, x + 14, y + 14);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 2, y + 2, 12, 12);
+
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.fillRect(x + 5, y + 2, 6, 5);
+ g.drawLine(x + 4, y + 8, x + 11, y + 8);
+ g.drawLine(x + 3, y + 9, x + 3, y + 13);
+ g.drawLine(x + 12, y + 9, x + 12, y + 13);
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.fillRect(x + 8, y + 3, 2, 3);
+ g.fillRect(x + 4, y + 9, 8, 5);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.drawLine(x + 5, y + 10, x + 9, y + 10);
+ g.drawLine(x + 5, y + 12, x + 8, y + 12);
+
+ g.setColor(saved);
+ }
+ }
+
+ /**
+ * An icon representing a computer.
+ *
+ * @see MetalIconFactory#getTreeComputerIcon()
+ */
+ private static class TreeComputerIcon implements Icon, Serializable
+ {
+
+ /**
+ * Creates a new icon instance.
+ */
+ public TreeComputerIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location, using colors from the
+ * current theme.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 3, y + 1, x + 12, y + 1);
+ g.drawLine(x + 2, y + 2, x + 2, y + 8);
+ g.drawLine(x + 13, y + 2, x + 13, y + 8);
+ g.drawLine(x + 3, y + 9, x + 3, y + 9);
+ g.drawLine(x + 12, y + 9, x + 12, y + 9);
+ g.drawRect(x + 1, y + 10, 13, 4);
+ g.drawLine(x + 5, y + 3, x + 10, y + 3);
+ g.drawLine(x + 5, y + 8, x + 10, y + 8);
+ g.drawLine(x + 4, y + 4, x + 4, y + 7);
+ g.drawLine(x + 11, y + 4, x + 11, y + 7);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 5, y + 4, 6, 4);
+
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(x + 6, y + 12, x + 8, y + 12);
+ g.drawLine(x + 10, y + 12, x + 12, y + 12);
+ g.setColor(saved);
+ }
+ }
+ /** The icon returned by {@link #getCheckBoxIcon()}. */
+ private static Icon checkBoxIcon;
+
+ /** The icon returned by {@link #getCheckBoxMenuItemIcon()}. */
+ private static Icon checkBoxMenuItemIcon;
+
+ /** The icon returned by {@link #getFileChooserDetailViewIcon()}. */
+ private static Icon fileChooserDetailViewIcon;
+
+ /** The icon returned by {@link #getFileChooserHomeFolderIcon()}. */
+ private static Icon fileChooserHomeFolderIcon;
+
+ /** The icon returned by {@link #getFileChooserListViewIcon()}. */
+ private static Icon fileChooserListViewIcon;
+
+ /** The icon returned by {@link #getFileChooserNewFolderIcon()}. */
+ private static Icon fileChooserNewFolderIcon;
+
+ /** The icon returned by {@link #getFileChooserUpFolderIcon()}. */
+ private static Icon fileChooserUpFolderIcon;
+
/** The cached RadioButtonIcon instance. */
private static RadioButtonIcon radioButtonIcon;
+ /** The icon returned by {@link #getRadioButtonMenuItemIcon()}. */
+ private static Icon radioButtonMenuItemIcon;
+
+ /** The icon returned by {@link #getInternalFrameDefaultMenuIcon()}. */
+ private static Icon internalFrameDefaultMenuIcon;
+
+ /** The icon returned by {@link #getTreeComputerIcon()}. */
+ private static Icon treeComputerIcon;
+
+ /** The icon instance returned by {@link #getTreeFloppyDriveIcon()}. */
+ private static Icon treeFloppyDriveIcon;
+
+ /** The icon instance returned by {@link #getTreeHardDriveIcon()}. */
+ private static Icon treeHardDriveIcon;
+
/**
* Creates a new instance. All the methods are static, so creating an
* instance isn't necessary.
*/
public MetalIconFactory()
- {
+ {
+ // Nothing to do here.
}
/**
@@ -1318,7 +2200,9 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getCheckBoxIcon()
{
- return new MetalCheckBoxIcon();
+ if (checkBoxIcon == null)
+ checkBoxIcon = new MetalCheckBoxIcon();
+ return checkBoxIcon;
}
/**
@@ -1329,7 +2213,69 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getCheckBoxMenuItemIcon()
{
- return new CheckBoxMenuItemIcon();
+ if (checkBoxMenuItemIcon == null)
+ checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
+ return checkBoxMenuItemIcon;
+ }
+
+ /**
+ * Returns an icon for use by the {@link JFileChooser} component.
+ *
+ * @return An icon.
+ */
+ public static Icon getFileChooserDetailViewIcon()
+ {
+ if (fileChooserDetailViewIcon == null)
+ fileChooserDetailViewIcon = new FileChooserDetailViewIcon();
+ return fileChooserDetailViewIcon;
+ }
+
+ /**
+ * Returns an icon for use by the {@link JFileChooser} component.
+ *
+ * @return An icon.
+ */
+ public static Icon getFileChooserHomeFolderIcon()
+ {
+ if (fileChooserHomeFolderIcon == null)
+ fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon();
+ return fileChooserHomeFolderIcon;
+ }
+
+ /**
+ * Returns an icon for use by the {@link JFileChooser} component.
+ *
+ * @return An icon.
+ */
+ public static Icon getFileChooserListViewIcon()
+ {
+ if (fileChooserListViewIcon == null)
+ fileChooserListViewIcon = new FileChooserListViewIcon();
+ return fileChooserListViewIcon;
+ }
+
+ /**
+ * Returns an icon for use by the {@link JFileChooser} component.
+ *
+ * @return An icon.
+ */
+ public static Icon getFileChooserNewFolderIcon()
+ {
+ if (fileChooserNewFolderIcon == null)
+ fileChooserNewFolderIcon = new FileChooserNewFolderIcon();
+ return fileChooserNewFolderIcon;
+ }
+
+ /**
+ * Returns an icon for use by the {@link JFileChooser} component.
+ *
+ * @return An icon.
+ */
+ public static Icon getFileChooserUpFolderIcon()
+ {
+ if (fileChooserUpFolderIcon == null)
+ fileChooserUpFolderIcon = new FileChooserUpFolderIcon();
+ return fileChooserUpFolderIcon;
}
/**
@@ -1351,7 +2297,9 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getRadioButtonMenuItemIcon()
{
- return new RadioButtonMenuItemIcon();
+ if (radioButtonMenuItemIcon == null)
+ radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
+ return radioButtonMenuItemIcon;
}
/**
@@ -1386,7 +2334,9 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getInternalFrameDefaultMenuIcon()
{
- return new InternalFrameDefaultMenuIcon();
+ if (internalFrameDefaultMenuIcon == null)
+ internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon();
+ return internalFrameDefaultMenuIcon;
}
/**
@@ -1475,4 +2425,40 @@ public class MetalIconFactory implements Serializable
return new TreeControlIcon(isCollapsed);
}
+ /**
+ * Returns a <code>16x16</code> icon representing a computer.
+ *
+ * @return The icon.
+ */
+ public static Icon getTreeComputerIcon()
+ {
+ if (treeComputerIcon == null)
+ treeComputerIcon = new TreeComputerIcon();
+ return treeComputerIcon;
+ }
+
+ /**
+ * Returns a <code>16x16</code> icon representing a floppy disk.
+ *
+ * @return The icon.
+ */
+ public static Icon getTreeFloppyDriveIcon()
+ {
+ if (treeFloppyDriveIcon == null)
+ treeFloppyDriveIcon = new TreeFloppyDriveIcon();
+ return treeFloppyDriveIcon;
+ }
+
+ /**
+ * Returns a <code>16x16</code> icon representing a hard disk.
+ *
+ * @return The icon.
+ */
+ public static Icon getTreeHardDriveIcon()
+ {
+ if (treeHardDriveIcon == null)
+ treeHardDriveIcon = new TreeHardDriveIcon();
+ return treeHardDriveIcon;
+ }
+
}