com.nokia.mid.ui
Class DirectUtils

java.lang.Object
  |
  +--com.nokia.mid.ui.DirectUtils

public class DirectUtils
extends java.lang.Object

This class is a placeholder for utility methods. It contains methods for converting standard lcdui classes to Nokia UI classes and vice versa, and a method for creating images that are empty with pixels either transparent or colored, and creating mutable images from encoded image byte arrays.

Since:
1.0
See Also:
Graphics, DirectGraphics, Canvas, FullCanvas

Method Summary
static javax.microedition.lcdui.Image createImage(byte[] imageData, int imageOffset, int imageLength)
          Creates a mutable image that is decoded from the data stored in the specified byte array at the specified offset and length.
static javax.microedition.lcdui.Image createImage(int width, int height, int ARGBcolor)
           The method will return a newly created mutable Image with the specified dimension and all the pixels of the image defined by the specified ARGB color.
static DirectGraphics getDirectGraphics(javax.microedition.lcdui.Graphics g)
          Converts standard javax.microedition.lcdui.Graphics to DirectGraphics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDirectGraphics

public static DirectGraphics getDirectGraphics(javax.microedition.lcdui.Graphics g)
Converts standard javax.microedition.lcdui.Graphics to DirectGraphics. The returned object refers to the same graphics context. This means that calling draw operations or changing the state, for example, drawing color etc., via the original Graphics reference affect the DirectGraphics object, and vice versa.

Note that even though the graphics context that the DirectGraphics and Graphics refer to is the same, the object reference returned from this method may or may not be equal compared to the Graphics reference passed to this method. This means that purely casting Graphics object (g) passed in paint method of lcdui Canvas to DirectGraphics may not work ok. The safest way is to always do the conversion with this method.

Parameters:
g - Graphics object for which DirectGraphics should be returned
Returns:
the DirectGraphics object based on Graphics
Since:
1.0

createImage

public static javax.microedition.lcdui.Image createImage(byte[] imageData,
                                                         int imageOffset,
                                                         int imageLength)
Creates a mutable image that is decoded from the data stored in the specified byte array at the specified offset and length. The data must be in a self-identifying image file format supported by the implementation, e.g., PNG.

Note that the semantics of this method are exactly the same as Image.createImage(byte[],int,int) except that the returned image is mutable.

Parameters:
imageData - the array of image data in a supported image format
imageOffset - the offset of the start of the data in the array
imageLength - the length of the data in the array
Returns:
the created mutable image
Throws:
java.lang.ArrayIndexOutOfBoundsException - if imageOffset and imageLength specify an invalid range
java.lang.NullPointerException - if imageData is null
java.lang.IllegalArgumentException - if imageData is incorrectly formatted or otherwise cannot be decoded
Since:
1.0
See Also:
Image.createImage(byte[],int,int)

createImage

public static javax.microedition.lcdui.Image createImage(int width,
                                                         int height,
                                                         int ARGBcolor)

The method will return a newly created mutable Image with the specified dimension and all the pixels of the image defined by the specified ARGB color. The color can contain alpha channel transparency information.

Parameters:
width - the width of the new image, in pixels
height - the height of the new image, in pixels
ARGBcolor - the initial color for image
Returns:
the created image
Throws:
java.lang.IllegalArgumentException - if either width or height is zero or less
Since:
1.0

forum.nokia.com/java

Copyright (c) 2002-2004 Nokia Corporation. All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc.