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