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.SubstanceCoreUtilities;
035:
036: /**
037: * Mixed color scheme.
038: *
039: * @author Kirill Grouchnikov
040: */
041: public class MixColorScheme extends BaseColorScheme {
042: /**
043: * The main ultra-light color.
044: */
045: private Color mainUltraLightColor;
046:
047: /**
048: * The main extra-light color.
049: */
050: private Color mainExtraLightColor;
051:
052: /**
053: * The main light color.
054: */
055: private Color mainLightColor;
056:
057: /**
058: * The main medium color.
059: */
060: private Color mainMidColor;
061:
062: /**
063: * The main dark color.
064: */
065: private Color mainDarkColor;
066:
067: /**
068: * The main ultra-dark color.
069: */
070: private Color mainUltraDarkColor;
071:
072: /**
073: * The foreground color.
074: */
075: private Color foregroundColor;
076:
077: /**
078: * The original color schemes.
079: */
080: private ColorScheme[] origSchemes;
081:
082: /**
083: * Creates a new mixed color scheme.
084: *
085: * @param origSchemes
086: * The original color schemes.
087: */
088: public MixColorScheme(ColorScheme... origSchemes) {
089: if ((origSchemes == null) || (origSchemes.length < 2)) {
090: throw new IllegalArgumentException(
091: "At least two schemes needed for a mix scheme");
092: }
093: this .origSchemes = origSchemes;
094: this .foregroundColor = this .origSchemes[0].getForegroundColor();
095: this .mainUltraDarkColor = this .origSchemes[0]
096: .getUltraDarkColor();
097: this .mainDarkColor = this .origSchemes[0].getDarkColor();
098: this .mainMidColor = this .origSchemes[0].getMidColor();
099: this .mainLightColor = this .origSchemes[0].getLightColor();
100: this .mainExtraLightColor = this .origSchemes[0]
101: .getExtraLightColor();
102: this .mainUltraLightColor = this .origSchemes[0]
103: .getUltraLightColor();
104:
105: StringBuffer idBuf = new StringBuffer();
106: idBuf.append("Mixed ");
107: String delim = "";
108: for (ColorScheme origScheme : origSchemes) {
109: idBuf.append(delim);
110: idBuf
111: .append(SubstanceCoreUtilities
112: .getSchemeId(origScheme));
113: delim = " & ";
114: }
115: this .id = idBuf.toString();
116: }
117:
118: /*
119: * (non-Javadoc)
120: *
121: * @see org.jvnet.substance.color.ColorScheme#getForegroundColor()
122: */
123: public Color getForegroundColor() {
124: return this .foregroundColor;
125: }
126:
127: /*
128: * (non-Javadoc)
129: *
130: * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor()
131: */
132: public Color getUltraLightColor() {
133: return this .mainUltraLightColor;
134: }
135:
136: /*
137: * (non-Javadoc)
138: *
139: * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor()
140: */
141: public Color getExtraLightColor() {
142: return this .mainExtraLightColor;
143: }
144:
145: /*
146: * (non-Javadoc)
147: *
148: * @see org.jvnet.substance.color.ColorScheme#getLightColor()
149: */
150: public Color getLightColor() {
151: return this .mainLightColor;
152: }
153:
154: /*
155: * (non-Javadoc)
156: *
157: * @see org.jvnet.substance.color.ColorScheme#getMidColor()
158: */
159: public Color getMidColor() {
160: return this .mainMidColor;
161: }
162:
163: /*
164: * (non-Javadoc)
165: *
166: * @see org.jvnet.substance.color.ColorScheme#getDarkColor()
167: */
168: public Color getDarkColor() {
169: return this .mainDarkColor;
170: }
171:
172: /*
173: * (non-Javadoc)
174: *
175: * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor()
176: */
177: public Color getUltraDarkColor() {
178: return this .mainUltraDarkColor;
179: }
180:
181: /**
182: * Returns the original color schemes of <code>this</code> mixed color
183: * scheme.
184: *
185: * @return The original color schemes of <code>this</code> mixed color
186: * scheme.
187: */
188: public ColorScheme[] getOrigSchemes() {
189: return this.origSchemes;
190: }
191: }
|