001: /*
002: * @(#)SystemColor.java 1.17 06/10/10
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: *
026: */
027: package java.awt;
028:
029: /**
030: * A class to encapsulate symbolic colors representing the color
031: * of GUI objects on a system. For systems which support the dynamic
032: * update of the system colors (when the user changes the colors)
033: * the actual RGB values of these symbolic colors will also change
034: * dynamically. In order to compare the "current" RGB value of a SystemColor
035: * object with a non-symbolic Color object, getRGB() should be used
036: * rather than equals().
037: *
038: * @version 1.13, 08/19/02
039: * @author Carl Quinn
040: * @author Amy Fowler
041: */
042: public final class SystemColor extends Color implements
043: java.io.Serializable {
044: /**
045: * The array index for the desktop background color.
046: */
047: public final static int DESKTOP = 0;
048: /**
049: * The array index for the active caption background color.
050: */
051: public final static int ACTIVE_CAPTION = 1;
052: /**
053: * The array index for the action caption text color.
054: */
055: public final static int ACTIVE_CAPTION_TEXT = 2;
056: /**
057: * The array index for the active caption border color.
058: */
059: public final static int ACTIVE_CAPTION_BORDER = 3;
060: /**
061: * The array index for the inactive caption background color.
062: */
063: public final static int INACTIVE_CAPTION = 4;
064: /**
065: * The array index for the inactive caption text color.
066: */
067: public final static int INACTIVE_CAPTION_TEXT = 5;
068: /**
069: * The array index for the inactive caption border color.
070: */
071: public final static int INACTIVE_CAPTION_BORDER = 6;
072: /**
073: * The array index for the window background color.
074: */
075: public final static int WINDOW = 7;
076: /**
077: * The array index for the window border color.
078: */
079: public final static int WINDOW_BORDER = 8;
080: /**
081: * The array index for the window text color.
082: */
083: public final static int WINDOW_TEXT = 9;
084: /**
085: * The array index for the menu background color.
086: */
087: public final static int MENU = 10;
088: /**
089: * The array index for the menu text color.
090: */
091: public final static int MENU_TEXT = 11;
092: /**
093: * The array index for the text background color.
094: */
095: public final static int TEXT = 12;
096: /**
097: * The array index for the text text color.
098: */
099: public final static int TEXT_TEXT = 13;
100: /**
101: * The array index for the text highlight color.
102: */
103: public final static int TEXT_HIGHLIGHT = 14;
104: /**
105: * The array index for the text highlight text color.
106: */
107: public final static int TEXT_HIGHLIGHT_TEXT = 15;
108: /**
109: * The array index for the text inactive text color.
110: */
111: public final static int TEXT_INACTIVE_TEXT = 16;
112: /**
113: * The array index for the control background color.
114: */
115: public final static int CONTROL = 17;
116: /**
117: * The array index for the control text color.
118: */
119: public final static int CONTROL_TEXT = 18;
120: /**
121: * The array index for the control highlight color.
122: */
123: public final static int CONTROL_HIGHLIGHT = 19;
124: /**
125: * The array index for the control light highlight color.
126: */
127: public final static int CONTROL_LT_HIGHLIGHT = 20;
128: /**
129: * The array index for the control shadow color.
130: */
131: public final static int CONTROL_SHADOW = 21;
132: /**
133: * The array index for the control dark shadow color.
134: */
135: public final static int CONTROL_DK_SHADOW = 22;
136: /**
137: * The array index for the scrollbar background color.
138: */
139: public final static int SCROLLBAR = 23;
140: /**
141: * The array index for the info background color.
142: */
143: public final static int INFO = 24;
144: /**
145: * The array index for the info text color.
146: */
147: public final static int INFO_TEXT = 25;
148: /**
149: * The number of system colors in the array.
150: */
151: public final static int NUM_COLORS = 26;
152: /**
153: * The color of the desktop background.
154: */
155: public final static SystemColor desktop = new SystemColor(
156: (byte) DESKTOP);
157: /**
158: * The background color for captions in window borders.
159: */
160: public final static SystemColor activeCaption = new SystemColor(
161: (byte) ACTIVE_CAPTION);
162: /**
163: * The text color for captions in window borders.
164: */
165: public final static SystemColor activeCaptionText = new SystemColor(
166: (byte) ACTIVE_CAPTION_TEXT);
167: /**
168: * The border color for captions in window borders.
169: */
170: public final static SystemColor activeCaptionBorder = new SystemColor(
171: (byte) ACTIVE_CAPTION_BORDER);
172: /**
173: * The background color for inactive captions in window borders.
174: */
175: public final static SystemColor inactiveCaption = new SystemColor(
176: (byte) INACTIVE_CAPTION);
177: /**
178: * The text color for inactive captions in window borders.
179: */
180: public final static SystemColor inactiveCaptionText = new SystemColor(
181: (byte) INACTIVE_CAPTION_TEXT);
182: /**
183: * The border color for inactive captios in window borders.
184: */
185: public final static SystemColor inactiveCaptionBorder = new SystemColor(
186: (byte) INACTIVE_CAPTION_BORDER);
187: /**
188: * The background color for windows.
189: */
190: public final static SystemColor window = new SystemColor(
191: (byte) WINDOW);
192: /**
193: * The border color for windows.
194: */
195: public final static SystemColor windowBorder = new SystemColor(
196: (byte) WINDOW_BORDER);
197: /**
198: * The text color for windows.
199: */
200: public final static SystemColor windowText = new SystemColor(
201: (byte) WINDOW_TEXT);
202: /**
203: * The background color for menus.
204: */
205: public final static SystemColor menu = new SystemColor((byte) MENU);
206: /**
207: * The text color for menus.
208: */
209: public final static SystemColor menuText = new SystemColor(
210: (byte) MENU_TEXT);
211: /**
212: * The background color for text components.
213: */
214: public final static SystemColor text = new SystemColor((byte) TEXT);
215: /**
216: * The text color for text components.
217: */
218: public final static SystemColor textText = new SystemColor(
219: (byte) TEXT_TEXT);
220: /**
221: * The background color for highlighted text.
222: */
223: public final static SystemColor textHighlight = new SystemColor(
224: (byte) TEXT_HIGHLIGHT);
225: /**
226: * The text color for highlighted text.
227: */
228: public final static SystemColor textHighlightText = new SystemColor(
229: (byte) TEXT_HIGHLIGHT_TEXT);
230: /**
231: * The text color for inactive text.
232: */
233: public final static SystemColor textInactiveText = new SystemColor(
234: (byte) TEXT_INACTIVE_TEXT);
235: /**
236: * The background color for control objects.
237: */
238: public final static SystemColor control = new SystemColor(
239: (byte) CONTROL);
240: /**
241: * The text color for control objects.
242: */
243: public final static SystemColor controlText = new SystemColor(
244: (byte) CONTROL_TEXT);
245: /**
246: * The regular highlight color for control objects.
247: */
248: public final static SystemColor controlHighlight = new SystemColor(
249: (byte) CONTROL_HIGHLIGHT);
250: /**
251: * The light highlight color for control objects.
252: */
253: public final static SystemColor controlLtHighlight = new SystemColor(
254: (byte) CONTROL_LT_HIGHLIGHT);
255: /**
256: * The regular shadow color for control objects.
257: */
258: public final static SystemColor controlShadow = new SystemColor(
259: (byte) CONTROL_SHADOW);
260: /**
261: * The dark shadow color for control objects.
262: */
263: public final static SystemColor controlDkShadow = new SystemColor(
264: (byte) CONTROL_DK_SHADOW);
265: /**
266: * The background color for scrollbars.
267: */
268: public final static SystemColor scrollbar = new SystemColor(
269: (byte) SCROLLBAR);
270: /**
271: * The background color for info(help) text.
272: */
273: public final static SystemColor info = new SystemColor((byte) INFO);
274: /**
275: * The text color for info(help) text.
276: */
277: public final static SystemColor infoText = new SystemColor(
278: (byte) INFO_TEXT);
279: /*
280: * System colors with default initial values, overwritten by toolkit if
281: * system values differ and are available.
282: */
283: private static int[] systemColors = { 0xFF005C5C, // desktop = new Color(0,92,92);
284: 0xFF000080, // activeCaption = new Color(0,0,128);
285: 0xFFFFFFFF, // activeCaptionText = Color.white;
286: 0xFFC0C0C0, // activeCaptionBorder = Color.lightGray;
287: 0xFF808080, // inactiveCaption = Color.gray;
288: 0xFFC0C0C0, // inactiveCaptionText = Color.lightGray;
289: 0xFFC0C0C0, // inactiveCaptionBorder = Color.lightGray;
290: 0xFFFFFFFF, // window = Color.white;
291: 0xFF000000, // windowBorder = Color.black;
292: 0xFF000000, // windowText = Color.black;
293: 0xFFC0C0C0, // menu = Color.lightGray;
294: 0xFF000000, // menuText = Color.black;
295: 0xFFC0C0C0, // text = Color.lightGray;
296: 0xFF000000, // textText = Color.black;
297: 0xFF000080, // textHighlight = new Color(0,0,128);
298: 0xFFFFFFFF, // textHighlightText = Color.white;
299: 0xFF808080, // textInactiveText = Color.gray;
300: 0xFFC0C0C0, // control = Color.lightGray;
301: 0xFF000000, // controlText = Color.black;
302: 0xFFFFFFFF, // controlHighlight = Color.white;
303: 0xFFE0E0E0, // controlLtHighlight = new Color(224,224,224);
304: 0xFF808080, // controlShadow = Color.gray;
305: 0xFF000000, // controlDkShadow = Color.black;
306: 0xFFE0E0E0, // scrollbar = new Color(224,224,224);
307: 0xFFE0E000, // info = new Color(224,224,0);
308: 0xFF000000, // infoText = Color.black;
309: };
310: /*
311: * JDK 1.1 serialVersionUID
312: */
313: private static final long serialVersionUID = 4503142729533789064L;
314: static {
315: updateSystemColors();
316: }
317:
318: /**
319: * called from <init> & toolkit to update the above systemColors cache
320: */
321: private static void updateSystemColors() {
322: Toolkit.getDefaultToolkit().loadSystemColors(systemColors);
323: }
324:
325: /**
326: * Create a symbolic color that represents an indexed entry into system
327: * color cache. Used by above static system colors.
328: */
329: private SystemColor(byte index) {
330: super (0, 0, 0);
331: value = index;
332: }
333:
334: /**
335: * Gets the "current" RGB value representing the symbolic color.
336: * (Bits 24-31 are 0xff, 16-23 are red, 8-15 are green, 0-7 are blue).
337: * @see java.awt.image.ColorModel#getRGBdefault
338: * @see java.awt.Color#getBlue
339: * @see java.awt.Color#getGreen
340: * @see java.awt.Color#getRed
341: */
342: public int getRGB() {
343: return systemColors[value];
344: }
345:
346: /**
347: * Returns the String representation of this Color's values.
348: */
349: public String toString() {
350: return getClass().getName() + "[i=" + (value) + "]";
351: }
352: }
|