001: /*
002: * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. 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 Substance Kirill Grouchnikov 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: package org.jvnet.substance.skin;
031:
032: import javax.swing.JTabbedPane;
033:
034: import org.jvnet.substance.SubstanceLookAndFeel;
035: import org.jvnet.substance.border.SubstanceBorderPainter;
036: import org.jvnet.substance.button.SubstanceButtonShaper;
037: import org.jvnet.substance.painter.ControlBackgroundComposite;
038: import org.jvnet.substance.painter.SubstanceGradientPainter;
039: import org.jvnet.substance.painter.decoration.SubstanceDecorationPainter;
040: import org.jvnet.substance.painter.highlight.SubstanceHighlightPainter;
041: import org.jvnet.substance.theme.SubstanceTheme;
042: import org.jvnet.substance.watermark.SubstanceWatermark;
043:
044: /**
045: * Abstract skin for <b>Substance</b> look and feel.
046: *
047: * @author Kirill Grouchnikov
048: * @since version 3.1
049: */
050: public abstract class SubstanceAbstractSkin implements SubstanceSkin {
051: /**
052: * The theme of <code>this</code> skin. The result may be
053: * <code>null</code> if <code>this</code> skin doesn't define a custom
054: * theme.
055: */
056: protected SubstanceTheme theme;
057:
058: /**
059: * The watermark of <code>this</code> skin. May be <code>null</code> if
060: * <code>this</code> skin doesn't define a custom watermark.
061: */
062: protected SubstanceWatermark watermark;
063:
064: /**
065: * The button shaper of <code>this</code> skin. May be <code>null</code>
066: * if <code>this</code> skin doesn't define a custom button shaper.
067: */
068: protected SubstanceButtonShaper buttonShaper;
069:
070: /**
071: * The gradient painter of <code>this</code> skin. May be
072: * <code>null</code> if <code>this</code> skin doesn't define a custom
073: * gradient painter.
074: */
075: protected SubstanceGradientPainter gradientPainter;
076:
077: /**
078: * The border painter of <code>this</code> skin. May be <code>null</code>
079: * if <code>this</code> skin doesn't define a custom border painter.
080: */
081: protected SubstanceBorderPainter borderPainter;
082:
083: protected SubstanceHighlightPainter highlightPainter;
084:
085: protected SubstanceDecorationPainter decorationPainter;
086:
087: /**
088: * The background composite for tabbed panes of <code>this</code> skin.
089: * May be <code>null</code> if <code>this</code> skin doesn't define a
090: * custom background composite for tabbed panes.
091: */
092: protected ControlBackgroundComposite tabBackgroundComposite;
093:
094: /*
095: * (non-Javadoc)
096: *
097: * @see org.jvnet.substance.skin.SubstanceSkin#getTheme()
098: */
099: public SubstanceTheme getTheme() {
100: return this .theme;
101: }
102:
103: /*
104: * (non-Javadoc)
105: *
106: * @see org.jvnet.substance.skin.SubstanceSkin#getWatermark()
107: */
108: public SubstanceWatermark getWatermark() {
109: return this .watermark;
110: }
111:
112: public SubstanceBorderPainter getBorderPainter() {
113: return this .borderPainter;
114: }
115:
116: public SubstanceButtonShaper getButtonShaper() {
117: return this .buttonShaper;
118: }
119:
120: public SubstanceGradientPainter getGradientPainter() {
121: return this .gradientPainter;
122: }
123:
124: public SubstanceHighlightPainter getHighlightPainter() {
125: return this .highlightPainter;
126: }
127:
128: public SubstanceDecorationPainter getDecorationPainter() {
129: return this .decorationPainter;
130: }
131:
132: /*
133: * (non-Javadoc)
134: *
135: * @see org.jvnet.substance.skin.SubstanceSkin#set()
136: */
137: public boolean set() {
138: // all settings must be non-null
139: if (this .theme == null) {
140: throw new IllegalStateException(
141: "Skin must define non-null theme");
142: }
143: if (this .watermark == null) {
144: throw new IllegalStateException(
145: "Skin must define non-null watermark");
146: }
147: if (this .buttonShaper == null) {
148: throw new IllegalStateException(
149: "Skin must define non-null button shaper");
150: }
151: if (this .gradientPainter == null) {
152: throw new IllegalStateException(
153: "Skin must define non-null gradient painter");
154: }
155: if (this .borderPainter == null) {
156: throw new IllegalStateException(
157: "Skin must define non-null border painter");
158: }
159: if (this .highlightPainter == null) {
160: throw new IllegalStateException(
161: "Skin must define non-null highlight painter");
162: }
163: if (this .decorationPainter == null) {
164: throw new IllegalStateException(
165: "Skin must define non-null decoration painter");
166: }
167:
168: if (!SubstanceLookAndFeel
169: .setCurrentGradientPainter(this .gradientPainter))
170: return false;
171: if (!SubstanceLookAndFeel
172: .setCurrentDecorationPainter(this .decorationPainter))
173: return false;
174: if (!SubstanceLookAndFeel
175: .setCurrentHighlightPainter(this .highlightPainter))
176: return false;
177: if (!SubstanceLookAndFeel
178: .setCurrentBorderPainter(this .borderPainter))
179: return false;
180: if (!SubstanceLookAndFeel
181: .setCurrentButtonShaper(this .buttonShaper))
182: return false;
183: if (!SubstanceLookAndFeel.setCurrentTheme(this .theme))
184: return false;
185: if (!SubstanceLookAndFeel.setCurrentWatermark(this .watermark))
186: return false;
187: SubstanceLookAndFeel.setBackgroundComposite(JTabbedPane.class,
188: this .tabBackgroundComposite);
189: return true;
190: }
191: }
|