01: /*
02: * $RCSfile: TileEncoderRegistryMode.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:50 $
10: * $State: Exp $
11: */package javax.media.jai.registry;
12:
13: import java.lang.reflect.Method;
14: import javax.media.jai.JAI;
15: import javax.media.jai.RegistryMode;
16: import javax.media.jai.tilecodec.TileCodecDescriptor;
17: import javax.media.jai.tilecodec.TileCodecParameterList;
18: import javax.media.jai.tilecodec.TileEncoderFactory;
19: import javax.media.jai.util.ImagingListener;
20:
21: /**
22: * A class which provides information about the "tileEncoder" registry
23: * mode.
24: *
25: * @since JAI 1.1
26: */
27: public class TileEncoderRegistryMode extends RegistryMode {
28:
29: public static final String MODE_NAME = "tileEncoder";
30:
31: // Method to return the factory method for the "tileDecoder" mode.
32: // The Method used to "create" objects from this factory.
33: private static Method factoryMethod = null;
34:
35: private static Method getThisFactoryMethod() {
36:
37: if (factoryMethod != null)
38: return factoryMethod;
39:
40: // The factory Class that this registry mode represents.
41: Class factoryClass = TileEncoderFactory.class;
42:
43: try {
44: Class[] paramTypes = new Class[] {
45: java.io.OutputStream.class,
46: TileCodecParameterList.class,
47: java.awt.image.SampleModel.class };
48:
49: factoryMethod = factoryClass.getMethod("createEncoder",
50: paramTypes);
51:
52: } catch (NoSuchMethodException e) {
53: ImagingListener listener = JAI.getDefaultInstance()
54: .getImagingListener();
55: String message = JaiI18N.getString("RegistryMode0") + " "
56: + factoryClass.getName() + ".";
57: listener.errorOccurred(message, e,
58: TileEncoderRegistryMode.class, false);
59: // e.printStackTrace();
60: }
61:
62: return factoryMethod;
63: }
64:
65: /**
66: * Creates a <code>TileEncoderRegistryMode</code> for describing
67: * the "tileEncoder" registry mode.
68: */
69: public TileEncoderRegistryMode() {
70: super (MODE_NAME, TileCodecDescriptor.class,
71: getThisFactoryMethod().getReturnType(),
72: getThisFactoryMethod(), // default factory method
73: true, // arePreferencesSupported
74: false); // arePropertiesSupported,
75: }
76: }
|