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.color.NegatedColorScheme;
036: import org.jvnet.substance.utils.SubstanceColorUtilities;
037: import org.jvnet.substance.utils.SubstanceCoreUtilities;
038:
039: /**
040: * Negated theme. Negated theme is based on some original theme, negating the
041: * original colors. This class is part of officially supported API.
042: *
043: * @author Kirill Grouchnikov
044: * @see InvertedColorScheme
045: */
046: public class SubstanceNegatedTheme extends SubstanceWrapperTheme {
047: /**
048: * Creates a new inverted theme. <b>Do not</b> use this constructor
049: * directly, use {@link SubstanceTheme#negate()} instead.
050: *
051: * @param substanceTheme
052: * The original theme.
053: */
054: public SubstanceNegatedTheme(SubstanceTheme substanceTheme) {
055: super (substanceTheme, new NegatedColorScheme(substanceTheme
056: .getColorScheme()), "Negated "
057: + substanceTheme.getDisplayName(), ThemeKind.NEGATED);
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: throw new UnsupportedOperationException(
069: "Inverting a negated theme is not supported");
070: }
071:
072: /*
073: * (non-Javadoc)
074: *
075: * @see org.jvnet.substance.theme.SubstanceTheme#negate()
076: */
077: @Override
078: public SubstanceTheme negate() {
079: return this .originalTheme;
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).negate();
105: }
106:
107: /*
108: * (non-Javadoc)
109: *
110: * @see org.jvnet.substance.theme.SubstanceTheme#tint(double)
111: */
112: @Override
113: public SubstanceTheme tint(double tintFactor) {
114: return this .originalTheme.tint(tintFactor).negate();
115: }
116:
117: /*
118: * (non-Javadoc)
119: *
120: * @see org.jvnet.substance.theme.SubstanceTheme#tone(double)
121: */
122: @Override
123: public SubstanceTheme tone(double toneFactor) {
124: return this .originalTheme.tone(toneFactor).negate();
125: }
126:
127: /*
128: * (non-Javadoc)
129: *
130: * @see org.jvnet.substance.theme.SubstanceTheme#shade(double)
131: */
132: @Override
133: public SubstanceTheme shade(double shadeFactor) {
134: return this .originalTheme.shade(shadeFactor).negate();
135: }
136:
137: /*
138: * (non-Javadoc)
139: *
140: * @see org.jvnet.substance.theme.SubstanceTheme#hueShift(double)
141: */
142: @Override
143: public SubstanceTheme hueShift(double hueShiftFactor) {
144: return this .originalTheme.hueShift(hueShiftFactor).negate();
145: }
146:
147: /*
148: * (non-Javadoc)
149: *
150: * @see org.jvnet.substance.theme.SubstanceTheme#getDefaultTheme()
151: */
152: @Override
153: public SubstanceTheme getDefaultTheme() {
154: if (this .defaultTheme == null)
155: this .defaultTheme = this .originalTheme.getDefaultTheme()
156: .negate();
157: return this .defaultTheme;
158: }
159:
160: /*
161: * (non-Javadoc)
162: *
163: * @see org.jvnet.substance.theme.SubstanceTheme#getDisabledTheme()
164: */
165: @Override
166: public SubstanceTheme getDisabledTheme() {
167: if (this.disabledTheme == null)
168: this.disabledTheme = this.originalTheme.getDisabledTheme()
169: .negate();
170: return this.disabledTheme;
171: }
172: }
|