java.awt

Class RenderingHints

Implemented Interfaces:
Cloneable, Map<K,V>

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

A collection of (key, value) items that provide 'hints' for the Graphics2D rendering pipeline. Because these items are hints only, they may be ignored by a particular Graphics2D implementation.

Nested Class Summary

static class
RenderingHints.Key
The base class used to represent keys.

Field Summary

static RenderingHints.Key
KEY_ALPHA_INTERPOLATION
A key for the 'alpha interpolation' hint.
static RenderingHints.Key
KEY_ANTIALIASING
A key for the 'antialiasing' hint.
static RenderingHints.Key
KEY_COLOR_RENDERING
A key for the 'color rendering' hint.
static RenderingHints.Key
KEY_DITHERING
A key for the 'dithering' hint.
static RenderingHints.Key
KEY_FRACTIONALMETRICS
A key for the 'fractional metrics' hint.
static RenderingHints.Key
KEY_INTERPOLATION
A key for the 'interpolation' hint.
static RenderingHints.Key
KEY_RENDERING
A key for the 'rendering' hint.
static RenderingHints.Key
KEY_STROKE_CONTROL
A key for the 'stroke control' hint.
static RenderingHints.Key
KEY_TEXT_ANTIALIASING
A key for the 'text antialiasing' hint.
static Object
VALUE_ALPHA_INTERPOLATION_DEFAULT
This value is for use with the KEY_ALPHA_INTERPOLATION key.
static Object
VALUE_ALPHA_INTERPOLATION_QUALITY
This value is for use with the KEY_ALPHA_INTERPOLATION key.
static Object
VALUE_ALPHA_INTERPOLATION_SPEED
This value is for use with the KEY_ALPHA_INTERPOLATION key.
static Object
VALUE_ANTIALIAS_DEFAULT
This value is for use with the KEY_ANTIALIASING key.
static Object
VALUE_ANTIALIAS_OFF
This value is for use with the KEY_ANTIALIASING key.
static Object
VALUE_ANTIALIAS_ON
This value is for use with the KEY_ANTIALIASING key.
static Object
VALUE_COLOR_RENDER_DEFAULT
This value is for use with the KEY_COLOR_RENDERING key.
static Object
VALUE_COLOR_RENDER_QUALITY
This value is for use with the KEY_COLOR_RENDERING key.
static Object
VALUE_COLOR_RENDER_SPEED
This value is for use with the KEY_COLOR_RENDERING key.
static Object
VALUE_DITHER_DEFAULT
This value is for use with the KEY_DITHERING key.
static Object
VALUE_DITHER_DISABLE
This value is for use with the KEY_DITHERING key.
static Object
VALUE_DITHER_ENABLE
This value is for use with the KEY_DITHERING key.
static Object
VALUE_FRACTIONALMETRICS_DEFAULT
This value is for use with the KEY_FRACTIONALMETRICS key.
static Object
VALUE_FRACTIONALMETRICS_OFF
This value is for use with the KEY_FRACTIONALMETRICS key.
static Object
VALUE_FRACTIONALMETRICS_ON
This value is for use with the KEY_FRACTIONALMETRICS key.
static Object
VALUE_INTERPOLATION_BICUBIC
This value is for use with the KEY_INTERPOLATION key.
static Object
VALUE_INTERPOLATION_BILINEAR
This value is for use with the KEY_INTERPOLATION key.
static Object
VALUE_INTERPOLATION_NEAREST_NEIGHBOR
This value is for use with the KEY_INTERPOLATION key.
static Object
VALUE_RENDER_DEFAULT
This value is for use with the KEY_RENDERING key.
static Object
VALUE_RENDER_QUALITY
This value is for use with the KEY_RENDERING key.
static Object
VALUE_RENDER_SPEED
This value is for use with the KEY_RENDERING key.
static Object
VALUE_STROKE_DEFAULT
This value is for use with the KEY_STROKE_CONTROL key.
static Object
VALUE_STROKE_NORMALIZE
This value is for use with the KEY_STROKE_CONTROL key.
static Object
VALUE_STROKE_PURE
This value is for use with the KEY_STROKE_CONTROL key.
static Object
VALUE_TEXT_ANTIALIAS_DEFAULT
This value is for use with the KEY_TEXT_ANTIALIASING key.
static Object
VALUE_TEXT_ANTIALIAS_OFF
This value is for use with the KEY_TEXT_ANTIALIASING key.
static Object
VALUE_TEXT_ANTIALIAS_ON
This value is for use with the KEY_TEXT_ANTIALIASING key.

Constructor Summary

RenderingHints(Map 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

void
add(RenderingHints hints)
Adds all the hints from a collection to this collection.
void
clear()
Clears all the hints from this collection.
Object
clone()
Creates a clone of this instance.
boolean
containsKey(Object key)
Returns true if the collection of hints contains the specified key, and false otherwise.
boolean
containsValue(Object value)
Returns true if the collection of hints contains the specified value, and false otherwise.
Set>
entrySet()
Returns a set of entries from the collection.
boolean
equals(Object o)
Checks this collection for equality with an arbitrary object.
Object
get(Object key)
Returns the value associated with the specified key, or null if there is no value defined for the key.
int
hashCode()
Returns a hash code for the collection of hints.
boolean
isEmpty()
Returns true if there are no hints in the collection, and false otherwise.
Set
keySet()
Returns a set containing the keys from this collection.
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).
void
putAll(Map m)
Adds a collection of (key, value) pairs to the collection.
Object
remove(Object key)
Removes a hint from the collection.
int
size()
Returns the number of hints in the collection.
String
toString()
Returns a string representation of this instance.
Collection
values()
Returns a collection of the values from this hint collection.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

KEY_ALPHA_INTERPOLATION

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

VALUE_ALPHA_INTERPOLATION_SPEEDPrefer speed over quality.
VALUE_ALPHA_INTERPOLATION_QUALITYPrefer quality over speed.
VALUE_ALPHA_INTERPOLATION_DEFAULTUse the default setting.

KEY_ANTIALIASING

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

VALUE_ANTIALIAS_OFFRender without antialiasing (better speed).
VALUE_ANTIALIAS_ONRender with antialiasing (better quality).
VALUE_ANTIALIAS_DEFAULTUse 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:

VALUE_COLOR_RENDER_SPEEDPrefer speed over quality.
VALUE_COLOR_RENDER_QUALITYPrefer quality over speed.
VALUE_COLOR_RENDER_DEFAULTUse the default setting.

KEY_DITHERING

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

VALUE_DITHER_DISABLEDisable dithering.
VALUE_DITHER_ENABLEEnable dithering.
VALUE_DITHER_DEFAULTUse the default value for dithering.

KEY_FRACTIONALMETRICS

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

VALUE_FRACTIONALMETRICS_OFFRender text with fractional metrics off.
VALUE_FRACTIONALMETRICS_ONRender text with fractional metrics on.
VALUE_FRACTIONALMETRICS_DEFAULTUse the default value for fractional metrics.

KEY_INTERPOLATION

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

VALUE_INTERPOLATION_NEAREST_NEIGHBORUse nearest neighbour interpolation.
VALUE_INTERPOLATION_BILINEARUse bilinear interpolation.
VALUE_INTERPOLATION_BICUBICUse bicubic interpolation.

KEY_RENDERING

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

VALUE_RENDER_SPEEDPrefer speed over quality when rendering.
VALUE_RENDER_QUALITYPrefer quality over speed when rendering.
VALUE_RENDER_DEFAULTUse 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:

VALUE_STROKE_DEFAULTUse the default setting.
VALUE_STROKE_NORMALIZEXXX
VALUE_STROKE_PUREXXX

KEY_TEXT_ANTIALIASING

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

VALUE_TEXT_ANTIALIAS_ONRender text with antialiasing (better quality usually).
VALUE_TEXT_ANTIALIAS_OFFRender test without antialiasing (better speed).
VALUE_TEXT_ANTIALIAS_DEFAULTUse the default value for text antialiasing.



























Constructor Details

RenderingHints

public RenderingHints(Map 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 Details

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.
Specified by:
clear in interface Map<K,V>

clone

public Object clone()
Creates a clone of this instance.
Overrides:
clone in interface Object
Returns:
A clone.

containsKey

public boolean containsKey(Object key)
Returns true if the collection of hints contains the specified key, and false otherwise.
Specified by:
containsKey in interface Map<K,V>
Parameters:
key - the key (null not permitted).
Returns:
A boolean.
Throws:
NullPointerException - if key is null.
ClassCastException - if key is not a RenderingHints.Key.

containsValue

public boolean containsValue(Object value)
Returns true if the collection of hints contains the specified value, and false otherwise.
Specified by:
containsValue in interface Map<K,V>
Parameters:
value - the value.
Returns:
A boolean.

entrySet

public Set> 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.
Specified by:
equals in interface Map<K,V>
Overrides:
equals in interface 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.
Specified by:
get in interface Map<K,V>
Parameters:
key - the key (null permitted).
Returns:
The value (possibly null).
Throws:
ClassCastException - if key is not a RenderingHints.Key.

hashCode

public int hashCode()
Returns a hash code for the collection of hints.
Specified by:
hashCode in interface Map<K,V>
Overrides:
hashCode in interface Object
Returns:
A hash code.

isEmpty

public boolean isEmpty()
Returns true if there are no hints in the collection, and false otherwise.
Specified by:
isEmpty in interface Map<K,V>
Returns:
A boolean.

keySet

public Set keySet()
Returns a set containing the keys from this collection.
Specified by:
keySet in interface Map<K,V>
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 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.
Specified by:
remove in interface Map<K,V>
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 RenderingHints.Key.

size

public int size()
Returns the number of hints in the collection.
Specified by:
size in interface Map<K,V>
Returns:
The number of hints.

toString

public String toString()
Returns a string representation of this instance.
Overrides:
toString in interface Object
Returns:
A string.

values

public Collection 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.
Specified by:
values in interface Map<K,V>
Returns:
A collection of values.

RenderingHints.java -- Copyright (C) 2000, 2001, 2002, 2004, 2005 Free Software Foundation This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.