Source Code Cross Referenced for AddCollectionDescriptor.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: AddCollectionDescriptor.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:28 $
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.awt.image.renderable.RenderableImage;
018:        import java.util.Collection;
019:        import java.util.Iterator;
020:        import javax.media.jai.JAI;
021:        import javax.media.jai.OperationDescriptorImpl;
022:        import javax.media.jai.ParameterBlockJAI;
023:        import javax.media.jai.ParameterListDescriptor;
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
031:         * "AddCollection" operation.
032:         *
033:         * <p> The AddCollection operation takes a collection of rendered
034:         * or renderable source images, and adds every set of pixels, one from
035:         * each source image of the corresponding position and band. No
036:         * additional parameters are required.
037:         *
038:         * <p> There is no restriction on the actual class type used to
039:         * represent the source collection, but all elements of the collection
040:         * must be instances of <code>RenderedImage</code> or
041:         * <code>RenderableImage</code> depending on the mode. The number of
042:         * images in the collection may vary from 2 to n.  The source images
043:         * may have different numbers of bands and data types.
044:         *
045:         * <p> By default, the destination image bounds are the intersection
046:         * of all of the source image bounds. If any of the two sources are
047:         * completely disjoint, the destination will have a width and a height
048:         * of 0. The number of bands of the destination image is equal to
049:         * the minimum number of bands of all the sources, and the data type is
050:         * the biggest data type of all the sources. If the result of the
051:         * operation underflows/overflows the minimum/maximum value supported
052:         * by the destination data type, then it will be clamped to the
053:         * minimum/maximum value respectively.
054:         *
055:         * <p> The destination pixel values are defined by the pseudocode:
056:         * <pre>
057:         * dst[x][y][b] = 0;
058:         * for (int i = 0; i < numSources; i++) {
059:         *     dst[x][y][b] += srcs[i][x][y][b];
060:         * }
061:         * </pre>
062:         *
063:         * <p><table border=1>
064:         * <caption>Resource List</caption>
065:         * <tr><th>Name</th>        <th>Value</th></tr>
066:         * <tr><td>GlobalName</td>  <td>AddCollection</td></tr>
067:         * <tr><td>LocalName</td>   <td>AddCollection</td></tr>
068:         * <tr><td>Vendor</td>      <td>com.sun.media.jai</td></tr>
069:         * <tr><td>Description</td> <td>Adds a collection of rendered images.</td></tr>
070:         * <tr><td>DocURL</td>      <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/AddCollectionDescriptor.html</td></tr>
071:         * <tr><td>Version</td>     <td>1.0</td></tr>
072:         * </table></p>
073:         *
074:         * <p> No parameters are needed for this operation.
075:         *
076:         * @see java.awt.image.RenderedImage
077:         * @see java.awt.image.renderable.RenderableImage
078:         * @see java.util.Collection
079:         * @see javax.media.jai.OperationDescriptor
080:         */
081:        public class AddCollectionDescriptor extends OperationDescriptorImpl {
082:
083:            /**
084:             * The resource strings that provide the general documentation
085:             * and specify the parameter list for this operation.
086:             */
087:            private static final String[][] resources = {
088:                    { "GlobalName", "AddCollection" },
089:                    { "LocalName", "AddCollection" },
090:                    { "Vendor", "com.sun.media.jai" },
091:                    { "Description",
092:                            JaiI18N.getString("AddCollectionDescriptor0") },
093:                    {
094:                            "DocURL",
095:                            "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/AddCollectionDescriptor.html" },
096:                    { "Version", JaiI18N.getString("DescriptorVersion") } };
097:
098:            /** The source class list for this operation. */
099:            private static final Class[][] sourceClasses = {
100:                    { java.util.Collection.class },
101:                    { java.util.Collection.class } };
102:
103:            private static final String[] supportedModes = { "rendered",
104:                    "renderable" };
105:
106:            /** Constructor. */
107:            public AddCollectionDescriptor() {
108:                super (resources, supportedModes, null, sourceClasses,
109:                        (ParameterListDescriptor) null);
110:            }
111:
112:            /** Validates input source collection. */
113:            protected boolean validateSources(String modeName,
114:                    ParameterBlock args, StringBuffer msg) {
115:                if (!super .validateSources(modeName, args, msg)) {
116:                    return false;
117:                }
118:
119:                Collection col = (Collection) args.getSource(0);
120:
121:                if (col.size() < 2) {
122:                    msg.append(getName() + " "
123:                            + JaiI18N.getString("AddCollectionDescriptor1"));
124:                    return false;
125:                }
126:
127:                Iterator iter = col.iterator();
128:                if (modeName.equalsIgnoreCase(RenderedRegistryMode.MODE_NAME)) {
129:                    while (iter.hasNext()) {
130:                        Object o = iter.next();
131:                        if (!(o instanceof  RenderedImage)) {
132:                            msg
133:                                    .append(getName()
134:                                            + " "
135:                                            + JaiI18N
136:                                                    .getString("AddCollectionDescriptor2"));
137:                            return false;
138:                        }
139:                    }
140:                } else if (modeName
141:                        .equalsIgnoreCase(RenderableRegistryMode.MODE_NAME)) {
142:                    while (iter.hasNext()) {
143:                        Object o = iter.next();
144:                        if (!(o instanceof  RenderableImage)) {
145:                            msg
146:                                    .append(getName()
147:                                            + " "
148:                                            + JaiI18N
149:                                                    .getString("AddCollectionDescriptor3"));
150:                            return false;
151:                        }
152:                    }
153:                }
154:
155:                return true;
156:            }
157:
158:            /**
159:             * Adds a collection of images.
160:             *
161:             * <p>Creates a <code>ParameterBlockJAI</code> from all
162:             * supplied arguments except <code>hints</code> and invokes
163:             * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
164:             *
165:             * @see JAI
166:             * @see ParameterBlockJAI
167:             * @see RenderedOp
168:             *
169:             * @param source0 <code>Collection</code> source 0.
170:             * @param hints The <code>RenderingHints</code> to use.
171:             * May be <code>null</code>.
172:             * @return The <code>RenderedOp</code> destination.
173:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
174:             */
175:            public static RenderedOp create(Collection source0,
176:                    RenderingHints hints) {
177:                ParameterBlockJAI pb = new ParameterBlockJAI("AddCollection",
178:                        RenderedRegistryMode.MODE_NAME);
179:
180:                pb.setSource("source0", source0);
181:
182:                return JAI.create("AddCollection", pb, hints);
183:            }
184:
185:            /**
186:             * Adds a collection of images.
187:             *
188:             * <p>Creates a <code>ParameterBlockJAI</code> from all
189:             * supplied arguments except <code>hints</code> and invokes
190:             * {@link JAI#createRenderable(String,ParameterBlock,RenderingHints)}.
191:             *
192:             * @see JAI
193:             * @see ParameterBlockJAI
194:             * @see RenderableOp
195:             *
196:             * @param source0 <code>Collection</code> source 0.
197:             * @param hints The <code>RenderingHints</code> to use.
198:             * May be <code>null</code>.
199:             * @return The <code>RenderableOp</code> destination.
200:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
201:             */
202:            public static RenderableOp createRenderable(Collection source0,
203:                    RenderingHints hints) {
204:                ParameterBlockJAI pb = new ParameterBlockJAI("AddCollection",
205:                        RenderableRegistryMode.MODE_NAME);
206:
207:                pb.setSource("source0", source0);
208:
209:                return JAI.createRenderable("AddCollection", pb, hints);
210:            }
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.