Source Code Cross Referenced for SmoothGradientArrowButton.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:         * SmoothGradientArrowButton.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.Color;
025:        import java.awt.Graphics;
026:        import java.awt.Rectangle;
027:
028:        import javax.swing.ButtonModel;
029:        import javax.swing.UIManager;
030:        import javax.swing.plaf.metal.MetalLookAndFeel;
031:        import javax.swing.plaf.metal.MetalScrollButton;
032:
033:        /* ----------------------------------------------------------
034:         * CVS NOTE: Changes to the CVS repository prior to the 
035:         *           release of version 3.0.0beta1 has meant a 
036:         *           resetting of CVS revision numbers.
037:         * ----------------------------------------------------------
038:         */
039:
040:        /**
041:         *
042:         *
043:         * @author Karsten Lentzsch
044:         * @author   Takis Diakoumis
045:         * @version  $Revision: 1.4 $
046:         * @date     $Date: 2006/05/14 06:56:07 $
047:         */
048:        final class SmoothGradientArrowButton extends MetalScrollButton {
049:
050:            private static Color shadowColor;
051:            private static Color highlightColor;
052:
053:            private boolean isFreeStanding;
054:
055:            public SmoothGradientArrowButton(int direction, int width,
056:                    boolean freeStanding) {
057:                super (direction, width, freeStanding);
058:                shadowColor = UIManager.getColor("ScrollBar.darkShadow");
059:                highlightColor = UIManager.getColor("ScrollBar.highlight");
060:                isFreeStanding = freeStanding;
061:            }
062:
063:            public void setFreeStanding(boolean freeStanding) {
064:                super .setFreeStanding(freeStanding);
065:                isFreeStanding = freeStanding;
066:            }
067:
068:            public void paint(Graphics g) {
069:                boolean leftToRight = SmoothGradientUtils.isLeftToRight(this );
070:                boolean isEnabled = getParent().isEnabled();
071:                boolean isPressed = getModel().isPressed();
072:
073:                Color arrowColor = isEnabled ? MetalLookAndFeel
074:                        .getControlInfo() : MetalLookAndFeel
075:                        .getControlDisabled();
076:                int width = getWidth();
077:                int height = getHeight();
078:                int w = width;
079:                int h = height;
080:                int arrowHeight = (height + 1) / 4;
081:
082:                g.setColor(isPressed ? MetalLookAndFeel.getControlShadow()
083:                        : getBackground());
084:                g.fillRect(0, 0, width, height);
085:
086:                if (getDirection() == NORTH) {
087:                    paintNorth(g, leftToRight, isEnabled, arrowColor,
088:                            isPressed, width, height, w, h, arrowHeight);
089:                } else if (getDirection() == SOUTH) {
090:                    paintSouth(g, leftToRight, isEnabled, arrowColor,
091:                            isPressed, width, height, w, h, arrowHeight);
092:                } else if (getDirection() == EAST) {
093:                    paintEast(g, isEnabled, arrowColor, isPressed, width,
094:                            height, w, h, arrowHeight);
095:                } else if (getDirection() == WEST) {
096:                    paintWest(g, isEnabled, arrowColor, isPressed, width,
097:                            height, w, h, arrowHeight);
098:                }
099:                if (SmoothGradientUtils.is3D("ScrollBar."))
100:                    paint3D(g);
101:            }
102:
103:            private void paintWest(Graphics g, boolean isEnabled,
104:                    Color arrowColor, boolean isPressed, int width, int height,
105:                    int w, int h, int arrowHeight) {
106:
107:                if (!isFreeStanding) {
108:                    height += 2;
109:                    width += 1;
110:                    g.translate(-1, 0);
111:                }
112:
113:                // Draw the arrow
114:                g.setColor(arrowColor);
115:
116:                int startX = (((w + 1) - arrowHeight) / 2);
117:                int startY = (h / 2);
118:
119:                for (int line = 0; line < arrowHeight; line++) {
120:                    g.drawLine(startX + line, startY - line, startX + line,
121:                            startY + line + 1);
122:                }
123:
124:                if (isEnabled) {
125:                    g.setColor(highlightColor);
126:
127:                    if (!isPressed) {
128:                        g.drawLine(1, 1, width - 1, 1);
129:                        g.drawLine(1, 1, 1, height - 3);
130:                    }
131:                    g.drawLine(1, height - 1, width - 1, height - 1);
132:
133:                    g.setColor(shadowColor);
134:                    g.drawLine(0, 0, width - 1, 0);
135:                    g.drawLine(0, 0, 0, height - 2);
136:                    g.drawLine(2, height - 2, width - 1, height - 2);
137:                } else {
138:                    SmoothGradientUtils.drawDisabledBorder(g, 0, 0, width + 1,
139:                            height);
140:                }
141:
142:                if (!isFreeStanding) {
143:                    height -= 2;
144:                    width -= 1;
145:                    g.translate(1, 0);
146:                }
147:            }
148:
149:            private void paintEast(Graphics g, boolean isEnabled,
150:                    Color arrowColor, boolean isPressed, int width, int height,
151:                    int w, int h, int arrowHeight) {
152:                if (!isFreeStanding) {
153:                    height += 2;
154:                    width += 1;
155:                }
156:
157:                // Draw the arrow
158:                g.setColor(arrowColor);
159:
160:                int startX = (((w + 1) - arrowHeight) / 2) + arrowHeight - 1;
161:                int startY = (h / 2);
162:                for (int line = 0; line < arrowHeight; line++) {
163:                    g.drawLine(startX - line, startY - line, startX - line,
164:                            startY + line + 1);
165:                }
166:
167:                if (isEnabled) {
168:                    g.setColor(highlightColor);
169:                    if (!isPressed) {
170:                        g.drawLine(0, 1, width - 3, 1);
171:                        g.drawLine(0, 1, 0, height - 3);
172:                    }
173:                    g.drawLine(width - 1, 1, width - 1, height - 1);
174:                    g.drawLine(0, height - 1, width - 1, height - 1);
175:
176:                    g.setColor(shadowColor);
177:                    g.drawLine(0, 0, width - 2, 0);
178:                    g.drawLine(width - 2, 1, width - 2, height - 2);
179:                    g.drawLine(0, height - 2, width - 2, height - 2);
180:                } else {
181:                    SmoothGradientUtils.drawDisabledBorder(g, -1, 0, width + 1,
182:                            height);
183:                }
184:                if (!isFreeStanding) {
185:                    height -= 2;
186:                    width -= 1;
187:                }
188:            }
189:
190:            private void paintSouth(Graphics g, boolean leftToRight,
191:                    boolean isEnabled, Color arrowColor, boolean isPressed,
192:                    int width, int height, int w, int h, int arrowHeight) {
193:
194:                if (!isFreeStanding) {
195:                    height += 1;
196:                    if (!leftToRight) {
197:                        width += 1;
198:                        g.translate(-1, 0);
199:                    } else {
200:                        width += 2;
201:                    }
202:                }
203:
204:                // Draw the arrow
205:                g.setColor(arrowColor);
206:
207:                int startY = (((h + 1) - arrowHeight) / 2) + arrowHeight - 1;
208:                int startX = (w / 2);
209:
210:                //	    System.out.println( "startX2 :" + startX + " startY2 :"+startY);
211:
212:                for (int line = 0; line < arrowHeight; line++) {
213:                    g.drawLine(startX - line, startY - line, startX + line + 1,
214:                            startY - line);
215:                }
216:
217:                if (isEnabled) {
218:                    g.setColor(highlightColor);
219:                    if (!isPressed) {
220:                        g.drawLine(1, 0, width - 3, 0);
221:                        g.drawLine(1, 0, 1, height - 3);
222:                    }
223:                    g.drawLine(1, height - 1, width - 1, height - 1);
224:                    g.drawLine(width - 1, 0, width - 1, height - 1);
225:
226:                    g.setColor(shadowColor);
227:                    g.drawLine(0, 0, 0, height - 2);
228:                    g.drawLine(width - 2, 0, width - 2, height - 2);
229:                    g.drawLine(1, height - 2, width - 2, height - 2);
230:                } else {
231:                    SmoothGradientUtils.drawDisabledBorder(g, 0, -1, width,
232:                            height + 1);
233:                }
234:
235:                if (!isFreeStanding) {
236:                    height -= 1;
237:                    if (!leftToRight) {
238:                        width -= 1;
239:                        g.translate(1, 0);
240:                    } else {
241:                        width -= 2;
242:                    }
243:                }
244:            }
245:
246:            private void paintNorth(Graphics g, boolean leftToRight,
247:                    boolean isEnabled, Color arrowColor, boolean isPressed,
248:                    int width, int height, int w, int h, int arrowHeight) {
249:                if (!isFreeStanding) {
250:                    height += 1;
251:                    g.translate(0, -1);
252:                    if (!leftToRight) {
253:                        width += 1;
254:                        g.translate(-1, 0);
255:                    } else {
256:                        width += 2;
257:                    }
258:                }
259:
260:                // Draw the arrow
261:                g.setColor(arrowColor);
262:                int startY = ((h + 1) - arrowHeight) / 2;
263:                int startX = (w / 2);
264:                // System.out.println( "startX :" + startX + " startY :"+startY);
265:                for (int line = 0; line < arrowHeight; line++) {
266:                    g.drawLine(startX - line, startY + line, startX + line + 1,
267:                            startY + line);
268:                }
269:
270:                if (isEnabled) {
271:                    g.setColor(highlightColor);
272:
273:                    if (!isPressed) {
274:                        g.drawLine(1, 1, width - 3, 1);
275:                        g.drawLine(1, 1, 1, height - 1);
276:                    }
277:
278:                    g.drawLine(width - 1, 1, width - 1, height - 1);
279:
280:                    g.setColor(shadowColor);
281:                    g.drawLine(0, 0, width - 2, 0);
282:                    g.drawLine(0, 0, 0, height - 1);
283:                    g.drawLine(width - 2, 2, width - 2, height - 1);
284:                } else {
285:                    SmoothGradientUtils.drawDisabledBorder(g, 0, 0, width,
286:                            height + 1);
287:                }
288:                if (!isFreeStanding) {
289:                    height -= 1;
290:                    g.translate(0, 1);
291:                    if (!leftToRight) {
292:                        width -= 1;
293:                        g.translate(1, 0);
294:                    } else {
295:                        width -= 2;
296:                    }
297:                }
298:            }
299:
300:            private void paint3D(Graphics g) {
301:                ButtonModel buttonModel = getModel();
302:                if (buttonModel.isArmed() && buttonModel.isPressed()
303:                        || buttonModel.isSelected())
304:                    return;
305:
306:                int width = getWidth();
307:                int height = getHeight();
308:                if (getDirection() == EAST)
309:                    width -= 2;
310:                else if (getDirection() == SOUTH)
311:                    height -= 2;
312:
313:                Rectangle r = new Rectangle(1, 1, width, height);
314:                boolean isHorizontal = (getDirection() == EAST || getDirection() == WEST);
315:                SmoothGradientUtils.addLight3DEffekt(g, r, isHorizontal);
316:            }
317:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.