Source Code Cross Referenced for RIFRegistry.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » javax » media » jai » registry » 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.registry 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: RIFRegistry.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:48 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai.registry;
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.RenderedImageFactory;
018:        import java.util.Iterator;
019:        import java.util.List;
020:        import java.util.Vector;
021:        import javax.media.jai.JAI;
022:        import javax.media.jai.OperationNode;
023:        import javax.media.jai.OperationRegistry;
024:        import javax.media.jai.PropertySource;
025:        import javax.media.jai.RenderedOp;
026:
027:        /**
028:         * Utility class to provide type-safe interaction with the
029:         * <code>OperationRegistry</code> for <code>RenderedImageFactory</code>
030:         * objects.
031:         *
032:         * If the <code>OperationRegistry</code> is <code>null</code>, then
033:         * <code>JAI.getDefaultInstance().getOperationRegistry()</code> will be used.
034:         *
035:         * @since JAI 1.1
036:         */
037:        public final class RIFRegistry {
038:
039:            private static final String MODE_NAME = RenderedRegistryMode.MODE_NAME;
040:
041:            /**
042:             * Register a RIF with a particular product and operation
043:             * against a specified mode. This is JAI 1.0.x equivalent
044:             * of <code>registry.registerRIF(...)</code>
045:             *
046:             * @param registry the <code>OperationRegistry</code> to register with.
047:             *         if this is <code>null</code>, then <code>
048:             *         JAI.getDefaultInstance().getOperationRegistry()</code>
049:             *         will be used.
050:             * @param operationName the operation name as a <code>String</code>
051:             * @param productName the product name as a <code>String</code>
052:             * @param rif the <code>RenderedImageFactory</code> to be registered
053:             *
054:             * @throws IllegalArgumentException if operationName, productName,
055:             *             or rif is <code>null</code>
056:             * @throws IllegalArgumentException if there is no <code>
057:             *             OperationDescriptor</code> registered against
058:             *             the <code>operationName</code>
059:             */
060:            public static void register(OperationRegistry registry,
061:                    String operationName, String productName,
062:                    RenderedImageFactory rif) {
063:
064:                registry = (registry != null) ? registry : JAI
065:                        .getDefaultInstance().getOperationRegistry();
066:
067:                registry.registerFactory(MODE_NAME, operationName, productName,
068:                        rif);
069:            }
070:
071:            /**
072:             * Unregister a RIF previously registered with a product
073:             * and operation against the specified mode.
074:             *
075:             * @param registry the <code>OperationRegistry</code> to unregister from.
076:             *         if this is <code>null</code>, then <code>
077:             *         JAI.getDefaultInstance().getOperationRegistry()</code>
078:             *         will be used.
079:             * @param operationName the operation name as a <code>String</code>
080:             * @param productName the product name as a <code>String</code>
081:             * @param rif the <code>RenderedImageFactory</code> to be unregistered
082:             *
083:             * @throws IllegalArgumentException if operationName, productName,
084:             *             or rif is <code>null</code>
085:             * @throws IllegalArgumentException if there is no <code>
086:             *             OperationDescriptor</code> registered against
087:             *             the <code>operationName</code>
088:             * @throws IllegalArgumentException if the rif was not previously
089:             *             registered against operationName and productName
090:             */
091:            public static void unregister(OperationRegistry registry,
092:                    String operationName, String productName,
093:                    RenderedImageFactory rif) {
094:
095:                registry = (registry != null) ? registry : JAI
096:                        .getDefaultInstance().getOperationRegistry();
097:
098:                registry.unregisterFactory(MODE_NAME, operationName,
099:                        productName, rif);
100:            }
101:
102:            /**
103:             * Sets a preference between two rifs for a given operation under a
104:             * specified product.
105:             *
106:             * @param registry the <code>OperationRegistry</code> to use.
107:             *         if this is <code>null</code>, then <code>
108:             *         JAI.getDefaultInstance().getOperationRegistry()</code>
109:             *         will be used.
110:             * @param operationName the operation name as a <code>String</code>
111:             * @param productName the product name as a <code>String</code>
112:             * @param preferredRIF the preferred rif
113:             * @param otherRIF the other rif
114:             *
115:             * @throws IllegalArgumentException if operationName, productName,
116:             *             preferredRIF or otherRIF is <code>null</code>
117:             * @throws IllegalArgumentException if there is no <code>
118:             *             OperationDescriptor</code> registered against
119:             *             the <code>operationName</code>
120:             * @throws IllegalArgumentException if either of the rifs
121:             *             were not previously registered against
122:             *             operationName and productName
123:             */
124:            public static void setPreference(OperationRegistry registry,
125:                    String operationName, String productName,
126:                    RenderedImageFactory preferredRIF,
127:                    RenderedImageFactory otherRIF) {
128:
129:                registry = (registry != null) ? registry : JAI
130:                        .getDefaultInstance().getOperationRegistry();
131:
132:                registry.setFactoryPreference(MODE_NAME, operationName,
133:                        productName, preferredRIF, otherRIF);
134:            }
135:
136:            /**
137:             * Unsets a preference between two rifs for a given operation under
138:             * a specified product.
139:             *
140:             * @param registry the <code>OperationRegistry</code> to use.
141:             *         if this is <code>null</code>, then <code>
142:             *         JAI.getDefaultInstance().getOperationRegistry()</code>
143:             *         will be used.
144:             * @param operationName the operation name as a <code>String</code>
145:             * @param productName the product name as a <code>String</code>
146:             * @param preferredRIF the factory object formerly preferred
147:             * @param otherRIF the other factory object
148:             *
149:             * @throws IllegalArgumentException if operationName, productName,
150:             *             preferredRIF or otherRIF is <code>null</code>
151:             * @throws IllegalArgumentException if there is no <code>
152:             *             OperationDescriptor</code> registered against
153:             *             the <code>operationName</code>
154:             * @throws IllegalArgumentException if either of the rifs
155:             *             were not previously registered against
156:             *             operationName and productName
157:             */
158:            public static void unsetPreference(OperationRegistry registry,
159:                    String operationName, String productName,
160:                    RenderedImageFactory preferredRIF,
161:                    RenderedImageFactory otherRIF) {
162:
163:                registry = (registry != null) ? registry : JAI
164:                        .getDefaultInstance().getOperationRegistry();
165:
166:                registry.unsetFactoryPreference(MODE_NAME, operationName,
167:                        productName, preferredRIF, otherRIF);
168:            }
169:
170:            /**
171:             * Removes all preferences between RIFs within a product registered
172:             * under a particular <code>OperationDescriptor</code>.
173:             *
174:             * @param registry the <code>OperationRegistry</code> to use.
175:             *         if this is <code>null</code>, then <code>
176:             *         JAI.getDefaultInstance().getOperationRegistry()</code>
177:             *         will be used.
178:             * @param operationName the operation name as a <code>String</code>
179:             * @param productName the product name as a <code>String</code>
180:             *
181:             * @throws IllegalArgumentException if operationName or productName
182:             *             is <code>null</code>
183:             * @throws IllegalArgumentException if there is no <code>
184:             *             OperationDescriptor</code> registered against
185:             *             the <code>operationName</code>
186:             */
187:            public static void clearPreferences(OperationRegistry registry,
188:                    String operationName, String productName) {
189:
190:                registry = (registry != null) ? registry : JAI
191:                        .getDefaultInstance().getOperationRegistry();
192:
193:                registry.clearFactoryPreferences(MODE_NAME, operationName,
194:                        productName);
195:            }
196:
197:            /**
198:             * Returns a list of the RIFs of a product registered under a
199:             * particular <code>OperationDescriptor</code>, in an ordering
200:             * that satisfies all of the pairwise preferences that have
201:             * been set. Returns <code>null</code> if cycles exist. Returns
202:             * <code>null</code>, if the product does not exist under this
203:             * operationName.
204:             *
205:             * @param registry the <code>OperationRegistry</code> to use.
206:             *         if this is <code>null</code>, then <code>
207:             *         JAI.getDefaultInstance().getOperationRegistry()</code>
208:             *         will be used.
209:             * @param operationName the operation name as a <code>String</code>
210:             * @param productName the product name as a <code>String</code>
211:             *
212:             * @return an ordered <code>List</code> of RIFs
213:             *
214:             * @throws IllegalArgumentException if operationName or productName
215:             *             is <code>null</code>
216:             * @throws IllegalArgumentException if there is no <code>
217:             *             OperationDescriptor</code> registered against
218:             *             the <code>operationName</code>
219:             */
220:            public static List getOrderedList(OperationRegistry registry,
221:                    String operationName, String productName) {
222:
223:                registry = (registry != null) ? registry : JAI
224:                        .getDefaultInstance().getOperationRegistry();
225:
226:                return registry.getOrderedFactoryList(MODE_NAME, operationName,
227:                        productName);
228:            }
229:
230:            /**
231:             * Returns an <code>Iterator</code> over all <code>
232:             * RenderedImageFactory</code> objects registered under the
233:             * operation name over all products. The order of objects in
234:             * the iteration will be according to the pairwise preferences
235:             * among products and image factories within a product. The
236:             * <code>remove()</code> method of the <code>Iterator</code>
237:             * may not be implemented.
238:             *
239:             * @param registry the <code>OperationRegistry</code> to use.
240:             *         if this is <code>null</code>, then <code>
241:             *         JAI.getDefaultInstance().getOperationRegistry()</code>
242:             *         will be used.
243:             * @param operationName the operation name as a <code>String</code>
244:             *
245:             * @return an <code>Iterator</code> over <code>RenderedImageFactory</code> objects
246:             *
247:             * @throws IllegalArgumentException if operationName is <code>null</code>
248:             * @throws IllegalArgumentException if there is no <code>
249:             *             OperationDescriptor</code> registered against
250:             *             the <code>operationName</code>
251:             *
252:             * @since JAI 1.1
253:             */
254:            public static Iterator getIterator(OperationRegistry registry,
255:                    String operationName) {
256:
257:                registry = (registry != null) ? registry : JAI
258:                        .getDefaultInstance().getOperationRegistry();
259:
260:                return registry.getFactoryIterator(MODE_NAME, operationName);
261:            }
262:
263:            /**
264:             * Returns the the most preferred <code>RenderedImageFactory</code>
265:             * object registered against the operation name. This
266:             * method will return the first object that would be
267:             * encountered by the <code>Iterator</code> returned by the
268:             * <code>getIterator()</code> method.
269:             *
270:             * @param registry the <code>OperationRegistry</code> to use.
271:             *         if this is <code>null</code>, then <code>
272:             *         JAI.getDefaultInstance().getOperationRegistry()</code>
273:             *         will be used.
274:             * @param operationName the operation name as a <code>String</code>
275:             *
276:             * @return a registered <code>RenderedImageFactory</code> object
277:             *
278:             * @throws IllegalArgumentException if operationName is <code>null</code>
279:             * @throws IllegalArgumentException if there is no <code>
280:             *             OperationDescriptor</code> registered against
281:             *             the <code>operationName</code>
282:             */
283:            public static RenderedImageFactory get(OperationRegistry registry,
284:                    String operationName) {
285:
286:                registry = (registry != null) ? registry : JAI
287:                        .getDefaultInstance().getOperationRegistry();
288:
289:                return (RenderedImageFactory) registry.getFactory(MODE_NAME,
290:                        operationName);
291:            }
292:
293:            /**
294:             * Constructs a <code>RenderedImage</code> (usually a
295:             * <code>RenderedOp</code>) representing the results of applying
296:             * a given operation to a particular ParameterBlock and rendering
297:             * hints. The registry is used to determine the RIF to be used to
298:             * instantiate the operation.
299:             *
300:             * <p> If none of the RIFs registered with this
301:             * <code>OperationRegistry</code> returns a non-null value, null is
302:             * returned. Exceptions thrown by the RIFs will be caught by this
303:             * method and will not be propagated.
304:             *
305:             * @param registry the <code>OperationRegistry</code> to use.
306:             *         if this is <code>null</code>, then <code>
307:             *         JAI.getDefaultInstance().getOperationRegistry()</code>
308:             *         will be used.
309:             * @param operationName the operation name as a <code>String</code>
310:             * @param paramBlock the operation's ParameterBlock.
311:             * @param renderHints a <code>RenderingHints</code> object
312:             *         containing rendering hints.
313:             *
314:             * @throws IllegalArgumentException if operationName is <code>null</code>
315:             * @throws IllegalArgumentException if there is no <code>
316:             *             OperationDescriptor</code> registered against
317:             *             the <code>operationName</code>
318:             */
319:            public static RenderedImage create(OperationRegistry registry,
320:                    String operationName, ParameterBlock paramBlock,
321:                    RenderingHints renderHints) {
322:
323:                registry = (registry != null) ? registry : JAI
324:                        .getDefaultInstance().getOperationRegistry();
325:
326:                Object args[] = { paramBlock, renderHints };
327:
328:                return (RenderedImage) registry.invokeFactory(MODE_NAME,
329:                        operationName, args);
330:            }
331:
332:            /**
333:             * Constructs and returns a <code>PropertySource</code> suitable for
334:             * use by a given <code>RenderedOp</code>.  The 
335:             * <code>PropertySource</code> includes properties copied from prior 
336:             * nodes as well as those generated at the node itself. Additionally,
337:             * property suppression is taken into account. The actual 
338:             * implementation of <code>getPropertySource()</code> may make use
339:             * of deferred execution and caching.
340:             *
341:             * @param op the <code>RenderedOp</code> requesting its 
342:             *        <code>PropertySource</code>.
343:             *
344:             * @throws IllegalArgumentException if <code>op</code> is <code>null</code>
345:             */
346:            public static PropertySource getPropertySource(RenderedOp op) {
347:
348:                if (op == null)
349:                    throw new IllegalArgumentException("op - "
350:                            + JaiI18N.getString("Generic0"));
351:
352:                return op.getRegistry().getPropertySource((OperationNode) op);
353:            }
354:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.