Source Code Cross Referenced for NullDescriptor.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: NullDescriptor.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.Rectangle;
015:        import java.awt.RenderingHints;
016:        import java.awt.image.RenderedImage;
017:        import java.awt.image.renderable.ParameterBlock;
018:        import java.awt.image.renderable.RenderableImage;
019:        import java.util.Vector;
020:        import javax.media.jai.JAI;
021:        import javax.media.jai.OperationDescriptorImpl;
022:        import javax.media.jai.OperationNode;
023:        import javax.media.jai.ParameterBlockJAI;
024:        import javax.media.jai.RenderableOp;
025:        import javax.media.jai.RenderedOp;
026:        import javax.media.jai.registry.RenderableRegistryMode;
027:        import javax.media.jai.registry.RenderedRegistryMode;
028:
029:        /**
030:         * An <code>OperationDescriptor</code> describing the "Null" operation.
031:         *
032:         * <p> The "Null" operation performs no processing.  It merely propagates its
033:         * first source along the operation chain unmodified.  There may be an
034:         * arbitrary number of sources but only the first one is passed along
035:         * so it must have the appropriate class type for the operation mode.
036:         *
037:         * <p> This operation may be useful as a placeholder in operation chains
038:         * and in creating nodes to which <code>PropertyGenerator</code>s may be
039:         * attached.  This would enable non-image data nodes to be present in chains
040:         * without requiring that specific <code>OperationDescriptor</code>s be
041:         * implemented for these operations.  The <code>PropertyGenerator</code>s
042:         * required would in this case be added locally to the nodes using the
043:         * <code>addPropertyGenerator()</code> method of the node.
044:         *
045:         * <p><table border=1>
046:         * <caption>Resource List</caption>
047:         * <tr><th>Name</th>        <th>Value</th></tr>
048:         * <tr><td>GlobalName</td>  <td>Null</td></tr>
049:         * <tr><td>LocalName</td>   <td>Null</td></tr>
050:         * <tr><td>Vendor</td>      <td>com.sun.media.jai</td></tr>
051:         * <tr><td>Description</td> <td>An operation which does no processing.</td></tr>
052:         * <tr><td>DocURL</td>      <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/NullDescriptor.html</td></tr>
053:         * <tr><td>Version</td>     <td>1.0</td></tr>
054:         * </table></p>
055:         *
056:         * <p> No parameters are needed for this operation.
057:         *
058:         * @see javax.media.jai.OperationDescriptor
059:         *
060:         * @since JAI 1.1
061:         */
062:        public class NullDescriptor extends OperationDescriptorImpl {
063:
064:            /**
065:             * The resource strings that provide the general documentation
066:             * and specify the parameter list for this operation.
067:             */
068:            private static final String[][] resources = {
069:                    { "GlobalName", "Null" },
070:                    { "LocalName", "Null" },
071:                    { "Vendor", "com.sun.media.jai" },
072:                    { "Description", JaiI18N.getString("NullDescriptor0") },
073:                    {
074:                            "DocURL",
075:                            "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/NullDescriptor.html" },
076:                    { "Version", JaiI18N.getString("DescriptorVersion") }, };
077:
078:            private static final String[] supportedModes = { "rendered",
079:                    "renderable" };
080:
081:            /** Constructor. */
082:            public NullDescriptor() {
083:                super (resources, supportedModes, 1, null, null, null, null);
084:            }
085:
086:            /**
087:             * If the PB has more than one source, replace it with a new PB which
088:             * has only one source equal to the first source of the input.
089:             * We want to support an arbitrary number of sources but only care that
090:             * there is at least one of the appropriate class.
091:             */
092:            private static ParameterBlock foolSourceValidation(
093:                    ParameterBlock args) {
094:                if (args.getNumSources() > 1) {
095:                    Vector singleSource = new Vector();
096:                    singleSource.add(args.getSource(0));
097:                    args = new ParameterBlock(singleSource, args
098:                            .getParameters());
099:                }
100:                return args;
101:            }
102:
103:            /**
104:             * Returns <code>true</code> if there is at least one source
105:             * and the first source is a <code>RenderedImage</code> or
106:             * <code>RenderableImage</code>.
107:             *
108:             * @throws IllegalArgumentException if <code>args</code> is <code>null</code>.
109:             * @throws IllegalArgumentException if <code>msg</code> is <code>null</code>
110:             *         and the validation fails.
111:             */
112:            protected boolean validateSources(String modeName,
113:                    ParameterBlock args, StringBuffer msg) {
114:
115:                if (args == null || msg == null) {
116:                    throw new IllegalArgumentException(JaiI18N
117:                            .getString("Generic0"));
118:                }
119:
120:                return super .validateSources(modeName,
121:                        foolSourceValidation(args), msg);
122:            }
123:
124:            /**
125:             * Calculates the region over which two distinct renderings
126:             * of the "Null" operation may be expected to differ.
127:             *
128:             * <p> The operation returns an empty <code>Shape</code> if the first
129:             * source in each of the two <code>ParameterBlock</code>s are equal
130:             * according to the <code>equals()</code> method of the old source or
131:             * <code>null</code> for all other cases.
132:             *
133:             * @param modeName The name of the mode.
134:             * @param oldParamBlock The previous sources and parameters.
135:             * @param oldHints The previous hints.
136:             * @param newParamBlock The current sources and parameters.
137:             * @param newHints The current hints.
138:             * @param node The affected node in the processing chain (ignored).
139:             *
140:             * @return The region over which the data of two renderings of this
141:             *         operation may be expected to be invalid or <code>null</code>
142:             *         if there is no common region of validity.
143:             *         A non-<code>null</code> empty region indicates that the
144:             *         operation would produce identical data over the bounds of the
145:             *         old rendering although perhaps not over the area occupied by
146:             *         the <i>tiles</i> of the old rendering.
147:             *
148:             * @throws IllegalArgumentException if <code>modeName</code>
149:             *         is <code>null</code> or if either <code>oldParamBlock</code>
150:             *         or <code>newParamBlock</code> is <code>null</code>.
151:             * @throws IllegalArgumentException if <code>oldParamBlock</code> or
152:             *         <code>newParamBlock</code> does not contain at least one source.
153:             */
154:            public Object getInvalidRegion(String modeName,
155:                    ParameterBlock oldParamBlock, RenderingHints oldHints,
156:                    ParameterBlock newParamBlock, RenderingHints newHints,
157:                    OperationNode node) {
158:                if (modeName == null || oldParamBlock == null
159:                        || newParamBlock == null) {
160:                    throw new IllegalArgumentException(JaiI18N
161:                            .getString("NullDescriptor1"));
162:                }
163:
164:                if (oldParamBlock.getNumSources() < 1
165:                        || newParamBlock.getNumSources() < 1) {
166:
167:                    throw new IllegalArgumentException(JaiI18N
168:                            .getString("NullDescriptor2"));
169:                }
170:
171:                return oldParamBlock.getSource(0).equals(
172:                        newParamBlock.getSource(0)) ? new Rectangle() : null;
173:            }
174:
175:            /**
176:             * An operation which does no processing.
177:             *
178:             * <p>Creates a <code>ParameterBlockJAI</code> from all
179:             * supplied arguments except <code>hints</code> and invokes
180:             * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
181:             *
182:             * @see JAI
183:             * @see ParameterBlockJAI
184:             * @see RenderedOp
185:             *
186:             * @param source0 <code>RenderedImage</code> source 0.
187:             * @param hints The <code>RenderingHints</code> to use.
188:             * May be <code>null</code>.
189:             * @return The <code>RenderedOp</code> destination.
190:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
191:             */
192:            public static RenderedOp create(RenderedImage source0,
193:                    RenderingHints hints) {
194:                ParameterBlockJAI pb = new ParameterBlockJAI("Null",
195:                        RenderedRegistryMode.MODE_NAME);
196:
197:                pb.setSource("source0", source0);
198:
199:                return JAI.create("Null", pb, hints);
200:            }
201:
202:            /**
203:             * An operation which does no processing.
204:             *
205:             * <p>Creates a <code>ParameterBlockJAI</code> from all
206:             * supplied arguments except <code>hints</code> and invokes
207:             * {@link JAI#createRenderable(String,ParameterBlock,RenderingHints)}.
208:             *
209:             * @see JAI
210:             * @see ParameterBlockJAI
211:             * @see RenderableOp
212:             *
213:             * @param source0 <code>RenderableImage</code> source 0.
214:             * @param hints The <code>RenderingHints</code> to use.
215:             * May be <code>null</code>.
216:             * @return The <code>RenderableOp</code> destination.
217:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
218:             */
219:            public static RenderableOp createRenderable(
220:                    RenderableImage source0, RenderingHints hints) {
221:                ParameterBlockJAI pb = new ParameterBlockJAI("Null",
222:                        RenderableRegistryMode.MODE_NAME);
223:
224:                pb.setSource("source0", source0);
225:
226:                return JAI.createRenderable("Null", pb, hints);
227:            }
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.