Source Code Cross Referenced for XorConstDescriptor.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: XorConstDescriptor.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:46 $
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 "XorConst" operation.
029:         *
030:         * <p> The XorConst operation takes one rendered or renderable image
031:         * and an array of integer constants, and performs a bit-wise logical
032:         * "xor" between every pixel in the same band of the source and the
033:         * constant from the corresponding array entry. If the number of
034:         * constants supplied is less than the number of bands of the
035:         * destination, then the constant from entry 0 is applied to all the
036:         * bands. Otherwise, a constant from a different entry is applied to
037:         * each band.
038:         *
039:         * <p> The source image must have an integral data type. By default,
040:         * the destination image bound, data type, and number of bands are the
041:         * same as the source image.
042:         *
043:         * <p>The following matrix defines the "xor" operation.
044:         * <p><table border=1>
045:         * <caption>Logical "xor"</caption>
046:         * <tr align=center><th>src</th> <th>const</th> <th>Result</th></tr>
047:         * <tr align=center><td>0</td>   <td>0</td>     <td>0</td></tr>
048:         * <tr align=center><td>0</td>   <td>1</td>     <td>1</td></tr>
049:         * <tr align=center><td>1</td>   <td>0</td>     <td>1</td></tr>
050:         * <tr align=center><td>1</td>   <td>1</td>     <td>0</td></tr>
051:         * </table></p>
052:         *
053:         * <p> The destination pixel values are defined by the pseudocode:
054:         * <pre>
055:         * if (constants.length < dstNumBands) {
056:         *     dst[x][y][b] = src[x][y][b] ^ constants[0];
057:         * } else {
058:         *     dst[x][y][b] = src[x][y][b] ^ constants[b];
059:         * }
060:         * </pre>
061:         *
062:         * <p><table border=1>
063:         * <caption>Resource List</caption>
064:         * <tr><th>Name</th>        <th>Value</th></tr>
065:         * <tr><td>GlobalName</td>  <td>XorConst</td></tr>
066:         * <tr><td>LocalName</td>   <td>XorConst</td></tr>
067:         * <tr><td>Vendor</td>      <td>com.sun.media.jai</td></tr>
068:         * <tr><td>Description</td> <td>Logically "xors" an image
069:         *                              with constants.</td></tr>
070:         * <tr><td>DocURL</td>      <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/XorConstDescriptor.html</td></tr>
071:         * <tr><td>Version</td>     <td>1.0</td></tr>
072:         * <tr><td>arg0Desc</td>    <td>The constants to logically "xor" with.</td></tr>
073:         * </table></p>
074:         *
075:         * <p><table border=1>
076:         * <caption>Parameter List</caption>
077:         * <tr><th>Name</th>      <th>Class Type</th>
078:         *                        <th>Default Value</th></tr>
079:         * <tr><td>constants</td> <td>int[]</td>
080:         *                        <td>{0}</td>
081:         * </table></p>
082:         *
083:         * @see javax.media.jai.OperationDescriptor
084:         */
085:        public class XorConstDescriptor extends OperationDescriptorImpl {
086:
087:            /**
088:             * The resource strings that provide the general documentation
089:             * and specify the parameter list for this operation.
090:             */
091:            private static final String[][] resources = {
092:                    { "GlobalName", "XorConst" },
093:                    { "LocalName", "XorConst" },
094:                    { "Vendor", "com.sun.media.jai" },
095:                    { "Description", JaiI18N.getString("XorConstDescriptor0") },
096:                    {
097:                            "DocURL",
098:                            "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/XorConstDescriptor.html" },
099:                    { "Version", JaiI18N.getString("DescriptorVersion") },
100:                    { "arg0Desc", JaiI18N.getString("XorConstDescriptor1") } };
101:
102:            /**
103:             * The parameter class list for this operation.
104:             * The number of constants provided should be either 1, in which case
105:             * this same constant is applied to all the source bands; or the same
106:             * number as the source bands, in which case one contant is applied
107:             * to each band.
108:             */
109:            private static final Class[] paramClasses = { int[].class };
110:
111:            /** The parameter name list for this operation. */
112:            private static final String[] paramNames = { "constants" };
113:
114:            /** The parameter default value list for this operation. */
115:            private static final Object[] paramDefaults = { new int[] { 0 } };
116:
117:            private static final String[] supportedModes = { "rendered",
118:                    "renderable" };
119:
120:            /** Constructor. */
121:            public XorConstDescriptor() {
122:                super (resources, supportedModes, 1, paramNames, paramClasses,
123:                        paramDefaults, null);
124:            }
125:
126:            /**
127:             * Validates the input source and parameter.
128:             *
129:             * <p> In addition to the standard checks performed by the
130:             * superclass method, this method checks that the source image has
131:             * an integral data type and that "constants" has length at least 1.
132:             */
133:            public boolean validateArguments(String modeName,
134:                    ParameterBlock args, StringBuffer message) {
135:                if (!super .validateArguments(modeName, args, message)) {
136:                    return false;
137:                }
138:
139:                if (!modeName.equalsIgnoreCase("rendered"))
140:                    return true;
141:
142:                RenderedImage src = args.getRenderedSource(0);
143:
144:                int dtype = src.getSampleModel().getDataType();
145:
146:                if (dtype != DataBuffer.TYPE_BYTE
147:                        && dtype != DataBuffer.TYPE_USHORT
148:                        && dtype != DataBuffer.TYPE_SHORT
149:                        && dtype != DataBuffer.TYPE_INT) {
150:                    message.append(getName() + " "
151:                            + JaiI18N.getString("XorConstDescriptor2"));
152:                    return false;
153:                }
154:
155:                int length = ((int[]) args.getObjectParameter(0)).length;
156:                if (length < 1) {
157:                    message.append(getName() + " "
158:                            + JaiI18N.getString("XorConstDescriptor3"));
159:                    return false;
160:                }
161:
162:                return true;
163:            }
164:
165:            /**
166:             * Logically "xors" an image with constants.
167:             *
168:             * <p>Creates a <code>ParameterBlockJAI</code> from all
169:             * supplied arguments except <code>hints</code> and invokes
170:             * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
171:             *
172:             * @see JAI
173:             * @see ParameterBlockJAI
174:             * @see RenderedOp
175:             *
176:             * @param source0 <code>RenderedImage</code> source 0.
177:             * @param constants The constants to logically "xor" with.
178:             * May be <code>null</code>.
179:             * @param hints The <code>RenderingHints</code> to use.
180:             * May be <code>null</code>.
181:             * @return The <code>RenderedOp</code> destination.
182:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
183:             */
184:            public static RenderedOp create(RenderedImage source0,
185:                    int[] constants, RenderingHints hints) {
186:                ParameterBlockJAI pb = new ParameterBlockJAI("XorConst",
187:                        RenderedRegistryMode.MODE_NAME);
188:
189:                pb.setSource("source0", source0);
190:
191:                pb.setParameter("constants", constants);
192:
193:                return JAI.create("XorConst", pb, hints);
194:            }
195:
196:            /**
197:             * Logically "xors" an image with constants.
198:             *
199:             * <p>Creates a <code>ParameterBlockJAI</code> from all
200:             * supplied arguments except <code>hints</code> and invokes
201:             * {@link JAI#createRenderable(String,ParameterBlock,RenderingHints)}.
202:             *
203:             * @see JAI
204:             * @see ParameterBlockJAI
205:             * @see RenderableOp
206:             *
207:             * @param source0 <code>RenderableImage</code> source 0.
208:             * @param constants The constants to logically "xor" with.
209:             * May be <code>null</code>.
210:             * @param hints The <code>RenderingHints</code> to use.
211:             * May be <code>null</code>.
212:             * @return The <code>RenderableOp</code> destination.
213:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
214:             */
215:            public static RenderableOp createRenderable(
216:                    RenderableImage source0, int[] constants,
217:                    RenderingHints hints) {
218:                ParameterBlockJAI pb = new ParameterBlockJAI("XorConst",
219:                        RenderableRegistryMode.MODE_NAME);
220:
221:                pb.setSource("source0", source0);
222:
223:                pb.setParameter("constants", constants);
224:
225:                return JAI.createRenderable("XorConst", pb, hints);
226:            }
227:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.