private void writeObject(ObjectOutputStream out) throws IOException {
        // -- Create a serializable form of the RenderingHints object. --

        // Create an empty Hashtable.
        Hashtable table = new Hashtable();

        // If there are hints, add them to the table.
        if(hints != null && !hints.isEmpty()) {
            // Get a view of the hints' keys.
            Set keySet = hints.keySet();

            // Proceed if the key set is non-empty.
            if(!keySet.isEmpty()) {
                // Get an iterator for the key set.
                Iterator keyIterator = keySet.iterator();

                // Get the cached hint table.
                Hashtable hintTable = getHintTable();

                // Get the suppressed key Vector.
                Vector suppressedKeys = getSuppressedKeys();

                // Loop over the keys.
                while(keyIterator.hasNext()) {
                    // Get the next key.
                    Object key = keyIterator.next();

                    // Skip this element if the key is suppressed.
                    if(suppressedKeys != null &&
                       suppressedKeys.indexOf(key) != -1) {
                        continue;
                    }

                    // Get the field of the key.
                    HintElement keyElement = (HintElement)hintTable.get(key);

                    // If the key was not in the table it is not a public
                    // static field in one of the KEY_CLASSES so skip it.
                    if(keyElement == null) {
                        continue;
                    }

                    // Get the next value.
                    Object value = hints.get(key);

                    // Pack the key/value pair in a Hashtable entry.
                    HintElement valueElement = null;
                    try {
                        // Try to create a HintElement from the value directly.
                        valueElement = new HintElement(value);
                    } catch(NotSerializableException nse) {
                        // The value is not serializable so try to get a
                        // HintElement from the table in case the value is
                        // a public static field in one of the KEY_CLASSES.
                        valueElement = (HintElement)hintTable.get(value);
                    }

                    // If the value element is valid add it and its key.
                    if(valueElement != null) {
                        table.put(keyElement, valueElement);
                    }
                }
            }
        }

        // Write serialized form to the stream.
        out.writeObject(table);
    }