Source Code Cross Referenced for WaveGradientPainter.java in  » Swing-Library » substance-look-feel » org » jvnet » substance » painter » 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.painter 
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.painter;
031:
032:        import java.awt.*;
033:        import java.awt.geom.GeneralPath;
034:        import java.awt.image.BufferedImage;
035:
036:        import org.jvnet.substance.color.ColorScheme;
037:        import org.jvnet.substance.utils.SubstanceColorUtilities;
038:        import org.jvnet.substance.utils.SubstanceCoreUtilities;
039:
040:        /**
041:         * Gradient painter that returns images with flat appearance and wavy color
042:         * areas. This class is part of officially supported API.
043:         * 
044:         * @author Kirill Grouchnikov
045:         */
046:        public class WaveGradientPainter extends BaseGradientPainter {
047:            /*
048:             * (non-Javadoc)
049:             * 
050:             * @see org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName()
051:             */
052:            public String getDisplayName() {
053:                return "Wave";
054:            }
055:
056:            /*
057:             * (non-Javadoc)
058:             * 
059:             * @see org.jvnet.substance.painter.SubstanceGradientPainter#getContourBackground(int,
060:             *      int, java.awt.Shape, boolean, org.jvnet.substance.color.ColorScheme,
061:             *      org.jvnet.substance.color.ColorScheme, float, boolean, boolean)
062:             */
063:            public BufferedImage getContourBackground(int width, int height,
064:                    Shape contour, boolean isFocused, ColorScheme colorScheme1,
065:                    ColorScheme colorScheme2, float cyclePos, boolean hasShine,
066:                    boolean useCyclePosAsInterpolation) {
067:
068:                BufferedImage mixResult = this .getMixContourBackground(width,
069:                        height, contour, isFocused, colorScheme1, colorScheme2,
070:                        cyclePos, hasShine, useCyclePosAsInterpolation);
071:                if (mixResult != null)
072:                    return mixResult;
073:
074:                // create rectangular background and later draw it on
075:                // result image with contour clip.
076:                BufferedImage rectangular = SubstanceCoreUtilities
077:                        .getBlankImage(width, height);
078:                Graphics2D rgraphics = (Graphics2D) rectangular.getGraphics();
079:                rgraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
080:                        RenderingHints.VALUE_ANTIALIAS_ON);
081:
082:                ColorScheme interpolationScheme1 = colorScheme1;
083:                ColorScheme interpolationScheme2 = useCyclePosAsInterpolation ? colorScheme2
084:                        : colorScheme1;
085:
086:                double cycleCoef = 1.0 - cyclePos / 10.0;
087:
088:                //		Color topBorderColor = SubstanceColorUtilities.getTopBorderColor(
089:                //				interpolationScheme1, interpolationScheme2, cycleCoef);
090:                //		Color midBorderColor = SubstanceColorUtilities.getMidBorderColor(
091:                //				interpolationScheme1, interpolationScheme2, cycleCoef);
092:                //		Color bottomBorderColor = SubstanceColorUtilities.getBottomBorderColor(
093:                //				interpolationScheme1, interpolationScheme2, cycleCoef);
094:
095:                Color darkFillColor = SubstanceColorUtilities.getTopFillColor(
096:                        interpolationScheme1, interpolationScheme2, cycleCoef,
097:                        useCyclePosAsInterpolation);
098:                Color midFillColor = SubstanceColorUtilities.getMidFillColor(
099:                        interpolationScheme1, interpolationScheme2, cycleCoef,
100:                        useCyclePosAsInterpolation);
101:                Color lightFillColor = SubstanceColorUtilities
102:                        .getBottomFillColor(interpolationScheme1,
103:                                interpolationScheme2, cycleCoef,
104:                                useCyclePosAsInterpolation);
105:
106:                if (!useCyclePosAsInterpolation) {
107:                    lightFillColor = SubstanceColorUtilities
108:                            .getInterpolatedColor(interpolationScheme1
109:                                    .getUltraLightColor(), interpolationScheme1
110:                                    .getExtraLightColor(), cycleCoef);
111:                    midFillColor = SubstanceColorUtilities
112:                            .getInterpolatedColor(interpolationScheme1
113:                                    .getLightColor(), interpolationScheme1
114:                                    .getMidColor(), cycleCoef);
115:                    darkFillColor = SubstanceColorUtilities
116:                            .getInterpolatedColor(interpolationScheme1
117:                                    .getMidColor(), interpolationScheme1
118:                                    .getMidColor(), cycleCoef);
119:                } else {
120:                    lightFillColor = SubstanceColorUtilities
121:                            .getInterpolatedColor(interpolationScheme1
122:                                    .getUltraLightColor(), interpolationScheme2
123:                                    .getUltraLightColor(), cycleCoef);
124:                    midFillColor = SubstanceColorUtilities
125:                            .getInterpolatedColor(interpolationScheme1
126:                                    .getLightColor(), interpolationScheme2
127:                                    .getLightColor(), cycleCoef);
128:                    darkFillColor = SubstanceColorUtilities
129:                            .getInterpolatedColor(interpolationScheme1
130:                                    .getMidColor(), interpolationScheme2
131:                                    .getMidColor(), cycleCoef);
132:                }
133:
134:                // Fill background
135:                GradientPaint gradientTop = new GradientPaint(0, 0,
136:                        lightFillColor, width / 4, height / 2, midFillColor);
137:                GeneralPath clipTop = new GeneralPath();
138:                clipTop.moveTo(0, 0);
139:                clipTop.lineTo(width, 0);
140:                clipTop.curveTo(5 * width / 6, height / 3, 3 * width / 4,
141:                        height / 2, width / 2, height / 2);
142:                clipTop.curveTo(width / 3, height / 2, width / 4, height, 0,
143:                        7 * height / 8);
144:                clipTop.lineTo(0, 0);
145:
146:                rgraphics.setClip(clipTop);
147:                rgraphics.setPaint(gradientTop);
148:                rgraphics.fillRect(0, 0, width, height);
149:
150:                GradientPaint gradientBottom = new GradientPaint(2 * width / 3,
151:                        2 * height / 3, darkFillColor, width, height,
152:                        midFillColor);
153:
154:                GeneralPath clipBottom = new GeneralPath();
155:                clipBottom.moveTo(0, height);
156:                clipBottom.lineTo(width, height);
157:                clipBottom.lineTo(width, 0);
158:                clipBottom.curveTo(5 * width / 6, height / 3, 3 * width / 4,
159:                        height / 2, width / 2, height / 2);
160:                clipBottom.curveTo(width / 3, height / 2, width / 4, height, 0,
161:                        7 * height / 8);
162:                clipBottom.lineTo(0, height);
163:
164:                rgraphics.setClip(clipBottom);
165:                rgraphics.setPaint(gradientBottom);
166:                rgraphics.fillRect(0, 0, width, height);
167:
168:                rgraphics.setClip(null);
169:                GeneralPath mid = new GeneralPath();
170:                mid.moveTo(width, 0);
171:                mid.curveTo(5 * width / 6, height / 3, 3 * width / 4,
172:                        height / 2, width / 2, height / 2);
173:                mid.curveTo(width / 3, height / 2, width / 4, height, 0,
174:                        7 * height / 8);
175:                rgraphics.draw(mid);
176:
177:                BufferedImage image = SubstanceCoreUtilities.getBlankImage(
178:                        width, height);
179:                Graphics2D graphics = (Graphics2D) image.getGraphics();
180:                graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
181:                        RenderingHints.VALUE_ANTIALIAS_ON);
182:
183:                graphics.setClip(contour);
184:                graphics.drawImage(rectangular, 0, 0, null);
185:
186:                graphics.setClip(null);
187:
188:                //		// Draw border
189:                //		GradientPaint gradientBorderTop = new GradientPaint(0, 0,
190:                //				topBorderColor, 0, height / 2, midBorderColor);
191:                //		graphics.setPaint(gradientBorderTop);
192:                //		graphics.setClip(0, 0, width, height / 2);
193:                //		graphics.draw(contour);
194:                //
195:                //		GradientPaint gradientBorderBottom = new GradientPaint(0, height / 2,
196:                //				midBorderColor, 0, height - 2, bottomBorderColor);
197:                //		graphics.setPaint(gradientBorderBottom);
198:                //		graphics.setClip(0, height / 2, width, 1 + height / 2);
199:                //		graphics.draw(contour);
200:
201:                return image;
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.