    All Packages    This Package    Previous    Next

# Class awt.GenericGraphics

    java.lang.Object
       |
       +----awt.GenericGraphics

public class GenericGraphics
extends Object

GenericGraphics is the base class for all graphics contexts for various devices. It will eventually be renamed to "Graphics".

Version:
  1.12 17 Mar 1995
Author:
  Sami Shaio

##

background
font
foreground
originX
originY
scaleX
scaleY

##

GenericGraphics(int, int, float, float)
  Create a graphics context.
GenericGraphics()
  Create a graphics context with origin at (0,0)

##

clearClip()
  Clears the clipping region.
clearRect(int, int, int, int)
  Clears the rectangle indicated by x,y,w,h.
clipRect(int, int, int, int)
  Sets the clipping rectangle for this Graphics context.
copyArea(int, int, int, int, int, int)
  Copies an area of the window that this graphics context paints to.
createChild(int, int, float, float)
  Create a new Graphics Object based on this one.
dispose()
  Disposes of this Graphics context.
drawChars(char[], int, int, int, int)
  Draws the given character array.
drawCharsWidth(char[], int, int, int, int)
  Draws the given character array and return the width in pixels.
drawImage(Image, int, int)
  Draws an image at x,y.
drawLine(int, int, int, int)
  Draws the given line.
drawRect(int, int, int, int)
  Draws the given rectangle.
drawString(String, int, int)
  Draws the given string.
drawStringWidth(String, int, int)
  Draws the given string and returns the length of the drawn string in pixels.
fillRect(int, int, int, int)
  Fills the given rectangle with the foreground color.
paint3DRect(int, int, int, int, boolean, boolean)
  Paints a highlighted rectangle.
setBackground(Color)
  Sets the background color.
setFont(Font)
  Sets the font for all subsequent text-drawing operations.
setForeground(Color)
  Sets the foreground color.
setOrigin(int, int)
  Sets the origin of this Graphics context.
setScaling(float, float)
  Sets the scaling factor for this Graphics context.

##

background

      public Color background

foreground

      public Color foreground

font

      public Font font

originX

      public int originX

originY

      public int originY

scaleX

      public float scaleX

scaleY

      public float scaleY

##

GenericGraphics

      public GenericGraphics(int oX,
                             int oY,
                             float sX,
                             float sY)

  Create a graphics context.

GenericGraphics

      public GenericGraphics()

  Create a graphics context with origin at (0,0)

##

createChild

      public abstract GenericGraphics createChild(int oX,
                                                  int oY,
                                                  float sX,
                                                  float sY)

  Create a new Graphics Object based on this one.

dispose

      public void dispose()

  Disposes of this Graphics context. It can't be used after being disposed.

setFont

      public void setFont(Font f)

  Sets the font for all subsequent text-drawing operations.

setForeground

      public void setForeground(Color c)

  Sets the foreground color.

setBackground

      public void setBackground(Color c)

  Sets the background color.

paint3DRect

      public void paint3DRect(int x,
                              int y,
                              int w,
                              int h,
                              boolean fill,
                              boolean raised)

  Paints a highlighted rectangle.

clipRect

      public abstract void clipRect(int X,
                                    int Y,
                                    int W,
                                    int H)

  Sets the clipping rectangle for this Graphics context.

clearClip

      public abstract void clearClip()

  Clears the clipping region.

clearRect

      public abstract void clearRect(int X,
                                     int Y,
                                     int W,
                                     int H)

  Clears the rectangle indicated by x,y,w,h.

fillRect

      public abstract void fillRect(int X,
                                    int Y,
                                    int W,
                                    int H)

  Fills the given rectangle with the foreground color.

drawRect

      public abstract void drawRect(int X,
                                    int Y,
                                    int W,
                                    int H)

  Draws the given rectangle.

drawString

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

  Draws the given string.

drawChars

      public abstract void drawChars(char chars[],
                                     int offset,
                                     int length,
                                     int x,
                                     int y)

  Draws the given character array.

drawStringWidth

      public abstract int drawStringWidth(String str,
                                          int x,
                                          int y)

  Draws the given string and returns the length of the drawn string in pixels. If font isn't set then returns -1.

drawCharsWidth

      public abstract int drawCharsWidth(char chars[],
                                         int offset,
                                         int length,
                                         int x,
                                         int y)

  Draws the given character array and return the width in pixels. If font isn't set then returns -1.

drawLine

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

  Draws the given line.

drawImage

      public abstract void drawImage(Image I,
                                     int X,
                                     int Y)

  Draws an image at x,y.

copyArea

      public abstract void copyArea(int X,
                                    int Y,
                                    int W,
                                    int H,
                                    int dx,
                                    int dy)

  Copies an area of the window that this graphics context paints to.
  Parameters:
    X - the x-coordinate of the source.
    Y - the y-coordinate of the source.
    W - the width.
    H - the height.
    dx - the x-coordinate of the destination.
    dy - the y-coordinate of the destination.

setOrigin

      public void setOrigin(int x,
                            int y)

  Sets the origin of this Graphics context. All subsequent operations are relative to this origin.

setScaling

      public void setScaling(float sx,
                             float sy)

  Sets the scaling factor for this Graphics context. Currently only used for line and rectangle drawing operations.

    All Packages    This Package    Previous    Next