java.lang.Object java.awt.RenderingHints
public class RenderingHints
The RenderingHints class contains rendering hints that can be used by the Graphics2D class, and classes that implement BufferedImageOp and Raster .
Nested Class Summary | |
---|---|
static class |
RenderingHints.Key
Defines the base type of all keys used to control various aspects of the rendering and imaging pipelines. |
Nested classes/interfaces inherited from interface java.util. Map |
---|
Map.Entry < K , V > |
Field Summary | |
---|---|
static RenderingHints.Key |
KEY_ALPHA_INTERPOLATION
Alpha interpolation hint key. |
static RenderingHints.Key |
KEY_ANTIALIASING
Antialiasing hint key. |
static RenderingHints.Key |
KEY_COLOR_RENDERING
Color rendering hint key. |
static RenderingHints.Key |
KEY_DITHERING
Dithering hint key. |
static RenderingHints.Key |
KEY_FRACTIONALMETRICS
Font fractional metrics hint key. |
static RenderingHints.Key |
KEY_INTERPOLATION
Interpolation hint key. |
static RenderingHints.Key |
KEY_RENDERING
Rendering hint key. |
static RenderingHints.Key |
KEY_STROKE_CONTROL
Stroke normalization control hint key. |
static RenderingHints.Key |
KEY_TEXT_ANTIALIASING
Text antialiasing hint key. |
static RenderingHints.Key |
KEY_TEXT_LCD_CONTRAST
LCD text contrast rendering hint key. |
static Object |
VALUE_ALPHA_INTERPOLATION_DEFAULT
Alpha interpolation hint value -- ALPHA_INTERPOLATION_DEFAULT. |
static Object |
VALUE_ALPHA_INTERPOLATION_QUALITY
Alpha interpolation hint value -- ALPHA_INTERPOLATION_QUALITY. |
static Object |
VALUE_ALPHA_INTERPOLATION_SPEED
Alpha interpolation hint value -- ALPHA_INTERPOLATION_SPEED. |
static Object |
VALUE_ANTIALIAS_DEFAULT
Antialiasing hint values -- rendering is done with the platform default antialiasing mode. |
static Object |
VALUE_ANTIALIAS_OFF
Antialiasing hint values -- rendering is done without antialiasing. |
static Object |
VALUE_ANTIALIAS_ON
Antialiasing hint values -- rendering is done with antialiasing. |
static Object |
VALUE_COLOR_RENDER_DEFAULT
Color rendering hint value -- COLOR_RENDER_DEFAULT. |
static Object |
VALUE_COLOR_RENDER_QUALITY
Color rendering hint value -- COLOR_RENDER_QUALITY. |
static Object |
VALUE_COLOR_RENDER_SPEED
Color rendering hint value -- COLOR_RENDER_SPEED. |
static Object |
VALUE_DITHER_DEFAULT
Dithering hint values -- use the platform default for dithering. |
static Object |
VALUE_DITHER_DISABLE
Dithering hint values -- do not dither when rendering. |
static Object |
VALUE_DITHER_ENABLE
Dithering hint values -- dither when rendering, if needed. |
static Object |
VALUE_FRACTIONALMETRICS_DEFAULT
Font fractional metrics hint values -- use the platform default for fractional metrics. |
static Object |
VALUE_FRACTIONALMETRICS_OFF
Font fractional metrics hint values -- fractional metrics disabled. |
static Object |
VALUE_FRACTIONALMETRICS_ON
Font fractional metrics hint values -- fractional metrics enabled. |
static Object |
VALUE_INTERPOLATION_BICUBIC
Interpolation hint value -- INTERPOLATION_BICUBIC. |
static Object |
VALUE_INTERPOLATION_BILINEAR
Interpolation hint value -- INTERPOLATION_BILINEAR. |
static Object |
VALUE_INTERPOLATION_NEAREST_NEIGHBOR
Interpolation hint value -- INTERPOLATION_NEAREST_NEIGHBOR. |
static Object |
VALUE_RENDER_DEFAULT
Rendering hint values -- The platform default rendering algorithms are chosen. |
static Object |
VALUE_RENDER_QUALITY
Rendering hint values -- Appropriate rendering algorithms are chosen with a preference for output quality. |
static Object |
VALUE_RENDER_SPEED
Rendering hint values -- Appropriate rendering algorithms are chosen with a preference for output speed. |
static Object |
VALUE_STROKE_DEFAULT
Stroke normalization control hint value -- STROKE_DEFAULT. |
static Object |
VALUE_STROKE_NORMALIZE
Stroke normalization control hint value -- STROKE_NORMALIZE. |
static Object |
VALUE_STROKE_PURE
Stroke normalization control hint value -- STROKE_PURE. |
static Object |
VALUE_TEXT_ANTIALIAS_DEFAULT
Text antialiasing hint value -- text rendering is done using the platform default text antialiasing mode. |
static Object |
VALUE_TEXT_ANTIALIAS_GASP
Text antialiasing hint value -- text rendering is requested to use information in the font resource which specifies for each point size whether to apply VALUE_TEXT_ANTIALIAS_ON or VALUE_TEXT_ANTIALIAS_OFF. |
static Object |
VALUE_TEXT_ANTIALIAS_LCD_HBGR
Text antialiasing hint value -- request that text be displayed optimised for an LCD display with subpixels in order from display left to right of B,G,R such that the horizontal subpixel resolution is three times that of the full pixel horizontal resolution (HBGR). |
static Object |
VALUE_TEXT_ANTIALIAS_LCD_HRGB
Text antialiasing hint value -- request that text be displayed optimised for an LCD display with subpixels in order from display left to right of R,G,B such that the horizontal subpixel resolution is three times that of the full pixel horizontal resolution (HRGB). |
static Object |
VALUE_TEXT_ANTIALIAS_LCD_VBGR
Text antialiasing hint value -- request that text be displayed optimised for an LCD display with subpixel organisation from display top to bottom of B,G,R such that the vertical subpixel resolution is three times that of the full pixel vertical resolution (VBGR). |
static Object |
VALUE_TEXT_ANTIALIAS_LCD_VRGB
Text antialiasing hint value -- request that text be displayed optimised for an LCD display with subpixel organisation from display top to bottom of R,G,B such that the vertical subpixel resolution is three times that of the full pixel vertical resolution (VRGB). |
static Object |
VALUE_TEXT_ANTIALIAS_OFF
Text antialiasing hint value -- text rendering is done without antialiasing. |
static Object |
VALUE_TEXT_ANTIALIAS_ON
Text antialiasing hint value -- text rendering is done with antialiasing. |
Constructor Summary | |
---|---|
RenderingHints
(
Map
<
RenderingHints.Key
,?> init) Constructs a new object with keys and values initialized from the specified Map object (which may be null). |
|
RenderingHints
(
RenderingHints.Key
key,
Object
value) Constructs a new object with the specified key/value pair. |
Method Summary | |
---|---|
void |
add
(
RenderingHints
hints) Adds all of the keys and corresponding values from the specified RenderingHints object to this RenderingHints object. |
void |
clear
() Clears this RenderingHints object of all key/value pairs. |
Object |
clone
() Creates a clone of this RenderingHints object that has the same contents as this RenderingHints object. |
boolean |
containsKey
(
Object
key) Returns true if this RenderingHints contains a mapping for the specified key. |
boolean |
containsValue
(
Object
value) Returns true if this RenderingHints maps one or more keys to the specified value. |
Set < Map.Entry < Object , Object >> |
entrySet
() Returns a Set view of the mappings contained in this RenderingHints. |
boolean |
equals
(
Object
o) Compares the specified Object with this RenderingHints for equality. |
Object |
get
(
Object
key) Returns the value to which the specified key is mapped. |
int |
hashCode
() Returns the hash code value for this RenderingHints. |
boolean |
isEmpty
() Returns true if this RenderingHints contains no key-value mappings. |
Set < Object > |
keySet
() Returns a Set view of the Keys contained in this RenderingHints. |
Object |
put
(
Object
key,
Object
value) Maps the specified key to the specified value in this RenderingHints object. |
void |
putAll
(
Map
<?,?> m) Copies all of the mappings from the specified Map to this RenderingHints. |
Object |
remove
(
Object
key) Removes the key and its corresponding value from this RenderingHints object. |
int |
size
() Returns the number of key-value mappings in this RenderingHints. |
String |
toString
() Returns a rather long string representation of the hashmap which contains the mappings of keys to values for this RenderingHints object. |
Collection < Object > |
values
() Returns a Collection view of the values contained in this RenderinHints. |
Methods inherited from class java.lang. Object |
---|
finalize , getClass , notify , notifyAll , wait , wait , wait |
Field Detail |
---|
public static final RenderingHints.Key KEY_ANTIALIASING
public static final Object VALUE_ANTIALIAS_ON
public static final Object VALUE_ANTIALIAS_OFF
public static final Object VALUE_ANTIALIAS_DEFAULT
public static final RenderingHints.Key KEY_RENDERING
public static final Object VALUE_RENDER_SPEED
public static final Object VALUE_RENDER_QUALITY
public static final Object VALUE_RENDER_DEFAULT
public static final RenderingHints.Key KEY_DITHERING
public static final Object VALUE_DITHER_DISABLE
public static final Object VALUE_DITHER_ENABLE
public static final Object VALUE_DITHER_DEFAULT
public static final RenderingHints.Key KEY_TEXT_ANTIALIASING
public static final Object VALUE_TEXT_ANTIALIAS_ON
public static final Object VALUE_TEXT_ANTIALIAS_OFF
public static final Object VALUE_TEXT_ANTIALIAS_DEFAULT
public static final ObjectVALUE_TEXT_ANTIALIAS_GASP
TrueType fonts typically provide this information in the 'gasp' table. In the absence of this information, the behaviour for a particular font and size is determined by implementation defaults.
Note: A font designer will typically carefully hint a font for the most common user interface point sizes. Consequently the 'gasp' table will likely specify to use only hinting at those sizes and not "smoothing". So in many cases the resulting text display is equivalent to VALUE_TEXT_ANTIALIAS_OFF. This may be unexpected but is correct.
Logical fonts which are composed of multiple physical fonts will for consistency will use the setting most appropriate for the overall composite font.
public static final ObjectVALUE_TEXT_ANTIALIAS_LCD_HRGB
Notes:
An implementation when choosing whether to apply any of the LCD text hint values may take into account factors including requiring color depth of the destination to be at least 15 bits per pixel (ie 5 bits per color component), characteristics of a font such as whether embedded bitmaps may produce better results, or when displaying to a non-local networked display device enabling it only if suitable protocols are available, or ignoring the hint if performing very high resolution rendering or the target device is not appropriate: eg when printing.
These hints can equally be applied when rendering to software images, but these images may not then be suitable for general export, as the text will have been rendered appropriately for a specific subpixel organisation. Also lossy images are not a good choice, nor image formats such as GIF which have limited colors. So unless the image is destined solely for rendering on a display device with the same configuration, some other text anti-aliasing hint such as VALUE_TEXT_ANTIALIAS_ON may be a better choice.
Selecting a value which does not match the LCD display in use will likely lead to a degradation in text quality. On display devices (ie CRTs) which do not have the same characteristics as LCD displays, the overall effect may appear similar to standard text anti-aliasing, but the quality may be degraded by color distortion. Analog connected LCD displays may also show little advantage over standard text-antialiasing and be similar to CRTs.
In other words for the best results use an LCD display with a digital display connector and specify the appropriate sub-pixel configuration.
public static final ObjectVALUE_TEXT_ANTIALIAS_LCD_HBGR
public static final ObjectVALUE_TEXT_ANTIALIAS_LCD_VRGB
public static final ObjectVALUE_TEXT_ANTIALIAS_LCD_VBGR
public static final RenderingHints.KeyKEY_TEXT_LCD_CONTRAST
public static final RenderingHints.Key KEY_FRACTIONALMETRICS
public static final Object VALUE_FRACTIONALMETRICS_OFF
public static final Object VALUE_FRACTIONALMETRICS_ON
public static final Object VALUE_FRACTIONALMETRICS_DEFAULT
public static final RenderingHints.Key KEY_INTERPOLATION
public static final Object VALUE_INTERPOLATION_NEAREST_NEIGHBOR
public static final Object VALUE_INTERPOLATION_BILINEAR
public static final Object VALUE_INTERPOLATION_BICUBIC
public static final RenderingHints.Key KEY_ALPHA_INTERPOLATION
public static final Object VALUE_ALPHA_INTERPOLATION_SPEED
public static final Object VALUE_ALPHA_INTERPOLATION_QUALITY
public static final Object VALUE_ALPHA_INTERPOLATION_DEFAULT
public static final RenderingHints.Key KEY_COLOR_RENDERING
public static final Object VALUE_COLOR_RENDER_SPEED
public static final Object VALUE_COLOR_RENDER_QUALITY
public static final Object VALUE_COLOR_RENDER_DEFAULT
public static final RenderingHints.Key KEY_STROKE_CONTROL
public static final Object VALUE_STROKE_DEFAULT
public static final Object VALUE_STROKE_NORMALIZE
public static final Object VALUE_STROKE_PURE
Constructor Detail |
---|
public RenderingHints(Map<RenderingHints.Key,?> init)
public RenderingHints(RenderingHints.Key key, Object value)
Method Detail |
---|
public int size()
public boolean isEmpty()
public boolean containsKey(Object key)
public boolean containsValue(Object value)
(value==null ? v==null : value.equals(v)). This operation will probably require time linear in the RenderingHints size for most implementations of RenderingHints.
public Object get(Object key)
public Object put(Object key, Object value)
public void add(RenderingHints hints)
public void clear()
public Object remove(Object key)
public void putAll(Map<?,?> m)
public Set<Object> keySet()
public Collection<Object> values()
public Set<Map.Entry<Object,Object>> entrySet()
The entrySet returned from a RenderingHints object is not modifiable.
public boolean equals(Object o)
(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.
public int hashCode()
public Object clone()
public String toString()