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.theme;
031:
032: import java.awt.Color;
033:
034: import org.jvnet.substance.color.InvertedColorScheme;
035: import org.jvnet.substance.utils.SubstanceColorUtilities;
036: import org.jvnet.substance.utils.SubstanceCoreUtilities;
037:
038: /**
039: * Inverted theme. Inverted theme is based on some original theme, switching the
040: * dark colors by light colors and inverting the foreground color. This class is
041: * part of officially supported API.
042: *
043: * @author Kirill Grouchnikov
044: * @see InvertedColorScheme
045: */
046: public class SubstanceInvertedTheme extends SubstanceWrapperTheme {
047: /**
048: * Creates a new inverted theme. <b>Do not</b> use this constructor
049: * directly, use {@link SubstanceTheme#invert()} instead.
050: *
051: * @param substanceTheme
052: * The original theme.
053: */
054: public SubstanceInvertedTheme(SubstanceTheme substanceTheme) {
055: super (substanceTheme, new InvertedColorScheme(substanceTheme
056: .getColorScheme()), "Inverted "
057: + substanceTheme.getDisplayName(), ThemeKind.INVERTED);
058: this .originalTheme = substanceTheme;
059: }
060:
061: /*
062: * (non-Javadoc)
063: *
064: * @see org.jvnet.substance.theme.SubstanceTheme#invert()
065: */
066: @Override
067: public SubstanceTheme invert() {
068: return this .originalTheme;
069: }
070:
071: /*
072: * (non-Javadoc)
073: *
074: * @see org.jvnet.substance.theme.SubstanceTheme#negate()
075: */
076: @Override
077: public SubstanceTheme negate() {
078: throw new UnsupportedOperationException(
079: "Negating an inverted theme is not supported");
080: }
081:
082: /*
083: * (non-Javadoc)
084: *
085: * @see org.jvnet.substance.theme.SubstanceTheme#getWatermarkStampColor()
086: */
087: @Override
088: public Color getWatermarkStampColor() {
089: return SubstanceCoreUtilities.isThemeDark(this ) ? SubstanceColorUtilities
090: .getAlphaColor(this .getColorScheme().getDarkColor(), 60)
091: : SubstanceColorUtilities.getAlphaColor(this
092: .getColorScheme().getUltraLightColor(), 25);
093: }
094:
095: /*
096: * (non-Javadoc)
097: *
098: * @see org.jvnet.substance.theme.SubstanceTheme#saturate(double, boolean)
099: */
100: @Override
101: public SubstanceTheme saturate(double saturateFactor,
102: boolean toSaturateEverything) {
103: return this .originalTheme.saturate(saturateFactor,
104: toSaturateEverything).invert();
105: // return new SubstanceInvertedTheme(this.originalTheme
106: // .saturate(saturateFactor));
107: }
108:
109: /*
110: * (non-Javadoc)
111: *
112: * @see org.jvnet.substance.theme.SubstanceTheme#tint(double)
113: */
114: @Override
115: public SubstanceTheme tint(double tintFactor) {
116: return this .originalTheme.tint(tintFactor).invert();
117: // return new
118: // SubstanceInvertedTheme(this.originalTheme.tint(tintFactor));
119: }
120:
121: /*
122: * (non-Javadoc)
123: *
124: * @see org.jvnet.substance.theme.SubstanceTheme#tone(double)
125: */
126: @Override
127: public SubstanceTheme tone(double toneFactor) {
128: return this .originalTheme.tone(toneFactor).invert();
129: // return new
130: // SubstanceInvertedTheme(this.originalTheme.tone(toneFactor));
131: }
132:
133: /*
134: * (non-Javadoc)
135: *
136: * @see org.jvnet.substance.theme.SubstanceTheme#shade(double)
137: */
138: @Override
139: public SubstanceTheme shade(double shadeFactor) {
140: return this .originalTheme.shade(shadeFactor).invert();
141: // return new
142: // SubstanceInvertedTheme(this.originalTheme.shade(shadeFactor));
143: }
144:
145: /*
146: * (non-Javadoc)
147: *
148: * @see org.jvnet.substance.theme.SubstanceTheme#hueShift(double)
149: */
150: @Override
151: public SubstanceTheme hueShift(double hueShiftFactor) {
152: return this .originalTheme.hueShift(hueShiftFactor).invert();
153: }
154:
155: // /*
156: // * (non-Javadoc)
157: // *
158: // * @see org.jvnet.substance.theme.SubstanceTheme#getDefaultTheme()
159: // */
160: // @Override
161: // public SubstanceTheme getDefaultTheme() {
162: // if (this.defaultTheme == null)
163: // this.defaultTheme = this.originalTheme.getDefaultTheme().invert();
164: // return this.defaultTheme;
165: // }
166: //
167: // /*
168: // * (non-Javadoc)
169: // *
170: // * @see org.jvnet.substance.theme.SubstanceTheme#getDisabledTheme()
171: // */
172: // @Override
173: // public SubstanceTheme getDisabledTheme() {
174: // if (this.disabledTheme == null)
175: // this.disabledTheme = this.originalTheme.getDisabledTheme().invert();
176: // return this.disabledTheme;
177: // }
178: }
|