Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
You can use theGraphics2D
rendering hints attribute to specify whether you want objects to be rendered as quickly as possible or whether you prefer that the rendering quality be as high as possible.To set or change the rendering hints attribute in the
Graphics2D
context, you can construct aRenderingHints
object and pass it intoGraphics2D
setRenderingHints.
If you just want to set one hint, you can callGraphics2D
setRenderingHint
and specify the key-value pair for the hint you want to set. (The key-value pairs are defined in theRenderingHints
class.)For example, to set a preference for antialiasing to be used if possible, you could use
setRenderingHint
:g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,aliasing);
Note: Not all platforms support modification of the rendering mode, so specifying rendering hints does not guarantee that they will be used.
RenderingHints
supports the following types of hints:
- Alpha interpolation--default, quality, or speed
- Antialiasing--default, on, or off
- Color rendering-default, quality, or speed
- Dithering--default, disable, or enable
- Fractional metrics--default, on, or off
- Interpolation--nearest-neighbor, bilinear, or bicubic
- Rendering--default, quality, or speed
- Text antialiasing--default, on, or off
When a hint is set to default, the platform rendering default is used is used.
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2001 Sun Microsystems, Inc. All rights reserved.