01: /*
02: * $RCSfile: RenderingKeyState.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:56:54 $
10: * $State: Exp $
11: */
12: package com.sun.media.jai.rmi;
13:
14: import java.awt.RenderingHints;
15: import java.io.IOException;
16: import java.io.ObjectInputStream;
17: import java.io.ObjectOutputStream;
18: import java.io.Serializable;
19: import java.util.Hashtable;
20: import javax.media.jai.remote.SerializerFactory;
21:
22: /**
23: * This class is a serializable proxy for the predefined <code>
24: * RenderingHints.Key</code> objects.
25: * For a hint key, the name of the class which contains the declaration
26: * of this key and the field name of this declaration are recorded.
27: *
28: *
29: * @since 1.1
30: */
31: public class RenderingKeyState extends SerializableStateImpl {
32: /**
33: * Returns the classes supported by this SerializableState.
34: */
35: public static Class[] getSupportedClasses() {
36: return new Class[] { RenderingHints.Key.class };
37: }
38:
39: /** Support subclasses as Raster is a factory class. */
40: public static boolean permitsSubclasses() {
41: return true;
42: }
43:
44: private transient RenderingHintsState.HintElement predefinedKey;
45:
46: /**
47: * Constructs a <code>RenderingKeyState</code> from a
48: * <code>RenderingHints.Key</code> object.
49: *
50: * @param c The <code>Class</code> of the object to be serialized.
51: * @param o The object to be serialized.
52: * @param h The <code>RenderingHints</code> used in serialization.
53: */
54: public RenderingKeyState(Class c, Object o, RenderingHints h) {
55: super (c, o, h);
56:
57: Hashtable predefinedObjects = RenderingHintsState
58: .getHintTable();
59:
60: predefinedKey = (RenderingHintsState.HintElement) predefinedObjects
61: .get(o);
62:
63: if (predefinedKey == null)
64: throw new RuntimeException(JaiI18N
65: .getString("RenderingKeyState0"));
66: }
67:
68: private void writeObject(ObjectOutputStream out) throws IOException {
69: out.writeObject(predefinedKey);
70: }
71:
72: private void readObject(ObjectInputStream in) throws IOException,
73: ClassNotFoundException {
74: predefinedKey = (RenderingHintsState.HintElement) in
75: .readObject();
76: theObject = predefinedKey.getObject();
77: }
78: }
|