The collection of state attributes associated with a
Graphics2D object is referred to as the Graphics2D rendering context.
To display text, shapes, or images, you set up the Graphics2D rendering context and then call one of the Graphics2D
rendering methods, such as draw or fill. As the following
figure shows, the Graphics2D rendering context contains several
attributes.
Graphics2D rendering context, you
use the set Attribute methods
The pen style :
setStrokethat is applied to the outline of a shape. This stroke attribute enables you to draw lines with any point size and dashing pattern and to apply end-cap and join decorations to a line.
The fill style :
setPaintthat is applied to a shape's interior. This paint attribute enables you to fill shapes with solid colors, gradients, and patterns.
The compositing style :
setCompositethat is used when rendered objects overlap existing objects.
The transform :
setTransformthat is applied during rendering to convert the rendered object from user space to device-space coordinates. Optional translation, rotation, scaling, or shearing transforms can also be applied through this attribute.
The clip :
setClipwhich restricts rendering to the area within the outline of the
Shapeused to define the clipping path. AnyShapecan be used to define the clip.The font :
setFontused to convert text strings to glyphs.
Rendering hints :
setRenderingHintsthat specify preferences in the trade-offs between speed and quality. For example, you can specify whether antialiasing should be used, if it's available.