Source Code Cross Referenced for SmoothGradientButtonUI.java in  » Database-Client » executequery » org » underworldlabs » swing » plaf » smoothgradient » 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 » Database Client » executequery » org.underworldlabs.swing.plaf.smoothgradient 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SmoothGradientButtonUI.java
003:         *
004:         * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License
008:         * as published by the Free Software Foundation; either version 2
009:         * of the License, or any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         *
020:         */
021:
022:        package org.underworldlabs.swing.plaf.smoothgradient;
023:
024:        import java.awt.Container;
025:        import java.awt.Graphics;
026:        import java.awt.Rectangle;
027:
028:        import javax.swing.AbstractButton;
029:        import javax.swing.ButtonModel;
030:        import javax.swing.JButton;
031:        import javax.swing.JComponent;
032:        import javax.swing.JToolBar;
033:        import javax.swing.UIManager;
034:        import javax.swing.border.EmptyBorder;
035:        import javax.swing.plaf.ComponentUI;
036:        import javax.swing.plaf.metal.MetalButtonUI;
037:
038:        /* ----------------------------------------------------------
039:         * CVS NOTE: Changes to the CVS repository prior to the 
040:         *           release of version 3.0.0beta1 has meant a 
041:         *           resetting of CVS revision numbers.
042:         * ----------------------------------------------------------
043:         */
044:
045:        /**
046:         *
047:         * @author   Takis Diakoumis
048:         * @version  $Revision: 1.4 $
049:         * @date     $Date: 2006/05/14 06:56:07 $
050:         */
051:        public class SmoothGradientButtonUI extends MetalButtonUI {
052:
053:            private static final SmoothGradientButtonUI INSTANCE = new SmoothGradientButtonUI();
054:
055:            private boolean borderPaintsFocus;
056:
057:            public static ComponentUI createUI(JComponent b) {
058:                return INSTANCE;
059:            }
060:
061:            /**
062:             * Installs defaults and honors the client property <code>isNarrow</code>.
063:             */
064:            public void installDefaults(AbstractButton b) {
065:                super .installDefaults(b);
066:                //        PolishedLookUtils.installNarrowMargin(b, getPropertyPrefix());
067:                borderPaintsFocus = Boolean.TRUE.equals(UIManager
068:                        .get("Button.borderPaintsFocus"));
069:            }
070:
071:            /**
072:             * Installs an extra listener for a change of the isNarrow property.
073:             */
074:            /*
075:               public void installListeners(AbstractButton b) {
076:                   super.installListeners(b);
077:                   PropertyChangeListener listener =
078:                       new ButtonMarginListener(getPropertyPrefix());
079:                   b.putClientProperty(ButtonMarginListener.CLIENT_KEY, listener);
080:                   b.addPropertyChangeListener(Options.IS_NARROW_KEY, listener);
081:               }
082:             */
083:            /**
084:             * Uninstalls the extra listener for a change of the isNarrow property.
085:             */
086:            /*
087:               public void uninstallListeners(AbstractButton b) {
088:                   super.uninstallListeners(b);
089:                   PropertyChangeListener listener =
090:                       (PropertyChangeListener) b.getClientProperty(
091:                           ButtonMarginListener.CLIENT_KEY);
092:                   b.removePropertyChangeListener(listener);
093:               }
094:             */
095:            // Painting ***************************************************************
096:            public void update(Graphics g, JComponent c) {
097:                AbstractButton b = (AbstractButton) c;
098:                if (c.isOpaque()) {
099:                    if (isToolBarButton(b)) {
100:                        c.setOpaque(false);
101:                    } else if (b.isContentAreaFilled()) {
102:                        g.setColor(c.getBackground());
103:                        g.fillRect(0, 0, c.getWidth(), c.getHeight());
104:
105:                        if (is3D(b)) {
106:                            Rectangle r = new Rectangle(1, 1, c.getWidth() - 2,
107:                                    c.getHeight() - 1);
108:                            SmoothGradientUtils.add3DEffekt(g, r);
109:                        }
110:                    }
111:                }
112:                paint(g, c);
113:            }
114:
115:            /**
116:             * Paints the focus with close to the button's border.
117:             */
118:            protected void paintFocus(Graphics g, AbstractButton b,
119:                    Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
120:
121:                if (borderPaintsFocus) {
122:                    return;
123:                }
124:
125:                boolean isDefault = b instanceof  JButton
126:                        && ((JButton) b).isDefaultButton();
127:                int topLeftInset = isDefault ? 3 : 2;
128:                int width = b.getWidth() - 1 - topLeftInset * 2;
129:                int height = b.getHeight() - 1 - topLeftInset * 2;
130:
131:                g.setColor(getFocusColor());
132:                g.drawRect(topLeftInset, topLeftInset, width - 1, height - 1);
133:            }
134:
135:            // Private Helper Code **************************************************************
136:
137:            /**
138:             * Checks and answers if this is button is in a tool bar.
139:             * 
140:             * @param b   the button to check
141:             * @return true if in tool bar, false otherwise
142:             */
143:            protected boolean isToolBarButton(AbstractButton b) {
144:                Container parent = b.getParent();
145:                return parent != null
146:                        && (parent instanceof  JToolBar || parent.getParent() instanceof  JToolBar);
147:            }
148:
149:            /**
150:             * Checks and answers if this button shall use a pseudo 3D effect
151:             * 
152:             * @param b  the button to check
153:             * @return true indicates a 3D effect, false flat
154:             */
155:            protected boolean is3D(AbstractButton b) {
156:                if (SmoothGradientUtils.force3D(b))
157:                    return true;
158:                if (SmoothGradientUtils.forceFlat(b))
159:                    return false;
160:                ButtonModel model = b.getModel();
161:                return SmoothGradientUtils.is3D("Button.")
162:                        && b.isBorderPainted() && model.isEnabled()
163:                        && !(model.isPressed() && model.isArmed())
164:                        && !(b.getBorder() instanceof  EmptyBorder);
165:
166:                /*
167:                 * Implementation note regarding the last line: instead of checking 
168:                 * for the EmptyBorder in NetBeans, I'd prefer to just check the
169:                 * 'borderPainted' property. I'd recommend to the NetBeans developers,
170:                 * to switch this property on and off, instead of changing the border.
171:                 */
172:            }
173:
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.