1 |
/* SystemColor.java -- Class to access system color values. |
/* SystemColor.java -- access dynamic system color values |
2 |
Copyright (C) 1999 Free Software Foundation, Inc. |
Copyright (C) 1999, 2002 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
38 |
|
|
39 |
package java.awt; |
package java.awt; |
40 |
|
|
41 |
/** |
import java.awt.image.ColorModel; |
42 |
* This class contains the various "system colors" in use by the |
import java.awt.geom.AffineTransform; |
43 |
* native windowing system. |
import java.awt.geom.Rectangle2D; |
44 |
* |
import java.io.Serializable; |
45 |
* @author Aaron M. Renn (arenn@urbanophile.com) |
|
46 |
*/ |
/** |
47 |
public final class SystemColor extends Color implements java.io.Serializable |
* This class contains the various "system colors" in use by the native |
48 |
{ |
* windowing system. The <code>getRGB()</code> method is dynamic on systems |
49 |
|
* which support dynamic system color changes, and most methods in the |
50 |
/* |
* superclass are written to use this dynamic value when reporting colors. |
51 |
* Static Variables |
* However, the <code>equals()</code> method is not dynamic, and does not |
52 |
|
* track the actual color of instances in this class. This means that equals |
53 |
|
* may give surprising results; you are better off relying on getRGB. |
54 |
|
* |
55 |
|
* @author Aaron M. Renn <arenn@urbanophile.com> |
56 |
|
* @author Eric Blake <ebb9@email.byu.edu> |
57 |
|
* @since 1.1 |
58 |
|
* @status updated to 1.4 |
59 |
*/ |
*/ |
60 |
|
public final class SystemColor extends Color implements Serializable |
|
/** |
|
|
* Array index of the desktop color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int DESKTOP = 0; |
|
|
|
|
|
/** |
|
|
* Array index of the active caption color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int ACTIVE_CAPTION = 1; |
|
|
|
|
|
/** |
|
|
* Array index of the active caption text color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int ACTIVE_CAPTION_TEXT = 2; |
|
|
|
|
|
/** |
|
|
* Array index of the active caption border color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int ACTIVE_CAPTION_BORDER = 3; |
|
|
|
|
|
/** |
|
|
* Array index of the inactive caption color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int INACTIVE_CAPTION = 4; |
|
|
|
|
|
/** |
|
|
* Array index of the inactive caption text color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int INACTIVE_CAPTION_TEXT = 5; |
|
|
|
|
|
/** |
|
|
* Array index of the inactive caption border color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int INACTIVE_CAPTION_BORDER = 6; |
|
|
|
|
|
/** |
|
|
* Array index of the window background color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int WINDOW = 7; |
|
|
|
|
|
/** |
|
|
* Array index of the window border color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int WINDOW_BORDER = 8; |
|
|
|
|
|
/** |
|
|
* Array index of the window text color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int WINDOW_TEXT = 9; |
|
|
|
|
|
/** |
|
|
* Array index of the menu background color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int MENU = 10; |
|
|
|
|
|
/** |
|
|
* Array index of the menu text color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int MENU_TEXT = 11; |
|
|
|
|
|
/** |
|
|
* Array index of the text background color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int TEXT = 12; |
|
|
|
|
|
/** |
|
|
* Array index of the text foreground color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int TEXT_TEXT = 13; |
|
|
|
|
|
/** |
|
|
* Array index of the highlighted text background color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int TEXT_HIGHLIGHT = 14; |
|
|
|
|
|
/** |
|
|
* Array index of the highlighted text foreground color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int TEXT_HIGHLIGHT_TEXT = 15; |
|
|
|
|
|
/** |
|
|
* Array index of the inactive text foreground color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int TEXT_INACTIVE_TEXT = 16; |
|
|
|
|
|
/** |
|
|
* Array index of the control background color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int CONTROL = 17; |
|
|
|
|
|
/** |
|
|
* Array index of the control text color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int CONTROL_TEXT = 18; |
|
|
|
|
|
/** |
|
|
* Array index of the highlighted control background color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int CONTROL_HIGHLIGHT = 19; |
|
|
|
|
|
/** |
|
|
* Array index of the lightly highlighted control background color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int CONTROL_LT_HIGHLIGHT = 20; |
|
|
|
|
|
/** |
|
|
* Array index of the shadowed control background color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int CONTROL_SHADOW = 21; |
|
|
|
|
|
/** |
|
|
* Array index of the darkly shadowed control background color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int CONTROL_DK_SHADOW = 22; |
|
|
|
|
|
/** |
|
|
* Array index of the scrollbar background color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int SCROLLBAR = 23; |
|
|
|
|
|
/** |
|
|
* Array index of the info background color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int INFO = 24; |
|
|
|
|
|
/** |
|
|
* Array index of the info text color. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int INFO_TEXT = 25; |
|
|
|
|
|
/** |
|
|
* The number of system colors. Used by |
|
|
* <code>Toolkit.loadSystemColors()</code>. |
|
|
*/ |
|
|
public static final int NUM_COLORS = 26; |
|
|
|
|
|
/** |
|
|
* The desktop color. |
|
|
*/ |
|
|
public static final SystemColor desktop; |
|
|
|
|
|
/** |
|
|
* The active caption background color. |
|
|
*/ |
|
|
public static final SystemColor activeCaption; |
|
|
|
|
|
/** |
|
|
* The active caption text color. |
|
|
*/ |
|
|
public static final SystemColor activeCaptionText; |
|
|
|
|
|
/** |
|
|
* The active caption border color. |
|
|
*/ |
|
|
public static final SystemColor activeCaptionBorder; |
|
|
|
|
|
/** |
|
|
* The inactive caption background color. |
|
|
*/ |
|
|
public static final SystemColor inactiveCaption; |
|
|
|
|
|
/** |
|
|
* The inactive caption text color. |
|
|
*/ |
|
|
public static final SystemColor inactiveCaptionText; |
|
|
|
|
|
/** |
|
|
* The inactive caption border color. |
|
|
*/ |
|
|
public static final SystemColor inactiveCaptionBorder; |
|
|
|
|
|
/** |
|
|
* The window background color. |
|
|
*/ |
|
|
public static final SystemColor window; |
|
|
|
|
|
/** |
|
|
* The window border color. |
|
|
*/ |
|
|
public static final SystemColor windowBorder; |
|
|
|
|
|
/** |
|
|
* The window text color. |
|
|
*/ |
|
|
public static final SystemColor windowText; |
|
|
|
|
|
/** |
|
|
* The menu background color. |
|
|
*/ |
|
|
public static final SystemColor menu; |
|
|
|
|
|
/** |
|
|
* The menu text color. |
|
|
*/ |
|
|
public static final SystemColor menuText; |
|
|
|
|
|
/** |
|
|
* The text background color. |
|
|
*/ |
|
|
public static final SystemColor text; |
|
|
|
|
|
/** |
|
|
* The text foreground color. |
|
|
*/ |
|
|
public static final SystemColor textText; |
|
|
|
|
|
/** |
|
|
* The highlighted text background color. |
|
|
*/ |
|
|
public static final SystemColor textHighlight; |
|
|
|
|
|
/** |
|
|
* The highlighted text foreground color. |
|
|
*/ |
|
|
public static final SystemColor textHighlightText; |
|
|
|
|
|
/** |
|
|
* The inactive text color. |
|
|
*/ |
|
|
public static final SystemColor textInactiveText; |
|
|
|
|
|
/** |
|
|
* The control background color. |
|
|
*/ |
|
|
public static final SystemColor control; |
|
|
|
|
|
/** |
|
|
* The control text color. |
|
|
*/ |
|
|
public static final SystemColor controlText; |
|
|
|
|
|
/** |
|
|
* The control highlight color. |
|
|
*/ |
|
|
public static final SystemColor controlHighlight; |
|
|
|
|
|
/** |
|
|
* The control light highlight color. |
|
|
*/ |
|
|
public static final SystemColor controlLtHighlight; |
|
|
|
|
|
/** |
|
|
* The control shadow color. |
|
|
*/ |
|
|
public static final SystemColor controlShadow; |
|
|
|
|
|
/** |
|
|
* The control dark shadow color. |
|
|
*/ |
|
|
public static final SystemColor controlDkShadow; |
|
|
|
|
|
/** |
|
|
* The scrollbar color. |
|
|
*/ |
|
|
public static final SystemColor scrollbar; |
|
|
|
|
|
/** |
|
|
* The info text background color. |
|
|
*/ |
|
|
public static final SystemColor info; |
|
|
|
|
|
/** |
|
|
* The info text foreground color. |
|
|
*/ |
|
|
public static final SystemColor infoText; |
|
|
|
|
|
// Serialization version constant |
|
|
private static final long serialVersionUID = 4503142729533789064L; |
|
|
|
|
|
static |
|
|
{ |
|
|
int[] sys_color_rgbs = new int[NUM_COLORS]; |
|
|
Toolkit.getDefaultToolkit().loadSystemColors(sys_color_rgbs); |
|
|
|
|
|
desktop = new SystemColor(sys_color_rgbs[DESKTOP]); |
|
|
activeCaption= new SystemColor(sys_color_rgbs[ACTIVE_CAPTION]); |
|
|
activeCaptionText= new SystemColor(sys_color_rgbs[ACTIVE_CAPTION_TEXT]); |
|
|
activeCaptionBorder = new SystemColor(sys_color_rgbs[ACTIVE_CAPTION_BORDER]); |
|
|
inactiveCaption = new SystemColor(sys_color_rgbs[INACTIVE_CAPTION]); |
|
|
inactiveCaptionText = new SystemColor(sys_color_rgbs[INACTIVE_CAPTION_TEXT]); |
|
|
inactiveCaptionBorder = |
|
|
new SystemColor(sys_color_rgbs[INACTIVE_CAPTION_BORDER]); |
|
|
window = new SystemColor(sys_color_rgbs[WINDOW]); |
|
|
windowBorder = new SystemColor(sys_color_rgbs[WINDOW_BORDER]); |
|
|
windowText = new SystemColor(sys_color_rgbs[WINDOW_TEXT]); |
|
|
menu = new SystemColor(sys_color_rgbs[MENU]); |
|
|
menuText = new SystemColor(sys_color_rgbs[MENU_TEXT]); |
|
|
text = new SystemColor(sys_color_rgbs[TEXT]); |
|
|
textText = new SystemColor(sys_color_rgbs[TEXT_TEXT]); |
|
|
textHighlight = new SystemColor(sys_color_rgbs[TEXT_HIGHLIGHT]); |
|
|
textHighlightText = new SystemColor(sys_color_rgbs[TEXT_HIGHLIGHT_TEXT]); |
|
|
textInactiveText = new SystemColor(sys_color_rgbs[TEXT_INACTIVE_TEXT]); |
|
|
control = new SystemColor(sys_color_rgbs[CONTROL]); |
|
|
controlText = new SystemColor(sys_color_rgbs[CONTROL_TEXT]); |
|
|
controlHighlight = new SystemColor(sys_color_rgbs[CONTROL_HIGHLIGHT]); |
|
|
controlLtHighlight = new SystemColor(sys_color_rgbs[CONTROL_LT_HIGHLIGHT]); |
|
|
controlShadow = new SystemColor(sys_color_rgbs[CONTROL_SHADOW]); |
|
|
controlDkShadow = new SystemColor(sys_color_rgbs[CONTROL_DK_SHADOW]); |
|
|
scrollbar = new SystemColor(sys_color_rgbs[SCROLLBAR]); |
|
|
info = new SystemColor(sys_color_rgbs[INFO]); |
|
|
infoText = new SystemColor(sys_color_rgbs[INFO_TEXT]); |
|
|
} |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/* |
|
|
* Constructors |
|
|
*/ |
|
|
|
|
|
private |
|
|
SystemColor(int rgb) |
|
61 |
{ |
{ |
62 |
super(rgb); |
// Implementation note: To be serial compatible with JDK, this class must |
63 |
} |
// violate the semantic meaning of super.value to be one of the |
64 |
|
// NUM_COLORS constants instead of the actual RGB value. Hence there are |
65 |
/*************************************************************************/ |
// a lot of ugly workarounds in Color and in this class. I would have |
66 |
|
// designed it MUCH differently, making a separate id field in this class. |
67 |
/* |
|
68 |
* Instance Methods |
/** |
69 |
*/ |
* Compatible with JDK 1.1+. |
70 |
|
*/ |
71 |
/** |
private static final long serialVersionUID = 4503142729533789064L; |
72 |
* Returns the RGB value for this color as an <code>int</code>. The first |
|
73 |
* byte is the blue value, the second the green value, the third the |
/** |
74 |
* red value and the fourth is set to 0xFF. |
* Array index of the desktop color. Used by |
75 |
* |
* {@link Toolkit#loadSystemColors()}. |
76 |
* @return The RGB value. |
* |
77 |
*/ |
* @see #desktop |
78 |
public int |
*/ |
79 |
getRGB() |
public static final int DESKTOP = 0; |
80 |
{ |
|
81 |
// Override only to be spec consistent. |
/** |
82 |
return(super.getRGB()); |
* Array index of the active caption color. Used by |
83 |
} |
* {@link Toolkit#loadSystemColors()}. |
84 |
|
* |
85 |
/*************************************************************************/ |
* @see #activeCaption |
86 |
|
*/ |
87 |
/** |
public static final int ACTIVE_CAPTION = 1; |
88 |
* Returns a string describing this color. |
|
89 |
* |
/** |
90 |
* @return A string describing this color. |
* Array index of the active caption text color. Used by |
91 |
*/ |
* {@link Toolkit#loadSystemColors()}. |
92 |
public String |
* |
93 |
toString() |
* @see #activeCaptionText |
94 |
{ |
*/ |
95 |
return("SystemColor(R=" + getRed() + ",G=" + getGreen() + ",B=" + |
public static final int ACTIVE_CAPTION_TEXT = 2; |
96 |
getBlue() + ")"); |
|
97 |
} |
/** |
98 |
|
* Array index of the active caption border color. Used by |
99 |
} // class SystemColor |
* {@link Toolkit#loadSystemColors()}. |
100 |
|
* |
101 |
|
* @see #activeCaptionBorder |
102 |
|
*/ |
103 |
|
public static final int ACTIVE_CAPTION_BORDER = 3; |
104 |
|
|
105 |
|
/** |
106 |
|
* Array index of the inactive caption color. Used by |
107 |
|
* {@link Toolkit#loadSystemColors()}. |
108 |
|
* |
109 |
|
* @see #inactiveCaption |
110 |
|
*/ |
111 |
|
public static final int INACTIVE_CAPTION = 4; |
112 |
|
|
113 |
|
/** |
114 |
|
* Array index of the inactive caption text color. Used by |
115 |
|
* {@link Toolkit#loadSystemColors()}. |
116 |
|
* |
117 |
|
* @see #inactiveCaptionText |
118 |
|
*/ |
119 |
|
public static final int INACTIVE_CAPTION_TEXT = 5; |
120 |
|
|
121 |
|
/** |
122 |
|
* Array index of the inactive caption border color. Used by |
123 |
|
* {@link Toolkit#loadSystemColors()}. |
124 |
|
* |
125 |
|
* @see #inactiveCaptionBorder |
126 |
|
*/ |
127 |
|
public static final int INACTIVE_CAPTION_BORDER = 6; |
128 |
|
|
129 |
|
/** |
130 |
|
* Array index of the window background color. Used by |
131 |
|
* {@link Toolkit#loadSystemColors()}. |
132 |
|
* |
133 |
|
* @see #window |
134 |
|
*/ |
135 |
|
public static final int WINDOW = 7; |
136 |
|
|
137 |
|
/** |
138 |
|
* Array index of the window border color. Used by |
139 |
|
* {@link Toolkit#loadSystemColors()}. |
140 |
|
* |
141 |
|
* @see #windowBorder |
142 |
|
*/ |
143 |
|
public static final int WINDOW_BORDER = 8; |
144 |
|
|
145 |
|
/** |
146 |
|
* Array index of the window text color. Used by |
147 |
|
* {@link Toolkit#loadSystemColors()}. |
148 |
|
* |
149 |
|
* @see #windowText |
150 |
|
*/ |
151 |
|
public static final int WINDOW_TEXT = 9; |
152 |
|
|
153 |
|
/** |
154 |
|
* Array index of the menu background color. Used by |
155 |
|
* {@link Toolkit#loadSystemColors()}. |
156 |
|
* |
157 |
|
* @see #menu |
158 |
|
*/ |
159 |
|
public static final int MENU = 10; |
160 |
|
|
161 |
|
/** |
162 |
|
* Array index of the menu text color. Used by |
163 |
|
* {@link Toolkit#loadSystemColors()}. |
164 |
|
* |
165 |
|
* @see #menuText |
166 |
|
*/ |
167 |
|
public static final int MENU_TEXT = 11; |
168 |
|
|
169 |
|
/** |
170 |
|
* Array index of the text background color. Used by |
171 |
|
* {@link Toolkit#loadSystemColors()}. |
172 |
|
* |
173 |
|
* @see #text |
174 |
|
*/ |
175 |
|
public static final int TEXT = 12; |
176 |
|
|
177 |
|
/** |
178 |
|
* Array index of the text foreground color. Used by |
179 |
|
* {@link Toolkit#loadSystemColors()}. |
180 |
|
* |
181 |
|
* @see #textText |
182 |
|
*/ |
183 |
|
public static final int TEXT_TEXT = 13; |
184 |
|
|
185 |
|
/** |
186 |
|
* Array index of the highlighted text background color. Used by |
187 |
|
* {@link Toolkit#loadSystemColors()}. |
188 |
|
* |
189 |
|
* @see #textHighlight |
190 |
|
*/ |
191 |
|
public static final int TEXT_HIGHLIGHT = 14; |
192 |
|
|
193 |
|
/** |
194 |
|
* Array index of the highlighted text foreground color. Used by |
195 |
|
* {@link Toolkit#loadSystemColors()}. |
196 |
|
* |
197 |
|
* @see #textHighlightText |
198 |
|
*/ |
199 |
|
public static final int TEXT_HIGHLIGHT_TEXT = 15; |
200 |
|
|
201 |
|
/** |
202 |
|
* Array index of the inactive text foreground color. Used by |
203 |
|
* {@link Toolkit#loadSystemColors()}. |
204 |
|
* |
205 |
|
* @see #textInactiveText |
206 |
|
*/ |
207 |
|
public static final int TEXT_INACTIVE_TEXT = 16; |
208 |
|
|
209 |
|
/** |
210 |
|
* Array index of the control background color. Used by |
211 |
|
* {@link Toolkit#loadSystemColors()}. |
212 |
|
* |
213 |
|
* @see #control |
214 |
|
*/ |
215 |
|
public static final int CONTROL = 17; |
216 |
|
|
217 |
|
/** |
218 |
|
* Array index of the control text color. Used by |
219 |
|
* {@link Toolkit#loadSystemColors()}. |
220 |
|
* |
221 |
|
* @see #controlText |
222 |
|
*/ |
223 |
|
public static final int CONTROL_TEXT = 18; |
224 |
|
|
225 |
|
/** |
226 |
|
* Array index of the highlighted control background color. Used by |
227 |
|
* {@link Toolkit#loadSystemColors()}. |
228 |
|
* |
229 |
|
* @see #controlHighlight |
230 |
|
*/ |
231 |
|
public static final int CONTROL_HIGHLIGHT = 19; |
232 |
|
|
233 |
|
/** |
234 |
|
* Array index of the lightly highlighted control background color. Used by |
235 |
|
* {@link Toolkit#loadSystemColors()}. |
236 |
|
* |
237 |
|
* @see #controlLtHighlight |
238 |
|
*/ |
239 |
|
public static final int CONTROL_LT_HIGHLIGHT = 20; |
240 |
|
|
241 |
|
/** |
242 |
|
* Array index of the shadowed control background color. Used by |
243 |
|
* {@link Toolkit#loadSystemColors()}. |
244 |
|
* |
245 |
|
* @see #controlShadow |
246 |
|
*/ |
247 |
|
public static final int CONTROL_SHADOW = 21; |
248 |
|
|
249 |
|
/** |
250 |
|
* Array index of the darkly shadowed control background color. Used by |
251 |
|
* {@link Toolkit#loadSystemColors()}. |
252 |
|
* |
253 |
|
* @see #controlDkShadow |
254 |
|
*/ |
255 |
|
public static final int CONTROL_DK_SHADOW = 22; |
256 |
|
|
257 |
|
/** |
258 |
|
* Array index of the scrollbar background color. Used by |
259 |
|
* {@link Toolkit#loadSystemColors()}. |
260 |
|
* |
261 |
|
* @see #scrollbar |
262 |
|
*/ |
263 |
|
public static final int SCROLLBAR = 23; |
264 |
|
|
265 |
|
/** |
266 |
|
* Array index of the info background color. Used by |
267 |
|
* {@link Toolkit#loadSystemColors()}. |
268 |
|
* |
269 |
|
* @see #info |
270 |
|
*/ |
271 |
|
public static final int INFO = 24; |
272 |
|
|
273 |
|
/** |
274 |
|
* Array index of the info text color. Used by |
275 |
|
* {@link Toolkit#loadSystemColors()}. |
276 |
|
* |
277 |
|
* @see #infoText |
278 |
|
*/ |
279 |
|
public static final int INFO_TEXT = 25; |
280 |
|
|
281 |
|
/** |
282 |
|
* The number of system colors. Used by |
283 |
|
* {@link Toolkit#loadSystemColors()}. |
284 |
|
*/ |
285 |
|
public static final int NUM_COLORS = 26; |
286 |
|
|
287 |
|
/** |
288 |
|
* The internal array used to dynamically update <code>getRGB()</code>. |
289 |
|
*/ |
290 |
|
private static final int[] colors = new int[NUM_COLORS]; |
291 |
|
|
292 |
|
/** The desktop color. */ |
293 |
|
public static final SystemColor desktop |
294 |
|
= new SystemColor(DESKTOP); |
295 |
|
|
296 |
|
/** The active caption background color. */ |
297 |
|
public static final SystemColor activeCaption |
298 |
|
= new SystemColor(ACTIVE_CAPTION); |
299 |
|
|
300 |
|
/** The active caption text color. */ |
301 |
|
public static final SystemColor activeCaptionText |
302 |
|
= new SystemColor(ACTIVE_CAPTION_TEXT); |
303 |
|
|
304 |
|
/** The active caption border color. */ |
305 |
|
public static final SystemColor activeCaptionBorder |
306 |
|
= new SystemColor(ACTIVE_CAPTION_BORDER); |
307 |
|
|
308 |
|
/** The inactive caption background color. */ |
309 |
|
public static final SystemColor inactiveCaption |
310 |
|
= new SystemColor(INACTIVE_CAPTION); |
311 |
|
|
312 |
|
/** The inactive caption text color. */ |
313 |
|
public static final SystemColor inactiveCaptionText |
314 |
|
= new SystemColor(INACTIVE_CAPTION_TEXT); |
315 |
|
|
316 |
|
/** The inactive caption border color. */ |
317 |
|
public static final SystemColor inactiveCaptionBorder |
318 |
|
= new SystemColor(INACTIVE_CAPTION_BORDER); |
319 |
|
|
320 |
|
/** The window background color. */ |
321 |
|
public static final SystemColor window |
322 |
|
= new SystemColor(WINDOW); |
323 |
|
|
324 |
|
/** The window border color. */ |
325 |
|
public static final SystemColor windowBorder |
326 |
|
= new SystemColor(WINDOW_BORDER); |
327 |
|
|
328 |
|
/** The window text color. */ |
329 |
|
public static final SystemColor windowText |
330 |
|
= new SystemColor(WINDOW_TEXT); |
331 |
|
|
332 |
|
/** The menu background color. */ |
333 |
|
public static final SystemColor menu |
334 |
|
= new SystemColor(MENU); |
335 |
|
|
336 |
|
/** The menu text color. */ |
337 |
|
public static final SystemColor menuText |
338 |
|
= new SystemColor(MENU_TEXT); |
339 |
|
|
340 |
|
/** The text background color. */ |
341 |
|
public static final SystemColor text |
342 |
|
= new SystemColor(TEXT); |
343 |
|
|
344 |
|
/** The text foreground color. */ |
345 |
|
public static final SystemColor textText |
346 |
|
= new SystemColor(TEXT_TEXT); |
347 |
|
|
348 |
|
/** The highlighted text background color. */ |
349 |
|
public static final SystemColor textHighlight |
350 |
|
= new SystemColor(TEXT_HIGHLIGHT); |
351 |
|
|
352 |
|
/** The highlighted text foreground color. */ |
353 |
|
public static final SystemColor textHighlightText |
354 |
|
= new SystemColor(TEXT_HIGHLIGHT_TEXT); |
355 |
|
|
356 |
|
/** The inactive text color. */ |
357 |
|
public static final SystemColor textInactiveText |
358 |
|
= new SystemColor(TEXT_INACTIVE_TEXT); |
359 |
|
|
360 |
|
/** The control background color. */ |
361 |
|
public static final SystemColor control |
362 |
|
= new SystemColor(CONTROL); |
363 |
|
|
364 |
|
/** The control text color. */ |
365 |
|
public static final SystemColor controlText |
366 |
|
= new SystemColor(CONTROL_TEXT); |
367 |
|
|
368 |
|
/** The control highlight color. */ |
369 |
|
public static final SystemColor controlHighlight |
370 |
|
= new SystemColor(CONTROL_HIGHLIGHT); |
371 |
|
|
372 |
|
/** The control light highlight color. */ |
373 |
|
public static final SystemColor controlLtHighlight |
374 |
|
= new SystemColor(CONTROL_LT_HIGHLIGHT); |
375 |
|
|
376 |
|
/** The control shadow color. */ |
377 |
|
public static final SystemColor controlShadow |
378 |
|
= new SystemColor(CONTROL_SHADOW); |
379 |
|
|
380 |
|
/** The control dark shadow color. */ |
381 |
|
public static final SystemColor controlDkShadow |
382 |
|
= new SystemColor(CONTROL_DK_SHADOW); |
383 |
|
|
384 |
|
/** The scrollbar color. */ |
385 |
|
public static final SystemColor scrollbar |
386 |
|
= new SystemColor(SCROLLBAR); |
387 |
|
|
388 |
|
/** The info text background color. */ |
389 |
|
public static final SystemColor info |
390 |
|
= new SystemColor(INFO); |
391 |
|
|
392 |
|
/** The info text foreground color. */ |
393 |
|
public static final SystemColor infoText |
394 |
|
= new SystemColor(INFO_TEXT); |
395 |
|
|
396 |
|
/** |
397 |
|
* Construct a system color which is dynamically updated. |
398 |
|
* |
399 |
|
* @param id the color id |
400 |
|
*/ |
401 |
|
private SystemColor(int id) |
402 |
|
{ |
403 |
|
// Note: See Color#Color(int, boolean) to explain why we use this |
404 |
|
// particular constructor. |
405 |
|
super(id, true); |
406 |
|
} |
407 |
|
|
408 |
|
/** |
409 |
|
* Returns the RGB value for this color, in the sRGB color space. The blue |
410 |
|
* value will be in bits 0-7, green in 8-15, red in 6-23, and the alpha |
411 |
|
* value (bits 24-31) is 0xff. This is dynamically updated, so it may not |
412 |
|
* match the results of <code>getRed()</code>, <code>getGreen()</code>, or |
413 |
|
* <code>getBlue()</code>. |
414 |
|
* |
415 |
|
* @return the current RGB value |
416 |
|
*/ |
417 |
|
public int getRGB() |
418 |
|
{ |
419 |
|
Toolkit.getDefaultToolkit().loadSystemColors(colors); |
420 |
|
return colors[value] | ALPHA_MASK; |
421 |
|
} |
422 |
|
|
423 |
|
/** |
424 |
|
* Returns a paint context, used for filling areas of a raster scan with |
425 |
|
* the current value of this system color. Since the system colors may be |
426 |
|
* dynamically updated, the returned value may not always be the same; but |
427 |
|
* as the system color is solid, the context does not need any of the |
428 |
|
* passed parameters to do its job. |
429 |
|
* |
430 |
|
* @param cm the requested color model, ignored |
431 |
|
* @param deviceBounds the bounding box in device coordinates, ignored |
432 |
|
* @param userBounds the bounding box in user coordinates, ignored |
433 |
|
* @param xform the bounds transformation, ignored |
434 |
|
* @param hints any rendering hints, ignored |
435 |
|
* @return a context for painting this solid color |
436 |
|
*/ |
437 |
|
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, |
438 |
|
Rectangle2D userBounds, |
439 |
|
AffineTransform xform, |
440 |
|
RenderingHints hints) |
441 |
|
{ |
442 |
|
Toolkit.getDefaultToolkit().loadSystemColors(colors); |
443 |
|
int color = colors[value] | ALPHA_MASK; |
444 |
|
if (context == null || color != context.color) |
445 |
|
context = new ColorPaintContext(color); |
446 |
|
return context; |
447 |
|
} |
448 |
|
|
449 |
|
/** |
450 |
|
* Returns a string describing this color. This is in the format |
451 |
|
* "java.awt.SystemColor[i=" + index + ']', where index is one of the |
452 |
|
* integer constants of this class. Unfortunately, this description |
453 |
|
* does not describe the current value of the color; for that you should |
454 |
|
* use <code>new Color(syscolor.getRGB()).toString()</code>. |
455 |
|
* |
456 |
|
* @return a string describing this color |
457 |
|
*/ |
458 |
|
public String toString() |
459 |
|
{ |
460 |
|
return "java.awt.SystemColor[i=" + value + ']'; |
461 |
|
} |
462 |
|
} // class SystemColor |