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 org.jvnet.substance.color.*;
033:
034: /**
035: * Hue-shifted theme. A hue-shifted theme is based on some original theme that
036: * is hue-shifted in HSB space. This class is part of officially supported API.
037: *
038: * @author Kirill Grouchnikov
039: * @since version 3.1
040: */
041: public class SubstanceHueShiftTheme extends SubstanceWrapperTheme {
042: /**
043: * The hue-shift factor of <code>this</code> theme.
044: */
045: private double hueShiftFactor;
046:
047: /**
048: * Creates a new hue-shift theme.<b>Do not</b> use this constructor
049: * directly, use {@link SubstanceTheme#hueShift(double)} instead.
050: *
051: * @param substanceTheme
052: * The original theme.
053: * @param hueShiftFactor
054: * Hue-shift factor.
055: */
056: SubstanceHueShiftTheme(SubstanceTheme substanceTheme,
057: double hueShiftFactor) {
058: super (substanceTheme, new HueShiftColorScheme(substanceTheme
059: .getColorScheme(), hueShiftFactor), "Hue-shift "
060: + substanceTheme.getDisplayName() + " "
061: + (int) (100 * hueShiftFactor) + "%", substanceTheme
062: .getKind());
063: this .hueShiftFactor = hueShiftFactor;
064: }
065:
066: /*
067: * (non-Javadoc)
068: *
069: * @see org.jvnet.substance.theme.SubstanceTheme#getDefaultTheme()
070: */
071: @Override
072: public SubstanceTheme getDefaultTheme() {
073: if (this .defaultTheme == null)
074: this .defaultTheme = this .originalTheme.getDefaultTheme()
075: .hueShift(this .hueShiftFactor);
076: return this .defaultTheme;
077: }
078:
079: /*
080: * (non-Javadoc)
081: *
082: * @see org.jvnet.substance.theme.SubstanceTheme#getDisabledTheme()
083: */
084: @Override
085: public SubstanceTheme getDisabledTheme() {
086: if (this .disabledTheme == null)
087: this .disabledTheme = this .originalTheme.getDisabledTheme()
088: .hueShift(this .hueShiftFactor);
089: return this .disabledTheme;
090: }
091:
092: /*
093: * (non-Javadoc)
094: *
095: * @see org.jvnet.substance.theme.SubstanceTheme#hueShift(double)
096: */
097: @Override
098: public SubstanceTheme hueShift(double hueShiftFactor) {
099: hueShiftFactor += this .hueShiftFactor;
100: if (hueShiftFactor != 0.0)
101: return this.getOriginalTheme().hueShift(hueShiftFactor);
102: else
103: return this.getOriginalTheme();
104: }
105: }
|