KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > metal > MetalTheme


1 /*
2  * @(#)MetalTheme.java 1.27 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7  
8 package javax.swing.plaf.metal;
9
10 import javax.swing.plaf.*;
11 import javax.swing.*;
12
13 /**
14  * This abstract class acts as a generic way to describe the colors
15  * used by Metal. Subclasses of <code>MetalTheme</code> can
16  * be used to swap the colors in a Metal application.
17  *
18  * @version 1.27 12/19/03
19  * @author Steve Wilson
20  */

21
22 public abstract class MetalTheme {
23
24     // Contants identifying the various Fonts that are Theme can support
25
static final int CONTROL_TEXT_FONT = 0;
26     static final int SYSTEM_TEXT_FONT = 1;
27     static final int USER_TEXT_FONT = 2;
28     static final int MENU_TEXT_FONT = 3;
29     static final int WINDOW_TITLE_FONT = 4;
30     static final int SUB_TEXT_FONT = 5;
31
32     static ColorUIResource white = new ColorUIResource( 255, 255, 255 );
33     private static ColorUIResource black = new ColorUIResource( 0, 0, 0 );
34
35     public abstract String JavaDoc getName();
36
37     protected abstract ColorUIResource getPrimary1(); // these are blue in Metal Default Theme
38
protected abstract ColorUIResource getPrimary2();
39     protected abstract ColorUIResource getPrimary3();
40
41     protected abstract ColorUIResource getSecondary1(); // these are gray in Metal Default Theme
42
protected abstract ColorUIResource getSecondary2();
43     protected abstract ColorUIResource getSecondary3();
44
45     public abstract FontUIResource getControlTextFont();
46     public abstract FontUIResource getSystemTextFont();
47     public abstract FontUIResource getUserTextFont();
48     public abstract FontUIResource getMenuTextFont();
49     public abstract FontUIResource getWindowTitleFont();
50     public abstract FontUIResource getSubTextFont();
51
52     protected ColorUIResource getWhite() { return white; }
53     protected ColorUIResource getBlack() { return black; }
54
55     public ColorUIResource getFocusColor() { return getPrimary2(); }
56
57     public ColorUIResource getDesktopColor() { return getPrimary2(); }
58
59     public ColorUIResource getControl() { return getSecondary3(); }
60     public ColorUIResource getControlShadow() { return getSecondary2(); }
61     public ColorUIResource getControlDarkShadow() { return getSecondary1(); }
62     public ColorUIResource getControlInfo() { return getBlack(); }
63     public ColorUIResource getControlHighlight() { return getWhite(); }
64     public ColorUIResource getControlDisabled() { return getSecondary2(); }
65
66     public ColorUIResource getPrimaryControl() { return getPrimary3(); }
67     public ColorUIResource getPrimaryControlShadow() { return getPrimary2(); }
68     public ColorUIResource getPrimaryControlDarkShadow() { return getPrimary1(); }
69     public ColorUIResource getPrimaryControlInfo() { return getBlack(); }
70     public ColorUIResource getPrimaryControlHighlight() { return getWhite(); }
71
72     /**
73      * Returns the color used, by default, for the text in labels
74      * and titled borders.
75      */

76     public ColorUIResource getSystemTextColor() { return getBlack(); }
77     public ColorUIResource getControlTextColor() { return getControlInfo(); }
78     public ColorUIResource getInactiveControlTextColor() { return getControlDisabled(); }
79     public ColorUIResource getInactiveSystemTextColor() { return getSecondary2(); }
80     public ColorUIResource getUserTextColor() { return getBlack(); }
81     public ColorUIResource getTextHighlightColor() { return getPrimary3(); }
82     public ColorUIResource getHighlightedTextColor() { return getControlTextColor(); }
83
84     public ColorUIResource getWindowBackground() { return getWhite(); }
85     public ColorUIResource getWindowTitleBackground() { return getPrimary3(); }
86     public ColorUIResource getWindowTitleForeground() { return getBlack(); }
87     public ColorUIResource getWindowTitleInactiveBackground() { return getSecondary3(); }
88     public ColorUIResource getWindowTitleInactiveForeground() { return getBlack(); }
89
90     public ColorUIResource getMenuBackground() { return getSecondary3(); }
91     public ColorUIResource getMenuForeground() { return getBlack(); }
92     public ColorUIResource getMenuSelectedBackground() { return getPrimary2(); }
93     public ColorUIResource getMenuSelectedForeground() { return getBlack(); }
94     public ColorUIResource getMenuDisabledForeground() { return getSecondary2(); }
95     public ColorUIResource getSeparatorBackground() { return getWhite(); }
96     public ColorUIResource getSeparatorForeground() { return getPrimary1(); }
97     public ColorUIResource getAcceleratorForeground() { return getPrimary1(); }
98     public ColorUIResource getAcceleratorSelectedForeground() { return getBlack(); }
99
100     public void addCustomEntriesToTable(UIDefaults table) {}
101
102     /**
103      * This is invoked when a MetalLookAndFeel is installed and about to
104      * start using this theme. When we can add API this should be nuked
105      * in favor of DefaultMetalTheme overriding addCustomEntriesToTable.
106      */

107     void install() {
108     }
109
110     /**
111      * Returns true if this is a theme provided by the core platform.
112      */

113     boolean isSystemTheme() {
114         return false;
115     }
116 }
117
Popular Tags