001: /*
002: * Copyright (c) 2001-2007 JGoodies Karsten Lentzsch. All Rights Reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * o Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * o Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * o Neither the name of JGoodies Karsten Lentzsch nor the names of
015: * its contributors may be used to endorse or promote products derived
016: * from this software without specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
020: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
021: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
022: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
025: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
026: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
027: * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028: * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029: */
030:
031: package com.jgoodies.looks.plastic;
032:
033: import java.awt.Color;
034:
035: import javax.swing.plaf.ColorUIResource;
036: import javax.swing.plaf.FontUIResource;
037: import javax.swing.plaf.metal.DefaultMetalTheme;
038:
039: import com.jgoodies.looks.FontPolicy;
040: import com.jgoodies.looks.FontSet;
041:
042: /**
043: * Unlike its superclass this theme class has relaxed access.
044: *
045: * @author Karsten Lentzsch
046: * @version $Revision: 1.6 $
047: */
048: public abstract class PlasticTheme extends DefaultMetalTheme {
049:
050: // Default 3D Effect Colors *********************************************
051:
052: public static final Color DARKEN_START = new Color(0, 0, 0, 0);
053: public static final Color DARKEN_STOP = new Color(0, 0, 0, 64);
054: public static final Color LT_DARKEN_STOP = new Color(0, 0, 0, 32);
055: public static final Color BRIGHTEN_START = new Color(255, 255, 255,
056: 0);
057: public static final Color BRIGHTEN_STOP = new Color(255, 255, 255,
058: 128);
059: public static final Color LT_BRIGHTEN_STOP = new Color(255, 255,
060: 255, 64);
061:
062: protected static final ColorUIResource WHITE = new ColorUIResource(
063: 255, 255, 255);
064:
065: protected static final ColorUIResource BLACK = new ColorUIResource(
066: 0, 0, 0);
067:
068: // Instance Fields ********************************************************
069:
070: /**
071: * Holds the set of fonts used by this theme.
072: * It is lazily initialized using the shared FontPolicy
073: * provided by the PlasticLookAndFeel.
074: *
075: * @see #getFontSet()
076: * @see PlasticLookAndFeel#getFontPolicy()
077: */
078: private FontSet fontSet;
079:
080: // Accessing Colors *****************************************************
081:
082: protected ColorUIResource getBlack() {
083: return BLACK;
084: }
085:
086: protected ColorUIResource getWhite() {
087: return WHITE;
088: }
089:
090: public ColorUIResource getSystemTextColor() {
091: return getControlInfo();
092: }
093:
094: public ColorUIResource getTitleTextColor() {
095: return getPrimary1();
096: }
097:
098: public ColorUIResource getMenuForeground() {
099: return getControlInfo();
100: }
101:
102: public ColorUIResource getMenuItemBackground() {
103: return getMenuBackground();
104: }
105:
106: public ColorUIResource getMenuItemSelectedBackground() {
107: return getMenuSelectedBackground();
108: }
109:
110: public ColorUIResource getMenuItemSelectedForeground() {
111: return getMenuSelectedForeground();
112: }
113:
114: public ColorUIResource getSimpleInternalFrameForeground() {
115: return getWhite();
116: }
117:
118: public ColorUIResource getSimpleInternalFrameBackground() {
119: return getPrimary1();
120: }
121:
122: public ColorUIResource getToggleButtonCheckColor() {
123: return getPrimary1();
124: }
125:
126: // Accessing Fonts ******************************************************
127:
128: public FontUIResource getTitleTextFont() {
129: return getFontSet().getTitleFont();
130: }
131:
132: public FontUIResource getControlTextFont() {
133: return getFontSet().getControlFont();
134: }
135:
136: public FontUIResource getMenuTextFont() {
137: return getFontSet().getMenuFont();
138: }
139:
140: public FontUIResource getSubTextFont() {
141: return getFontSet().getSmallFont();
142: }
143:
144: public FontUIResource getSystemTextFont() {
145: return getFontSet().getControlFont();
146: }
147:
148: public FontUIResource getUserTextFont() {
149: return getFontSet().getControlFont();
150: }
151:
152: public FontUIResource getWindowTitleFont() {
153: return getFontSet().getWindowTitleFont();
154: }
155:
156: protected FontSet getFontSet() {
157: if (fontSet == null) {
158: FontPolicy policy = PlasticLookAndFeel.getFontPolicy();
159: fontSet = policy.getFontSet("Plastic", null);
160: }
161: return fontSet;
162: }
163:
164: // Custom Equals Implementation *****************************************
165:
166: /**
167: * Plastic themes are equal if and only if their classes are the same.
168: *
169: * @return true if this theme is equal to the given object
170: */
171: public boolean equals(Object o) {
172: if (this == o)
173: return true;
174: if (o == null)
175: return false;
176: return getClass().equals(o.getClass());
177: }
178:
179: /**
180: * Returns this theme's hash code, the classes' hash code.
181: *
182: * @return this theme's hash code
183: */
184: public int hashCode() {
185: return getClass().hashCode();
186: }
187:
188: }
|