java.awt

Class RenderingHints

public class RenderingHints extends Object implements Map<Object,Object>, Cloneable

A collection of (key, value) items that provide 'hints' for the {@link java.awt.Graphics2D} rendering pipeline. Because these items are hints only, they may be ignored by a particular {@link java.awt.Graphics2D} implementation.
Nested Class Summary
abstract static classRenderingHints.Key
The base class used to represent keys.
Field Summary
static RenderingHints.KeyKEY_ALPHA_INTERPOLATION
A key for the 'alpha interpolation' hint.
static RenderingHints.KeyKEY_ANTIALIASING
A key for the 'antialiasing' hint.
static RenderingHints.KeyKEY_COLOR_RENDERING
A key for the 'color rendering' hint.
static RenderingHints.KeyKEY_DITHERING
A key for the 'dithering' hint.
static RenderingHints.KeyKEY_FRACTIONALMETRICS
A key for the 'fractional metrics' hint.
static RenderingHints.KeyKEY_INTERPOLATION
A key for the 'interpolation' hint.
static RenderingHints.KeyKEY_RENDERING
A key for the 'rendering' hint.
static RenderingHints.KeyKEY_STROKE_CONTROL
A key for the 'stroke control' hint.
static RenderingHints.KeyKEY_TEXT_ANTIALIASING
A key for the 'text antialiasing' hint.
static ObjectVALUE_ALPHA_INTERPOLATION_DEFAULT
This value is for use with the {@link #KEY_ALPHA_INTERPOLATION} key.
static ObjectVALUE_ALPHA_INTERPOLATION_QUALITY
This value is for use with the {@link #KEY_ALPHA_INTERPOLATION} key.
static ObjectVALUE_ALPHA_INTERPOLATION_SPEED
This value is for use with the {@link #KEY_ALPHA_INTERPOLATION} key.
static ObjectVALUE_ANTIALIAS_DEFAULT
This value is for use with the {@link #KEY_ANTIALIASING} key.
static ObjectVALUE_ANTIALIAS_OFF
This value is for use with the {@link #KEY_ANTIALIASING} key.
static ObjectVALUE_ANTIALIAS_ON
This value is for use with the {@link #KEY_ANTIALIASING} key.
static ObjectVALUE_COLOR_RENDER_DEFAULT
This value is for use with the {@link #KEY_COLOR_RENDERING} key.
static ObjectVALUE_COLOR_RENDER_QUALITY
This value is for use with the {@link #KEY_COLOR_RENDERING} key.
static ObjectVALUE_COLOR_RENDER_SPEED
This value is for use with the {@link #KEY_COLOR_RENDERING} key.
static ObjectVALUE_DITHER_DEFAULT
This value is for use with the {@link #KEY_DITHERING} key.
static ObjectVALUE_DITHER_DISABLE
This value is for use with the {@link #KEY_DITHERING} key.
static ObjectVALUE_DITHER_ENABLE
This value is for use with the {@link #KEY_DITHERING} key.
static ObjectVALUE_FRACTIONALMETRICS_DEFAULT
This value is for use with the {@link #KEY_FRACTIONALMETRICS} key.
static ObjectVALUE_FRACTIONALMETRICS_OFF
This value is for use with the {@link #KEY_FRACTIONALMETRICS} key.
static ObjectVALUE_FRACTIONALMETRICS_ON
This value is for use with the {@link #KEY_FRACTIONALMETRICS} key.
static ObjectVALUE_INTERPOLATION_BICUBIC
This value is for use with the {@link #KEY_INTERPOLATION} key.
static ObjectVALUE_INTERPOLATION_BILINEAR
This value is for use with the {@link #KEY_INTERPOLATION} key.
static ObjectVALUE_INTERPOLATION_NEAREST_NEIGHBOR
This value is for use with the {@link #KEY_INTERPOLATION} key.
static ObjectVALUE_RENDER_DEFAULT
This value is for use with the {@link #KEY_RENDERING} key.
static ObjectVALUE_RENDER_QUALITY
This value is for use with the {@link #KEY_RENDERING} key.
static ObjectVALUE_RENDER_SPEED
This value is for use with the {@link #KEY_RENDERING} key.
static ObjectVALUE_STROKE_DEFAULT
This value is for use with the {@link #KEY_STROKE_CONTROL} key.
static ObjectVALUE_STROKE_NORMALIZE
This value is for use with the {@link #KEY_STROKE_CONTROL} key.
static ObjectVALUE_STROKE_PURE
This value is for use with the {@link #KEY_STROKE_CONTROL} key.
static ObjectVALUE_TEXT_ANTIALIAS_DEFAULT
This value is for use with the {@link #KEY_TEXT_ANTIALIASING} key.
static ObjectVALUE_TEXT_ANTIALIAS_OFF
This value is for use with the {@link #KEY_TEXT_ANTIALIASING} key.
static ObjectVALUE_TEXT_ANTIALIAS_ON
This value is for use with the {@link #KEY_TEXT_ANTIALIASING} key.
Constructor Summary
RenderingHints(Map<RenderingHints.Key,?> init)
Creates a new collection of hints containing all the (key, value) pairs in the specified map.
RenderingHints(RenderingHints.Key key, Object value)
Creates a new collection containing a single (key, value) pair.
Method Summary
voidadd(RenderingHints hints)
Adds all the hints from a collection to this collection.
voidclear()
Clears all the hints from this collection.
Objectclone()
Creates a clone of this instance.
booleancontainsKey(Object key)
Returns true if the collection of hints contains the specified key, and false otherwise.
booleancontainsValue(Object value)
Returns true if the collection of hints contains the specified value, and false otherwise.
Set<Entry<Object,Object>>entrySet()
Returns a set of entries from the collection.
booleanequals(Object o)
Checks this collection for equality with an arbitrary object.
Objectget(Object key)
Returns the value associated with the specified key, or null if there is no value defined for the key.
inthashCode()
Returns a hash code for the collection of hints.
booleanisEmpty()
Returns true if there are no hints in the collection, and false otherwise.
Set<Object>keySet()
Returns a set containing the keys from this collection.
Objectput(Object key, Object value)
Adds a (key, value) pair to the collection of hints (if the collection already contains the specified key, then the value is updated).
voidputAll(Map<?,?> m)
Adds a collection of (key, value) pairs to the collection.
Objectremove(Object key)
Removes a hint from the collection.
intsize()
Returns the number of hints in the collection.
StringtoString()
Returns a string representation of this instance.
Collection<Object>values()
Returns a collection of the values from this hint collection.

Field Detail

KEY_ALPHA_INTERPOLATION

public static final RenderingHints.Key KEY_ALPHA_INTERPOLATION
A key for the 'alpha interpolation' hint. Permitted values are:

{@link #VALUE_ALPHA_INTERPOLATION_SPEED} Prefer speed over quality.
{@link #VALUE_ALPHA_INTERPOLATION_QUALITY} Prefer quality over speed.
{@link #VALUE_ALPHA_INTERPOLATION_DEFAULT} Use the default setting.

KEY_ANTIALIASING

public static final RenderingHints.Key KEY_ANTIALIASING
A key for the 'antialiasing' hint. Permitted values are:

{@link #VALUE_ANTIALIAS_OFF} Render without antialiasing (better speed).
{@link #VALUE_ANTIALIAS_ON} Render with antialiasing (better quality).
{@link #VALUE_ANTIALIAS_DEFAULT} Use the default value for antialiasing.

KEY_COLOR_RENDERING

public static final RenderingHints.Key KEY_COLOR_RENDERING
A key for the 'color rendering' hint. Permitted values are:

{@link #VALUE_COLOR_RENDER_SPEED} Prefer speed over quality.
{@link #VALUE_COLOR_RENDER_QUALITY} Prefer quality over speed.
{@link #VALUE_COLOR_RENDER_DEFAULT} Use the default setting.

KEY_DITHERING

public static final RenderingHints.Key KEY_DITHERING
A key for the 'dithering' hint. Permitted values are:

{@link #VALUE_DITHER_DISABLE} Disable dithering.
{@link #VALUE_DITHER_ENABLE} Enable dithering.
{@link #VALUE_DITHER_DEFAULT} Use the default value for dithering.

KEY_FRACTIONALMETRICS

public static final RenderingHints.Key KEY_FRACTIONALMETRICS
A key for the 'fractional metrics' hint. Permitted values are:

{@link #VALUE_FRACTIONALMETRICS_OFF} Render text with fractional metrics off.
{@link #VALUE_FRACTIONALMETRICS_ON} Render text with fractional metrics on.
{@link #VALUE_FRACTIONALMETRICS_DEFAULT} Use the default value for fractional metrics.

KEY_INTERPOLATION

public static final RenderingHints.Key KEY_INTERPOLATION
A key for the 'interpolation' hint. Permitted values are:

{@link #VALUE_INTERPOLATION_NEAREST_NEIGHBOR} Use nearest neighbour interpolation.
{@link #VALUE_INTERPOLATION_BILINEAR} Use bilinear interpolation.
{@link #VALUE_INTERPOLATION_BICUBIC} Use bicubic interpolation.

KEY_RENDERING

public static final RenderingHints.Key KEY_RENDERING
A key for the 'rendering' hint. Permitted values are:

{@link #VALUE_RENDER_SPEED} Prefer speed over quality when rendering.
{@link #VALUE_RENDER_QUALITY} Prefer quality over speed when rendering.
{@link #VALUE_RENDER_DEFAULT} Use the default value for quality vs. speed when rendering.

KEY_STROKE_CONTROL

public static final RenderingHints.Key KEY_STROKE_CONTROL
A key for the 'stroke control' hint. Permitted values are:

{@link #VALUE_STROKE_DEFAULT} Use the default setting.
{@link #VALUE_STROKE_NORMALIZE} XXX
{@link #VALUE_STROKE_PURE} XXX

KEY_TEXT_ANTIALIASING

public static final RenderingHints.Key KEY_TEXT_ANTIALIASING
A key for the 'text antialiasing' hint. Permitted values are:

{@link #VALUE_TEXT_ANTIALIAS_ON} Render text with antialiasing (better quality usually).
{@link #VALUE_TEXT_ANTIALIAS_OFF} Render test without antialiasing (better speed).
{@link #VALUE_TEXT_ANTIALIAS_DEFAULT} Use the default value for text antialiasing.

VALUE_ALPHA_INTERPOLATION_DEFAULT

public static final Object VALUE_ALPHA_INTERPOLATION_DEFAULT
This value is for use with the {@link #KEY_ALPHA_INTERPOLATION} key.

VALUE_ALPHA_INTERPOLATION_QUALITY

public static final Object VALUE_ALPHA_INTERPOLATION_QUALITY
This value is for use with the {@link #KEY_ALPHA_INTERPOLATION} key.

VALUE_ALPHA_INTERPOLATION_SPEED

public static final Object VALUE_ALPHA_INTERPOLATION_SPEED
This value is for use with the {@link #KEY_ALPHA_INTERPOLATION} key.

VALUE_ANTIALIAS_DEFAULT

public static final Object VALUE_ANTIALIAS_DEFAULT
This value is for use with the {@link #KEY_ANTIALIASING} key.

VALUE_ANTIALIAS_OFF

public static final Object VALUE_ANTIALIAS_OFF
This value is for use with the {@link #KEY_ANTIALIASING} key.

VALUE_ANTIALIAS_ON

public static final Object VALUE_ANTIALIAS_ON
This value is for use with the {@link #KEY_ANTIALIASING} key.

VALUE_COLOR_RENDER_DEFAULT

public static final Object VALUE_COLOR_RENDER_DEFAULT
This value is for use with the {@link #KEY_COLOR_RENDERING} key.

VALUE_COLOR_RENDER_QUALITY

public static final Object VALUE_COLOR_RENDER_QUALITY
This value is for use with the {@link #KEY_COLOR_RENDERING} key.

VALUE_COLOR_RENDER_SPEED

public static final Object VALUE_COLOR_RENDER_SPEED
This value is for use with the {@link #KEY_COLOR_RENDERING} key.

VALUE_DITHER_DEFAULT

public static final Object VALUE_DITHER_DEFAULT
This value is for use with the {@link #KEY_DITHERING} key.

VALUE_DITHER_DISABLE

public static final Object VALUE_DITHER_DISABLE
This value is for use with the {@link #KEY_DITHERING} key.

VALUE_DITHER_ENABLE

public static final Object VALUE_DITHER_ENABLE
This value is for use with the {@link #KEY_DITHERING} key.

VALUE_FRACTIONALMETRICS_DEFAULT

public static final Object VALUE_FRACTIONALMETRICS_DEFAULT
This value is for use with the {@link #KEY_FRACTIONALMETRICS} key.

VALUE_FRACTIONALMETRICS_OFF

public static final Object VALUE_FRACTIONALMETRICS_OFF
This value is for use with the {@link #KEY_FRACTIONALMETRICS} key.

VALUE_FRACTIONALMETRICS_ON

public static final Object VALUE_FRACTIONALMETRICS_ON
This value is for use with the {@link #KEY_FRACTIONALMETRICS} key.

VALUE_INTERPOLATION_BICUBIC

public static final Object VALUE_INTERPOLATION_BICUBIC
This value is for use with the {@link #KEY_INTERPOLATION} key.

VALUE_INTERPOLATION_BILINEAR

public static final Object VALUE_INTERPOLATION_BILINEAR
This value is for use with the {@link #KEY_INTERPOLATION} key.

VALUE_INTERPOLATION_NEAREST_NEIGHBOR

public static final Object VALUE_INTERPOLATION_NEAREST_NEIGHBOR
This value is for use with the {@link #KEY_INTERPOLATION} key.

VALUE_RENDER_DEFAULT

public static final Object VALUE_RENDER_DEFAULT
This value is for use with the {@link #KEY_RENDERING} key.

VALUE_RENDER_QUALITY

public static final Object VALUE_RENDER_QUALITY
This value is for use with the {@link #KEY_RENDERING} key.

VALUE_RENDER_SPEED

public static final Object VALUE_RENDER_SPEED
This value is for use with the {@link #KEY_RENDERING} key.

VALUE_STROKE_DEFAULT

public static final Object VALUE_STROKE_DEFAULT
This value is for use with the {@link #KEY_STROKE_CONTROL} key.

VALUE_STROKE_NORMALIZE

public static final Object VALUE_STROKE_NORMALIZE
This value is for use with the {@link #KEY_STROKE_CONTROL} key.

VALUE_STROKE_PURE

public static final Object VALUE_STROKE_PURE
This value is for use with the {@link #KEY_STROKE_CONTROL} key.

VALUE_TEXT_ANTIALIAS_DEFAULT

public static final Object VALUE_TEXT_ANTIALIAS_DEFAULT
This value is for use with the {@link #KEY_TEXT_ANTIALIASING} key.

VALUE_TEXT_ANTIALIAS_OFF

public static final Object VALUE_TEXT_ANTIALIAS_OFF
This value is for use with the {@link #KEY_TEXT_ANTIALIASING} key.

VALUE_TEXT_ANTIALIAS_ON

public static final Object VALUE_TEXT_ANTIALIAS_ON
This value is for use with the {@link #KEY_TEXT_ANTIALIASING} key.

Constructor Detail

RenderingHints

public RenderingHints(Map<RenderingHints.Key,?> init)
Creates a new collection of hints containing all the (key, value) pairs in the specified map.

Parameters: init a map containing a collection of hints (null permitted).

RenderingHints

public RenderingHints(RenderingHints.Key key, Object value)
Creates a new collection containing a single (key, value) pair.

Parameters: key the key. value the value.

Method Detail

add

public void add(RenderingHints hints)
Adds all the hints from a collection to this collection.

Parameters: hints the hint collection.

clear

public void clear()
Clears all the hints from this collection.

clone

public Object clone()
Creates a clone of this instance.

Returns: A clone.

containsKey

public boolean containsKey(Object key)
Returns true if the collection of hints contains the specified key, and false otherwise.

Parameters: key the key (null not permitted).

Returns: A boolean.

Throws: NullPointerException if key is null. ClassCastException if key is not a {@link Key}.

containsValue

public boolean containsValue(Object value)
Returns true if the collection of hints contains the specified value, and false otherwise.

Parameters: value the value.

Returns: A boolean.

entrySet

public Set<Entry<Object,Object>> entrySet()
Returns a set of entries from the collection.

Returns: A set of entries.

equals

public boolean equals(Object o)
Checks this collection for equality with an arbitrary object.

Parameters: o the object (null permitted)

Returns: A boolean.

get

public Object get(Object key)
Returns the value associated with the specified key, or null if there is no value defined for the key.

Parameters: key the key (null permitted).

Returns: The value (possibly null).

Throws: ClassCastException if key is not a {@link Key}.

See Also: containsKey

hashCode

public int hashCode()
Returns a hash code for the collection of hints.

Returns: A hash code.

isEmpty

public boolean isEmpty()
Returns true if there are no hints in the collection, and false otherwise.

Returns: A boolean.

keySet

public Set<Object> keySet()
Returns a set containing the keys from this collection.

Returns: A set of keys.

put

public Object put(Object key, Object value)
Adds a (key, value) pair to the collection of hints (if the collection already contains the specified key, then the value is updated).

Parameters: key the key. value the value.

Returns: the previous value of the key or null if the key didn't have a value yet.

putAll

public void putAll(Map<?,?> m)
Adds a collection of (key, value) pairs to the collection.

Parameters: m a map containing (key, value) items.

Throws: ClassCastException if the map contains a key that is not a subclass of {@link RenderingHints.Key}. IllegalArgumentException if the map contains a value that is not compatible with its key.

remove

public Object remove(Object key)
Removes a hint from the collection.

Parameters: key the key.

Returns: The value that was associated with the key, or null if the key was not part of the collection

Throws: ClassCastException if the key is not a subclass of {@link RenderingHints.Key}.

size

public int size()
Returns the number of hints in the collection.

Returns: The number of hints.

toString

public String toString()
Returns a string representation of this instance.

Returns: A string.

values

public Collection<Object> values()
Returns a collection of the values from this hint collection. The collection is backed by the RenderingHints instance, so updates to one will affect the other.

Returns: A collection of values.