Source Code Cross Referenced for XPStyleBorder.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 XPStyleBorder 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 XPStyleBorder(Color foreground, Color background) {
091:                super ();
092:                setForegroundColor(foreground);
093:                setBackgroundColor(background);
094:                setSelected();
095:            }
096:
097:            public XPStyleBorder(Color foreground, Color background, int state) {
098:                this (foreground, background);
099:                setBorderState(state);
100:            }
101:
102:            //~ Methods ------------------------------------------------------------------------------------------------------------------
103:
104:            public void setBackgroundColor(Color background) {
105:                backgroundColor = background;
106:                backgroundFade = UIUtils
107:                        .getSafeColor(
108:                                ((3 * background.getRed()) + (1 * OUTLINE_CLR
109:                                        .getRed())) / 4, ((3 * background
110:                                        .getGreen()) + (1 * OUTLINE_CLR
111:                                        .getGreen())) / 4, ((3 * background
112:                                        .getBlue()) + (1 * OUTLINE_CLR
113:                                        .getBlue())) / 4);
114:            }
115:
116:            public Color getBackgroundColor() {
117:                return backgroundColor;
118:            }
119:
120:            public static Insets getBorderInsets() {
121:                return new Insets(4, 4, 4, 4);
122:            }
123:
124:            public static XPStyleBorder getDefaultInstance(Color foreground,
125:                    Color background) {
126:                return new XPStyleBorder(foreground, background,
127:                        BORDER_STATE_DEFAULT);
128:            }
129:
130:            public static XPStyleBorder getFocusedInstance(Color foreground,
131:                    Color background) {
132:                return new XPStyleBorder(foreground, background,
133:                        BORDER_STATE_FOCUSED);
134:            }
135:
136:            public Insets getBorderInsets(Component c) {
137:                return XPStyleBorder.getBorderInsets();
138:            }
139:
140:            public boolean isBorderOpaque() {
141:                return false;
142:            }
143:
144:            public void setBorderState(int state) {
145:                borderState = state;
146:            }
147:
148:            public int getBorderState() {
149:                return borderState;
150:            }
151:
152:            public void setFocused() {
153:                setBorderState(XPStyleBorder.BORDER_STATE_FOCUSED);
154:            }
155:
156:            public boolean isFocused() {
157:                return getBorderState() == XPStyleBorder.BORDER_STATE_FOCUSED;
158:            }
159:
160:            public void setForegroundColor(Color foreground) {
161:                DEFAULT_TOP_LIGHT_CLR = UIUtils.getSafeColor(foreground
162:                        .getRed() + 15, foreground.getGreen() + 15, foreground
163:                        .getBlue() + 15);
164:                DEFAULT_TOP_DARK_CLR = UIUtils.getSafeColor(
165:                        foreground.getRed() + 8, foreground.getGreen() + 8,
166:                        foreground.getBlue() + 8);
167:                DEFAULT_BOTTOM_LIGHT_CLR = UIUtils.getSafeColor(foreground
168:                        .getRed() - 11, foreground.getGreen() - 11, foreground
169:                        .getBlue() - 11);
170:                DEFAULT_BOTTOM_DARK_CLR = UIUtils.getSafeColor(foreground
171:                        .getRed() - 25, foreground.getGreen() - 25, foreground
172:                        .getBlue() - 25);
173:            }
174:
175:            public Color getForegroundColor() {
176:                return UIUtils.getSafeColor(Math.max(DEFAULT_TOP_LIGHT_CLR
177:                        .getRed() - 15, 0), Math.max(DEFAULT_TOP_LIGHT_CLR
178:                        .getGreen() - 15, 0), Math.max(DEFAULT_TOP_LIGHT_CLR
179:                        .getBlue() - 15, 0));
180:            }
181:
182:            public static XPStyleBorder getSelectedInstance(Color foreground,
183:                    Color background) {
184:                return new XPStyleBorder(foreground, background,
185:                        BORDER_STATE_SELECTED);
186:            }
187:
188:            public void setDefault() {
189:                setBorderState(XPStyleBorder.BORDER_STATE_DEFAULT);
190:            }
191:
192:            public boolean isDefault() {
193:                return getBorderState() == XPStyleBorder.BORDER_STATE_DEFAULT;
194:            }
195:
196:            public void setSelected() {
197:                setBorderState(XPStyleBorder.BORDER_STATE_SELECTED);
198:            }
199:
200:            public boolean isSelected() {
201:                return getBorderState() == XPStyleBorder.BORDER_STATE_SELECTED;
202:            }
203:
204:            public void paintBorder(Component c, Graphics g, int x, int y,
205:                    int width, int height) {
206:                if (!(g instanceof  Graphics2D)) {
207:                    return;
208:                }
209:
210:                Graphics2D g2d = (Graphics2D) g;
211:
212:                // Background points for "rounded" edges
213:                g2d.setColor(backgroundColor);
214:                g2d.drawLine(x, y, x, y);
215:                g2d.drawLine(x, (y + height) - 1, x, (y + height) - 1);
216:                g2d.drawLine((x + width) - 1, y, (x + width) - 1, y);
217:                g2d.drawLine((x + width) - 1, (y + height) - 1,
218:                        (x + width) - 1, (y + height) - 1);
219:
220:                // Fade points for smooth "rounded" edges
221:                g2d.setColor(backgroundFade);
222:                g2d.drawLine(x + 1, y, x + 1, y);
223:                g2d.drawLine(x, y + 1, x, y + 1);
224:                g2d.drawLine(x + 1, (y + height) - 1, x + 1, (y + height) - 1);
225:                g2d.drawLine(x, (y + height) - 2, x, (y + height) - 2);
226:                g2d.drawLine((x + width) - 1, y + 1, (x + width) - 1, y + 1);
227:                g2d.drawLine((x + width) - 2, y, (x + width) - 2, y);
228:                g2d.drawLine((x + width) - 2, (y + height) - 1,
229:                        (x + width) - 2, (y + height) - 1);
230:                g2d.drawLine((x + width) - 1, (y + height) - 2,
231:                        (x + width) - 1, (y + height) - 2);
232:
233:                // Points connecting outer black borders
234:                g2d.setColor(OUTLINE_CLR);
235:                g2d.drawLine(x + 1, y + 1, x + 1, y + 1);
236:                g2d.drawLine((x + width) - 2, y + 1, (x + width) - 2, y + 1);
237:                g2d.drawLine(x + 1, (y + height) - 2, x + 1, (y + height) - 2);
238:                g2d.drawLine((x + width) - 2, (y + height) - 2,
239:                        (x + width) - 2, (y + height) - 2);
240:
241:                // Outer black borders
242:                g2d.setColor(OUTLINE_CLR);
243:                g2d.drawLine(x + 2, y, (x + width) - 3, y);
244:                g2d.drawLine(x, y + 2, x, (y + height) - 3);
245:                g2d.drawLine((x + width) - 1, y + 2, (x + width) - 1,
246:                        (y + height) - 3);
247:                g2d.drawLine(x + 2, (y + height) - 1, (x + width) - 3,
248:                        (y + height) - 1);
249:
250:                // Top light line
251:                switch (borderState) {
252:                case BORDER_STATE_DEFAULT:
253:                    g2d.setColor(DEFAULT_TOP_LIGHT_CLR);
254:
255:                    break;
256:                case BORDER_STATE_FOCUSED:
257:                    g2d.setColor(FOCUSED_TOP_LIGHT_CLR);
258:
259:                    break;
260:                case BORDER_STATE_SELECTED:
261:                    g2d.setColor(SELECTED_TOP_LIGHT_CLR);
262:
263:                    break;
264:                }
265:
266:                g.drawLine(x + 2, y + 1, (x + width) - 3, y + 1);
267:
268:                // Top dark lines
269:                switch (borderState) {
270:                case BORDER_STATE_DEFAULT:
271:                    g2d.setColor(DEFAULT_TOP_DARK_CLR);
272:
273:                    break;
274:                case BORDER_STATE_FOCUSED:
275:                    g2d.setColor(FOCUSED_TOP_DARK_CLR);
276:
277:                    break;
278:                case BORDER_STATE_SELECTED:
279:                    g2d.setColor(SELECTED_TOP_DARK_CLR);
280:
281:                    break;
282:                }
283:
284:                g2d.drawLine(x + 1, y + 2, (x + width) - 2, y + 2);
285:                g2d.drawLine(x + 1, y + 3, (x + width) - 2, y + 3);
286:
287:                // Bottom light lines
288:                switch (borderState) {
289:                case BORDER_STATE_DEFAULT:
290:                    g2d.setColor(DEFAULT_BOTTOM_LIGHT_CLR);
291:
292:                    break;
293:                case BORDER_STATE_FOCUSED:
294:                    g2d.setColor(FOCUSED_BOTTOM_LIGHT_CLR);
295:
296:                    break;
297:                case BORDER_STATE_SELECTED:
298:                    g2d.setColor(SELECTED_BOTTOM_LIGHT_CLR);
299:
300:                    break;
301:                }
302:
303:                g2d.drawLine(x + 1, (y + height) - 4, (x + width) - 2,
304:                        (y + height) - 4);
305:                g2d.drawLine(x + 1, (y + height) - 3, (x + width) - 2,
306:                        (y + height) - 3);
307:
308:                // Bottom dark line
309:                switch (borderState) {
310:                case BORDER_STATE_DEFAULT:
311:                    g2d.setColor(DEFAULT_BOTTOM_DARK_CLR);
312:
313:                    break;
314:                case BORDER_STATE_FOCUSED:
315:                    g2d.setColor(FOCUSED_BOTTOM_DARK_CLR);
316:
317:                    break;
318:                case BORDER_STATE_SELECTED:
319:                    g2d.setColor(SELECTED_BOTTOM_DARK_CLR);
320:
321:                    break;
322:                }
323:
324:                g2d.drawLine(x + 2, (y + height) - 2, (x + width) - 3,
325:                        (y + height) - 2);
326:
327:                // Side gradients
328:                switch (borderState) {
329:                case BORDER_STATE_DEFAULT:
330:                    startColor = DEFAULT_TOP_DARK_CLR;
331:                    stopColor = DEFAULT_BOTTOM_LIGHT_CLR;
332:
333:                    break;
334:                case BORDER_STATE_FOCUSED:
335:                    startColor = FOCUSED_TOP_DARK_CLR;
336:                    stopColor = FOCUSED_BOTTOM_LIGHT_CLR;
337:
338:                    break;
339:                case BORDER_STATE_SELECTED:
340:                    startColor = SELECTED_TOP_DARK_CLR;
341:                    stopColor = SELECTED_BOTTOM_LIGHT_CLR;
342:
343:                    break;
344:                }
345:
346:                g2d.setPaint(new GradientPaint(x + 1, y + 3, startColor, x + 1,
347:                        (y + height) - 5, stopColor));
348:                g2d.fillRect(x + 1, y + 3, 3, height - 7);
349:                g2d.fillRect((x + width) - 4, y + 3, 3, height - 7);
350:            }
351:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.