net.rim.device.api.ui.image
Class Image

java.lang.Object
  extended by net.rim.device.api.ui.image.Image

public abstract class Image
extends Object

Represents an image of agnostic type that can be painted into a graphics context. Recommended for containers or components that would like to support and display different types of images, e.g. Bitmap, BMPEncodedImage, PNGEncodedImage, etc. An image cannot be instantiated directly. Different types of images can be created by calling the following methods in the ImageFactory:

Since:
BlackBerry API 5.0.0

Field Summary
static int BOTTOM
          The image will be painted at the bottom of the graphics context.
static int HCENTER
          The image will be centered vertically in the graphics context.
static int LEFT
          The image will be left-justified in the graphics context.
static int RIGHT
          The image will be right-justified in the graphics context.
static int TOP
          The image will be painted at the top of the graphics context.
static int VCENTER
          The image will be centered vertically in the graphics context.
 
Method Summary
abstract  int getHeight(int width, int height)
          Returns the height of the painted image for the specified region.
abstract  int getWidth(int width, int height)
          Returns the width of the painted image for the specified region.
abstract  void paint(Graphics graphics, int x, int y, int width, int height)
          Paints the image in the given graphics context starting at (x, y) with provided width and height.
abstract  void paint(Graphics graphics, int x, int y, int width, int height, int style)
          Paints the image in the given graphics context starting at (x, y) with provided width and height.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

TOP

public static final int TOP
The image will be painted at the top of the graphics context.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

VCENTER

public static final int VCENTER
The image will be centered vertically in the graphics context.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

BOTTOM

public static final int BOTTOM
The image will be painted at the bottom of the graphics context.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

LEFT

public static final int LEFT
The image will be left-justified in the graphics context.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

HCENTER

public static final int HCENTER
The image will be centered vertically in the graphics context.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

RIGHT

public static final int RIGHT
The image will be right-justified in the graphics context.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0


Method Detail

getHeight

public abstract int getHeight(int width,
                              int height)
Returns the height of the painted image for the specified region. The scale factor for width and height will be the same. Typically, the returned height or width will be the same or smaller than the values passed in.

Parameters:
width - The width of the available region for this image.
height - The height of the available region for this image.
Returns:
The height of the image when painted into the specified region.
Throws:
IllegalArgumentException - if width or height is less than 1.
Since:
BlackBerry API 5.0.0

getWidth

public abstract int getWidth(int width,
                             int height)
Returns the width of the painted image for the specified region. The scale factor for width and height will be the same. Typically, the returned height or width will be the same or smaller than the values passed in.

Parameters:
width - The width of the available region for this image.
height - The height of the available region for this image.
Returns:
The width of the image when painted into the specified region.
Throws:
IllegalArgumentException - if width or height is less than 1.
Since:
BlackBerry API 5.0.0

paint

public abstract void paint(Graphics graphics,
                           int x,
                           int y,
                           int width,
                           int height)
Paints the image in the given graphics context starting at (x, y) with provided width and height. The image is scaled to fit in the given width and height. The aspect ratio of the image is preserved. The image is centered horizontally and vertically in the graphics context.

Parameters:
graphics - Graphics context to paint into.
x - x drawing offset.
y - y drawing offset.
width - Desired width of the image.
height - Desired height of the image.
Since:
BlackBerry API 5.0.0

paint

public abstract void paint(Graphics graphics,
                           int x,
                           int y,
                           int width,
                           int height,
                           int style)
Paints the image in the given graphics context starting at (x, y) with provided width and height. The image is scaled to fit in the given width and height. The aspect ratio of the image is preseved. The image is aligned and justified according to the specified style.

Parameters:
graphics - Graphics context to paint into.
x - x drawing offset.
y - y drawing offset.
width - Desired width of the image.
height - Desired height of the image.
style - One of the following alignment styles: Image.TOP, Image.BOTTOM, Image.LEFT, Image.RIGHT, Image.VCENTER, Image.HCENTER.
Since:
BlackBerry API 5.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal