Source Code Cross Referenced for CustomTaskButtonBorder.java in  » IDE-Netbeans » cvsclient » org » netbeans » lib » profiler » ui » components » 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 » IDE Netbeans » cvsclient » org.netbeans.lib.profiler.ui.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         * The Original Software is NetBeans. The Initial Developer of the Original
026:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
027:         * Microsystems, Inc. All Rights Reserved.
028:         *
029:         * If you wish your version of this file to be governed by only the CDDL
030:         * or only the GPL Version 2, indicate your decision by adding
031:         * "[Contributor] elects to include this software in this distribution
032:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
033:         * single choice of license, a recipient has the option to distribute
034:         * your version of this file under either the CDDL, the GPL Version 2 or
035:         * to extend the choice of license to its licensees as provided above.
036:         * However, if you add GPL Version 2 code and therefore, elected the GPL
037:         * Version 2 license, then the option applies only if the new code is
038:         * made subject to such option by the copyright holder.
039:         */
040:
041:        package org.netbeans.lib.profiler.ui.components;
042:
043:        import org.netbeans.lib.profiler.ui.UIUtils;
044:        import java.awt.*;
045:        import javax.swing.border.AbstractBorder;
046:
047:        /**
048:         *
049:         * @author  Jiri Sedlacek
050:         */
051:        public class CustomTaskButtonBorder extends AbstractBorder {
052:            //~ Static fields/initializers -----------------------------------------------------------------------------------------------
053:
054:            public static final int BORDER_STATE_DEFAULT = 10;
055:            public static final int BORDER_STATE_FOCUSED = 20;
056:            public static final int BORDER_STATE_SELECTED = 30;
057:            private static final Color OUTLINE_CLR = new Color(0, 0, 0);
058:            private static final Color FOCUSED_TOP_LIGHT_CLR = new Color(206,
059:                    231, 255);
060:            private static final Color FOCUSED_TOP_DARK_CLR = new Color(188,
061:                    212, 246);
062:            private static final Color FOCUSED_BOTTOM_LIGHT_CLR = new Color(
063:                    137, 173, 228);
064:            private static final Color FOCUSED_BOTTOM_DARK_CLR = new Color(105,
065:                    130, 238);
066:            private static final Color SELECTED_TOP_LIGHT_CLR = new Color(255,
067:                    240, 207);
068:            private static final Color SELECTED_TOP_DARK_CLR = new Color(253,
069:                    216, 137);
070:            private static final Color SELECTED_BOTTOM_LIGHT_CLR = new Color(
071:                    248, 178, 48);
072:            private static final Color SELECTED_BOTTOM_DARK_CLR = new Color(
073:                    229, 151, 0);
074:
075:            //~ Instance fields ----------------------------------------------------------------------------------------------------------
076:
077:            private Color DEFAULT_BOTTOM_DARK_CLR;
078:            private Color DEFAULT_BOTTOM_LIGHT_CLR;
079:            private Color DEFAULT_TOP_DARK_CLR;
080:            private Color DEFAULT_TOP_LIGHT_CLR;
081:            private Color backgroundColor;
082:            private Color backgroundFade;
083:            private Color startColor;
084:            private Color stopColor;
085:            private int borderState;
086:
087:            //~ Constructors -------------------------------------------------------------------------------------------------------------
088:
089:            /** Creates a new instance of CustomTaskButtonBorder */
090:            public CustomTaskButtonBorder(Color foreground, Color background) {
091:                super ();
092:                setForegroundColor(foreground);
093:                setBackgroundColor(background);
094:                setDefault();
095:            }
096:
097:            public CustomTaskButtonBorder(Color foreground, Color background,
098:                    int state) {
099:                this (foreground, background);
100:                setBorderState(state);
101:            }
102:
103:            //~ Methods ------------------------------------------------------------------------------------------------------------------
104:
105:            public void setBackgroundColor(Color background) {
106:                backgroundColor = background;
107:                backgroundFade = UIUtils
108:                        .getSafeColor(
109:                                ((3 * background.getRed()) + (1 * OUTLINE_CLR
110:                                        .getRed())) / 4, ((3 * background
111:                                        .getGreen()) + (1 * OUTLINE_CLR
112:                                        .getGreen())) / 4, ((3 * background
113:                                        .getBlue()) + (1 * OUTLINE_CLR
114:                                        .getBlue())) / 4);
115:            }
116:
117:            public Color getBackgroundColor() {
118:                return backgroundColor;
119:            }
120:
121:            public static Insets getBorderInsets() {
122:                return new Insets(4, 4, 4, 4);
123:            }
124:
125:            public static CustomTaskButtonBorder getDefaultInstance(
126:                    Color foreground, Color background) {
127:                return new CustomTaskButtonBorder(foreground, background,
128:                        BORDER_STATE_DEFAULT);
129:            }
130:
131:            public static CustomTaskButtonBorder getFocusedInstance(
132:                    Color foreground, Color background) {
133:                return new CustomTaskButtonBorder(foreground, background,
134:                        BORDER_STATE_FOCUSED);
135:            }
136:
137:            public Insets getBorderInsets(Component c) {
138:                return CustomTaskButtonBorder.getBorderInsets();
139:            }
140:
141:            public boolean isBorderOpaque() {
142:                return false;
143:            }
144:
145:            public void setBorderState(int state) {
146:                borderState = state;
147:            }
148:
149:            public int getBorderState() {
150:                return borderState;
151:            }
152:
153:            public void setFocused() {
154:                setBorderState(CustomTaskButtonBorder.BORDER_STATE_FOCUSED);
155:            }
156:
157:            public void setForegroundColor(Color foreground) {
158:                DEFAULT_TOP_LIGHT_CLR = UIUtils.getSafeColor(foreground
159:                        .getRed() + 15, foreground.getGreen() + 15, foreground
160:                        .getBlue() + 15);
161:                DEFAULT_TOP_DARK_CLR = UIUtils.getSafeColor(
162:                        foreground.getRed() + 8, foreground.getGreen() + 8,
163:                        foreground.getBlue() + 8);
164:                DEFAULT_BOTTOM_LIGHT_CLR = UIUtils.getSafeColor(foreground
165:                        .getRed() - 11, foreground.getGreen() - 11, foreground
166:                        .getBlue() - 11);
167:                DEFAULT_BOTTOM_DARK_CLR = UIUtils.getSafeColor(foreground
168:                        .getRed() - 25, foreground.getGreen() - 25, foreground
169:                        .getBlue() - 25);
170:            }
171:
172:            public Color getForegroundColor() {
173:                return UIUtils.getSafeColor(
174:                        DEFAULT_TOP_LIGHT_CLR.getRed() - 15,
175:                        DEFAULT_TOP_LIGHT_CLR.getGreen() - 15,
176:                        DEFAULT_TOP_LIGHT_CLR.getBlue() - 15);
177:            }
178:
179:            public static CustomTaskButtonBorder getSelectedInstance(
180:                    Color foreground, Color background) {
181:                return new CustomTaskButtonBorder(foreground, background,
182:                        BORDER_STATE_SELECTED);
183:            }
184:
185:            public void setDefault() {
186:                setBorderState(CustomTaskButtonBorder.BORDER_STATE_DEFAULT);
187:            }
188:
189:            public void setSelected() {
190:                setBorderState(CustomTaskButtonBorder.BORDER_STATE_SELECTED);
191:            }
192:
193:            public void paintBorder(Component c, Graphics g, int x, int y,
194:                    int width, int height) {
195:                if (!(g instanceof  Graphics2D)) {
196:                    return;
197:                }
198:
199:                Graphics2D g2d = (Graphics2D) g;
200:
201:                // Background points for "rounded" edges
202:                g2d.setColor(backgroundColor);
203:                g2d.drawLine(x, y, x, y);
204:                g2d.drawLine(x, (y + height) - 1, x, (y + height) - 1);
205:                g2d.drawLine((x + width) - 1, y, (x + width) - 1, y);
206:                g2d.drawLine((x + width) - 1, (y + height) - 1,
207:                        (x + width) - 1, (y + height) - 1);
208:
209:                // Fade points for smooth "rounded" edges
210:                g2d.setColor(backgroundFade);
211:                g2d.drawLine(x + 1, y, x + 1, y);
212:                g2d.drawLine(x, y + 1, x, y + 1);
213:                g2d.drawLine(x + 1, (y + height) - 1, x + 1, (y + height) - 1);
214:                g2d.drawLine(x, (y + height) - 2, x, (y + height) - 2);
215:                g2d.drawLine((x + width) - 1, y + 1, (x + width) - 1, y + 1);
216:                g2d.drawLine((x + width) - 2, y, (x + width) - 2, y);
217:                g2d.drawLine((x + width) - 2, (y + height) - 1,
218:                        (x + width) - 2, (y + height) - 1);
219:                g2d.drawLine((x + width) - 1, (y + height) - 2,
220:                        (x + width) - 1, (y + height) - 2);
221:
222:                // Points connecting outer black borders
223:                g2d.setColor(OUTLINE_CLR);
224:                g2d.drawLine(x + 1, y + 1, x + 1, y + 1);
225:                g2d.drawLine((x + width) - 2, y + 1, (x + width) - 2, y + 1);
226:                g2d.drawLine(x + 1, (y + height) - 2, x + 1, (y + height) - 2);
227:                g2d.drawLine((x + width) - 2, (y + height) - 2,
228:                        (x + width) - 2, (y + height) - 2);
229:
230:                // Outer black borders
231:                g2d.setColor(OUTLINE_CLR);
232:                g2d.drawLine(x + 2, y, (x + width) - 3, y);
233:                g2d.drawLine(x, y + 2, x, (y + height) - 3);
234:                g2d.drawLine((x + width) - 1, y + 2, (x + width) - 1,
235:                        (y + height) - 3);
236:                g2d.drawLine(x + 2, (y + height) - 1, (x + width) - 3,
237:                        (y + height) - 1);
238:
239:                // Top light line
240:                switch (borderState) {
241:                case BORDER_STATE_DEFAULT:
242:                    g2d.setColor(DEFAULT_TOP_LIGHT_CLR);
243:
244:                    break;
245:                case BORDER_STATE_FOCUSED:
246:                    g2d.setColor(FOCUSED_TOP_LIGHT_CLR);
247:
248:                    break;
249:                case BORDER_STATE_SELECTED:
250:                    g2d.setColor(SELECTED_TOP_LIGHT_CLR);
251:
252:                    break;
253:                }
254:
255:                g.drawLine(x + 2, y + 1, (x + width) - 3, y + 1);
256:
257:                // Top dark lines
258:                switch (borderState) {
259:                case BORDER_STATE_DEFAULT:
260:                    g2d.setColor(DEFAULT_TOP_DARK_CLR);
261:
262:                    break;
263:                case BORDER_STATE_FOCUSED:
264:                    g2d.setColor(FOCUSED_TOP_DARK_CLR);
265:
266:                    break;
267:                case BORDER_STATE_SELECTED:
268:                    g2d.setColor(SELECTED_TOP_DARK_CLR);
269:
270:                    break;
271:                }
272:
273:                g2d.drawLine(x + 1, y + 2, (x + width) - 2, y + 2);
274:                g2d.drawLine(x + 1, y + 3, (x + width) - 2, y + 3);
275:
276:                // Bottom light lines
277:                switch (borderState) {
278:                case BORDER_STATE_DEFAULT:
279:                    g2d.setColor(DEFAULT_BOTTOM_LIGHT_CLR);
280:
281:                    break;
282:                case BORDER_STATE_FOCUSED:
283:                    g2d.setColor(FOCUSED_BOTTOM_LIGHT_CLR);
284:
285:                    break;
286:                case BORDER_STATE_SELECTED:
287:                    g2d.setColor(SELECTED_BOTTOM_LIGHT_CLR);
288:
289:                    break;
290:                }
291:
292:                g2d.drawLine(x + 1, (y + height) - 4, (x + width) - 2,
293:                        (y + height) - 4);
294:                g2d.drawLine(x + 1, (y + height) - 3, (x + width) - 2,
295:                        (y + height) - 3);
296:
297:                // Bottom dark line
298:                switch (borderState) {
299:                case BORDER_STATE_DEFAULT:
300:                    g2d.setColor(DEFAULT_BOTTOM_DARK_CLR);
301:
302:                    break;
303:                case BORDER_STATE_FOCUSED:
304:                    g2d.setColor(FOCUSED_BOTTOM_DARK_CLR);
305:
306:                    break;
307:                case BORDER_STATE_SELECTED:
308:                    g2d.setColor(SELECTED_BOTTOM_DARK_CLR);
309:
310:                    break;
311:                }
312:
313:                g2d.drawLine(x + 2, (y + height) - 2, (x + width) - 3,
314:                        (y + height) - 2);
315:
316:                // Side gradients
317:                switch (borderState) {
318:                case BORDER_STATE_DEFAULT:
319:                    startColor = DEFAULT_TOP_DARK_CLR;
320:                    stopColor = DEFAULT_BOTTOM_LIGHT_CLR;
321:
322:                    break;
323:                case BORDER_STATE_FOCUSED:
324:                    startColor = FOCUSED_TOP_DARK_CLR;
325:                    stopColor = FOCUSED_BOTTOM_LIGHT_CLR;
326:
327:                    break;
328:                case BORDER_STATE_SELECTED:
329:                    startColor = SELECTED_TOP_DARK_CLR;
330:                    stopColor = SELECTED_BOTTOM_LIGHT_CLR;
331:
332:                    break;
333:                }
334:
335:                g2d.setPaint(new GradientPaint(x + 1, y + 3, startColor, x + 1,
336:                        (y + height) - 5, stopColor));
337:                g2d.fillRect(x + 1, y + 3, 3, height - 7);
338:                g2d.fillRect((x + width) - 4, y + 3, 3, height - 7);
339:            }
340:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.