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.color;
031:
032: import java.awt.Color;
033:
034: import org.jvnet.substance.utils.SubstanceColorUtilities;
035: import org.jvnet.substance.utils.SubstanceCoreUtilities;
036:
037: /**
038: * Saturated color scheme. A saturated color scheme is a color scheme that is
039: * saturated / desaturated (using HSV).
040: *
041: * @author Kirill Grouchnikov
042: * @see ShiftColorScheme
043: */
044: public class SaturatedColorScheme extends BaseColorScheme {
045: /**
046: * Shift factor.
047: */
048: private double saturationFactor;
049:
050: /**
051: * The main ultra-light color.
052: */
053: private Color mainUltraLightColor;
054:
055: /**
056: * The main extra-light color.
057: */
058: private Color mainExtraLightColor;
059:
060: /**
061: * The main light color.
062: */
063: private Color mainLightColor;
064:
065: /**
066: * The main medium color.
067: */
068: private Color mainMidColor;
069:
070: /**
071: * The main dark color.
072: */
073: private Color mainDarkColor;
074:
075: /**
076: * The main ultra-dark color.
077: */
078: private Color mainUltraDarkColor;
079:
080: /**
081: * The foreground color.
082: */
083: private Color foregroundColor;
084:
085: /**
086: * The original color scheme.
087: */
088: private ColorScheme origScheme;
089:
090: /**
091: * Creates a new saturated color scheme.
092: *
093: * @param origScheme
094: * The original color scheme.
095: * @param saturationFactor
096: * Saturation factor. Should be in -1.0..1.0 range.
097: */
098: public SaturatedColorScheme(ColorScheme origScheme,
099: double saturationFactor) {
100: this .saturationFactor = saturationFactor;
101: this .origScheme = origScheme;
102: this .foregroundColor = origScheme.getForegroundColor();
103: this .mainUltraDarkColor = SubstanceColorUtilities
104: .getSaturatedColor(origScheme.getUltraDarkColor(),
105: saturationFactor);
106: this .mainDarkColor = SubstanceColorUtilities.getSaturatedColor(
107: origScheme.getDarkColor(), saturationFactor);
108: this .mainMidColor = SubstanceColorUtilities.getSaturatedColor(
109: origScheme.getMidColor(), saturationFactor);
110: this .mainLightColor = SubstanceColorUtilities
111: .getSaturatedColor(origScheme.getLightColor(),
112: saturationFactor);
113: this .mainExtraLightColor = SubstanceColorUtilities
114: .getSaturatedColor(origScheme.getExtraLightColor(),
115: saturationFactor);
116: this .mainUltraLightColor = SubstanceColorUtilities
117: .getSaturatedColor(origScheme.getUltraLightColor(),
118: saturationFactor);
119:
120: this .id = "Saturated "
121: + SubstanceCoreUtilities.getSchemeId(origScheme)
122: + saturationFactor;
123: }
124:
125: /*
126: * (non-Javadoc)
127: *
128: * @see org.jvnet.substance.color.ColorScheme#getForegroundColor()
129: */
130: public Color getForegroundColor() {
131: return this .foregroundColor;
132: }
133:
134: /*
135: * (non-Javadoc)
136: *
137: * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor()
138: */
139: public Color getUltraLightColor() {
140: return this .mainUltraLightColor;
141: }
142:
143: /*
144: * (non-Javadoc)
145: *
146: * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor()
147: */
148: public Color getExtraLightColor() {
149: return this .mainExtraLightColor;
150: }
151:
152: /*
153: * (non-Javadoc)
154: *
155: * @see org.jvnet.substance.color.ColorScheme#getLightColor()
156: */
157: public Color getLightColor() {
158: return this .mainLightColor;
159: }
160:
161: /*
162: * (non-Javadoc)
163: *
164: * @see org.jvnet.substance.color.ColorScheme#getMidColor()
165: */
166: public Color getMidColor() {
167: return this .mainMidColor;
168: }
169:
170: /*
171: * (non-Javadoc)
172: *
173: * @see org.jvnet.substance.color.ColorScheme#getDarkColor()
174: */
175: public Color getDarkColor() {
176: return this .mainDarkColor;
177: }
178:
179: /*
180: * (non-Javadoc)
181: *
182: * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor()
183: */
184: public Color getUltraDarkColor() {
185: return this .mainUltraDarkColor;
186: }
187:
188: /**
189: * Returns the original color scheme.
190: *
191: * @return The original color scheme.
192: */
193: public ColorScheme getOrigScheme() {
194: return this .origScheme;
195: }
196:
197: /**
198: * Returns the saturation factor.
199: *
200: * @return Saturation factor.
201: */
202: public double getSaturationFactor() {
203: return this.saturationFactor;
204: }
205: }
|