com.nokia.mid.ui
Class DirectUtils

java.lang.Object
  extended by com.nokia.mid.ui.DirectUtils

public class DirectUtils
extends java.lang.Object

This class is a placeholder of utility methods. It contains methods for converting standard lcdui classes to Nokia UI classes and vice versa, and method for creating Image out of ARGB pixel array, creating empty transparent or specific background colored images, creating mutable image from encoded image byte array.

Since:
1.0
See Also:
Graphics, DirectGraphics, Canvas

Field Summary
static int STYLE_LIGHT
          The light style constant.
 
Method Summary
static javax.microedition.lcdui.Image createImage(byte[] imageData, int imageOffset, int imageLength)
          Creates a mutable image which 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 color)
           The method will return a newly created mutable Image with specified dimension with all pixels of an image of defined ARGB color.
static DirectGraphics getDirectGraphics(javax.microedition.lcdui.Graphics g)
          Converts standard javax.microedition.lcdui.Graphics to DirectGraphics.
static javax.microedition.lcdui.Font getFont(int face, int style, int height)
           The method returns new instance of javax.microedition.lcdui.Font with custom font height.
static boolean setHeader(javax.microedition.lcdui.Displayable displayable, java.lang.String headerText, javax.microedition.lcdui.Image headerImage, int headerTextColor, int headerBgColor, int headerDividerColor)
          Sets the header bar brandable elements on a displayable.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STYLE_LIGHT

public static final int STYLE_LIGHT
The light style constant. This may be combined with the other javax.microedition.lcdui.Font style constants

See Also:
Constant Field Values
Method Detail

getDirectGraphics

public static DirectGraphics getDirectGraphics(javax.microedition.lcdui.Graphics g)
Converts standard javax.microedition.lcdui.Graphics to DirectGraphics. The returned Graphics context is the same, e.g. calling draw operations via original Graphics reference affect the DirectGraphics context and vice versa. Note that eventhough the graphics context is the same the returned object reference may or may not be the same as passed. This means that purely casting Graphics (g) passed in paint of lcdui Canvas to DirectGraphics may not work ok. The safe 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 which 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, such as 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 color)

The method will return a newly created mutable Image with specified dimension with all pixels of an image of defined 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
Returns:
the created image
Throws:
java.lang.IllegalArgumentException - if either width or height is zero or less
Since:
1.0

getFont

public static javax.microedition.lcdui.Font getFont(int face,
                                                    int style,
                                                    int height)

The method returns new instance of javax.microedition.lcdui.Font with custom font height. System provides a font that matches the requested attributes as closely as possible.

Font created in this way can be used only for Graphics instance (Canvas, CustomItem, Image). This font is not supported for high-level UI components (ChoiceGroup, StringItem and List). If font with custom height is set to some high-level component, it's replaced by default font.

Actual font height could be affected by system limitations, there may be a maximum height defined by the system.

Parameters:
face - one of Font.FACE_SYSTEM, Font.FACE_MONOSPACE, or Font.FACE_PROPORTIONAL
style - Font.STYLE_PLAIN, DirectUtils.STYLE_LIGHT, or a combination of Font.STYLE_BOLD, Font.STYLE_ITALIC, and Font.STYLE_UNDERLINED
height - font height in pixels
Returns:
new instance of javax.microedition.lcdui.Font
Throws:
java.lang.IllegalArgumentException - if height is negative, if face or style are not legal values

setHeader

public static boolean setHeader(javax.microedition.lcdui.Displayable displayable,
                                java.lang.String headerText,
                                javax.microedition.lcdui.Image headerImage,
                                int headerTextColor,
                                int headerBgColor,
                                int headerDividerColor)
Sets the header bar brandable elements on a displayable. It is a deputy of setHeader in LCDUIUtils function.If application is manufacturer signed, but no the background attribute,this function will be called.The support of this API is subject to MIDlet's credentials and that it return true if request succeeded and false if request failed.

Parameters:
displayable - - the Displayable to set the header elements on.
headerText - - the String that must be displayed in the status zone. Midlet name will be displayed if headerText is set to null/empty when headerImage is null. To show an empty text, set headerImage to a valid image and headerText to null/empty.
headerImage - - the image to display in the status zone. null means no image should be set in header.
headerTextColor - - the color of the title text. -1 means that text color should be set to default.
headerBgColor - - the color of the status zone background. -1 means that bg color should be set to default.
headerDividerColor - - the color of the header bar divider line. -1 means that divider color should be set to default.
Returns:
true if application is signed to manufacture domain. other domain returns false.
Throws:
java.lang.NullPointerException - if displayable is null
java.lang.IllegalArgumentException - if displayable is not a Canvas or Form.


Copyright © 2012 Nokia Corporation. All rights reserved.

Nokia is registered trademark of Nokia Corporation. Java and all Java-based marks are trademarks or registered trademarks of Oracle Corporation. Other product and company names mentioned herein may be trademarks or trade names of their respective owners. This document is confidential information of Nokia Corporation.

Disclaimer
The information in this document is provided "as is," with no warranties whatsoever, including any warranty of merchantability, fitness for any particular purpose, or any warranty otherwise arising out of any proposal, specification, or sample. Furthermore, information provided in this document is preliminary, and may be changed substantially prior to final release.

Nokia Corporation disclaims all liability, including liability for infringement of any proprietary rights, relating to this document and implementation of any information presented in this document.

Nokia Corporation retains the right to make changes to this document at any time, without notice.

License
Subject to above disclaimer, a license is hereby granted to use this documentation solely under existing Limited License Agreement and non-disclosure agreement between the companies for the agreed application development for Series 40 Nokia phones. No other licenses e.g. to any intellectual property rights are granted herein. Any use of the screen shots of this documentation, including any icons thereof, is subject to Nokia's prior written approval.