Source Code Cross Referenced for AndDescriptor.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » javax » media » jai » operator » 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 » Java Advanced Imaging » javax.media.jai.operator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: AndDescriptor.java,v $
003:         *
004:         * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * Use is subject to license terms.
007:         *
008:         * $Revision: 1.1 $
009:         * $Date: 2005/02/11 04:57:29 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai.operator;
013:
014:        import java.awt.RenderingHints;
015:        import java.awt.image.DataBuffer;
016:        import java.awt.image.RenderedImage;
017:        import java.awt.image.renderable.ParameterBlock;
018:        import java.awt.image.renderable.RenderableImage;
019:        import javax.media.jai.JAI;
020:        import javax.media.jai.OperationDescriptorImpl;
021:        import javax.media.jai.ParameterBlockJAI;
022:        import javax.media.jai.RenderableOp;
023:        import javax.media.jai.RenderedOp;
024:        import javax.media.jai.registry.RenderableRegistryMode;
025:        import javax.media.jai.registry.RenderedRegistryMode;
026:
027:        /**
028:         * An <code>OperationDescriptor</code> describing the "And" operation.
029:         *
030:         * <p> The And operation takes two source images, and performs a bit-wise
031:         * logical "and" on every pair of pixels, one from each source image,
032:         * of the corresponding position and band. No additional parameters are
033:         * required.
034:         *
035:         * <p> Both source images must have integral data types. The two
036:         * data types may be different.
037:         *
038:         * <p> Unless altered by an <code>ImageLayout</code> hint, the
039:         * destination image bound is the intersection of the two source image
040:         * bounds.  If the two sources don't intersect, the destination will
041:         * have a width and height of 0.  The number of bands of the
042:         * destination image is equal to the lesser number of bands of the
043:         * sources, and the data type is the smallest data type with
044:         * sufficient range to cover the range of both source data types.
045:         *
046:         * <p>The following matrix defines the logical "and" operation.
047:         * <p><table border=1>
048:         * <caption>Logical "and"</caption>
049:         * <tr align=center><th>src1</th> <th>src2</th> <th>Result</th></tr>
050:         * <tr align=center><td>1</td>    <td>1</td>    <td>1</td></tr>
051:         * <tr align=center><td>1</td>    <td>0</td>    <td>0</td></tr>
052:         * <tr align=center><td>0</td>    <td>1</td>    <td>0</td></tr>
053:         * <tr align=center><td>0</td>    <td>0</td>    <td>0</td></tr>
054:         * </table></p>
055:         *
056:         * <p> The destination pixel values are defined by the pseudocode:
057:         * <pre>
058:         * dst[x][y][b] = srcs[0][x][y][b] & srcs[1][x][y][b];
059:         * </pre>
060:         *
061:         * <p><table border=1>
062:         * <caption>Resource List</caption>
063:         * <tr><th>Name</th>        <th>Value</th></tr>
064:         * <tr><td>GlobalName</td>  <td>And</td></tr>
065:         * <tr><td>LocalName</td>   <td>And</td></tr>
066:         * <tr><td>Vendor</td>      <td>com.sun.media.jai</td></tr>
067:         * <tr><td>Description</td> <td>Logically "ands" two images.</td></tr>
068:         * <tr><td>DocURL</td>      <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/AndDescriptor.html</td></tr>
069:         * <tr><td>Version</td>     <td>1.0</td></tr>
070:         * </table></p>
071:         *
072:         * <p> No parameters are needed for this operation.
073:         *
074:         * @see javax.media.jai.OperationDescriptor
075:         */
076:        public class AndDescriptor extends OperationDescriptorImpl {
077:
078:            /**
079:             * The resource strings that provide the general documentation
080:             * and specify the parameter list for this operation.
081:             */
082:            private static final String[][] resources = {
083:                    { "GlobalName", "And" },
084:                    { "LocalName", "And" },
085:                    { "Vendor", "com.sun.media.jai" },
086:                    { "Description", JaiI18N.getString("AndDescriptor0") },
087:                    {
088:                            "DocURL",
089:                            "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/AndDescriptor.html" },
090:                    { "Version", JaiI18N.getString("DescriptorVersion") } };
091:
092:            private static final String[] supportedModes = { "rendered",
093:                    "renderable" };
094:
095:            /** Constructor. */
096:            public AndDescriptor() {
097:                super (resources, supportedModes, 2, null, null, null, null);
098:            }
099:
100:            /**
101:             * Validates the input sources.
102:             *
103:             * <p> In addition to the standard checks performed by the
104:             * superclass method, this method checks that the source images
105:             * are of integral data type.
106:             */
107:            protected boolean validateSources(String modeName,
108:                    ParameterBlock args, StringBuffer msg) {
109:
110:                if (!super .validateSources(modeName, args, msg)) {
111:                    return false;
112:                }
113:
114:                if (!modeName.equalsIgnoreCase("rendered"))
115:                    return true;
116:
117:                for (int i = 0; i < 2; i++) {
118:
119:                    RenderedImage src = args.getRenderedSource(0);
120:
121:                    int dtype = src.getSampleModel().getDataType();
122:
123:                    if (dtype != DataBuffer.TYPE_BYTE
124:                            && dtype != DataBuffer.TYPE_USHORT
125:                            && dtype != DataBuffer.TYPE_SHORT
126:                            && dtype != DataBuffer.TYPE_INT) {
127:                        msg.append(getName() + " "
128:                                + JaiI18N.getString("AndDescriptor1"));
129:                        return false;
130:                    }
131:                }
132:
133:                return true;
134:            }
135:
136:            /**
137:             * Logically "ands" two images.
138:             *
139:             * <p>Creates a <code>ParameterBlockJAI</code> from all
140:             * supplied arguments except <code>hints</code> and invokes
141:             * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
142:             *
143:             * @see JAI
144:             * @see ParameterBlockJAI
145:             * @see RenderedOp
146:             *
147:             * @param source0 <code>RenderedImage</code> source 0.
148:             * @param source1 <code>RenderedImage</code> source 1.
149:             * @param hints The <code>RenderingHints</code> to use.
150:             * May be <code>null</code>.
151:             * @return The <code>RenderedOp</code> destination.
152:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
153:             * @throws IllegalArgumentException if <code>source1</code> is <code>null</code>.
154:             */
155:            public static RenderedOp create(RenderedImage source0,
156:                    RenderedImage source1, RenderingHints hints) {
157:                ParameterBlockJAI pb = new ParameterBlockJAI("And",
158:                        RenderedRegistryMode.MODE_NAME);
159:
160:                pb.setSource("source0", source0);
161:                pb.setSource("source1", source1);
162:
163:                return JAI.create("And", pb, hints);
164:            }
165:
166:            /**
167:             * Logically "ands" two images.
168:             *
169:             * <p>Creates a <code>ParameterBlockJAI</code> from all
170:             * supplied arguments except <code>hints</code> and invokes
171:             * {@link JAI#createRenderable(String,ParameterBlock,RenderingHints)}.
172:             *
173:             * @see JAI
174:             * @see ParameterBlockJAI
175:             * @see RenderableOp
176:             *
177:             * @param source0 <code>RenderableImage</code> source 0.
178:             * @param source1 <code>RenderableImage</code> source 1.
179:             * @param hints The <code>RenderingHints</code> to use.
180:             * May be <code>null</code>.
181:             * @return The <code>RenderableOp</code> destination.
182:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
183:             * @throws IllegalArgumentException if <code>source1</code> is <code>null</code>.
184:             */
185:            public static RenderableOp createRenderable(
186:                    RenderableImage source0, RenderableImage source1,
187:                    RenderingHints hints) {
188:                ParameterBlockJAI pb = new ParameterBlockJAI("And",
189:                        RenderableRegistryMode.MODE_NAME);
190:
191:                pb.setSource("source0", source0);
192:                pb.setSource("source1", source1);
193:
194:                return JAI.createRenderable("And", pb, hints);
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.