001: // This file is part of KeY - Integrated Deductive Software Design
002: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003: // Universitaet Koblenz-Landau, Germany
004: // Chalmers University of Technology, Sweden
005: //
006: // The KeY system is protected by the GNU General Public License.
007: // See LICENSE.TXT for details.
008: //
009: // This file is part of KeY - Integrated Deductive Software Design
010: // Copyright (C) 2001-2004 Universitaet Karlsruhe, Germany
011: // Universitaet Koblenz-Landau, Germany
012: // Chalmers University of Technology, Sweden
013: //
014: // The KeY system is protected by the GNU General Public License.
015: // See LICENSE.TXT for details.
016:
017: package de.uka.ilkd.key.gui;
018:
019: import java.awt.*;
020: import java.awt.image.BufferedImage;
021:
022: import javax.swing.Icon;
023: import javax.swing.plaf.metal.MetalLookAndFeel;
024: import javax.swing.plaf.metal.MetalIconFactory.FolderIcon16;
025:
026: class KeYFolderIcon extends FolderIcon16 {
027:
028: private static final Icon closedIcon = new KeYFolderIcon(
029: Color.green.darker());
030: private static final Icon closableIcon = new KeYFolderIcon(
031: Color.blue.darker());
032: private static final Dimension folderIcon16Size = new Dimension(16,
033: 16);
034:
035: private final Color frontColor;
036:
037: public static Icon getKeYFolderIconClosed() {
038: return closedIcon;
039: }
040:
041: public static Icon getKeYFolderIconClosable() {
042: return closableIcon;
043: }
044:
045: public KeYFolderIcon(Color p_frontColor) {
046: frontColor = p_frontColor;
047: }
048:
049: public void paintIcon(Component c, Graphics g, int x, int y) {
050: GraphicsConfiguration gc = c.getGraphicsConfiguration();
051: Image image;
052: if (gc != null) {
053: image = gc.createCompatibleImage(getIconWidth(),
054: getIconHeight(), Transparency.BITMASK);
055: } else {
056: image = new BufferedImage(getIconWidth(), getIconHeight(),
057: BufferedImage.TYPE_INT_ARGB);
058: }
059: Graphics imageG = image.getGraphics();
060: paintMe(c, imageG);
061: imageG.dispose();
062:
063: g.drawImage(image, x, y + getShift(), null);
064: }
065:
066: private void paintMe(Component c, Graphics g) {
067:
068: int right = folderIcon16Size.width - 1;
069: int bottom = folderIcon16Size.height - 1;
070:
071: // Draw tab top
072: g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
073: g.setColor(Color.green.darker().darker());
074: g.drawLine(right - 5, 3, right, 3);
075: g.drawLine(right - 6, 4, right, 4);
076:
077: // Draw folder front
078:
079: //g.setColor( MetalLookAndFeel.getPrimaryControl() );
080: g.setColor(frontColor);
081: g.fillRect(2, 7, 13, 8);
082:
083: // Draw tab bottom
084: g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
085: g.drawLine(right - 6, 5, right - 1, 5);
086:
087: // Draw outline
088: g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
089: g.drawLine(0, 6, 0, bottom); // left side
090: g.drawLine(1, 5, right - 7, 5); // first part of top
091: g.drawLine(right - 6, 6, right - 1, 6); // second part of top
092: g.drawLine(right, 5, right, bottom); // right side
093: g.drawLine(0, bottom, right, bottom); // bottom
094:
095: // Draw highlight
096: g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
097: g.drawLine(1, 6, 1, bottom - 1);
098: g.drawLine(1, 6, right - 7, 6);
099: g.drawLine(right - 6, 7, right - 1, 7);
100:
101: }
102:
103: public int getShift() {
104: return -1;
105: }
106:
107: public int getAdditionalHeight() {
108: return 2;
109: }
110:
111: public int getIconWidth() {
112: return folderIcon16Size.width;
113: }
114:
115: public int getIconHeight() {
116: return folderIcon16Size.height + getAdditionalHeight();
117: }
118: }
|