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: * Blended color scheme.
039: *
040: * @author Kirill Grouchnikov
041: */
042: public class BlendBiColorScheme extends BaseColorScheme {
043: /**
044: * The main ultra-light color.
045: */
046: private Color mainUltraLightColor;
047:
048: /**
049: * The main extra-light color.
050: */
051: private Color mainExtraLightColor;
052:
053: /**
054: * The main light color.
055: */
056: private Color mainLightColor;
057:
058: /**
059: * The main medium color.
060: */
061: private Color mainMidColor;
062:
063: /**
064: * The main dark color.
065: */
066: private Color mainDarkColor;
067:
068: /**
069: * The main ultra-dark color.
070: */
071: private Color mainUltraDarkColor;
072:
073: /**
074: * The foreground color.
075: */
076: private Color foregroundColor;
077:
078: /**
079: * The main original color scheme.
080: */
081: private ColorScheme firstScheme;
082:
083: /**
084: * The secondary original color scheme.
085: */
086: private ColorScheme secondScheme;
087:
088: /**
089: * Likeness to the first scheme. Values close to 0.0 will create scheme that
090: * closely matches the second original scheme. Values close to 1.0 will
091: * create scheme that closely matches the second original theme.
092: */
093: private double firstSchemeLikeness;
094:
095: /**
096: * Creates a new blended color scheme.
097: *
098: * @param firstScheme
099: * The first original color scheme.
100: * @param secondScheme
101: * The second original color scheme.
102: * @param firstSchemeLikeness
103: * Likeness to the first scheme. Values close to 0.0 will create
104: * scheme that closely matches the second original scheme. Values
105: * close to 1.0 will create scheme that closely matches the
106: * second original theme.
107: */
108: public BlendBiColorScheme(ColorScheme firstScheme,
109: ColorScheme secondScheme, double firstSchemeLikeness) {
110: this .firstScheme = firstScheme;
111: this .secondScheme = secondScheme;
112: this .firstSchemeLikeness = firstSchemeLikeness;
113: this .foregroundColor = new Color(SubstanceColorUtilities
114: .getInterpolatedRGB(firstScheme.getForegroundColor(),
115: secondScheme.getForegroundColor(),
116: firstSchemeLikeness));
117: this .mainUltraDarkColor = new Color(SubstanceColorUtilities
118: .getInterpolatedRGB(firstScheme.getUltraDarkColor(),
119: secondScheme.getUltraDarkColor(),
120: firstSchemeLikeness));
121: this .mainDarkColor = new Color(SubstanceColorUtilities
122: .getInterpolatedRGB(firstScheme.getDarkColor(),
123: secondScheme.getDarkColor(),
124: firstSchemeLikeness));
125: this .mainMidColor = new Color(
126: SubstanceColorUtilities.getInterpolatedRGB(firstScheme
127: .getMidColor(), secondScheme.getMidColor(),
128: firstSchemeLikeness));
129: this .mainLightColor = new Color(SubstanceColorUtilities
130: .getInterpolatedRGB(firstScheme.getLightColor(),
131: secondScheme.getLightColor(),
132: firstSchemeLikeness));
133: this .mainExtraLightColor = new Color(SubstanceColorUtilities
134: .getInterpolatedRGB(firstScheme.getExtraLightColor(),
135: secondScheme.getExtraLightColor(),
136: firstSchemeLikeness));
137: this .mainUltraLightColor = new Color(SubstanceColorUtilities
138: .getInterpolatedRGB(firstScheme.getUltraLightColor(),
139: secondScheme.getUltraLightColor(),
140: firstSchemeLikeness));
141:
142: this .id = "Blended "
143: + SubstanceCoreUtilities.getSchemeId(firstScheme)
144: + " & "
145: + SubstanceCoreUtilities.getSchemeId(secondScheme)
146: + ":" + firstSchemeLikeness;
147: }
148:
149: /*
150: * (non-Javadoc)
151: *
152: * @see org.jvnet.substance.color.ColorScheme#getForegroundColor()
153: */
154: public Color getForegroundColor() {
155: return this .foregroundColor;
156: }
157:
158: /*
159: * (non-Javadoc)
160: *
161: * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor()
162: */
163: public Color getUltraLightColor() {
164: return this .mainUltraLightColor;
165: }
166:
167: /*
168: * (non-Javadoc)
169: *
170: * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor()
171: */
172: public Color getExtraLightColor() {
173: return this .mainExtraLightColor;
174: }
175:
176: /*
177: * (non-Javadoc)
178: *
179: * @see org.jvnet.substance.color.ColorScheme#getLightColor()
180: */
181: public Color getLightColor() {
182: return this .mainLightColor;
183: }
184:
185: /*
186: * (non-Javadoc)
187: *
188: * @see org.jvnet.substance.color.ColorScheme#getMidColor()
189: */
190: public Color getMidColor() {
191: return this .mainMidColor;
192: }
193:
194: /*
195: * (non-Javadoc)
196: *
197: * @see org.jvnet.substance.color.ColorScheme#getDarkColor()
198: */
199: public Color getDarkColor() {
200: return this .mainDarkColor;
201: }
202:
203: /*
204: * (non-Javadoc)
205: *
206: * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor()
207: */
208: public Color getUltraDarkColor() {
209: return this .mainUltraDarkColor;
210: }
211:
212: /**
213: * Returns the likeness to the first scheme.
214: *
215: * @return Likeness to the first scheme
216: */
217: public double getFirstSchemeLikeness() {
218: return this .firstSchemeLikeness;
219: }
220:
221: /**
222: * Returns the main original color scheme.
223: *
224: * @return The main original color scheme.
225: */
226: public ColorScheme getFirstScheme() {
227: return this .firstScheme;
228: }
229:
230: /**
231: * Returns the secondary original color scheme.
232: *
233: * @return The secondary original color scheme.
234: */
235: public ColorScheme getSecondScheme() {
236: return this.secondScheme;
237: }
238: }
|