| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface DirectGraphics
DirectGraphics contains some graphics extensions to MIDP Graphics: drawing triangles, drawing manipulated images (rotated, flipped) and drawing raw pixel array directly to graphics context. DirectUtils class can be used to convert standard Graphics to proprietary DirectGraphics object:
DirectGraphics dg = DirectUtils.getDirectGraphics(g);The operations to DirectGraphics reference will affect also original graphics context, for example, setting color of DirectGraphics will change current painting color of Graphics and vice versa. In fact developer can see DirectGraphics as a new way to do call to Graphics. DirectGraphics doesn't inherit standard Graphics because of API dependency reasons. ARGB values used with some methods of this interface are interpreted with the least significant eight bits giving the blue component, the next eight more significant bits giving the green component, the next eight more significant bits giving the red component and the next eight more significant bits giving the alpha component. That is to say, the color component is specified in the form of 0xAARRGGBB. This correspons to native format specified by { @link DirectGraphics#TYPE_ARGB_8888 }. Manipulation parameters to drawPixels are formed by bitwise ORring FLIP_HORIZONTAL or FLIP_VERTICAL with a degree value: ROTATE_90, ROTATE_180 or ROTATE_270. Currently only these constant defined degree values are supported when rotating images.
Copyright (c) 2001 Nokia Mobile Phones
| Field Summary | |
|---|---|
| static int | FLIP_HORIZONTALConstant for horizontal image flipping. | 
| static int | FLIP_VERTICALConstant for vertical image flipping. | 
| static int | FORM_CHOICE_HIGHLIGHT_BORDER_TYPEConstant for drawing the Form's Choice element highlight border type. | 
| static int | FORM_ITEM_BORDER_TYPEConstant for drawing the Form's item border type. | 
| static int | FORM_TEXT_FIELD_BORDER_TYPEConstant for drawing the Form's TextField border type. | 
| static int | ROTATE_180Constant for rotating image 180 degrees counter-clockwise. | 
| static int | ROTATE_270Constant for rotating image 270 degrees counter-clockwise. | 
| static int | ROTATE_90Constant for rotating image 90 degrees counter-clockwise. | 
| static int | TYPE_BYTE_1_GRAY1 bit format, 2 distinct color values (on/off), stored as a byte. | 
| static int | TYPE_BYTE_1_GRAY_VERTICAL1 bit format, 2 distinct color values (on/off), stored as a byte. | 
| static int | TYPE_BYTE_2_GRAY2 bit format, 4 gray scale colors. | 
| static int | TYPE_BYTE_332_RGB3 bits for red, 3 bits for green, and 2 bits for blue component in a pixel, stored as a byte. | 
| static int | TYPE_BYTE_4_GRAY4 bit format, 16 gray scale colors. | 
| static int | TYPE_BYTE_8_GRAY8 bit format, 256 gray scale colors. | 
| static int | TYPE_INT_888_RGB8 bits for red, green and blue component in a pixel (0x00RRGGBB). | 
| static int | TYPE_INT_8888_ARGB8 bits for alpha, red, green and blue component in a pixel (0xAARRGGBB). | 
| static int | TYPE_USHORT_1555_ARGB1 bit for alpha, 5 bits for red, green and blue component in a pixel. | 
| static int | TYPE_USHORT_444_RGB4 bits for red, green and blue component in a pixel, stored as a short (0x0RGB). | 
| static int | TYPE_USHORT_4444_ARGB4 bits for alpha, red, green and blue component in a pixel, stored as a short (0xARGB). | 
| static int | TYPE_USHORT_555_RGB5 bits for red, green and blue component in a pixel. | 
| static int | TYPE_USHORT_565_RGB5 bits for red, 6 bits for green and 5 bits for blue component in a pixel. | 
| Method Summary | |
|---|---|
|  void | drawElementBorder(int x,
                  int y,
                  int w,
                  int h,
                  int borderType,
                  boolean withFocus)Draws the specified border type at the specified coordinates. | 
|  void | drawImage(javax.microedition.lcdui.Image img,
          int x,
          int y,
          int anchor,
          int manipulation)Draws image to the graphics context. | 
|  void | drawPixels(byte[] pixels,
           byte[] transparencyMask,
           int offset,
           int scanlength,
           int x,
           int y,
           int width,
           int height,
           int manipulation,
           int format)Copies or draws the pixel data directly to graphics context to specific location. | 
|  void | drawPixels(int[] pixels,
           boolean transparency,
           int offset,
           int scanlength,
           int x,
           int y,
           int width,
           int height,
           int manipulation,
           int format)Copies or draws the pixel data directly to graphics context to specific location from the array starting from specified offset. | 
|  void | drawPixels(short[] pixels,
           boolean transparency,
           int offset,
           int scanlength,
           int x,
           int y,
           int width,
           int height,
           int manipulation,
           int format)Copies or draws the pixel data directly to graphics context to specific location. | 
|  void | drawPolygon(int[] xPoints,
            int xOffset,
            int[] yPoints,
            int yOffset,
            int nPoints,
            int argbColor)Draws a closed polygon defined by arrays of x and y coordinates. | 
|  void | drawTriangle(int x1,
             int y1,
             int x2,
             int y2,
             int x3,
             int y3,
             int argbColor)Draws closed triangle defined by coordinates. | 
|  void | fillPolygon(int[] xPoints,
            int xOffset,
            int[] yPoints,
            int yOffset,
            int nPoints,
            int argbColor)Fills a closed polygon defined by arrays of x and y coordinates. | 
|  void | fillTriangle(int x1,
             int y1,
             int x2,
             int y2,
             int x3,
             int y3,
             int argbColor)Fills closed triangle defined by coordinates. | 
|  int | getAlphaComponent()Gets the alpha component of the current color. | 
|  int | getNativePixelFormat()Returns the native color format used, for example, DirectGraphics#TYPE_BYTE_GRAY_1orDirectGraphics#TYPE_USHORT_ARGB_4444. | 
|  void | getPixels(byte[] pixels,
          byte[] transparencyMask,
          int offset,
          int scanlength,
          int x,
          int y,
          int width,
          int height,
          int format)Gets the pixel (including any transparency mask) values of an image to an array of byte values from specific screen location. | 
|  void | getPixels(int[] pixels,
          int offset,
          int scanlength,
          int x,
          int y,
          int width,
          int height,
          int format)Gets the pixel values of an image to an array of ARGB values. | 
|  void | getPixels(short[] pixels,
          int offset,
          int scanlength,
          int x,
          int y,
          int width,
          int height,
          int format)Gets the pixel values of an image to an array of short values from specific screen location. | 
|  void | setARGBColor(int argbColor)Sets the current color to the specified ARGB value. | 
| Field Detail | 
|---|
static final int FLIP_HORIZONTAL
drawImage(Image img, int x, int y, int anchor, int manipulation), 
Constant Field Valuesstatic final int FLIP_VERTICAL
drawImage(Image img, int x, int y, int anchor, int manipulation), 
Constant Field Valuesstatic final int ROTATE_90
drawImage(Image img, int x, int y, int anchor, int manipulation), 
Constant Field Valuesstatic final int ROTATE_180
drawImage(Image img, int x, int y, int anchor, int manipulation), 
Constant Field Valuesstatic final int ROTATE_270
drawImage(Image img, int x, int y, int anchor, int manipulation), 
Constant Field Valuesstatic final int TYPE_BYTE_1_GRAY_VERTICAL
  BYTE   0 1 2 3 4 5 6 7
  LSB    + +         + +
         + + +       + +
         + + + +     + +
         + + + + +   + +
         + +   + + + + +
         + +     + + + +
         + +       + + +
  MSB    + +         + +
         byte [] byteArray = new byte[8]
         byteArray[0] = 0xFF // binary 11111111
         byteArray[1] = 0xFF // binary 11111111
         byteArray[2] = 0x0E // binary 00001110
         byteArray[3] = 0x1C // binary 00011100
         byteArray[4] = 0x38 // binary 00111000
         byteArray[5] = 0x70 // binary 01110000
         byteArray[5] = 0xFF // binary 11111111
         byteArray[7] = 0xFF // binary 11111111
 
static final int TYPE_BYTE_1_GRAY
static final int TYPE_BYTE_2_GRAY
static final int TYPE_BYTE_4_GRAY
static final int TYPE_BYTE_8_GRAY
static final int TYPE_BYTE_332_RGB
static final int TYPE_USHORT_4444_ARGB
static final int TYPE_USHORT_444_RGB
static final int TYPE_USHORT_555_RGB
static final int TYPE_USHORT_1555_ARGB
static final int TYPE_USHORT_565_RGB
static final int TYPE_INT_888_RGB
static final int TYPE_INT_8888_ARGB
static final int FORM_ITEM_BORDER_TYPE
static final int FORM_TEXT_FIELD_BORDER_TYPE
static final int FORM_CHOICE_HIGHLIGHT_BORDER_TYPE
| Method Detail | 
|---|
int getAlphaComponent()
void setARGBColor(int argbColor)
argbColor - the color being set
void drawImage(javax.microedition.lcdui.Image img,
               int x,
               int y,
               int anchor,
               int manipulation)
img - the specified image to be drawnx - the x coordinate of the anchor pointy - the y coordinate of the anchor pointanchor - the anchor point for positioning the imagemanipulation - flip or rotate value or a combination of values, 0 if none
java.lang.IllegalArgumentException - if anchor is not a legal value or manipulation is not
             supported
java.lang.NullPointerException - if img is nullImage, 
FLIP_VERTICAL, 
FLIP_HORIZONTAL, 
ROTATE_90
void drawTriangle(int x1,
                  int y1,
                  int x2,
                  int y2,
                  int x3,
                  int y3,
                  int argbColor)
x1 - the x coordinate of first vertexy1 - the y coordinate of first vertexx2 - the x coordinate of second vertexy2 - the y coordinate of second vertexx3 - the x coordinate of third vertexy3 - the y coordinate of third vertexargbColor - the ARGB color value used painting the triangle
void fillTriangle(int x1,
                  int y1,
                  int x2,
                  int y2,
                  int x3,
                  int y3,
                  int argbColor)
x1 - the x coordinate of first vertexy1 - the y coordinate of first vertexx2 - the x coordinate of second vertexy2 - the y coordinate of second vertexx3 - the x coordinate of third vertexy3 - the y coordinate of third vertexargbColor - the ARGB color value used painting the triangle
void drawPolygon(int[] xPoints,
                 int xOffset,
                 int[] yPoints,
                 int yOffset,
                 int nPoints,
                 int argbColor)
xPoints - an array of x coordinatesxOffset - an offset to first x point in xPointsyPoints - an array of y coordinatesyOffset - an offset to first y point in yPointsnPoints - the total number of pointsargbColor - the ARGB color value used painting the polygon
void fillPolygon(int[] xPoints,
                 int xOffset,
                 int[] yPoints,
                 int yOffset,
                 int nPoints,
                 int argbColor)
xPoints - an array of x coordinatesxOffset - an offset to first x point in xPointsyPoints - an array of y coordinatesyOffset - an offset to first y point in yPointsnPoints - the total number of pointsargbColor - the ARGB color value used painting the polygon
void drawPixels(int[] pixels,
                boolean transparency,
                int offset,
                int scanlength,
                int x,
                int y,
                int width,
                int height,
                int manipulation,
                int format)
pixels - an array of pixel values (0xAARRGGBB)transparency - true if the pixel's transparency value will be checkedoffset - the index of the first pixel valuescanlength - the relative array offset between the corresponding pixels in
            consecutive rowsx - the horizontal rendering location on graphics contexty - the vertical rendering location on graphics contextwidth - the width of the region to the renderedheight - the height of the region to the renderedmanipulation - the manipulation done to the image before the draw, 0 means
            none.format - the display format used
java.lang.NullPointerException - if pixels is null
java.lang.ArrayIndexOutOfBoundsException - if requested to access
java.lang.IllegalArgumentException - if foramt is not supported pixels beyond the length of array
             or with negative index
void getPixels(int[] pixels,
               int offset,
               int scanlength,
               int x,
               int y,
               int width,
               int height,
               int format)
pixels - an array in which the image pixel information will be storedoffset - the index into the array where the first pixel value will be
            storedscanlength - the relative offset in the array between corresponding pixels
            in consecutive rowsx - the x-coordinate of the upper left corner of the regiony - the y-coordinate of the upper left corner of the regionwidth - the width of the regionheight - the height of the regionformat - the display format used
java.lang.NullPointerException - if pixels is null
java.lang.ArrayIndexOutOfBoundsException - if array size is too small
java.lang.IllegalArgumentException - if foramt is not supported for the image pixels or negative
             index access is attempted, contents of the array remain
             unchanged
void getPixels(byte[] pixels,
               byte[] transparencyMask,
               int offset,
               int scanlength,
               int x,
               int y,
               int width,
               int height,
               int format)
pixels - an array in which the image pixel information will be storedtransparencyMask - an array in which the transparency mask will be storedoffset - the index into the array where the first pixel and mask value
            will be storedscanlength - the relative offset in the array between corresponding pixels
            and mask value in consecutive rowsx - the x-coordinate of the upper left corner of the regiony - the y-coordinate of the upper left corner of the regionwidth - the width of the regionheight - the height of the regionformat - the display format used
java.lang.NullPointerException - if pixels is null
java.lang.ArrayIndexOutOfBoundsException - if array size is too small
java.lang.IllegalArgumentException - if foramt is not supported for the image pixels or negative
             index access is attempted, contents of the array remain
             unchanged
void getPixels(short[] pixels,
               int offset,
               int scanlength,
               int x,
               int y,
               int width,
               int height,
               int format)
pixels - an array in which the image pixel information will be storedoffset - the index into the array where the first pixel value will be
            storedscanlength - the relative offset in the array between corresponding pixels
            in consecutive rowsx - the x-coordinate of the upper left corner of the regiony - the y-coordinate of the upper left corner of the regionwidth - the width of the regionheight - the height of the regionformat - the display format used
java.lang.NullPointerException - if pixels is null
java.lang.ArrayIndexOutOfBoundsException - if array size is too small
java.lang.IllegalArgumentException - if foramt is not supported for the image pixels or negative
             index access is attempted, contents of the array remain
             unchanged
void drawPixels(byte[] pixels,
                byte[] transparencyMask,
                int offset,
                int scanlength,
                int x,
                int y,
                int width,
                int height,
                int manipulation,
                int format)
pixels - an array of pixel valuestransparencyMask - an array defining transparency maskoffset - the index of the first pixel and mask valuescanlength - the relative array offset between the corresponding pixels and
            mask value in consecutive rowsx - the horizontal rendering location on graphics contexty - the vertical rendering location on graphics contextwidth - the width of the region to the renderedheight - the height of the region to the renderedmanipulation - the manipulation done to the image before the draw, 0 means
            none.format - the display format used
java.lang.NullPointerException - if pixels is null
java.lang.ArrayIndexOutOfBoundsException - if requested to access
java.lang.IllegalArgumentException - if foramt is not supported beyond the length of array or with
             negative index
void drawPixels(short[] pixels,
                boolean transparency,
                int offset,
                int scanlength,
                int x,
                int y,
                int width,
                int height,
                int manipulation,
                int format)
pixels - an array of pixel valuestransparency - true if the pixel's transparency value will be checkedoffset - the index of the first pixel valuescanlength - the relative array offset between the corresponding pixels in
            consecutive rowsx - the horizontal rendering location on graphics contexty - the vertical rendering location on graphics contextwidth - the width of the region to the renderedheight - the height of the region to the renderedmanipulation - the manipulation done to the image before the draw, 0 means
            none.format - the display format used
java.lang.NullPointerException - if pixels is null
java.lang.ArrayIndexOutOfBoundsException - if requested to access
java.lang.IllegalArgumentException - if foramt is not supported beyond the length of array or with
             negative indexint getNativePixelFormat()
DirectGraphics#TYPE_BYTE_GRAY_1 or
 DirectGraphics#TYPE_USHORT_ARGB_4444. Application can check the
 expected by drawPixels and returned from getPixels methods of this
 interface.
void drawElementBorder(int x,
                       int y,
                       int w,
                       int h,
                       int borderType,
                       boolean withFocus)
x - the x coordinate of the border to be drawny - the y coordinate of the border to be drawnw - the width of the border to be drawnh - the height of the border to be drawnborderType - the border type to draw.
java.lang.IllegalArgumentException - if the specified border type is invalid.| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||