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

📄 metaliconfactory.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* MetalIconFactory.java --   Copyright (C) 2005 Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package javax.swing.plaf.metal;import java.awt.Color;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;import javax.swing.JSlider;import javax.swing.SwingConstants;import javax.swing.UIManager;import javax.swing.plaf.UIResource;/** * Creates icons for the {@link MetalLookAndFeel}. */public class MetalIconFactory implements Serializable {  /** A constant representing "dark". */  public static final boolean DARK = false;      /** A constant representing "light". */  public static final boolean LIGHT = true;      /**   * An icon displayed for {@link JCheckBoxMenuItem} components.   */  private static class CheckBoxMenuItemIcon implements Icon, Serializable   {    /**     * Creates a new icon instance.     */    public CheckBoxMenuItemIcon()     {      // Nothing to do here.    }          /**     * Returns the width of the icon, in pixels.     *      * @return The width of the icon (10 pixels).     */    public int getIconWidth()     {      return 10;    }        /**     * Returns the height of the icon, in pixels.     *      * @return The height of the icon (10 pixels).     */    public int getIconHeight()     {      return 10;    }        /**     * Paints the icon.     *      * @param c  the component.     * @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)     {      JCheckBoxMenuItem item = (JCheckBoxMenuItem) c;              if (item.isArmed())        g.setColor(MetalLookAndFeel.getBlack());      else        g.setColor(MetalLookAndFeel.getControlDarkShadow());      g.drawLine(x, y, x + 8, y);      g.drawLine(x, y + 1, x, y + 8);      g.drawLine(x + 2, y + 8, x + 8, y + 8);      g.drawLine(x + 8, y + 2, x + 8, y + 7);            g.setColor(MetalLookAndFeel.getWhite());      g.drawLine(x + 1, y + 1, x + 7, y + 1);      g.drawLine(x + 1, y + 2, x + 1, y + 7);      g.drawLine(x + 1, y + 9, x + 9, y + 9);      g.drawLine(x + 9, y + 1, x + 9, y + 8);      // if the item is selected, we should draw a tick      if (item.isSelected())      {        g.setColor(MetalLookAndFeel.getBlack());        g.fillRect(x + 2, y + 2, 2, 5);        for (int i = 0; i < 6; i++)          g.drawLine(x + 8 - i, y + i, x + 9 - i, y + i);      }    }          }  /**   * 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)     {      

⌨️ 快捷键说明

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