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

📄 smoothgradienticonfactory.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * SmoothGradientIconFactory.java * * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * */package org.underworldlabs.swing.plaf.smoothgradient;import java.awt.Color;import java.awt.Component;import java.awt.GradientPaint;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.Paint;import java.io.Serializable;import javax.swing.ButtonModel;import javax.swing.Icon;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JComponent;import javax.swing.JMenuItem;import javax.swing.plaf.UIResource;import javax.swing.plaf.metal.MetalLookAndFeel;/* ---------------------------------------------------------- * CVS NOTE: Changes to the CVS repository prior to the  *           release of version 3.0.0beta1 has meant a  *           resetting of CVS revision numbers. * ---------------------------------------------------------- *//** * * @author   Takis Diakoumis * @version  $Revision: 1.4 $ * @date     $Date: 2006/05/14 06:56:07 $ */final class SmoothGradientIconFactory {        public static Icon getInternalFrameMinimizeIcon(int size) {        return new InternalFrameMinimizeIcon(size);    }        private static class InternalFrameMinimizeIcon implements Icon, UIResource, Serializable {        int iconSize = 16;                public InternalFrameMinimizeIcon(int size) {            iconSize = size;        }                public void paintIcon(Component c, Graphics g, int x, int y) {            JButton parentButton = (JButton)c;            ButtonModel buttonModel = parentButton.getModel();                        Color mainItemColor = SmoothGradientLookAndFeel.getPrimaryControlDarkShadow();            Color darkHighlightColor = MetalLookAndFeel.getBlack();                        // background gradients            Color bgStart = SmoothGradientLookAndFeel.FRAME_BUTTON_START_ACTIVE;            Color bgStop = SmoothGradientLookAndFeel.FRAME_BUTTON_STOP_ACTIVE;                        // if the internal frame is inactive            if (parentButton.getClientProperty("paintActive") != Boolean.TRUE) {                mainItemColor = SmoothGradientLookAndFeel.getControlDarkShadow();                bgStart = SmoothGradientLookAndFeel.FRAME_BUTTON_START_INACTIVE;                bgStop = SmoothGradientLookAndFeel.FRAME_BUTTON_STOP_INACTIVE;                                // if inactive and pressed                if (buttonModel.isPressed() && buttonModel.isArmed())                    mainItemColor = darkHighlightColor;                            }                        // if the button is pressed and the mouse is over it            else if (buttonModel.isPressed() && buttonModel.isArmed()) {                mainItemColor = darkHighlightColor;            }                        Graphics2D g2d = (Graphics2D)g;            g2d.translate(x, y);                        g2d.setPaint(new GradientPaint(0, iconSize, bgStart, 0, 0, bgStop));                        g2d.fillRect(0, 0, iconSize, iconSize);                        g2d.setColor(mainItemColor);            g2d.drawLine(4, 9, 12, 9);            g2d.drawLine(3, 10, 13, 10);            g2d.drawLine(3, 11, 13, 11);            g2d.drawLine(4, 12, 12, 12);                        g.translate(-x, -y);        }                public int getIconWidth() {            return iconSize;        }                public int getIconHeight() {            return iconSize;        }            }  // class InternalFrameMinimizeIcon        public static Icon getInternalFrameMaximizeIcon(int size) {        return new InternalFrameMaximizeIcon(size);    }        private static class InternalFrameMaximizeIcon implements Icon, UIResource, Serializable {        int iconSize = 16;                public InternalFrameMaximizeIcon(int size) {            iconSize = size;        }                public void paintIcon(Component c, Graphics g, int x, int y) {            JButton parentButton = (JButton)c;            ButtonModel buttonModel = parentButton.getModel();                        Color mainItemColor = SmoothGradientLookAndFeel.getPrimaryControlDarkShadow();            Color darkHighlightColor = MetalLookAndFeel.getBlack();                        // background gradients            Color bgStart = SmoothGradientLookAndFeel.FRAME_BUTTON_START_ACTIVE;            Color bgStop = SmoothGradientLookAndFeel.FRAME_BUTTON_STOP_ACTIVE;                        // if the internal frame is inactive            if (parentButton.getClientProperty("paintActive") != Boolean.TRUE) {                mainItemColor = SmoothGradientLookAndFeel.getControlDarkShadow();                bgStart = SmoothGradientLookAndFeel.FRAME_BUTTON_START_INACTIVE;                bgStop = SmoothGradientLookAndFeel.FRAME_BUTTON_STOP_INACTIVE;                                // if inactive and pressed                if (buttonModel.isPressed() && buttonModel.isArmed())                    mainItemColor = darkHighlightColor;                            }                        // if the button is pressed and the mouse is over it            else if (buttonModel.isPressed() && buttonModel.isArmed()) {                mainItemColor = darkHighlightColor;            }                        Graphics2D g2d = (Graphics2D)g;            g2d.translate(x, y);                        Paint _paint = g2d.getPaint();            // fill the background            g2d.setPaint(new GradientPaint(0, iconSize, bgStart, 0, 0, bgStop));            g2d.fillRect(0, 0, iconSize, iconSize);                        g2d.setPaint(_paint);            // paint the image            g2d.setColor(mainItemColor);            g2d.drawLine(4, 3, 11, 3);            g2d.fillRect(3, 4, 10, 3);            g2d.drawLine(3, 7, 3, 11);            g2d.drawLine(12, 7, 12, 11);            g2d.drawLine(4, 12, 11, 12);                        g.translate(-x, -y);        }                public int getIconWidth() {            return iconSize;        }                public int getIconHeight() {            return iconSize;        }            }  // class InternalFrameMaximizeIcon        public static Icon getInternalFrameAltMaximizeIcon(int size) {        return new InternalFrameAltMaximizeIcon(size);    }        private static class InternalFrameAltMaximizeIcon implements Icon, UIResource, Serializable {        int iconSize = 16;                public InternalFrameAltMaximizeIcon(int size) {            iconSize = size;        }                public void paintIcon(Component c, Graphics g, int x, int y) {            JButton parentButton = (JButton)c;            ButtonModel buttonModel = parentButton.getModel();                        Color mainItemColor = SmoothGradientLookAndFeel.getPrimaryControlDarkShadow();            Color darkHighlightColor = MetalLookAndFeel.getBlack();                        // background gradients            Color bgStart = SmoothGradientLookAndFeel.FRAME_BUTTON_START_ACTIVE;            Color bgStop = SmoothGradientLookAndFeel.FRAME_BUTTON_STOP_ACTIVE;                        // if the internal frame is inactive            if (parentButton.getClientProperty("paintActive") != Boolean.TRUE) {                mainItemColor = SmoothGradientLookAndFeel.getControlDarkShadow();                bgStart = SmoothGradientLookAndFeel.FRAME_BUTTON_START_INACTIVE;                bgStop = SmoothGradientLookAndFeel.FRAME_BUTTON_STOP_INACTIVE;                                // if inactive and pressed                if (buttonModel.isPressed() && buttonModel.isArmed()) {                    mainItemColor = darkHighlightColor;                }                            }                        // if the button is pressed and the mouse is over it            else if (buttonModel.isPressed() && buttonModel.isArmed()) {                mainItemColor = darkHighlightColor;            }                        Graphics2D g2d = (Graphics2D)g;            g2d.translate(x, y);                        Paint _paint = g2d.getPaint();            // fill the background            g2d.setPaint(new GradientPaint(0, iconSize, bgStart, 0, 0, bgStop));            g2d.fillRect(0, 0, iconSize, iconSize);                        g2d.setPaint(_paint);            // paint the image            g2d.setColor(mainItemColor);            g2d.drawLine(6, 3, 11, 3);            g2d.drawLine(5, 4, 12, 4);            g2d.drawLine(12, 5, 12, 10);            g2d.fillRect(3, 6, 8, 3);            g2d.drawLine(3, 9, 3, 12);            g2d.drawLine(4, 12, 10, 12);            g2d.drawLine(10, 9, 10, 12);                        g.translate(-x, -y);        }                public int getIconWidth() {            return iconSize;        }                public int getIconHeight() {            return iconSize;        }            }  // class InternalFrameAltMaximizeIcon        public static Icon getInternalFrameCloseIcon(int size) {        return new InternalFrameCloseIcon(size);    }        private static class InternalFrameCloseIcon implements Icon, UIResource, Serializable {        int iconSize = 16;                public InternalFrameCloseIcon(int size) {            iconSize = size;        }                public void paintIcon(Component c, Graphics g, int x, int y) {            JButton parentButton = (JButton)c;            ButtonModel buttonModel = parentButton.getModel();                        Color mainItemColor = SmoothGradientLookAndFeel.getPrimaryControlDarkShadow();            Color darkHighlightColor = MetalLookAndFeel.getBlack();                        // background gradients            Color bgStart = SmoothGradientLookAndFeel.FRAME_BUTTON_START_ACTIVE;            Color bgStop = SmoothGradientLookAndFeel.FRAME_BUTTON_STOP_ACTIVE;                        // if the internal frame is inactive            if (parentButton.getClientProperty("paintActive") != Boolean.TRUE) {                mainItemColor = SmoothGradientLookAndFeel.getControlDarkShadow();                bgStart = SmoothGradientLookAndFeel.FRAME_BUTTON_START_INACTIVE;                bgStop = SmoothGradientLookAndFeel.FRAME_BUTTON_STOP_INACTIVE;                                // if inactive and pressed                if (buttonModel.isPressed() && buttonModel.isArmed())                    mainItemColor = darkHighlightColor;                            }                        // if the button is pressed and the mouse is over it            else if (buttonModel.isPressed() && buttonModel.isArmed()) {                mainItemColor = darkHighlightColor;            }                        Graphics2D g2d = (Graphics2D)g;            g2d.translate(x, y);                        Paint _paint = g2d.getPaint();            // fill the background            g2d.setPaint(new GradientPaint(0, iconSize, bgStart, 0, 0, bgStop));            g2d.fillRect(0, 0, iconSize, iconSize);

⌨️ 快捷键说明

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