Source Code Cross Referenced for ButtonStateIcon.java in  » Swing-Library » substance-look-feel » contrib » ch » randelshofer » quaqua » 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 » contrib.ch.randelshofer.quaqua 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)ButtonStateIcon.java  3.1  2005-12-08
003:         *
004:         * Copyright (c) 2003-2005 Werner Randelshofer
005:         * Staldenmattweg 2, Immensee, CH-6405, Switzerland.
006:         * All rights reserved.
007:         *
008:         * This software is the confidential and proprietary information of
009:         * Werner Randelshofer. ("Confidential Information").  You shall not
010:         * disclose such Confidential Information and shall use it only in
011:         * accordance with the terms of the license agreement you entered into
012:         * with Werner Randelshofer.
013:         */
014:
015:        package contrib.ch.randelshofer.quaqua;
016:
017:        import java.awt.*;
018:        import javax.swing.*;
019:        import javax.swing.plaf.*;
020:
021:        import contrib.ch.randelshofer.quaqua.util.*;
022:
023:        /**
024:         * An Icon with different visuals reflecting the state of the AbstractButton
025:         * on which it draws on.
026:         *
027:         * @author  Werner Randelshofer
028:         * @version 3.1 2005-12-08 Draw pressed state if model is armed, instead of
029:         * drawing pressed state if model is armed and pressed.
030:         * <br>3.0 2005-10-17 Changed superclass to MultiIcon.
031:         * <br>2.0.1 2005-10-02 Used Enabled image for Pressed-Unarmed state.
032:         * <br>2.0.1 2005-09-11 generateMissing icons can now deal with only one
033:         * provided icon image.
034:         * <br>2.0 2005-03-19 Reworked.
035:         * <br>1.0 October 5, 2003 Create..
036:         */
037:        public class ButtonStateIcon extends MultiIcon {
038:            private final static int E = 0;
039:            private final static int EP = 1;
040:            private final static int ES = 2;
041:            private final static int EPS = 3;
042:            private final static int D = 4;
043:            private final static int DS = 5;
044:            private final static int I = 6;
045:            private final static int IS = 7;
046:            private final static int DI = 8;
047:            private final static int DIS = 9;
048:
049:            /**
050:             * Creates a new instance.
051:             * All icons must have the same dimensions.
052:             * If an icon is null, an icon is derived for the state from the
053:             * other icons.
054:             */
055:            public ButtonStateIcon(Icon e, Icon ep, Icon es, Icon eps, Icon d,
056:                    Icon ds) {
057:                super (new Icon[] { e, ep, es, eps, d, ds });
058:            }
059:
060:            /**
061:             * Creates a new instance.
062:             * All icons must have the same dimensions.
063:             *
064:             * The array indices are used to represente the following states:
065:             * [0] Enabled
066:             * [1] Enabled Pressed
067:             * [2] Enabled Selected
068:             * [3] Enabled Pressed Selected
069:             * [4] Disabled
070:             * [5] Disabled Selected
071:             * [6] Enabled Inactive
072:             * [7] Enabled Inactive Selected
073:             * [8] Disabled Inactive
074:             * [9] Disabled Inactive Selected
075:             *
076:             * If an array element is null, an icon is derived for the state from the
077:             * other icons.
078:             */
079:            public ButtonStateIcon(Image[] images) {
080:                super (images);
081:            }
082:
083:            /**
084:             * Creates a new instance.
085:             * All icons must have the same dimensions.
086:             * If an icon is null, nothing is drawn for this state.
087:             */
088:            public ButtonStateIcon(Icon[] icons) {
089:                super (icons);
090:            }
091:
092:            /**
093:             * Creates a new instance.
094:             * The icon representations are created lazily from the image.
095:             */
096:            public ButtonStateIcon(Image tiledImage, int tileCount,
097:                    boolean isTiledHorizontally) {
098:                super (tiledImage, tileCount, isTiledHorizontally);
099:            }
100:
101:            protected Icon getIcon(Component c) {
102:                Icon icon;
103:                boolean isActive = QuaquaUtilities.isOnActiveWindow(c);
104:
105:                if (c instanceof  AbstractButton) {
106:                    ButtonModel model = ((AbstractButton) c).getModel();
107:                    if (isActive) {
108:                        if (model.isEnabled()) {
109:                            if (/*model.isPressed() && */model.isArmed()) {
110:                                if (model.isSelected()) {
111:                                    icon = icons[EPS];
112:                                } else {
113:                                    icon = icons[EP];
114:                                }
115:                            } else if (model.isSelected()) {
116:                                icon = icons[ES];
117:                            } else {
118:                                icon = icons[E];
119:                            }
120:                        } else {
121:                            if (model.isSelected()) {
122:                                icon = icons[DS];
123:                            } else {
124:                                icon = icons[D];
125:                            }
126:                        }
127:                    } else {
128:                        if (model.isEnabled()) {
129:                            if (model.isSelected()) {
130:                                icon = icons[IS];
131:                            } else {
132:                                icon = icons[I];
133:                            }
134:                        } else {
135:                            if (model.isSelected()) {
136:                                icon = icons[DIS];
137:                            } else {
138:                                icon = icons[DI];
139:                            }
140:                        }
141:                    }
142:                } else {
143:                    if (isActive) {
144:                        if (c.isEnabled()) {
145:                            icon = icons[E];
146:                        } else {
147:                            icon = icons[D];
148:                        }
149:                    } else {
150:                        if (c.isEnabled()) {
151:                            icon = icons[I];
152:                        } else {
153:                            icon = icons[DI];
154:                        }
155:                    }
156:                }
157:                return icon;
158:            }
159:
160:            protected void generateMissingIcons() {
161:                if (icons.length != 10) {
162:                    Icon[] helper = icons;
163:                    icons = new Icon[10];
164:                    System.arraycopy(helper, 0, icons, 0, Math.min(
165:                            helper.length, icons.length));
166:                }
167:
168:                if (icons[EP] == null) {
169:                    icons[EP] = icons[E];
170:                }
171:                if (icons[ES] == null) {
172:                    icons[ES] = icons[EP];
173:                }
174:                if (icons[EPS] == null) {
175:                    icons[EPS] = icons[EP];
176:                }
177:                if (icons[D] == null) {
178:                    icons[D] = icons[E];
179:                }
180:                if (icons[DS] == null) {
181:                    icons[DS] = icons[ES];
182:                }
183:                if (icons[I] == null) {
184:                    icons[I] = icons[E];
185:                }
186:                if (icons[IS] == null) {
187:                    icons[IS] = icons[ES];
188:                }
189:                if (icons[DI] == null) {
190:                    icons[DI] = icons[D];
191:                }
192:                if (icons[DIS] == null) {
193:                    icons[DIS] = icons[DS];
194:                }
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.