Source Code Cross Referenced for AlphaComposite.java in  » 6.0-JDK-Modules » j2me » java » awt » 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 » 6.0 JDK Modules » j2me » java.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)AlphaComposite.java	1.7 06/10/10
003:         *
004:         * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation. 
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt). 
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA 
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions. 
025:         *
026:         */
027:
028:        package java.awt;
029:
030:        public final class AlphaComposite implements  Composite {
031:            /**
032:             * Porter-Duff Clear rule.
033:             * Both the color and the alpha of the destination are cleared.
034:             * Neither the source nor the destination is used as input.
035:             *<p>
036:             * Fs = 0 and Fd = 0, thus:
037:             *<pre>
038:             *  Cd = 0
039:             *  Ad = 0
040:             *</pre>
041:             *
042:             */
043:            public static final int CLEAR = 1;
044:            /**
045:             * Porter-Duff Source rule.
046:             * The source is copied to the destination.
047:             * The destination is not used as input.
048:             *<p>
049:             * Fs = 1 and Fd = 0, thus:
050:             *<pre>
051:             *  Cd = Cs
052:             *  Ad = As
053:             *</pre>
054:             */
055:            public static final int SRC = 2;
056:            /**
057:             * Porter-Duff Source Over Destination rule.
058:             * The source is composited over the destination.
059:             *<p>
060:             * Fs = 1 and Fd = (1-As), thus:
061:             *<pre>
062:             *  Cd = Cs + Cd*(1-As)
063:             *  Ad = As + Ad*(1-As)
064:             *</pre>
065:             */
066:            public static final int SRC_OVER = 3;
067:            /**
068:             * <code>AlphaComposite</code> object that implements the opaque CLEAR rule
069:             * with an alpha of 1.0f.
070:             * @see #CLEAR
071:             */
072:            public static final AlphaComposite Clear = new AlphaComposite(CLEAR);
073:            /**
074:             * <code>AlphaComposite</code> object that implements the opaque SRC rule
075:             * with an alpha of 1.0f.
076:             * @see #SRC
077:             */
078:            public static final AlphaComposite Src = new AlphaComposite(SRC);
079:            /**
080:             * <code>AlphaComposite</code> object that implements the opaque SRC_OVER rule
081:             * with an alpha of 1.0f.
082:             * @see #SRC_OVER
083:             */
084:            public static final AlphaComposite SrcOver = new AlphaComposite(
085:                    SRC_OVER);
086:            private static final int MIN_RULE = CLEAR;
087:            private static final int MAX_RULE = SRC_OVER;
088:            float extraAlpha;
089:            int rule;
090:
091:            private AlphaComposite(int rule) {
092:                this (rule, 1.0f);
093:            }
094:
095:            private AlphaComposite(int rule, float alpha) {
096:                if (alpha < 0.0f || alpha > 1.0f) {
097:                    throw new IllegalArgumentException(
098:                            "alpha value out of range");
099:                }
100:                if (rule < MIN_RULE || rule > MAX_RULE) {
101:                    throw new IllegalArgumentException("unknown composite rule");
102:                }
103:                this .rule = rule;
104:                this .extraAlpha = alpha;
105:            }
106:
107:            /**
108:             * Creates an <code>AlphaComposite</code> object with the specified rule.
109:             * @param rule the compositing rule
110:             * @throws IllegalArgumentException if <code>rule</code> is not one of
111:             *         the following:  {@link #CLEAR}, {@link #SRC}, {@link #DST},
112:             *         {@link #SRC_OVER}, {@link #DST_OVER}, {@link #SRC_IN},
113:             *         {@link #DST_IN}, {@link #SRC_OUT}, {@link #DST_OUT},
114:             *         {@link #SRC_ATOP}, {@link #DST_ATOP}, or {@link #XOR}
115:             */
116:            public static AlphaComposite getInstance(int rule) {
117:                switch (rule) {
118:                case CLEAR:
119:                    return Clear;
120:
121:                case SRC:
122:                    return Src;
123:
124:                case SRC_OVER:
125:                    return SrcOver;
126:
127:                default:
128:                    throw new IllegalArgumentException("unknown composite rule");
129:                }
130:            }
131:
132:            /**
133:             * Creates an <code>AlphaComposite</code> object with the specified rule and
134:             * the constant alpha to multiply with the alpha of the source.
135:             * The source is multiplied with the specified alpha before being composited
136:             * with the destination.
137:             * @param rule the compositing rule
138:             * @param alpha the constant alpha to be multiplied with the alpha of
139:             * the source. <code>alpha</code> must be a floating point number in the
140:             * inclusive range [0.0,&nbsp;1.0].
141:             */
142:            public static AlphaComposite getInstance(int rule, float alpha) {
143:                if (alpha == 1.0f) {
144:                    return getInstance(rule);
145:                }
146:                return new AlphaComposite(rule, alpha);
147:            }
148:
149:            /**
150:             * Returns the alpha value of this<code>AlphaComposite</code>.  If this
151:             * <code>AlphaComposite</code> does not have an alpha value, 1.0 is returned.
152:             * @return the alpha value of this <code>AlphaComposite</code>.
153:             */
154:            public float getAlpha() {
155:                return extraAlpha;
156:            }
157:
158:            /**
159:             * Returns the compositing rule of this <code>AlphaComposite</code>.
160:             * @return the compositing rule of this <code>AlphaComposite</code>.
161:             */
162:            public int getRule() {
163:                return rule;
164:            }
165:
166:            /**
167:             * Returns the hashcode for this composite.
168:             * @return      a hash code for this composite.
169:             */
170:            public int hashCode() {
171:                return (Float.floatToIntBits(extraAlpha) * 31 + rule);
172:            }
173:
174:            /**
175:             * Tests if the specified {@link Object} is equal to this
176:             * <code>AlphaComposite</code> object.
177:             * @param obj the <code>Object</code> to test for equality
178:             * @return <code>true</code> if <code>obj</code> equals this
179:             * <code>AlphaComposite</code>; <code>false</code> otherwise.
180:             */
181:            public boolean equals(Object obj) {
182:                if (!(obj instanceof  AlphaComposite)) {
183:                    return false;
184:                }
185:                AlphaComposite ac = (AlphaComposite) obj;
186:                if (rule != ac.rule) {
187:                    return false;
188:                }
189:                if (extraAlpha != ac.extraAlpha) {
190:                    return false;
191:                }
192:                return true;
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.