O'Reilly logo

J2ME in a Nutshell by Kim Topley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Graphics Attributes

The Graphics class provides operations that let you do the following:

  • Draw straight lines, arcs, and rectangles

  • Fill the space occupied by an arc or a rectangle

  • Render images

  • Draw text presented in the form of a String or as character data

All these operations use a coordinate system to indicate at least their starting point, and most of them also use one or more attributes of the Graphics object that act as implicit parameters. When the paint( ) method is called, the attributes of the Graphics object that is passed to it have well-defined values that can be modified if necessary. The attributes and their initial values are listed in Table 5-1. A more detailed description of each attribute and the way in which it is used are found in later sections.

Table 5-1. Graphics Attributes

Attribute

Use

Initial Value

Clip

The clip sets the region of the Canvas within which graphics operations have any effect. The clip is discussed in Section 5.7.

Depends on the reason paint( ) was invoked

Color

The color that will be used when drawing or filling shapes or rendering text. See Section 5.3.2 for further details.

Black

Font

The font used when rendering text. Fonts are discussed in Section 5.8.

Set to the platform’s default font

Stroke Style

Determines whether lines, rectangles, and arcs are drawn using solid or dotted strokes, as described in Section 5.4.1.

Set to draw a solid line

Origin

The position of the coordinate point (0, 0) relative to the top left ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required