Source Code Cross Referenced for SynthContext.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » plaf » synth » 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 » Apache Harmony Java SE » javax package » javax.swing.plaf.synth 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        package javax.swing.plaf.synth;
019:
020:        import javax.swing.JComponent;
021:
022:        public class SynthContext {
023:
024:            private JComponent component;
025:
026:            private SynthStyle style;
027:
028:            private int state;
029:
030:            private Region region;
031:
032:            /**
033:             * Constructs SynthContext with given parameters
034:             */
035:            public SynthContext(JComponent component, Region region,
036:                    SynthStyle style, int state) {
037:                this .component = component;
038:                this .style = style;
039:                this .state = state;
040:                this .region = region;
041:            }
042:
043:            /**
044:             * For the most of UIs context needed to represent style and state
045:             */
046:            SynthContext(SynthStyle style, int state) {
047:                this .style = style;
048:                this .state = state;
049:            }
050:
051:            /**
052:             * Sometimes context just represents currentState
053:             */
054:            SynthContext(int state) {
055:                this .state = state;
056:            }
057:
058:            /**
059:             * @return The component uses this context
060:             */
061:            public JComponent getComponent() {
062:                return component;
063:            }
064:
065:            /**
066:             * @return The state for the component uses this context
067:             */
068:            public int getComponentState() {
069:                return state;
070:            }
071:
072:            /** @return parent style */
073:            public SynthStyle getStyle() {
074:                return style;
075:            }
076:
077:            /** @return the region of the context */
078:            public Region getRegion() {
079:                return region;
080:            }
081:
082:            void setState(int state) {
083:                this .state = state;
084:            }
085:
086:            /**
087:             * Removes proposed state from current if it exists
088:             */
089:            void lossState(int proposed) {
090:
091:                this .state &= ~proposed;
092:            }
093:
094:            /**
095:             * Adds additional state to current if it doesn't exist
096:             */
097:            void gainState(int proposed) {
098:                this .state |= proposed;
099:            }
100:
101:            static boolean isEnabled(int verifiedState) {
102:                return (verifiedState & SynthConstants.ENABLED) != 0;
103:            }
104:
105:            static boolean isDisabled(int verifiedState) {
106:                return (verifiedState & SynthConstants.DISABLED) != 0;
107:            }
108:
109:            static boolean isFocused(int verifiedState) {
110:                return (verifiedState & SynthConstants.FOCUSED) != 0;
111:            }
112:
113:            static boolean isDefault(int verifiedState) {
114:                return (verifiedState & SynthConstants.DEFAULT) != 0;
115:            }
116:
117:            static boolean isMouseOver(int verifiedState) {
118:                return (verifiedState & SynthConstants.MOUSE_OVER) != 0;
119:            }
120:
121:            static boolean isPressed(int verifiedState) {
122:                return (verifiedState & SynthConstants.PRESSED) != 0;
123:            }
124:
125:            static boolean isSelected(int verifiedState) {
126:                return (verifiedState & SynthConstants.SELECTED) != 0;
127:            }
128:
129:            /**
130:             * Used in UI's. Created to reduce code doubling
131:             * */
132:            static int getCommonComponentState(JComponent c) {
133:                int result = c.isEnabled() ? SynthConstants.ENABLED
134:                        : SynthConstants.DISABLED;
135:                if (c.isFocusOwner()) {
136:                    result |= SynthConstants.FOCUSED;
137:                }
138:                return result;
139:            }
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.