Source Code Cross Referenced for StandardBorderPainter.java in  » Swing-Library » substance-look-feel » org » jvnet » substance » border » 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.border 
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.border;
031:
032:        import java.awt.*;
033:
034:        import org.jvnet.substance.color.ColorScheme;
035:        import org.jvnet.substance.scroll.SubstanceScrollBarButton;
036:        import org.jvnet.substance.utils.SubstanceColorUtilities;
037:        import org.jvnet.substance.utils.SubstanceSizeUtils;
038:
039:        /**
040:         * The default border painter. This class is part of officially supported API.
041:         * 
042:         * @author Kirill Grouchnikov
043:         */
044:        public class StandardBorderPainter implements  SubstanceBorderPainter {
045:            /*
046:             * (non-Javadoc)
047:             * 
048:             * @see org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName()
049:             */
050:            public String getDisplayName() {
051:                return "Standard";
052:            }
053:
054:            /*
055:             * (non-Javadoc)
056:             * 
057:             * @see org.jvnet.substance.border.SubstanceBorderPainter#paintBorder(java.awt.Graphics,
058:             *      java.awt.Component, int, int, java.awt.Shape, java.awt.Shape,
059:             *      org.jvnet.substance.color.ColorScheme,
060:             *      org.jvnet.substance.color.ColorScheme, float, boolean)
061:             */
062:            public void paintBorder(Graphics g, Component c, int width,
063:                    int height, Shape contour, Shape innerContour,
064:                    ColorScheme colorScheme1, ColorScheme colorScheme2,
065:                    float cyclePos, boolean useCyclePosAsInterpolation) {
066:                Graphics2D graphics = (Graphics2D) g.create();
067:                graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
068:                        RenderingHints.VALUE_ANTIALIAS_ON);
069:                graphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
070:                        RenderingHints.VALUE_STROKE_NORMALIZE);
071:
072:                ColorScheme interpolationScheme1 = colorScheme1;
073:                ColorScheme interpolationScheme2 = useCyclePosAsInterpolation ? colorScheme2
074:                        : colorScheme1;
075:
076:                double cycleCoef = 1.0 - cyclePos / 10.0;
077:
078:                Color topBorderColor = getTopBorderColor(interpolationScheme1,
079:                        interpolationScheme2, cycleCoef,
080:                        useCyclePosAsInterpolation);
081:                Color midBorderColor = getMidBorderColor(interpolationScheme1,
082:                        interpolationScheme2, cycleCoef,
083:                        useCyclePosAsInterpolation);
084:                Color bottomBorderColor = getBottomBorderColor(
085:                        interpolationScheme1, interpolationScheme2, cycleCoef,
086:                        useCyclePosAsInterpolation);
087:
088:                // Shape currClip = graphics.getClip();
089:                float strokeWidth = SubstanceSizeUtils
090:                        .getBorderStrokeWidth(SubstanceSizeUtils
091:                                .getComponentFontSize(c));
092:                int joinKind = (c instanceof  SubstanceScrollBarButton) ? BasicStroke.JOIN_BEVEL
093:                        : BasicStroke.JOIN_ROUND;
094:                int capKind = (c instanceof  SubstanceScrollBarButton) ? BasicStroke.CAP_BUTT
095:                        : BasicStroke.CAP_BUTT;
096:                graphics.setStroke(new BasicStroke(strokeWidth, capKind,
097:                        joinKind));
098:
099:                // Draw border
100:                if ((topBorderColor != null) && (midBorderColor != null)) {
101:                    GradientPaint gradientBorderTop = new GradientPaint(0, 0,
102:                            topBorderColor, 0, height / 2, midBorderColor);
103:                    Graphics2D topGr = (Graphics2D) graphics.create();
104:                    topGr.setPaint(gradientBorderTop);
105:                    topGr.clip(new Rectangle(0, 0, width, height / 2));
106:                    topGr.draw(contour);
107:                    topGr.dispose();
108:                    // graphics.setClip(currClip);
109:                }
110:
111:                if ((bottomBorderColor != null) && (midBorderColor != null)) {
112:                    Graphics2D bottomGr = (Graphics2D) graphics.create();
113:                    GradientPaint gradientBorderBottom = new GradientPaint(0,
114:                            height / 2, midBorderColor, 0, height,
115:                            bottomBorderColor);
116:                    bottomGr.setPaint(gradientBorderBottom);
117:                    bottomGr.clip(new Rectangle(0, height / 2, width,
118:                            1 + height / 2));
119:                    bottomGr.draw(contour);
120:                    bottomGr.dispose();
121:                }
122:
123:                graphics.dispose();
124:            }
125:
126:            /**
127:             * Computes the color of the top portion of the border. Override to provide
128:             * different visual.
129:             * 
130:             * @param interpolationScheme1
131:             *            The first interpolation scheme.
132:             * @param interpolationScheme2
133:             *            The second interpolation scheme.
134:             * @param cycleCoef
135:             *            Cycle coefficient.
136:             * @param useCyclePosAsInterpolation
137:             *            Indicates whether the cycle coefficient should be used as the
138:             *            interpolation parameter.
139:             * @return The color of the top portion of the border.
140:             */
141:            public Color getTopBorderColor(ColorScheme interpolationScheme1,
142:                    ColorScheme interpolationScheme2, double cycleCoef,
143:                    boolean useCyclePosAsInterpolation) {
144:                return SubstanceColorUtilities.getTopBorderColor(
145:                        interpolationScheme1, interpolationScheme2, cycleCoef);
146:            }
147:
148:            /**
149:             * Computes the color of the middle portion of the border. Override to
150:             * provide different visual.
151:             * 
152:             * @param interpolationScheme1
153:             *            The first interpolation scheme.
154:             * @param interpolationScheme2
155:             *            The second interpolation scheme.
156:             * @param cycleCoef
157:             *            Cycle coefficient.
158:             * @param useCyclePosAsInterpolation
159:             *            Indicates whether the cycle coefficient should be used as the
160:             *            interpolation parameter.
161:             * @return The color of the middle portion of the border.
162:             */
163:            public Color getMidBorderColor(ColorScheme interpolationScheme1,
164:                    ColorScheme interpolationScheme2, double cycleCoef,
165:                    boolean useCyclePosAsInterpolation) {
166:                return SubstanceColorUtilities.getMidBorderColor(
167:                        interpolationScheme1, interpolationScheme2, cycleCoef);
168:            }
169:
170:            /**
171:             * Computes the color of the bottom portion of the border. Override to
172:             * provide different visual.
173:             * 
174:             * @param interpolationScheme1
175:             *            The first interpolation scheme.
176:             * @param interpolationScheme2
177:             *            The second interpolation scheme.
178:             * @param cycleCoef
179:             *            Cycle coefficient.
180:             * @param useCyclePosAsInterpolation
181:             *            Indicates whether the cycle coefficient should be used as the
182:             *            interpolation parameter.
183:             * @return The color of the bottom portion of the border.
184:             */
185:            public Color getBottomBorderColor(ColorScheme interpolationScheme1,
186:                    ColorScheme interpolationScheme2, double cycleCoef,
187:                    boolean useCyclePosAsInterpolation) {
188:                return SubstanceColorUtilities.getBottomBorderColor(
189:                        interpolationScheme1, interpolationScheme2, cycleCoef);
190:            }
191:
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.