org.havi.ui
Class HBackgroundImage

java.lang.Object
  extended byorg.havi.ui.HBackgroundImage

public class HBackgroundImage
extends java.lang.Object

This class represents a background image. Images of this class can be used as full screen backgrounds outside the java.awt framework.


The parameters to the constructors are as follows, in cases where parameters are not used, then the constructor should use the default values.

Default parameter values exposed in the constructors

ParameterDescriptionDefault value Set methodGet method
None.

Default parameter values not exposed in the constructors

DescriptionDefault valueSet method Get method
None.


Constructor Summary
HBackgroundImage(byte[] pixels)
          Create an HBackgroundImage object from an array of bytes encoded in the same encoding format as when reading this type of image data from a file.
HBackgroundImage(java.lang.String filename)
          Create an HBackgroundImage object.
HBackgroundImage(java.net.URL contents)
          Create an HBackgroundImage object.
 
Method Summary
 void flush()
          Flush all the resources used by this image.
 int getHeight()
          Determines the height of the image.
 int getWidth()
          Determines the width of the image.
 void load(HBackgroundImageListener l)
          Load the data for this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HBackgroundImage

public HBackgroundImage(java.lang.String filename)
Create an HBackgroundImage object. Loading of the data for the object shall not happen at this time.

Parameters:
filename - the name of the file to use as the source of data in a platform-specific URL format.

HBackgroundImage

public HBackgroundImage(byte[] pixels)
Create an HBackgroundImage object from an array of bytes encoded in the same encoding format as when reading this type of image data from a file.

If this constructor succeeds then the object will automatically be in the loaded state and calling the load(org.havi.ui.event.HBackgroundImageListener) method shall immediately generate an HBackgroundImageEvent reporting success.

If the byte array does not contain a valid image then this constructor may throw a java.lang.IllegalArgumentException.

Calling the flush() method on an object built with this constructor shall have no effect.

Parameters:
pixels - the data for the HBackgroundImage object encoded in the specified format for image files of this type.

HBackgroundImage

public HBackgroundImage(java.net.URL contents)
Create an HBackgroundImage object. Loading of the data for the object shall not happen at this time.

Parameters:
contents - a URL referring to the data to load.
Method Detail

load

public void load(HBackgroundImageListener l)
Load the data for this object. This method is asynchronous. The completion of data loading is reported through the listener provided.

Multiple calls to load shall each add an extra listener, all of which are informed when the loading is completed. If load is called with the same listener more than once, the listener shall then receive multiple copies of a single event.

Parameters:
l - the listener to call when loading of data is completed.
See Also:
HBackgroundImageEvent

getHeight

public int getHeight()
Determines the height of the image. This is returned in pixels as defined by the format of the image concerned. If this information is not known when this method is called then -1 is returned.

The image must have been successfully loaded to completion before this information is guaranteed to be available. It is implementation specific whether this information is available before the image is successfully loaded to completion. An image whose loading failed for any reason shall be considered as having this information unavailable.

Returns:
the height of the image

getWidth

public int getWidth()
Determines the width of the image. This is returned in pixels as defined by the format of the image concerned. If this information is not known when this method is called then -1 is returned.

The image must have been successfully loaded to completion before this information is guaranteed to be available. It is implementation specific whether this information is available before the image is successfully loaded to completion. An image whose loading failed for any reason shall be considered as having this information unavailable.

Returns:
the width of the image

flush

public void flush()
Flush all the resources used by this image. This includes any pixel data being cached as well as all underlying system resources used to store data or pixels for the image. After calling this method the image is in a state similar to when it was first created without any load method having been called. When this method is called, the image shall not be in use by an application. Resources related to any HBackgroundDevice are not released.