⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 metaliconfactory.java

📁 Mobile 应用程序使用 Java Micro Edition (Java ME) 平台
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * @(#)MetalIconFactory.java	1.64 05/11/17 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package javax.swing.plaf.metal;import javax.swing.*;import javax.swing.plaf.UIResource;import java.awt.*;import java.awt.image.BufferedImage;import java.io.Serializable;import java.util.Enumeration;import java.util.Vector;import sun.swing.CachedPainter;/** * Factory object that vends <code>Icon</code>s for * the Java<sup><font size="-2">TM</font></sup> look and feel (Metal). * These icons are used extensively in Metal via the defaults mechanism. * While other look and feels often use GIFs for icons, creating icons * in code facilitates switching to other themes. * * <p> * Each method in this class returns * either an <code>Icon</code> or <code>null</code>, * where <code>null</code> implies that there is no default icon. * * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing.  As of 1.4, support for long term storage * of all JavaBeans<sup><font size="-2">TM</font></sup> * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * * @version 1.64 11/17/05 * @author Michael C. Albers */public class MetalIconFactory implements Serializable {    // List of code-drawn Icons    private static Icon fileChooserDetailViewIcon;    private static Icon fileChooserHomeFolderIcon;    private static Icon fileChooserListViewIcon;    private static Icon fileChooserNewFolderIcon;    private static Icon fileChooserUpFolderIcon;    private static Icon internalFrameAltMaximizeIcon;    private static Icon internalFrameCloseIcon;    private static Icon internalFrameDefaultMenuIcon;    private static Icon internalFrameMaximizeIcon;    private static Icon internalFrameMinimizeIcon;    private static Icon radioButtonIcon;     private static Icon treeComputerIcon;    private static Icon treeFloppyDriveIcon;    private static Icon treeHardDriveIcon;    private static Icon menuArrowIcon;    private static Icon menuItemArrowIcon;    private static Icon checkBoxMenuItemIcon;    private static Icon radioButtonMenuItemIcon;    private static Icon checkBoxIcon;    // Ocean icons    private static Icon oceanHorizontalSliderThumb;    private static Icon oceanVerticalSliderThumb;    // Constants    public static final boolean DARK = false;    public static final boolean LIGHT = true;    // Accessor functions for Icons. Does the caching work.    public static Icon getFileChooserDetailViewIcon() {	if (fileChooserDetailViewIcon == null) {	    fileChooserDetailViewIcon = new FileChooserDetailViewIcon();	}	return fileChooserDetailViewIcon;    }    public static Icon getFileChooserHomeFolderIcon() {	if (fileChooserHomeFolderIcon == null) {	    fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon();	}	return fileChooserHomeFolderIcon;    }    public static Icon getFileChooserListViewIcon() {	if (fileChooserListViewIcon == null) {	    fileChooserListViewIcon = new FileChooserListViewIcon();	}	return fileChooserListViewIcon;    }    public static Icon getFileChooserNewFolderIcon() {	if (fileChooserNewFolderIcon == null) {	    fileChooserNewFolderIcon = new FileChooserNewFolderIcon();	}	return fileChooserNewFolderIcon;    }    public static Icon getFileChooserUpFolderIcon() {	if (fileChooserUpFolderIcon == null) {	    fileChooserUpFolderIcon = new FileChooserUpFolderIcon();	}	return fileChooserUpFolderIcon;    }    public static Icon getInternalFrameAltMaximizeIcon(int size) {	return new InternalFrameAltMaximizeIcon(size);    }    public static Icon getInternalFrameCloseIcon(int size) {	return new InternalFrameCloseIcon(size);    }    public static Icon getInternalFrameDefaultMenuIcon() {	if (internalFrameDefaultMenuIcon == null) {	    internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon();	}	return internalFrameDefaultMenuIcon;    }    public static Icon getInternalFrameMaximizeIcon(int size) {	return new InternalFrameMaximizeIcon(size);    }    public static Icon getInternalFrameMinimizeIcon(int size) {	return new InternalFrameMinimizeIcon(size);    }    public static Icon getRadioButtonIcon() {	if (radioButtonIcon == null) {	    radioButtonIcon = new RadioButtonIcon();	}	return radioButtonIcon;    }    /**     * Returns a checkbox icon.     * @since 1.3     */    public static Icon getCheckBoxIcon() {	if (checkBoxIcon == null) {	    checkBoxIcon = new CheckBoxIcon();	}	return checkBoxIcon;    }    public static Icon getTreeComputerIcon() {        if ( treeComputerIcon == null ) {	    treeComputerIcon = new TreeComputerIcon();	}	return treeComputerIcon;    }    public static Icon getTreeFloppyDriveIcon() {        if ( treeFloppyDriveIcon == null ) {	    treeFloppyDriveIcon = new TreeFloppyDriveIcon();	}	return treeFloppyDriveIcon;    }    public static Icon getTreeFolderIcon() {	return new TreeFolderIcon();    }    public static Icon getTreeHardDriveIcon() {        if ( treeHardDriveIcon == null ) {	    treeHardDriveIcon = new TreeHardDriveIcon();	}	return treeHardDriveIcon;    }    public static Icon getTreeLeafIcon() {	return new TreeLeafIcon();    }    public static Icon getTreeControlIcon( boolean isCollapsed ) {	    return new TreeControlIcon( isCollapsed );    }    public static Icon getMenuArrowIcon() {	if (menuArrowIcon == null) {	    menuArrowIcon = new MenuArrowIcon();	}	return menuArrowIcon;    }    /**     * Returns an icon to be used by <code>JCheckBoxMenuItem</code>.     *     * @return the default icon for check box menu items,     *         or <code>null</code> if no default exists     */    public static Icon getMenuItemCheckIcon() {        return null;    }    public static Icon getMenuItemArrowIcon() {	if (menuItemArrowIcon == null) {	    menuItemArrowIcon = new MenuItemArrowIcon();	}	return menuItemArrowIcon;    }    public static Icon getCheckBoxMenuItemIcon() {	if (checkBoxMenuItemIcon == null) {	    checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();	}	return checkBoxMenuItemIcon;    }    public static Icon getRadioButtonMenuItemIcon() {	if (radioButtonMenuItemIcon == null) {	    radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();	}	return radioButtonMenuItemIcon;    }    public static Icon getHorizontalSliderThumbIcon() {        if (MetalLookAndFeel.usingOcean()) {            if (oceanHorizontalSliderThumb == null) {                oceanHorizontalSliderThumb =                               new OceanHorizontalSliderThumbIcon();            }            return oceanHorizontalSliderThumb;        }      // don't cache these, bumps don't get updated otherwise	return new HorizontalSliderThumbIcon();    }    public static Icon getVerticalSliderThumbIcon() {        if (MetalLookAndFeel.usingOcean()) {            if (oceanVerticalSliderThumb == null) {                oceanVerticalSliderThumb = new OceanVerticalSliderThumbIcon();            }            return oceanVerticalSliderThumb;        }        // don't cache these, bumps don't get updated otherwise	return new VerticalSliderThumbIcon();    }    // File Chooser Detail View code    private static class FileChooserDetailViewIcon implements Icon, UIResource, Serializable {        public void paintIcon(Component c, Graphics g, int x, int y) {	    g.translate(x, y);	    // Draw outside edge of each of the documents	    g.setColor(MetalLookAndFeel.getPrimaryControlInfo());	    //     top	    g.drawLine(2,2, 5,2); // top	    g.drawLine(2,3, 2,7); // left	    g.drawLine(3,7, 6,7); // bottom	    g.drawLine(6,6, 6,3); // right	    //     bottom	    g.drawLine(2,10, 5,10); // top	    g.drawLine(2,11, 2,15); // left	    g.drawLine(3,15, 6,15); // bottom	    g.drawLine(6,14, 6,11); // right	    // Draw little dots next to documents	    //     Same color as outside edge	    g.drawLine(8,5, 15,5);     // top	    g.drawLine(8,13, 15,13);   // bottom	    // Draw inner highlight on documents	    g.setColor(MetalLookAndFeel.getPrimaryControl());	    g.drawRect(3,3, 2,3);   // top	    g.drawRect(3,11, 2,3);  // bottom	    // Draw inner inner highlight on documents	    g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());	    g.drawLine(4,4, 4,5);     // top	    g.drawLine(4,12, 4,13);   // bottom	    	    g.translate(-x, -y);	}		public int getIconWidth() {	    return 18;	}		public int getIconHeight() {	    return 18;	}    }  // End class FileChooserDetailViewIcon    // File Chooser Home Folder code    private static class FileChooserHomeFolderIcon implements Icon, UIResource, Serializable {        public void paintIcon(Component c, Graphics g, int x, int y) {	    g.translate(x, y);	    // Draw outside edge of house	    g.setColor(MetalLookAndFeel.getPrimaryControlInfo());	    g.drawLine(8,1, 1,8);  // left edge of roof	    g.drawLine(8,1, 15,8); // right edge of roof	    g.drawLine(11,2, 11,3); // left edge of chimney	    g.drawLine(12,2, 12,4); // right edge of chimney	    g.drawLine(3,7, 3,15); // left edge of house	    g.drawLine(13,7, 13,15); // right edge of house	    g.drawLine(4,15, 12,15); // bottom edge of house	    // Draw door frame	    //     same color as edge of house	    g.drawLine( 6,9,  6,14); // left	    g.drawLine(10,9, 10,14); // right	    g.drawLine( 7,9,  9, 9); // top	    // Draw roof body    	    g.setColor(MetalLookAndFeel.getControlDarkShadow());	    g.fillRect(8,2, 1,1); //top toward bottom	    g.fillRect(7,3, 3,1);	    g.fillRect(6,4, 5,1);	    g.fillRect(5,5, 7,1);	    g.fillRect(4,6, 9,2);	    // Draw doornob	    //     same color as roof body	    g.drawLine(9,12, 9,12);	    // Paint the house	    g.setColor(MetalLookAndFeel.getPrimaryControl());	    g.drawLine(4,8, 12,8); // above door	    g.fillRect(4,9, 2,6); // left of door	    g.fillRect(11,9, 2,6); // right of door	    g.translate(-x, -y);	}		public int getIconWidth() {	    return 18;	}		public int getIconHeight() {	    return 18;	}    }  // End class FileChooserHomeFolderIcon    // File Chooser List View code    private static class FileChooserListViewIcon implements Icon, UIResource, Serializable {        public void paintIcon(Component c, Graphics g, int x, int y) {	    g.translate(x, y);	    // Draw outside edge of each of the documents	    g.setColor(MetalLookAndFeel.getPrimaryControlInfo());	    //     top left	    g.drawLine(2,2, 5,2); // top	    g.drawLine(2,3, 2,7); // left	    g.drawLine(3,7, 6,7); // bottom	    g.drawLine(6,6, 6,3); // right	    //     top right	    g.drawLine(10,2, 13,2); // top	    g.drawLine(10,3, 10,7); // left	    g.drawLine(11,7, 14,7); // bottom	    g.drawLine(14,6, 14,3); // right	    //     bottom left	    g.drawLine(2,10, 5,10); // top	    g.drawLine(2,11, 2,15); // left	    g.drawLine(3,15, 6,15); // bottom	    g.drawLine(6,14, 6,11); // right	    //     bottom right	    g.drawLine(10,10, 13,10); // top	    g.drawLine(10,11, 10,15); // left	    g.drawLine(11,15, 14,15); // bottom	    g.drawLine(14,14, 14,11); // right	    // Draw little dots next to documents	    //     Same color as outside edge	    g.drawLine(8,5, 8,5);     // top left	    g.drawLine(16,5, 16,5);   // top right	    g.drawLine(8,13, 8,13);   // bottom left	    g.drawLine(16,13, 16,13); // bottom right	    // Draw inner highlight on documents	    g.setColor(MetalLookAndFeel.getPrimaryControl());	    g.drawRect(3,3, 2,3);   // top left	    g.drawRect(11,3, 2,3);  // top right	    g.drawRect(3,11, 2,3);  // bottom left	    g.drawRect(11,11, 2,3); // bottom right	    // Draw inner inner highlight on documents	    g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());	    g.drawLine(4,4, 4,5);     // top left	    g.drawLine(12,4, 12,5);   // top right	    g.drawLine(4,12, 4,13);   // bottom left	    g.drawLine(12,12, 12,13); // bottom right	    	    g.translate(-x, -y);	}		public int getIconWidth() {	    return 18;	}		public int getIconHeight() {	    return 18;	}    }  // End class FileChooserListViewIcon

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -