Source Code Cross Referenced for AddConstToCollectionDescriptor.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: AddConstToCollectionDescriptor.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.RenderedImage;
016:        import java.awt.image.renderable.ParameterBlock;
017:        import java.util.Collection;
018:        import java.util.Iterator;
019:        import javax.media.jai.JAI;
020:        import javax.media.jai.OperationDescriptorImpl;
021:        import javax.media.jai.ParameterBlockJAI;
022:        import javax.media.jai.registry.CollectionRegistryMode;
023:
024:        /**
025:         * An <code>OperationDescriptor</code> describing the
026:         * "AddConstToCollection" operation.
027:         *
028:         * <p> The AddConstToCollection operation takes a collection of
029:         * rendered images and an array of double constants, and for each
030:         * rendered image in the collection adds a constant to every pixel of
031:         * its corresponding band. If the number of constants supplied is less
032:         * than the number of bands of a source image then the same constant
033:         * from entry 0 is applied to all the bands.  Otherwise, a constant
034:         * from a different entry is applied to each band.
035:         *
036:         * <p> The operation will attempt to store the result images in the same
037:         * collection class as that of the source images. If a new instance of
038:         * the source collection class can not be created, then the operation
039:         * will store the result images in a java.util.Vector. There will be the
040:         * same number of images in the output collection as in the source
041:         * collection.
042:         *
043:         * <p><table border=1>
044:         * <caption>Resource List</caption>
045:         * <tr><th>Name</th>        <th>Value</th></tr>
046:         * <tr><td>GlobalName</td>  <td>AddConstToCollection</td></tr>
047:         * <tr><td>LocalName</td>   <td>AddConstToCollection</td></tr>
048:         * <tr><td>Vendor</td>      <td>com.sun.media.jai</td></tr>
049:         * <tr><td>Description</td> <td>Adds constants to a collection
050:         *                              of rendered images.<td></tr>
051:         * <tr><td>DocURL</td>      <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/AddConstToCollectionDescriptor.html</td></tr>
052:         * <tr><td>Version</td>     <td>1.0</td></tr>
053:         * <tr><td>arg0Desc</td>    <td>The constants to be added.</td></tr>
054:         * </table></p>
055:         *
056:         * <p><table border=1>
057:         * <caption>Parameter List</caption>
058:         * <tr><th>Name</th>      <th>Class Type</th>
059:         *                        <th>Default Value</th></tr>
060:         * <tr><td>constants</td> <td>double[]</td>
061:         *                        <td>{0.0}</td>
062:         * </table></p>
063:         *
064:         * @see javax.media.jai.CollectionImage
065:         * @see java.util.Collection
066:         * @see javax.media.jai.OperationDescriptor
067:         */
068:        public class AddConstToCollectionDescriptor extends
069:                OperationDescriptorImpl {
070:
071:            /**
072:             * The resource strings that provide the general documentation
073:             * and specify the parameter list for this operation.
074:             */
075:            private static final String[][] resources = {
076:                    { "GlobalName", "AddConstToCollection" },
077:                    { "LocalName", "AddConstToCollection" },
078:                    { "Vendor", "com.sun.media.jai" },
079:                    {
080:                            "Description",
081:                            JaiI18N
082:                                    .getString("AddConstToCollectionDescriptor0") },
083:                    {
084:                            "DocURL",
085:                            "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/AddConstToCollectionDescriptor.html" },
086:                    { "Version", JaiI18N.getString("DescriptorVersion") },
087:                    {
088:                            "arg0Desc",
089:                            JaiI18N
090:                                    .getString("AddConstToCollectionDescriptor1") } };
091:
092:            /** The parameter name list for this operation. */
093:            private static final String[] paramNames = { "constants" };
094:
095:            /** The parameter class list for this operation. */
096:            private static final Class[] paramClasses = { double[].class };
097:
098:            /** The parameter default value list for this operation. */
099:            private static final Object[] paramDefaults = { new double[] { 0.0 } };
100:
101:            private static final String[] supportedModes = { "collection" };
102:
103:            /** Constructor. */
104:            public AddConstToCollectionDescriptor() {
105:                super (resources, supportedModes, 1, paramNames, paramClasses,
106:                        paramDefaults, null);
107:            }
108:
109:            /** Validates input source and parameter. */
110:            public boolean validateArguments(String modeName,
111:                    ParameterBlock args, StringBuffer msg) {
112:                if (!super .validateArguments(modeName, args, msg)) {
113:                    return false;
114:                }
115:
116:                Collection col = (Collection) args.getSource(0);
117:
118:                if (col.size() < 1) {
119:                    msg
120:                            .append(getName()
121:                                    + " "
122:                                    + JaiI18N
123:                                            .getString("AddConstToCollectionDescriptor2"));
124:                    return false;
125:                }
126:
127:                Iterator iter = col.iterator();
128:                while (iter.hasNext()) {
129:                    Object o = iter.next();
130:                    if (!(o instanceof  RenderedImage)) {
131:                        msg
132:                                .append(getName()
133:                                        + " "
134:                                        + JaiI18N
135:                                                .getString("AddConstToCollectionDescriptor3"));
136:                        return false;
137:                    }
138:                }
139:
140:                int length = ((double[]) args.getObjectParameter(0)).length;
141:                if (length < 1) {
142:                    msg
143:                            .append(getName()
144:                                    + " "
145:                                    + JaiI18N
146:                                            .getString("AddConstToCollectionDescriptor4"));
147:                    return false;
148:                }
149:
150:                return true;
151:            }
152:
153:            /**
154:             * Adds constants to a collection of rendered images.
155:             *
156:             * <p>Creates a <code>ParameterBlockJAI</code> from all
157:             * supplied arguments except <code>hints</code> and invokes
158:             * {@link JAI#createCollection(String,ParameterBlock,RenderingHints)}.
159:             *
160:             * @see JAI
161:             * @see ParameterBlockJAI
162:             * @see Collection
163:             *
164:             * @param source0 <code>Collection</code> source 0.
165:             * @param constants The constants to be added.
166:             * May be <code>null</code>.
167:             * @param hints The <code>RenderingHints</code> to use.
168:             * May be <code>null</code>.
169:             * @return The <code>Collection</code> destination.
170:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
171:             */
172:            public static Collection createCollection(Collection source0,
173:                    double[] constants, RenderingHints hints) {
174:                ParameterBlockJAI pb = new ParameterBlockJAI(
175:                        "AddConstToCollection",
176:                        CollectionRegistryMode.MODE_NAME);
177:
178:                pb.setSource("source0", source0);
179:
180:                pb.setParameter("constants", constants);
181:
182:                return JAI.createCollection("AddConstToCollection", pb, hints);
183:            }
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.