Source Code Cross Referenced for ShiftColorScheme.java in  » Swing-Library » substance-look-feel » org » jvnet » substance » color » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » substance look feel » org.jvnet.substance.color 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:         * Base class for shifted color schemes. A shifted color scheme is based on some
039:         * original color scheme, a shift color and a shift factor. All colors of the
040:         * original color scheme are shifted towards the shift color based on the shift
041:         * factor. The closer the shift factor value is to 1.0, the closer the colors of
042:         * the shifted color scheme will be to the shift color.
043:         * 
044:         * @author Kirill Grouchnikov
045:         */
046:        public class ShiftColorScheme extends BaseColorScheme {
047:            /**
048:             * Shift factor for background colors.
049:             */
050:            private double backgroundShiftFactor;
051:
052:            /**
053:             * Shift factor for foreground colors.
054:             */
055:            private double foregroundShiftFactor;
056:
057:            /**
058:             * Shift color for background colors.
059:             */
060:            private Color backgroundShiftColor;
061:
062:            /**
063:             * Shift color for foreground color.
064:             */
065:            private Color foregroundShiftColor;
066:
067:            /**
068:             * The main ultra-light color.
069:             */
070:            private Color mainUltraLightColor;
071:
072:            /**
073:             * The main extra-light color.
074:             */
075:            private Color mainExtraLightColor;
076:
077:            /**
078:             * The main light color.
079:             */
080:            private Color mainLightColor;
081:
082:            /**
083:             * The main medium color.
084:             */
085:            private Color mainMidColor;
086:
087:            /**
088:             * The main dark color.
089:             */
090:            private Color mainDarkColor;
091:
092:            /**
093:             * The main ultra-dark color.
094:             */
095:            private Color mainUltraDarkColor;
096:
097:            /**
098:             * The foreground color.
099:             */
100:            private Color foregroundColor;
101:
102:            /**
103:             * The original color scheme.
104:             */
105:            private ColorScheme origScheme;
106:
107:            /**
108:             * Creates a new shifted color scheme.
109:             * 
110:             * @param origScheme
111:             *            The original color scheme.
112:             * @param shiftColor
113:             *            Shift color for the colors.
114:             * @param shiftFactor
115:             *            Shift factor for the colors. Should be in 0.0-1.0 range.
116:             */
117:            public ShiftColorScheme(ColorScheme origScheme, Color shiftColor,
118:                    double shiftFactor) {
119:                this (origScheme, shiftColor, shiftFactor, shiftColor,
120:                        shiftFactor / 2.0, false);
121:            }
122:
123:            /**
124:             * Creates a new shifted color scheme.
125:             * 
126:             * @param origScheme
127:             *            The original color scheme.
128:             * @param backgroundShiftColor
129:             *            Shift color for the background colors.
130:             * @param backgroundShiftFactor
131:             *            Shift factor for the background colors. Should be in 0.0-1.0
132:             *            range.
133:             * @param foregroundShiftColor
134:             *            Shift color for the foreground colors.
135:             * @param foregroundShiftFactor
136:             *            Shift factor for the foreground colors. Should be in 0.0-1.0
137:             *            range.
138:             * @param shiftByBrightness
139:             *            If <code>true</code>, the shift will account for the
140:             *            brightness of the original color scheme colors.
141:             */
142:            public ShiftColorScheme(ColorScheme origScheme,
143:                    Color backgroundShiftColor, double backgroundShiftFactor,
144:                    Color foregroundShiftColor, double foregroundShiftFactor,
145:                    boolean shiftByBrightness) {
146:                this .backgroundShiftColor = backgroundShiftColor;
147:                this .backgroundShiftFactor = backgroundShiftFactor;
148:                this .foregroundShiftColor = foregroundShiftColor;
149:                this .foregroundShiftFactor = foregroundShiftFactor;
150:                this .origScheme = origScheme;
151:                this .foregroundColor = (this .foregroundShiftColor != null) ? SubstanceColorUtilities
152:                        .getInterpolatedColor(this .foregroundShiftColor,
153:                                origScheme.getForegroundColor(),
154:                                this .foregroundShiftFactor)
155:                        : origScheme.getForegroundColor();
156:                shiftByBrightness = shiftByBrightness
157:                        && (this .backgroundShiftColor != null);
158:                Color ultraDarkToShiftTo = shiftByBrightness ? SubstanceColorUtilities
159:                        .deriveByBrightness(this .backgroundShiftColor,
160:                                origScheme.getUltraDarkColor())
161:                        : this .backgroundShiftColor;
162:                this .mainUltraDarkColor = (this .backgroundShiftColor != null) ? SubstanceColorUtilities
163:                        .getInterpolatedColor(ultraDarkToShiftTo, origScheme
164:                                .getUltraDarkColor(),
165:                                this .backgroundShiftFactor)
166:                        : origScheme.getUltraDarkColor();
167:                Color darkToShiftTo = shiftByBrightness ? SubstanceColorUtilities
168:                        .deriveByBrightness(this .backgroundShiftColor,
169:                                origScheme.getDarkColor())
170:                        : this .backgroundShiftColor;
171:                this .mainDarkColor = (this .backgroundShiftColor != null) ? SubstanceColorUtilities
172:                        .getInterpolatedColor(darkToShiftTo, origScheme
173:                                .getDarkColor(), this .backgroundShiftFactor)
174:                        : origScheme.getDarkColor();
175:                Color midToShiftTo = shiftByBrightness ? SubstanceColorUtilities
176:                        .deriveByBrightness(this .backgroundShiftColor,
177:                                origScheme.getMidColor())
178:                        : this .backgroundShiftColor;
179:                this .mainMidColor = (this .backgroundShiftColor != null) ? SubstanceColorUtilities
180:                        .getInterpolatedColor(midToShiftTo, origScheme
181:                                .getMidColor(), this .backgroundShiftFactor)
182:                        : origScheme.getMidColor();
183:                Color lightToShiftTo = shiftByBrightness ? SubstanceColorUtilities
184:                        .deriveByBrightness(this .backgroundShiftColor,
185:                                origScheme.getLightColor())
186:                        : this .backgroundShiftColor;
187:                this .mainLightColor = (this .backgroundShiftColor != null) ? SubstanceColorUtilities
188:                        .getInterpolatedColor(lightToShiftTo, origScheme
189:                                .getLightColor(), this .backgroundShiftFactor)
190:                        : origScheme.getLightColor();
191:                Color extraLightToShiftTo = shiftByBrightness ? SubstanceColorUtilities
192:                        .deriveByBrightness(this .backgroundShiftColor,
193:                                origScheme.getExtraLightColor())
194:                        : this .backgroundShiftColor;
195:                this .mainExtraLightColor = (this .backgroundShiftColor != null) ? SubstanceColorUtilities
196:                        .getInterpolatedColor(extraLightToShiftTo, origScheme
197:                                .getExtraLightColor(),
198:                                this .backgroundShiftFactor)
199:                        : origScheme.getExtraLightColor();
200:                Color ultraLightToShiftTo = shiftByBrightness ? SubstanceColorUtilities
201:                        .deriveByBrightness(this .backgroundShiftColor,
202:                                origScheme.getUltraLightColor())
203:                        : this .backgroundShiftColor;
204:                this .mainUltraLightColor = (this .backgroundShiftColor != null) ? SubstanceColorUtilities
205:                        .getInterpolatedColor(ultraLightToShiftTo, origScheme
206:                                .getUltraLightColor(),
207:                                this .backgroundShiftFactor)
208:                        : origScheme.getUltraLightColor();
209:
210:                this .id = this .getClass().getName() + "["
211:                        + SubstanceCoreUtilities.getSchemeId(origScheme) + "->"
212:                        + backgroundShiftColor + "," + backgroundShiftFactor
213:                        + ":" + shiftByBrightness + "]";
214:            }
215:
216:            /*
217:             * (non-Javadoc)
218:             * 
219:             * @see org.jvnet.substance.color.ColorScheme#getForegroundColor()
220:             */
221:            public Color getForegroundColor() {
222:                return this .foregroundColor;
223:            }
224:
225:            /*
226:             * (non-Javadoc)
227:             * 
228:             * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor()
229:             */
230:            public Color getUltraLightColor() {
231:                return this .mainUltraLightColor;
232:            }
233:
234:            /*
235:             * (non-Javadoc)
236:             * 
237:             * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor()
238:             */
239:            public Color getExtraLightColor() {
240:                return this .mainExtraLightColor;
241:            }
242:
243:            /*
244:             * (non-Javadoc)
245:             * 
246:             * @see org.jvnet.substance.color.ColorScheme#getLightColor()
247:             */
248:            public Color getLightColor() {
249:                return this .mainLightColor;
250:            }
251:
252:            /*
253:             * (non-Javadoc)
254:             * 
255:             * @see org.jvnet.substance.color.ColorScheme#getMidColor()
256:             */
257:            public Color getMidColor() {
258:                return this .mainMidColor;
259:            }
260:
261:            /*
262:             * (non-Javadoc)
263:             * 
264:             * @see org.jvnet.substance.color.ColorScheme#getDarkColor()
265:             */
266:            public Color getDarkColor() {
267:                return this .mainDarkColor;
268:            }
269:
270:            /*
271:             * (non-Javadoc)
272:             * 
273:             * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor()
274:             */
275:            public Color getUltraDarkColor() {
276:                return this .mainUltraDarkColor;
277:            }
278:
279:            /**
280:             * Returns the original color scheme.
281:             * 
282:             * @return The original color scheme.
283:             */
284:            public ColorScheme getOrigScheme() {
285:                return this .origScheme;
286:            }
287:
288:            /**
289:             * Returns the shift factor.
290:             * 
291:             * @return Shift factor.
292:             */
293:            public double getShiftFactor() {
294:                return this.backgroundShiftFactor;
295:            }
296:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.