Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| MID Profile
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.microedition.lcdui
Class Graphics

    java.lang.Object
      |
      +--javax.microedition.lcdui.Graphics

public class Graphics
extends Object

Provides simple 2D geometric rendering capability. Drawing primitives are provided for text, images, lines, rectangles, and arcs. Rectangles and arcs may also be filled with a solid color. Rectangles may also be specified with rounded corners.

The only drawing operation provided is pixel replacement. The destination pixel value is simply replaced by the current pixel value specified in the graphics object being used for rendering. No facility for combining pixel values, such as raster-ops or alpha blending, is provided.

A 24-bit color model is provided, with 8 bits for each of red, green, and blue components of a color. Not all devices support a full 24 bits' worth of color and thus they will map colors requested by the application into colors available on the device. Facilities are provided in the `Display` class for obtaining device characteristics, such as whether color is available and how many distinct gray levels are available. This enables applications to adapt their behavior to a device without compromising device independence.

Graphics may be rendered directly to the display or to an off-screen image buffer. The destination of rendered graphics depends on the provenance of the graphics object. A graphics object for rendering to the display is passed to the Canvas object's `paint()` method. This is the only means by which a graphics object may be obtained whose destination is the display. Furthermore, applications may draw using this graphics object only for the duration of the paint() method.

A graphics object for rendering to an off-screen image buffer may be obtained by calling the `getGraphics()` method on the desired image. A graphics object so obtained may be held indefinitely by the application, and requests may be issued on this graphics object at any time.

The default coordinate system's origin is at the upper left-hand corner of the destination. The X-axis direction is positive towards the right, and the Y-axis direction is positive downwards. Applications may assume that horizontal and vertical distances in the coordinate system represent equal distances on the actual device display, that is, pixels are square. A facility is provided for translating the origin of the coordinate system. All coordinates are specified as integers.

The coordinate system represents locations between pixels, not the pixels themselves. Therefore, the first pixel in the upper left corner of the display lies in the square bounded by coordinates (0,0) , (1,0) , (0,1) , (1,1).

Under this definition, the semantics for fill operations are clear. Since coordinate grid lines lie between pixels, fill operations affect pixels that lie entirely within the region bounded by the coordinates of the operation. For example, the operation

        g.fillRect(0, 0, 3, 2)

paints exactly six pixels. (In this example, and in all subsequent examples, the variable `g` is assumed to contain a reference to a Graphics object.)

Lines, arcs, rectangles, and rounded rectangles may be drawn with either a SOLID or a DOTTED stroke style, as set by the `setStrokeStyle()` method. The stroke style does not affect fill, text, and image operations.

For the SOLID stroke style, drawing operations are performed with a one-pixel wide pen that fills the pixel immediately below and to the right of the specified coordinate. Drawn lines touch pixels at both endpoints. Thus, the operation

        g.drawLine(0, 0, 0, 0)

paints exactly one pixel, the first pixel in the upper left corner of the display.

Drawing operations under the DOTTED stroke style will touch a subset of pixels that would have been touched under the SOLID stroke style. The frequency and length of dots is implementation-dependent. The endpoints of lines and arcs are not guaranteed to be drawn, nor are the corner points of rectangles guaranteed to be drawn. Dots are drawn by painting with the current color; spaces between dots are left untouched.

An artifact of the coordinate system is that the area affected by a fill operation differs slightly from the area affected by a draw operation given the same coordinates. For example, consider the operations

        g.fillRect(x, y, w, h); // 1
        g.drawRect(x, y, w, h); // 2

Statement (1) fills a rectangle w pixels wide and h pixels high. Statement (2) draws a rectangle whose left and top edges are within the area filled by statement (1). However, the bottom and right edges lie one pixel outside the filled area. This is counterintuitive, but it preserves the invariant that

        g.drawLine(x, y, x+w, y);
        g.drawLine(x+w, y, x+w, y+h);
        g.drawLine(x+w, y+h, x, y+h);
        g.drawLine(x, y+h, x, y);

has an effect identical to statement (2) above.

The exact pixels painted by drawLine() and drawArc() are not specified. Pixels touched by a fill operation must either exactly overlap or directly abut pixels touched by the corresponding draw operation. A fill operation must never leave a gap between the filled area and the pixels touched by the corresponding draw operation, nor may the fill operation touch pixels outside the area bounded by the corresponding draw operation.

There is a single clipping rectangle. Operations are provided for intersecting the current clip rectangle with a given rectangle and for setting the current clip rectangle outright. The only pixels touched by graphics operations are those that lie entirely within the clip rectangle. Pixels outside the clip rectangle are not affected by any graphics operations. It is legal to specify a clipping rectangle whose width or height is zero or negative. In this case the clipping rectangle is considered to be empty, that is, no pixels are contained within it. Therefore, if any graphics operations are issued under such a clipping rectangle, no pixels will be modified.

If a graphics operation is affected by the clip rectangle, the pixels touched by that operation must be the same ones that would be touched as if the clip rectangle did not affect the operation. For example, consider a clip rectangle (cx, cy, cw, ch) and a point (x1, y1) that lies outside this rectangle and a point (x2, y2) that lies within this rectangle. In the following code fragment,

        g.setClip(0, 0, canvas.getWidth(), canvas.getHeight());
        g.drawLine(x1, y1, x2, y2); // 3
        g.setClip(cx, cy, cw, ch);
        g.drawLine(x1, y1, x2, y2); // 4

The pixels touched by statement (4) must be identical to the pixels within (cx, cy, cw, ch) touched by statement (3).

### Anchor Points

The drawing of text is based on "anchor points". Anchor points are used to minimize the amount of computation required when placing text. For example, in order to center a piece of text, an application needs to call stringWidth() or charWidth() to get the width and then perform a combination of subtraction and division to compute the proper location. The method to draw text is defined as follows:

        public void drawString(String text, int x, int y, int anchor);

This method draws text in current foreground and background colors, using the current font with its anchor point at (x,y). The definition of the anchor point must be one of the horizontal constants (LEFT, HCENTER, RIGHT) combined with one of the vertical constants (TOP, BASELINE, BOTTOM) using the logical OR operator.

Vertical centering of the text is not specified since it is not considered useful, it is hard to specify, and it is burdensome to implement. Thus, the VCENTER value is not allowed in the anchor point parameter of text drawing calls.

The actual position of the bounding box of the text relative to the (x, y) location is determined by the anchor point. These anchor points occur at named locations along the outer edge of the bounding box. Thus, if `f` is `g`'s current font (as returned by `g.getFont()`, the following calls will all have identical results:

        g.drawString(str, x, y, TOP|LEFT);
        g.drawString(str, x + f.stringWidth(str)/2, y, TOP|HCENTER);
        g.drawString(str, x + f.stringWidth(str), y, TOP|RIGHT);

        g.drawString(str, x,
            y + f.getBaselinePosition(), BASELINE|LEFT);
        g.drawString(str, x + f.stringWidth(str)/2,
            y + f.getBaselinePosition(), BASELINE|HCENTER);
        g.drawString(str, x + f.stringWidth(str),
            y + f.getBaselinePosition(), BASELINE|RIGHT);

        drawString(str, x,
            y + f.getHeight(), BOTTOM|LEFT);
        drawString(str, x + f.stringWidth(str)/2,
            y + f.getHeight(), BOTTOM|HCENTER);
        drawString(str, x + f.stringWidth(str),
            y + f.getHeight(), BOTTOM|RIGHT);

For text drawing, the inter-character and inter-line spacing (leading) specified by the font designer are included as part of the values returned in the `stringWidth()` and `getHeight()` calls of class `Font`. For example, given the following code:

        // (5)
        g.drawString(string1+string2, x, y, TOP|LEFT);

        // (6)
        g.drawString(string1, x, y, TOP|LEFT);
        g.drawString(string2, x + f.stringWidth(string1), y, TOP|LEFT);

Code fragments (5) and (6) behave identically. This occurs because f.stringWidth() includes the inter-character spacing. Similarly, reasonable vertical spacing may be achieved simply by adding the font height to the Y-position of subsequent lines. For example:

        g.drawString(string1, x, y, TOP|LEFT);
        g.drawString(string2, x, y + f.fontHeight(), TOP|LEFT);

draws string1 and string2 on separate lines with an appropriate amount of inter-line spacing.

The stringWidth() of the string and the fontHeight() of the font in which it is drawn define the size of the bounding box of a piece of text. As described above, this box includes inter-line and inter-character spacing. The implementation is required to put this space below and to right of the pixels actually belonging to the characters drawn. Applications that wish to position graphics closely with respect text (for example, to paint a rectangle around a string of text) may assume that there is space below and to the right of a string and that there is no space above and to the left of the string.

Anchor points are also used for positioning of images. Similar to text drawing, the anchor point for an image specifies the point on the bounding rectangle of the destination that is to positioned at the (x,y) location given in the graphics request. Unlike text, vertical centering of images is well-defined, and thus the VCENTER value may be used within the anchor point parameter of image drawing requests. Because images have no notion of a baseline, the BASELINE value may not be used within the anchor point parameter of image drawing requests.

Field Summary
`static int` | `BASELINE` Constant for positioning the anchor point at the baseline of text.
`static int` | `BOTTOM` Constant for positioning the anchor point of text and images below the text or image.
`static int` | `DOTTED` Constant for the DOTTED stroke style.
`static int` | `HCENTER` Constant for centering text and images horizontally around the anchor point
`static int` | `LEFT` Constant for positioning the anchor point of text and images to the left of the text or image.
`static int` | `RIGHT` Constant for positioning the anchor point of text and images to the right of the text or image.
`static int` | `SOLID` Constant for the SOLID stroke style.
`static int` | `TOP` Constant for positioning the anchor point of text and images above the text or image.
`static int` | `VCENTER` Constant for centering images vertically around the anchor point.

Method Summary
`void` | `clipRect(int x, int y, int width, int height)` Intersects the current clip with the specified rectangle.
`void` | `drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)` Draws the outline of a circular or elliptical arc covering the specified rectangle, using the current color and stroke style.
`void` | `drawChar(char character, int x, int y, int anchor)` Draws the specified character using the current font and color.
`void` | `drawChars(char[] data, int offset, int length, int x, int y, int anchor)` Draws the specified characters using the current font and color.
`void` | `drawImage(Image img, int x, int y, int anchor)` Draws the specified image by using the anchor point.
`void` | `drawLine(int x1, int y1, int x2, int y2)` Draws a line between the coordinates (x1,y1) and (x2,y2) using the current color and stroke style.
`void` | `drawRect(int x, int y, int width, int height)` Draws the outline of the specified rectangle using the current color and stroke style.
`void` | `drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)` Draws the outline of the specified rounded corner rectangle using the current color and stroke style.
`void` | `drawString(String str, int x, int y, int anchor)` Draws the specified String using the current font and color.
`void` | `drawSubstring(String str, int offset, int len, int x, int y, int anchor)` Draws the specified String using the current font and color.
`void` | `fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)` Fills a circular or elliptical arc covering the specified rectangle.
`void` | `fillRect(int x, int y, int width, int height)` Fills the specified rectangle with the current color.
`void` | `fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)` Fills the specified rounded corner rectangle with the current color.
`int` | `getBlueComponent()` Gets the blue component of the current color.
`int` | `getClipHeight()` Gets the height of the current clipping area.
`int` | `getClipWidth()` Gets the width of the current clipping area.
`int` | `getClipX()` Gets the X offset of the current clipping area, relative to the coordinate system origin of this graphics context.
`int` | `getClipY()` Gets the Y offset of the current clipping area, relative to the coordinate system origin of this graphics context.
`int` | `getColor()` Gets the current color.
`Font` | `getFont()` Gets the current font.
`int` | `getGrayScale()` Gets the current grayscale value of the color being used for rendering operations.
`int` | `getGreenComponent()` Gets the green component of the current color.
`int` | `getRedComponent()` Gets the red component of the current color.
`int` | `getStrokeStyle()` Gets the stroke style used for drawing operations.
`int` | `getTranslateX()` Gets the X coordinate of the translated origin of this graphics context.
`int` | `getTranslateY()` Gets the Y coordinate of the translated origin of this graphics context.
`void` | `setClip(int x, int y, int width, int height)` Sets the current clip to the rectangle specified by the given coordinates.
`void` | `setColor(int RGB)` Sets the current color to the specified RGB values.
`void` | `setColor(int red, int green, int blue)` Sets the current color to the specified RGB values.
`void` | `setFont(Font font)` Sets the font for all subsequent text rendering operations.
`void` | `setGrayScale(int value)` Sets the current grayscale to be used for all subsequent rendering operations.
`void` | `setStrokeStyle(int style)` Sets the stroke style used for drawing lines, arcs, rectangles, and rounded rectangles.
`void` | `translate(int x, int y)` Translates the origin of the graphics context to the point (x, y) in the current coordinate system.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### HCENTER

    public static final int HCENTER

  Constant for centering text and images horizontally around the anchor point

  Value 1 is assigned to HCENTER.

### VCENTER

    public static final int VCENTER

  Constant for centering images vertically around the anchor point.

  Value 2 is assigned to VCENTER.

### LEFT

    public static final int LEFT

  Constant for positioning the anchor point of text and images to the left of the text or image.

  Value 4 is assigned to LEFT.

### RIGHT

    public static final int RIGHT

  Constant for positioning the anchor point of text and images to the right of the text or image.

  Value 8 is assigned to RIGHT.

### TOP

    public static final int TOP

  Constant for positioning the anchor point of text and images above the text or image.

  Value 16 is assigned to TOP.

### BOTTOM

    public static final int BOTTOM

  Constant for positioning the anchor point of text and images below the text or image.

  Value 32 is assigned to BOTTOM.

### BASELINE

    public static final int BASELINE

  Constant for positioning the anchor point at the baseline of text.

  Value 64 is assigned to BASELINE.

### SOLID

    public static final int SOLID

  Constant for the SOLID stroke style.

  Value 0 is assigned to SOLID.

### DOTTED

    public static final int DOTTED

  Constant for the DOTTED stroke style.

  Value 1 is assigned to DOTTED.

Method Detail

### translate

    public void translate(int x,
                          int y)

  Translates the origin of the graphics context to the point (x, y) in the current coordinate system. All coordinates used in subsequent rendering operations on this graphics context will be relative to this new origin.

  The effect of calls to translate() are cumulative. For example, calling translate(1, 2) and then translate(3, 4) results in a translation of (4, 6).

  The application can set an absolute origin (ax, ay) using the following technique:

  `g.translate(ax - g.getTranslateX(), ay - g.getTranslateY())`

  Parameters:
    `x` - the x coordinate of the new translation origin
    `y` - the y coordinate of the new translation origin
  See Also:
    `getTranslateX()`, `getTranslateY()`

### getTranslateX

    public int getTranslateX()

  Gets the X coordinate of the translated origin of this graphics context.
  Returns:
    X of current origin

### getTranslateY

    public int getTranslateY()

  Gets the Y coordinate of the translated origin of this graphics context.
  Returns:
    Y of current origin

### getColor

    public int getColor()

  Gets the current color.
  Returns:
    an integer in form 0x00RRGGBB
  See Also:
    `setColor(int, int, int)`

### getRedComponent

    public int getRedComponent()

  Gets the red component of the current color.
  Returns:
    integer value in range 0-255
  See Also:
    `setColor(int, int, int)`

### getGreenComponent

    public int getGreenComponent()

  Gets the green component of the current color.
  Returns:
    integer value in range 0-255
  See Also:
    `setColor(int, int, int)`

### getBlueComponent

    public int getBlueComponent()

  Gets the blue component of the current color.
  Returns:
    integer value in range 0-255
  See Also:
    `setColor(int, int, int)`

### getGrayScale

    public int getGrayScale()

  Gets the current grayscale value of the color being used for rendering operations. If the color was set by setGrayScale(), that value is simply returned. If the color was set by one of the methods that allows setting of the red, green, and blue components, the value returned is computed from the RGB color components (possibly in a device-specific fashion) that best approximates the brightness of that color.
  Returns:
    integer value in range 0-255

### setColor

    public void setColor(int red,
                         int green,
                         int blue)

  Sets the current color to the specified RGB values. All subsequent rendering operations will use this specified color.
  Parameters:
    `red` - The red component of the color being set in range 0-255.
    `green` - The green component of the color being set in range 0-255.
    `blue` - The blue component of the color being set in range 0-255.
  Throws:
    IllegalArgumentException - if any of the color components are outside of range 0-255.

### setColor

    public void setColor(int RGB)

  Sets the current color to the specified RGB values. All subsequent rendering operations will use this specified color. The RGB value passed in is interpreted with the least significant eight bits giving the blue component, the next eight more significant bits giving the green component, and the next eight more significant bits giving the red component. That is to say, the color component is specified in the form of 0x00RRGGBB. The high order byte of this value is ignored.
  Parameters:
    `RGB` - the color being set

### setGrayScale

    public void setGrayScale(int value)

  Sets the current grayscale to be used for all subsequent rendering operations. For monochrome displays, the behavior is clear. For color displays, this sets the color for all subsequent drawing operations to be a gray color equivalent to the value passed in. The value must be in the range 0-255.
  Parameters:
    `value` - the desired grayscale value
  Throws:
    IllegalArgumentException - if the gray value is out of range

### getFont

    public Font getFont()

  Gets the current font.
  Returns:
    current font
  See Also:
    `Font`, `setFont(javax.microedition.lcdui.Font)`

### setStrokeStyle

    public void setStrokeStyle(int style)

  Sets the stroke style used for drawing lines, arcs, rectangles, and rounded rectangles. This does not affect fill, text, and image operations.
  Parameters:
    `style` - can be SOLID or DOTTED
  Throws:
    IllegalArgumentException - if the style is illegal

### getStrokeStyle

    public int getStrokeStyle()

  Gets the stroke style used for drawing operations.
  Returns:
    stroke style, SOLID or DOTTED

### setFont

    public void setFont(Font font)

  Sets the font for all subsequent text rendering operations. If font is null, it is equivalent to `setFont(Font.getDefaultFont())`.
  Parameters:
    `font` - the specified font
  See Also:
    `Font`, `getFont()`, `drawString(java.lang.String, int, int, int)`, `drawChars(char[], int, int, int, int, int)`

### getClipX

    public int getClipX()

  Gets the X offset of the current clipping area, relative to the coordinate system origin of this graphics context. Separating the getClip operation into two methods returning integers is more performance and memory efficient than one getClip() call returning an object.
  Returns:
    X offset of the current clipping area
  See Also:
    `clipRect(int, int, int, int)`, `setClip(int, int, int, int)`

### getClipY

    public int getClipY()

  Gets the Y offset of the current clipping area, relative to the coordinate system origin of this graphics context. Separating the getClip operation into two methods returning integers is more performance and memory efficient than one getClip() call returning an object.
  Returns:
    Y offset of the current clipping area
  See Also:
    `clipRect(int, int, int, int)`, `setClip(int, int, int, int)`

### getClipWidth

    public int getClipWidth()

  Gets the width of the current clipping area.
  Returns:
    width of the current clipping area.
  See Also:
    `clipRect(int, int, int, int)`, `setClip(int, int, int, int)`

### getClipHeight

    public int getClipHeight()

  Gets the height of the current clipping area.
  Returns:
    height of the current clipping area.
  See Also:
    `clipRect(int, int, int, int)`, `setClip(int, int, int, int)`

### clipRect

    public void clipRect(int x,
                         int y,
                         int width,
                         int height)

  Intersects the current clip with the specified rectangle. The resulting clipping area is the intersection of the current clipping area and the specified rectangle. This method can only be used to make the current clip smaller. To set the current clip larger, use the setClip method. Rendering operations have no effect outside of the clipping area.
  Parameters:
    `x` - the x coordinate of the rectangle to intersect the clip with
    `y` - the y coordinate of the rectangle to intersect the clip with
    `width` - the width of the rectangle to intersect the clip with
    `height` - the height of the rectangle to intersect the clip with
  See Also:
    `setClip(int, int, int, int)`

### setClip

    public void setClip(int x,
                        int y,
                        int width,
                        int height)

  Sets the current clip to the rectangle specified by the given coordinates. Rendering operations have no effect outside of the clipping area.
  Parameters:
    `x` - the x coordinate of the new clip rectangle
    `y` - the y coordinate of the new clip rectangle
    `width` - the width of the new clip rectangle
    `height` - the height of the new clip rectangle
  See Also:
    `clipRect(int, int, int, int)`

### drawLine

    public void drawLine(int x1,
                         int y1,
                         int x2,
                         int y2)

  Draws a line between the coordinates (x1,y1) and (x2,y2) using the current color and stroke style.
  Parameters:
    `x1` - the x coordinate of the start of the line
    `y1` - the y coordinate of the start of the line
    `x2` - the x coordinate of the end of the line
    `y2` - the y coordinate of the end of the line

### fillRect

    public void fillRect(int x,
                         int y,
                         int width,
                         int height)

  Fills the specified rectangle with the current color. If either width or height is zero or less, nothing is drawn.
  Parameters:
    `x` - the x coordinate of the rectangle to be filled
    `y` - the y coordinate of the rectangle to be filled
    `width` - the width of the rectangle to be filled
    `height` - the height of the rectangle to be filled
  See Also:
    `drawRect(int, int, int, int)`

### drawRect

    public void drawRect(int x,
                         int y,
                         int width,
                         int height)

  Draws the outline of the specified rectangle using the current color and stroke style. The resulting rectangle will cover an area (width + 1) pixels wide by (height + 1) pixels tall. If either width or height is less than zero, nothing is drawn.
  Parameters:
    `x` - the x coordinate of the rectangle to be drawn
    `y` - the y coordinate of the rectangle to be drawn
    `width` - the width of the rectangle to be drawn
    `height` - the height of the rectangle to be drawn
  See Also:
    `fillRect(int, int, int, int)`

### drawRoundRect

    public void drawRoundRect(int x,
                              int y,
                              int width,
                              int height,
                              int arcWidth,
                              int arcHeight)

  Draws the outline of the specified rounded corner rectangle using the current color and stroke style. The resulting rectangle will cover an area (width + 1) pixels wide by (height + 1) pixels tall. If either width or height is less than zero, nothing is drawn.
  Parameters:
    `x` - the x coordinate of the rectangle to be drawn
    `y` - the y coordinate of the rectangle to be drawn
    `width` - the width of the rectangle to be drawn
    `height` - the height of the rectangle to be drawn
    `arcWidth` - the horizontal diameter of the arc at the four corners
    `arcHeight` - the vertical diameter of the arc at the four corners
  See Also:
    `fillRoundRect(int, int, int, int, int, int)`

### fillRoundRect

    public void fillRoundRect(int x,
                              int y,
                              int width,
                              int height,
                              int arcWidth,
                              int arcHeight)

  Fills the specified rounded corner rectangle with the current color. If either width or height is zero or less, nothing is drawn.
  Parameters:
    `x` - the x coordinate of the rectangle to be filled
    `y` - the y coordinate of the rectangle to be filled
    `width` - the width of the rectangle to be filled
    `height` - the height of the rectangle to be filled
    `arcWidth` - the horizontal diameter of the arc at the four corners
    `arcHeight` - the vertical diameter of the arc at the four corners
  See Also:
    `drawRoundRect(int, int, int, int, int, int)`

### fillArc

    public void fillArc(int x,
                        int y,
                        int width,
                        int height,
                        int startAngle,
                        int arcAngle)

  Fills a circular or elliptical arc covering the specified rectangle.

  The resulting arc begins at `startAngle` and extends for `arcAngle` degrees. Angles are interpreted such that 0 degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation.

  The center of the arc is the center of the rectangle whose origin is (x, y) and whose size is specified by the `width` and `height` arguments.

  If either width or height is zero or less, nothing is drawn.

  The filled region consists of the "pie wedge" region bounded by the arc segment as if drawn by drawArc(), the radius extending from the center to this arc at `startAngle` degrees, and radius extending from the center to this arc at `startAngle + arcAngle` degrees.

  The angles are specified relative to the non-square extents of the bounding rectangle such that 45 degrees always falls on the line from the center of the ellipse to the upper right corner of the bounding rectangle. As a result, if the bounding rectangle is noticeably longer in one axis than the other, the angles to the start and end of the arc segment will be skewed farther along the longer axis of the bounds.

  Parameters:
    `x` - the x coordinate of the upper-left corner of the arc to be filled.
    `y` - the y coordinate of the upper-left corner of the arc to be filled.
    `width` - the width of the arc to be filled
    `height` - the height of the arc to be filled
    `startAngle` - the beginning angle.
    `arcAngle` - the angular extent of the arc, relative to the start angle.
  See Also:
    `drawArc(int, int, int, int, int, int)`

### drawArc

    public void drawArc(int x,
                        int y,
                        int width,
                        int height,
                        int startAngle,
                        int arcAngle)

  Draws the outline of a circular or elliptical arc covering the specified rectangle, using the current color and stroke style.

  The resulting arc begins at `startAngle` and extends for `arcAngle` degrees, using the current color. Angles are interpreted such that 0 degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation.

  The center of the arc is the center of the rectangle whose origin is (x, y) and whose size is specified by the `width` and `height` arguments.

  The resulting arc covers an area `width + 1` pixels wide by `height + 1` pixels tall. If either width or height is less than zero, nothing is drawn.

  The angles are specified relative to the non-square extents of the bounding rectangle such that 45 degrees always falls on the line from the center of the ellipse to the upper right corner of the bounding rectangle. As a result, if the bounding rectangle is noticeably longer in one axis than the other, the angles to the start and end of the arc segment will be skewed farther along the longer axis of the bounds.

  Parameters:
    `x` - the x coordinate of the upper-left corner of the arc to be drawn.
    `y` - the y coordinate of the upper-left corner of the arc to be drawn.
    `width` - the width of the arc to be drawn
    `height` - the height of the arc to be drawn
    `startAngle` - the beginning angle
    `arcAngle` - the angular extent of the arc, relative to the start angle.
  See Also:
    `fillArc(int, int, int, int, int, int)`

### drawString

    public void drawString(String str,
                           int x,
                           int y,
                           int anchor)

  Draws the specified String using the current font and color. The x,y position is the position of the anchor point. See anchor points.
  Parameters:
    `str` - the String to be drawn
    `x` - the x coordinate of the anchor point
    `y` - the y coordinate of the anchor point
    `anchor` - the anchor point for positioning the text
  Throws:
    NullPointerException - if str is null
    IllegalArgumentException - if anchor is not a legal value
  See Also:
    `drawChars(char[], int, int, int, int, int)`

### drawSubstring

    public void drawSubstring(String str,
                              int offset,
                              int len,
                              int x,
                              int y,
                              int anchor)

  Draws the specified String using the current font and color. The x,y position is the position of the anchor point. See anchor points.
  Parameters:
    `str` - the String to be drawn
    `offset` - zero-based index of first character in the substring
    `len` - length of the substring
    `x` - the x coordinate of the anchor point
    `y` - the y coordinate of the anchor point
    `anchor` - the anchor point for positioning the text
  Throws:
    StringIndexOutOfBoundsException - if offset and length do not specify a valid range within the String str
    IllegalArgumentException - if anchor is not a legal value
    NullPointerException - if str is null
  See Also:
    `drawString(String, int, int, int).`

### drawChar

    public void drawChar(char character,
                         int x,
                         int y,
                         int anchor)

  Draws the specified character using the current font and color.
  Parameters:
    `character` - the character to be drawn
    `x` - the x coordinate of the anchor point
    `y` - the y coordinate of the anchor point
    `anchor` - the anchor point for positioning the text; see anchor points a valid range within the data array
  Throws:
    IllegalArgumentException - if anchor is not a legal value
  See Also:
    `drawString(java.lang.String, int, int, int)`, `drawChars(char[], int, int, int, int, int)`

### drawChars

    public void drawChars(char[] data,
                          int offset,
                          int length,
                          int x,
                          int y,
                          int anchor)

  Draws the specified characters using the current font and color.
  Parameters:
    `data` - the array of characters to be drawn
    `offset` - the start offset in the data
    `length` - the number of characters to be drawn
    `x` - the x coordinate of the anchor point
    `y` - the y coordinate of the anchor point
    `anchor` - the anchor point for positioning the text; see anchor points
  Throws:
    ArrayIndexOutOfBoundsException - if offset and length do not specify a valid range within the data array
    IllegalArgumentException - if anchor is not a legal value
    NullPointerException - if data is null
  See Also:
    `drawString(java.lang.String, int, int, int)`

### drawImage

    public void drawImage(Image img,
                          int x,
                          int y,
                          int anchor)

  Draws the specified image by using the anchor point. The image can be drawn in different positions relative to the anchor point by passing the appropriate position constants. See anchor points.
  Parameters:
    `img` - the specified image to be drawn
    `x` - the x coordinate of the anchor point
    `y` - the y coordinate of the anchor point
    `anchor` - the anchor point for positioning the image
  Throws:
    IllegalArgumentException - if anchor is not a legal value
    NullPointerException - if img is null
  See Also:
    `Image`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| MID Profile
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a comment or suggestion Version 0.95 of MID Profile Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries. Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road,Palo Alto, California, 94303, U.S.A. All Rights Reserved.