Source Code Cross Referenced for CIFRegistry.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: CIFRegistry.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:47 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai.registry;
013:
014:        import java.awt.RenderingHints;
015:        import java.awt.image.renderable.ParameterBlock;
016:        import java.util.Iterator;
017:        import java.util.List;
018:        import java.util.Vector;
019:        import javax.media.jai.CollectionImage;
020:        import javax.media.jai.CollectionImageFactory;
021:        import javax.media.jai.CollectionOp;
022:        import javax.media.jai.JAI;
023:        import javax.media.jai.OperationNode;
024:        import javax.media.jai.OperationRegistry;
025:        import javax.media.jai.PropertySource;
026:
027:        /**
028:         * Utility class to provide type-safe interaction with the
029:         * <code>OperationRegistry</code> for <code>CollectionImageFactory</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 CIFRegistry {
038:
039:            private static final String MODE_NAME = CollectionRegistryMode.MODE_NAME;
040:
041:            /**
042:             * Register a CIF with a particular product and operation
043:             * against a specified mode. This is JAI 1.0.x equivalent
044:             * of <code>registry.registerCIF(...)</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 cif the <code>CollectionImageFactory</code> to be registered
053:             *
054:             * @throws IllegalArgumentException if operationName, productName,
055:             *             or cif 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:                    CollectionImageFactory cif) {
063:
064:                registry = (registry != null) ? registry : JAI
065:                        .getDefaultInstance().getOperationRegistry();
066:
067:                registry.registerFactory(MODE_NAME, operationName, productName,
068:                        cif);
069:            }
070:
071:            /**
072:             * Unregister a CIF 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 cif the <code>CollectionImageFactory</code> to be unregistered
082:             *
083:             * @throws IllegalArgumentException if operationName, productName,
084:             *             or cif 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 cif was not previously
089:             *             registered against operationName and productName
090:             */
091:            public static void unregister(OperationRegistry registry,
092:                    String operationName, String productName,
093:                    CollectionImageFactory cif) {
094:
095:                registry = (registry != null) ? registry : JAI
096:                        .getDefaultInstance().getOperationRegistry();
097:
098:                registry.unregisterFactory(MODE_NAME, operationName,
099:                        productName, cif);
100:            }
101:
102:            /**
103:             * Sets a preference between two cifs 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 preferredCIF the preferred cif
113:             * @param otherCIF the other cif
114:             *
115:             * @throws IllegalArgumentException if operationName, productName,
116:             *             preferredCIF or otherCIF 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 cifs
121:             *             were not previously registered against
122:             *             operationName and productName
123:             */
124:            public static void setPreference(OperationRegistry registry,
125:                    String operationName, String productName,
126:                    CollectionImageFactory preferredCIF,
127:                    CollectionImageFactory otherCIF) {
128:
129:                registry = (registry != null) ? registry : JAI
130:                        .getDefaultInstance().getOperationRegistry();
131:
132:                registry.setFactoryPreference(MODE_NAME, operationName,
133:                        productName, preferredCIF, otherCIF);
134:            }
135:
136:            /**
137:             * Unsets a preference between two cifs 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 preferredCIF the factory object formerly preferred
147:             * @param otherCIF the other factory object
148:             *
149:             * @throws IllegalArgumentException if operationName, productName,
150:             *             preferredCIF or otherCIF 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 cifs
155:             *             were not previously registered against
156:             *             operationName and productName
157:             */
158:            public static void unsetPreference(OperationRegistry registry,
159:                    String operationName, String productName,
160:                    CollectionImageFactory preferredCIF,
161:                    CollectionImageFactory otherCIF) {
162:
163:                registry = (registry != null) ? registry : JAI
164:                        .getDefaultInstance().getOperationRegistry();
165:
166:                registry.unsetFactoryPreference(MODE_NAME, operationName,
167:                        productName, preferredCIF, otherCIF);
168:            }
169:
170:            /**
171:             * Removes all preferences between CIFs 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 CIFs 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 CIFs
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:             * CollectionImageFactory</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>CollectionImageFactory</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>CollectionImageFactory</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>CollectionImageFactory</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 CollectionImageFactory get(
284:                    OperationRegistry registry, String operationName) {
285:
286:                registry = (registry != null) ? registry : JAI
287:                        .getDefaultInstance().getOperationRegistry();
288:
289:                return (CollectionImageFactory) registry.getFactory(MODE_NAME,
290:                        operationName);
291:            }
292:
293:            /**
294:             * Constructs a <code>CollectionImageFactory</code> (usually a
295:             * <code>CollectionOp</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 CIF to be used to
298:             * instantiate the operation.
299:             *
300:             * <p> If none of the CIFs registered with this
301:             * <code>OperationRegistry</code> returns a non-null value, null is
302:             * returned. Exceptions thrown by the CIFs 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 CollectionImage 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 (CollectionImage) 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>CollectionOp</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 implementation
338:             * of <code>getPropertySource()</code> may make use of deferred
339:             * execution and caching.
340:             *
341:             * @param op the <code>CollectionOp</code> requesting its 
342:             *        <code>PropertySource</code>.
343:             *
344:             * @throws IllegalArgumentException if <code>op</code> is <code>null</code>
345:             * @throws IllegalArgumentException if <code>op.isRenderable()</code>
346:             *	    returns <code>true</code>
347:             */
348:            public static PropertySource getPropertySource(CollectionOp op) {
349:
350:                if (op == null)
351:                    throw new IllegalArgumentException("op - "
352:                            + JaiI18N.getString("Generic0"));
353:
354:                if (op.isRenderable())
355:                    throw new IllegalArgumentException("op - "
356:                            + JaiI18N.getString("CIFRegistry0"));
357:
358:                return op.getRegistry().getPropertySource((OperationNode) op);
359:            }
360:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.