Source Code Cross Referenced for SubstanceMixTheme.java in  » Swing-Library » substance-look-feel » org » jvnet » substance » theme » 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.theme 
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.theme;
031:
032:        import org.jvnet.substance.color.ColorScheme;
033:        import org.jvnet.substance.color.MixColorScheme;
034:
035:        /**
036:         * Mixed theme. Mixed theme is based on two original themes, using the first
037:         * theme for the left part of the painting, the second theme for the right part
038:         * of the painting, and the theme blend gradient in the middle. Here is how you
039:         * can create and set a mixed theme:<br>
040:         * <br>
041:         * 
042:         * <code>
043:         * SubstanceTheme mixed = new SubstanceMixTheme(<br>
044:         * &nbsp;&nbsp;SubstanceAquaTheme(), SubstanceBottleGreenTheme());<br>
045:         * SubstanceLookAndFeel.setCurrentTheme(mixed);<br>
046:         * for (Frame frame : Frame.getFrames()) {<br>
047:         * &nbsp;&nbsp;SwingUtilities.updateComponentTreeUI(frame);<br>
048:         * }
049:         * </code><br>
050:         * This class is part of officially supported API.
051:         * 
052:         * @author Kirill Grouchnikov
053:         */
054:        public class SubstanceMixTheme extends SubstanceTheme {
055:            /**
056:             * The original themes.
057:             */
058:            private SubstanceTheme[] originalThemes;
059:
060:            /**
061:             * Creates a new mixed theme.
062:             * 
063:             * @param originalThemes
064:             *            The original themes.
065:             */
066:            public SubstanceMixTheme(SubstanceTheme... originalThemes) {
067:                super (new MixColorScheme(getSchemes(originalThemes)),
068:                        getName(originalThemes), ThemeKind.MIXED);
069:                this .originalThemes = originalThemes;
070:            }
071:
072:            /**
073:             * Returns the color schemes of the specified themes.
074:             * 
075:             * @param themes
076:             *            Themes array.
077:             * @return Color schemes array, each entry corresponding to an entry in the
078:             *         input theme array.
079:             */
080:            private static ColorScheme[] getSchemes(SubstanceTheme... themes) {
081:                ColorScheme[] result = new ColorScheme[themes.length];
082:                for (int i = 0; i < themes.length; i++) {
083:                    result[i] = themes[i].getColorScheme();
084:                }
085:                return result;
086:            }
087:
088:            /**
089:             * Returns the name of a mixed theme that is based on the specified themes.
090:             * 
091:             * @param themes
092:             *            Themes array.
093:             * @return Name of a mixed theme that is based on the specified themes.
094:             */
095:            private static String getName(SubstanceTheme... themes) {
096:                StringBuffer idBuf = new StringBuffer();
097:                idBuf.append("Mixed ");
098:                String delim = "";
099:                for (SubstanceTheme theme : themes) {
100:                    idBuf.append(delim);
101:                    idBuf.append(theme.getDisplayName());
102:                    delim = " & ";
103:                }
104:                return idBuf.toString();
105:            }
106:
107:            /**
108:             * Returns the original themes.
109:             * 
110:             * @return The original themes.
111:             */
112:            public SubstanceTheme[] getOriginalThemes() {
113:                return this .originalThemes;
114:            }
115:
116:            /*
117:             * (non-Javadoc)
118:             * 
119:             * @see org.jvnet.substance.theme.SubstanceTheme#tint(double)
120:             */
121:            @Override
122:            public SubstanceTheme tint(double tintFactor) {
123:                SubstanceTheme[] tinted = new SubstanceTheme[this .originalThemes.length];
124:                for (int i = 0; i < this .originalThemes.length; i++)
125:                    tinted[i] = this .originalThemes[i].tint(tintFactor);
126:                return new SubstanceMixTheme(tinted);
127:            }
128:
129:            /*
130:             * (non-Javadoc)
131:             * 
132:             * @see org.jvnet.substance.theme.SubstanceTheme#tone(double)
133:             */
134:            @Override
135:            public SubstanceTheme tone(double toneFactor) {
136:                SubstanceTheme[] toned = new SubstanceTheme[this .originalThemes.length];
137:                for (int i = 0; i < this .originalThemes.length; i++)
138:                    toned[i] = this .originalThemes[i].tone(toneFactor);
139:                return new SubstanceMixTheme(toned);
140:            }
141:
142:            /*
143:             * (non-Javadoc)
144:             * 
145:             * @see org.jvnet.substance.theme.SubstanceTheme#shade(double)
146:             */
147:            @Override
148:            public SubstanceTheme shade(double shadeFactor) {
149:                SubstanceTheme[] shaded = new SubstanceTheme[this .originalThemes.length];
150:                for (int i = 0; i < this .originalThemes.length; i++)
151:                    shaded[i] = this .originalThemes[i].shade(shadeFactor);
152:                return new SubstanceMixTheme(shaded);
153:            }
154:
155:            /*
156:             * (non-Javadoc)
157:             * 
158:             * @see org.jvnet.substance.theme.SubstanceTheme#saturate(double, boolean)
159:             */
160:            @Override
161:            public SubstanceTheme saturate(double saturateFactor,
162:                    boolean toSaturateEverything) {
163:                SubstanceTheme[] saturated = new SubstanceTheme[this .originalThemes.length];
164:                for (int i = 0; i < this .originalThemes.length; i++)
165:                    saturated[i] = this .originalThemes[i].saturate(
166:                            saturateFactor, toSaturateEverything);
167:                return new SubstanceMixTheme(saturated);
168:            }
169:
170:            /*
171:             * (non-Javadoc)
172:             * 
173:             * @see org.jvnet.substance.theme.SubstanceTheme#hueShift(double)
174:             */
175:            @Override
176:            public SubstanceTheme hueShift(double hueShiftFactor) {
177:                SubstanceTheme[] shaded = new SubstanceTheme[this .originalThemes.length];
178:                for (int i = 0; i < this .originalThemes.length; i++)
179:                    shaded[i] = this .originalThemes[i].hueShift(hueShiftFactor);
180:                return new SubstanceMixTheme(shaded);
181:            }
182:
183:            /*
184:             * (non-Javadoc)
185:             * 
186:             * @see org.jvnet.substance.theme.SubstanceTheme#invert()
187:             */
188:            @Override
189:            public SubstanceTheme invert() {
190:                SubstanceTheme[] inverted = new SubstanceTheme[this .originalThemes.length];
191:                for (int i = 0; i < this .originalThemes.length; i++)
192:                    inverted[i] = this .originalThemes[i].invert();
193:                return new SubstanceMixTheme(inverted);
194:            }
195:
196:            /*
197:             * (non-Javadoc)
198:             * 
199:             * @see org.jvnet.substance.theme.SubstanceTheme#negate()
200:             */
201:            @Override
202:            public SubstanceTheme negate() {
203:                SubstanceTheme[] negated = new SubstanceTheme[this .originalThemes.length];
204:                for (int i = 0; i < this .originalThemes.length; i++)
205:                    negated[i] = this .originalThemes[i].negate();
206:                return new SubstanceMixTheme(negated);
207:            }
208:
209:            //
210:            /*
211:             * (non-Javadoc)
212:             * 
213:             * @see org.jvnet.substance.theme.SubstanceTheme#getFirstTheme()
214:             */
215:            @Override
216:            public SubstanceTheme getFirstTheme() {
217:                return this .getOriginalThemes()[0];
218:            }
219:
220:            /*
221:             * (non-Javadoc)
222:             * 
223:             * @see org.jvnet.substance.theme.SubstanceTheme#getSecondTheme()
224:             */
225:            @Override
226:            public SubstanceTheme getSecondTheme() {
227:                return this .getOriginalThemes()[this .getOriginalThemes().length - 1];
228:            }
229:
230:            /*
231:             * (non-Javadoc)
232:             * 
233:             * @see org.jvnet.substance.theme.SubstanceTheme#getDefaultTheme()
234:             */
235:            @Override
236:            public SubstanceTheme getDefaultTheme() {
237:                return this .getOriginalThemes()[0].getDefaultTheme();
238:            }
239:
240:            /*
241:             * (non-Javadoc)
242:             * 
243:             * @see org.jvnet.substance.theme.SubstanceTheme#getDisabledTheme()
244:             */
245:            @Override
246:            public SubstanceTheme getDisabledTheme() {
247:                return this .getOriginalThemes()[0].getDisabledTheme();
248:            }
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.