01: /*
02: * $RCSfile: RenderableRegistryMode.java,v $
03: *
04: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
05: *
06: * Use is subject to license terms.
07: *
08: * $Revision: 1.1 $
09: * $Date: 2005/02/11 04:57:49 $
10: * $State: Exp $
11: */
12: package javax.media.jai.registry;
13:
14: import java.awt.image.renderable.RenderableImage;
15: import java.lang.reflect.Method;
16: import javax.media.jai.JAI;
17: import javax.media.jai.RegistryMode;
18: import javax.media.jai.util.ImagingListener;
19:
20: /**
21: * A class that provides information about the "renderable" registry
22: * (operation) mode.
23: *
24: * @since JAI 1.1
25: */
26: public class RenderableRegistryMode extends RegistryMode {
27:
28: public static final String MODE_NAME = "renderable";
29:
30: // The Method used to "create" objects from this factory.
31: private static Method factoryMethod = null;
32:
33: private static Method getThisFactoryMethod() {
34:
35: if (factoryMethod != null)
36: return factoryMethod;
37:
38: // The factory Class that this registry mode represents.
39: Class factoryClass = java.awt.image.renderable.ContextualRenderedImageFactory.class;
40:
41: try {
42: Class[] paramTypes = new Class[] {
43: java.awt.image.renderable.RenderContext.class,
44: java.awt.image.renderable.ParameterBlock.class };
45:
46: factoryMethod = factoryClass
47: .getMethod("create", paramTypes);
48:
49: } catch (NoSuchMethodException e) {
50: ImagingListener listener = JAI.getDefaultInstance()
51: .getImagingListener();
52: String message = JaiI18N.getString("RegistryMode0") + " "
53: + factoryClass.getName() + ".";
54: listener.errorOccurred(message, e,
55: RenderableRegistryMode.class, false);
56: // e.printStackTrace();
57: }
58:
59: return factoryMethod;
60: }
61:
62: /**
63: * Constructor. A <code>RegistryMode</code> that represents a
64: * <code>ContextualRenderedImageFactory</code> keyed in a case
65: * insensitive fashion by the string "renderable". The "renderable"
66: * mode has no preferences but supports properties.
67: */
68: public RenderableRegistryMode() {
69:
70: super (MODE_NAME, javax.media.jai.OperationDescriptor.class,
71: RenderableImage.class, getThisFactoryMethod(), false,
72: true);
73: }
74: }
|