2
* Copyright (c) 2002 and later by MH Software-Entwicklung. All Rights Reserved.
4
* JTattoo is multiple licensed. If your are an open source developer you can use
5
* it under the terms and conditions of the GNU General Public License version 2.0
6
* or later as published by the Free Software Foundation.
10
* If you pay for a license you will become a registered user who could use the
11
* software under the terms and conditions of the GNU Lesser General Public License
12
* version 2.0 or later with classpath exception as published by the Free Software
16
* see: classpath-exception.txt
18
* Registered users could also use JTattoo under the terms and conditions of the
19
* Apache License, Version 2.0 as published by the Apache Software Foundation.
21
* see: APACHE-LICENSE-2.0.txt
24
package com.jtattoo.plaf.mint;
26
import com.jtattoo.plaf.*;
28
import java.awt.geom.Area;
29
import java.awt.geom.RoundRectangle2D;
30
import javax.swing.Icon;
31
import javax.swing.JButton;
34
* @author Michael Hagen
36
public class MintIcons extends BaseIcons {
38
public static Icon getIconIcon() {
39
if (iconIcon == null) {
40
if (AbstractLookAndFeel.getTheme().isMacStyleWindowDecorationOn()) {
41
iconIcon = new MacIconIcon();
43
iconIcon = new TitleButtonIcon(TitleButtonIcon.ICON_ICON_TYP);
49
public static Icon getMinIcon() {
50
if (minIcon == null) {
51
if (AbstractLookAndFeel.getTheme().isMacStyleWindowDecorationOn()) {
52
minIcon = new MacMinIcon();
54
minIcon = new TitleButtonIcon(TitleButtonIcon.MIN_ICON_TYP);
60
public static Icon getMaxIcon() {
61
if (maxIcon == null) {
62
if (AbstractLookAndFeel.getTheme().isMacStyleWindowDecorationOn()) {
63
maxIcon = new MacMaxIcon();
65
maxIcon = new TitleButtonIcon(TitleButtonIcon.MAX_ICON_TYP);
71
public static Icon getCloseIcon() {
72
if (closeIcon == null) {
73
if (AbstractLookAndFeel.getTheme().isMacStyleWindowDecorationOn()) {
74
closeIcon = new MacCloseIcon();
76
closeIcon = new TitleButtonIcon(TitleButtonIcon.CLOSE_ICON_TYP);
82
//------------------------------------------------------------------------------
83
private static class TitleButtonIcon implements Icon {
85
private static Color closerColorLight = new Color(241, 172, 154);
86
private static Color closerColorDark = new Color(224, 56, 2);
87
public static final int ICON_ICON_TYP = 0;
88
public static final int MIN_ICON_TYP = 1;
89
public static final int MAX_ICON_TYP = 2;
90
public static final int CLOSE_ICON_TYP = 3;
91
private int iconTyp = ICON_ICON_TYP;
93
public TitleButtonIcon(int typ) {
97
public int getIconHeight() {
101
public int getIconWidth() {
105
public void paintIcon(Component c, Graphics g, int x, int y) {
106
int w = c.getWidth();
107
int h = c.getHeight();
109
JButton b = (JButton) c;
110
Graphics2D g2D = (Graphics2D) g;
112
boolean isActive = JTattooUtilities.isActive(b);
113
boolean isPressed = b.getModel().isPressed();
114
boolean isArmed = b.getModel().isArmed();
115
boolean isRollover = b.getModel().isRollover();
117
Color cHi = ColorHelper.brighter(AbstractLookAndFeel.getTheme().getWindowTitleColorLight(), 40);
118
Color cLo = ColorHelper.darker(AbstractLookAndFeel.getTheme().getWindowTitleColorDark(), 10);
119
if (iconTyp == CLOSE_ICON_TYP) {
120
cHi = closerColorLight;
121
cLo = closerColorDark;
124
Color fcHi = ColorHelper.brighter(AbstractLookAndFeel.getTheme().getWindowTitleColorDark(), 80);
125
Color fcLo = ColorHelper.darker(AbstractLookAndFeel.getTheme().getWindowTitleColorDark(), 40);
128
cHi = ColorHelper.brighter(AbstractLookAndFeel.getTheme().getWindowInactiveTitleColorLight(), 40);
129
cLo = ColorHelper.darker(AbstractLookAndFeel.getTheme().getWindowInactiveTitleColorDark(), 10);
130
fcHi = ColorHelper.brighter(AbstractLookAndFeel.getTheme().getWindowInactiveTitleColorLight(), 60);
131
fcLo = ColorHelper.darker(AbstractLookAndFeel.getTheme().getWindowInactiveTitleColorDark(), 10);
133
if (isPressed && isArmed) {
134
Color cTemp = ColorHelper.darker(cLo, 10);
135
cLo = ColorHelper.darker(cHi, 10);
137
} else if (isRollover) {
138
cHi = ColorHelper.brighter(cHi, 30);
139
cLo = ColorHelper.brighter(cLo, 30);
142
Shape savedClip = g.getClip();
143
Area area = new Area(new RoundRectangle2D.Double(1, 1, w - 1, h - 1, 3, 3));
146
g2D.setPaint(new GradientPaint(0, 0, fcLo, w, h, fcHi));
147
g.fillRect(1, 1, w - 1, h - 1);
149
g2D.setPaint(new GradientPaint(0, 0, ColorHelper.brighter(cHi, 80), w, h, ColorHelper.darker(cLo, 30)));
150
g.fillRect(2, 2, w - 3, h - 3);
152
g2D.setPaint(new GradientPaint(0, 0, cHi, w, h, cLo));
153
g.fillRect(3, 3, w - 5, h - 5);
155
g2D.setClip(savedClip);
158
cLo = ColorHelper.darker(cLo, 30);
160
if (iconTyp == ICON_ICON_TYP) {
161
icon = new BaseIcons.IconSymbol(cHi, cLo, null);
162
} else if (iconTyp == MIN_ICON_TYP) {
163
icon = new BaseIcons.MinSymbol(cHi, cLo, null);
164
} else if (iconTyp == MAX_ICON_TYP) {
165
icon = new BaseIcons.MaxSymbol(cHi, cLo, null);
166
} else if (iconTyp == CLOSE_ICON_TYP) {
167
icon = new BaseIcons.CloseSymbol(cHi, cLo, null);
170
icon.paintIcon(c, g, 0, 0);