FileDocCategorySizeDatePackage
RenderingHints.javaAPI DocJava SE 5 API24619Fri Aug 26 14:56:46 BST 2005java.awt

RenderingHints

public class RenderingHints extends Object implements Cloneable, Map
The RenderingHints class contains rendering hints that can be used by the {@link java.awt.Graphics2D} class, and classes that implement {@link java.awt.image.BufferedImageOp} and {@link java.awt.image.Raster}.

Fields Summary
HashMap
hintmap
public static final Key
KEY_ANTIALIASING
Antialiasing hint key.
public static final Object
VALUE_ANTIALIAS_ON
Antialiasing hint values -- rendering is done with antialiasing.
public static final Object
VALUE_ANTIALIAS_OFF
Antialiasing hint values -- rendering is done without antialiasing.
public static final Object
VALUE_ANTIALIAS_DEFAULT
Antialiasing hint values -- rendering is done with the platform default antialiasing mode.
public static final Key
KEY_RENDERING
Rendering hint key.
public static final Object
VALUE_RENDER_SPEED
Rendering hint values -- Appropriate rendering algorithms are chosen with a preference for output speed.
public static final Object
VALUE_RENDER_QUALITY
Rendering hint values -- Appropriate rendering algorithms are chosen with a preference for output quality.
public static final Object
VALUE_RENDER_DEFAULT
Rendering hint values -- The platform default rendering algorithms are chosen.
public static final Key
KEY_DITHERING
Dithering hint key.
public static final Object
VALUE_DITHER_DISABLE
Dithering hint values -- do not dither when rendering.
public static final Object
VALUE_DITHER_ENABLE
Dithering hint values -- dither when rendering, if needed.
public static final Object
VALUE_DITHER_DEFAULT
Dithering hint values -- use the platform default for dithering.
public static final Key
KEY_TEXT_ANTIALIASING
Text antialiasing hint key.
public static final Object
VALUE_TEXT_ANTIALIAS_ON
Text antialiasing hint value -- text rendering is done with antialiasing.
public static final Object
VALUE_TEXT_ANTIALIAS_OFF
Text antialiasing hint value -- text rendering is done without antialiasing.
public static final Object
VALUE_TEXT_ANTIALIAS_DEFAULT
Text antialiasing hint value -- text rendering is done using the platform default text antialiasing mode.
public static final Key
KEY_FRACTIONALMETRICS
Font fractional metrics hint key.
public static final Object
VALUE_FRACTIONALMETRICS_OFF
Font fractional metrics hint values -- fractional metrics disabled.
public static final Object
VALUE_FRACTIONALMETRICS_ON
Font fractional metrics hint values -- fractional metrics enabled.
public static final Object
VALUE_FRACTIONALMETRICS_DEFAULT
Font fractional metrics hint values -- use the platform default for fractional metrics.
public static final Key
KEY_INTERPOLATION
Interpolation hint key.
public static final Object
VALUE_INTERPOLATION_NEAREST_NEIGHBOR
Interpolation hint value -- INTERPOLATION_NEAREST_NEIGHBOR.
public static final Object
VALUE_INTERPOLATION_BILINEAR
Interpolation hint value -- INTERPOLATION_BILINEAR.
public static final Object
VALUE_INTERPOLATION_BICUBIC
Interpolation hint value -- INTERPOLATION_BICUBIC.
public static final Key
KEY_ALPHA_INTERPOLATION
Alpha interpolation hint key.
public static final Object
VALUE_ALPHA_INTERPOLATION_SPEED
Alpha interpolation hint value -- ALPHA_INTERPOLATION_SPEED.
public static final Object
VALUE_ALPHA_INTERPOLATION_QUALITY
Alpha interpolation hint value -- ALPHA_INTERPOLATION_QUALITY.
public static final Object
VALUE_ALPHA_INTERPOLATION_DEFAULT
Alpha interpolation hint value -- ALPHA_INTERPOLATION_DEFAULT.
public static final Key
KEY_COLOR_RENDERING
Color rendering hint key.
public static final Object
VALUE_COLOR_RENDER_SPEED
Color rendering hint value -- COLOR_RENDER_SPEED.
public static final Object
VALUE_COLOR_RENDER_QUALITY
Color rendering hint value -- COLOR_RENDER_QUALITY.
public static final Object
VALUE_COLOR_RENDER_DEFAULT
Color rendering hint value -- COLOR_RENDER_DEFAULT.
public static final Key
KEY_STROKE_CONTROL
Stroke normalization control hint key.
public static final Object
VALUE_STROKE_DEFAULT
Stroke normalization control hint value -- STROKE_DEFAULT.
public static final Object
VALUE_STROKE_NORMALIZE
Stroke normalization control hint value -- STROKE_NORMALIZE.
public static final Object
VALUE_STROKE_PURE
Stroke normalization control hint value -- STROKE_PURE.
Constructors Summary
public RenderingHints(Map init)
Constructs a new object with keys and values initialized from the specified Map object (which may be null).

param
init a map of key/value pairs to initialize the hints or null if the object should be empty


                                 		            
       
	if (init != null) {
	    hintmap.putAll(init);
	}
    
public RenderingHints(Key key, Object value)
Constructs a new object with the specified key/value pair.

param
key the key of the particular hint property
param
value the value of the hint property specified with key

	hintmap.put(key, value);
    
Methods Summary
public voidadd(java.awt.RenderingHints hints)
Adds all of the keys and corresponding values from the specified RenderingHints object to this RenderingHints object. Keys that are present in this RenderingHints object, but not in the specified RenderingHints object are not affected.

param
hints the set of key/value pairs to be added to this RenderingHints object

	hintmap.putAll(hints.hintmap);
    
public voidclear()
Clears this RenderingHints object of all key/value pairs.

	hintmap.clear();
    
public java.lang.Objectclone()
Creates a clone of this RenderingHints object that has the same contents as this RenderingHints object.

return
a clone of this instance.

        RenderingHints rh;
        try {
            rh = (RenderingHints) super.clone();
	    if (hintmap != null) {
		rh.hintmap = (HashMap) hintmap.clone();
	    }
        } catch (CloneNotSupportedException e) {
	    // this shouldn't happen, since we are Cloneable
	    throw new InternalError();
	}

        return rh;
    
public booleancontainsKey(java.lang.Object key)
Returns true if this RenderingHints contains a mapping for the specified key.

param
key key whose presence in this RenderingHints is to be tested.
return
true if this RenderingHints contains a mapping for the specified key.
exception
ClassCastException key is not of type RenderingHints.Key
exception
NullPointerException key is null

	return hintmap.containsKey((Key) key);
    
public booleancontainsValue(java.lang.Object value)
Returns true if this RenderingHints maps one or more keys to the specified value. More formally, returns true if and only if this RenderingHints contains at least one mapping to a value v such that
(value==null ? v==null : value.equals(v))
. This operation will probably require time linear in the RenderingHints size for most implementations of RenderingHints.

param
value value whose presence in this RenderingHints is to be tested.
return
true if this RenderingHints maps one or more keys to the specified value.

	return hintmap.containsValue(value);
    
public java.util.SetentrySet()
Returns a Set view of the mappings contained in this RenderingHints. Each element in the returned Set is a Map.Entry. The Set is backed by the RenderingHints, so changes to the RenderingHints are reflected in the Set, and vice-versa. If the RenderingHints is modified while while an iteration over the Set is in progress, the results of the iteration are undefined.

The entrySet returned from a RenderingHints object is not modifiable.

return
a Set view of the mappings contained in this RenderingHints.

	return Collections.unmodifiableMap(hintmap).entrySet();
    
public booleanequals(java.lang.Object o)
Compares the specified Object with this RenderingHints for equality. Returns true if the specified object is also a Map and the two Map objects represent the same mappings. More formally, two Map objects t1 and t2 represent the same mappings if t1.keySet().equals(t2.keySet()) and for every key k in t1.keySet(),
(t1.get(k)==null ? t2.get(k)==null : t1.get(k).equals(t2.get(k)))
. This ensures that the equals method works properly across different implementations of the Map interface.

param
o Object to be compared for equality with this RenderingHints.
return
true if the specified Object is equal to this RenderingHints.

	if (o instanceof RenderingHints) {
	    return hintmap.equals(((RenderingHints) o).hintmap);
	} else if (o instanceof Map) {
	    return hintmap.equals(o);
	}
	return false;
    
public java.lang.Objectget(java.lang.Object key)
Returns the value to which the specified key is mapped.

param
key a rendering hint key
return
the value to which the key is mapped in this object or null if the key is not mapped to any value in this object.
exception
ClassCastException key is not of type RenderingHints.Key.
see
#put(Object, Object)

	return hintmap.get((Key) key);
    
public inthashCode()
Returns the hash code value for this RenderingHints. The hash code of a RenderingHints is defined to be the sum of the hashCodes of each Entry in the RenderingHints object's entrySet view. This ensures that t1.equals(t2) implies that t1.hashCode()==t2.hashCode() for any two Map objects t1 and t2, as required by the general contract of Object.hashCode.

return
the hash code value for this RenderingHints.
see
java.util.Map.Entry#hashCode()
see
Object#hashCode()
see
Object#equals(Object)
see
#equals(Object)

	return hintmap.hashCode();
    
public booleanisEmpty()
Returns true if this RenderingHints contains no key-value mappings.

return
true if this RenderingHints contains no key-value mappings.

	return hintmap.isEmpty();
    
public java.util.SetkeySet()
Returns a Set view of the Keys contained in this RenderingHints. The Set is backed by the RenderingHints, so changes to the RenderingHints are reflected in the Set, and vice-versa. If the RenderingHints is modified while an iteration over the Set is in progress, the results of the iteration are undefined. The Set supports element removal, which removes the corresponding mapping from the RenderingHints, via the Iterator.remove, Set.remove, removeAll retainAll, and clear operations. It does not support the add or addAll operations.

return
a Set view of the keys contained in this RenderingHints.

	return hintmap.keySet();
    
public java.lang.Objectput(java.lang.Object key, java.lang.Object value)
Maps the specified key to the specified value in this RenderingHints object. Neither the key nor the value can be null. The value can be retrieved by calling the get method with a key that is equal to the original key.

param
key the rendering hint key.
param
value the rendering hint value.
return
the previous value of the specified key in this object or null if it did not have one.
exception
NullPointerException if the key or value is null.
exception
ClassCastException key is not of type RenderingHints.Key.
exception
IllegalArgumentException value is not appropriate for the specified key.
see
#get(Object)

	if (!((Key) key).isCompatibleValue(value)) {
	    throw new IllegalArgumentException(value+
					       " incompatible with "+
					       key);
	}
        return hintmap.put((Key) key, value);
    
public voidputAll(java.util.Map m)
Copies all of the mappings from the specified Map to this RenderingHints. These mappings replace any mappings that this RenderingHints had for any of the keys currently in the specified Map.

param
m the specified Map
exception
ClassCastException class of a key or value in the specified Map prevents it from being stored in this RenderingHints.
exception
IllegalArgumentException some aspect of a key or value in the specified Map prevents it from being stored in this RenderingHints.

	// ## javac bug?
	//if (m instanceof RenderingHints) {
	if (RenderingHints.class.isInstance(m)) {
	    //hintmap.putAll(((RenderingHints) m).hintmap);
	    for (Map.Entry<?,?> entry : m.entrySet())
		hintmap.put(entry.getKey(), entry.getValue());
	} else {
	    // Funnel each key/value pair through our protected put method
	    for (Map.Entry<?,?> entry : m.entrySet())
		put(entry.getKey(), entry.getValue());
	}
    
public java.lang.Objectremove(java.lang.Object key)
Removes the key and its corresponding value from this RenderingHints object. This method does nothing if the key is not in this RenderingHints object.

param
key the rendering hints key that needs to be removed
exception
ClassCastException key is not of type RenderingHints.Key.
return
the value to which the key had previously been mapped in this RenderingHints object, or null if the key did not have a mapping.

	return hintmap.remove((Key) key);
    
public intsize()
Returns the number of key-value mappings in this RenderingHints.

return
the number of key-value mappings in this RenderingHints.

	return hintmap.size();
    
public java.lang.StringtoString()
Returns a rather long string representation of the hashmap which contains the mappings of keys to values for this RenderingHints object.

return
a string representation of this object.

        if (hintmap == null) {
            return getClass().getName() + "@" +
                Integer.toHexString(hashCode()) +
                " (0 hints)";
        }

        return hintmap.toString();
    
public java.util.Collectionvalues()
Returns a Collection view of the values contained in this RenderinHints. The Collection is backed by the RenderingHints, so changes to the RenderingHints are reflected in the Collection, and vice-versa. If the RenderingHints is modified while an iteration over the Collection is in progress, the results of the iteration are undefined. The Collection supports element removal, which removes the corresponding mapping from the RenderingHints, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

return
a Collection view of the values contained in this RenderingHints.

	return hintmap.values();