JavaScript Client API

com.mi.rs.ImageRenderTarget Class Reference

Description

The target for images returned by the render command. There are two modes with which an ImageRenderTarget can be used:

1. If an image is provided in the constructor, then the ImageRenderTarget will take ownership of the onload, onabort, and onerror events of the provided image. These events will be used by the service to load render URLs automatically and must not be set by the application as long as the ImageRenderTarget instance is is in use. Note that the com.mi.rs.event.RENDER_URL_EVENT event will not be dispatched in this mode. The type of the image is browser dependent but an image created as an HTML img tag will work in all supported browsers.

2. If no image is provided then the ImageRenderTarget will dispatch a com.mi.rs.event.RENDER_URL_EVENT when a render URL needs to be loaded. The application is responsible for loading this URL exactly once and call one of the methods renderURLLoadError, renderURLLoadAborted, or renderURLLoadComplete when the URL has finished loading. The service will halt any further command processing until one of these functions are called.

This class is an event dispatcher. This means it implements the functions addEventListener and removeEventListener functions as documented in the class com.mi.util.EventDispatcher. The following events can be dispatched by this class:

com.mi.rs.event.RENDER_URL_EVENT com.mi.rs.event.IMAGE_LOADED_EVENT com.mi.rs.event.IMAGE_ABORTED_EVENT com.mi.rs.event.IMAGE_ERROR_EVENT

Constructor

 ImageRenderTarget( Image image, Object useHiddenBuffer)
Creates an ImageRenderTarget object that can act as a target for render commands. More...

Member Functions

void addEventListener( String type, Function listener, Object context)
Adds a listener for the given event type. More...
void removeEventListener( String type, Function listener)
Removes the provided event listener. More...
void renderURLLoadAborted()
Must be called when an external render URL has been aborted. More...
void renderURLLoadComplete()
Must be called when an external render URL has loaded successfully. More...
void renderURLLoadError()
Must be called when an external render URL has experienced an error. More...
String toString()
Returns a string describing this Object. More...

Variables

Image  image
The image instance that will display the rendered image, or null if external render URL loading is used.

Constructor

com.​mi.​rs.​ImageRenderTarget( Image image, Object useHiddenBuffer)

Creates an ImageRenderTarget object that can act as a target for render commands.

Parameters

image
Optional image object that will display the rendered image. The exact type of this object will vary between browsers, but the object created by adding an <img> tag will work in all supported browsers.
useHiddenBuffer

Member Functions

void com.​mi.​rs.​ImageRenderTarget.prototype.addEventListener( String type, Function listener, Object context)

Adds a listener for the given event type. If the listener is already registered to listen to event type, it is not registered again.

The callback function will need to have the following signiature: function callback(event, context).

Parameters

type
The name of the event to listen to.
listener
The reference to the listener function.
context
The optional user-supplied context object. Useful for instance to hold a reference to the object that registered the callback.
void com.​mi.​rs.​ImageRenderTarget.prototype.removeEventListener( String type, Function listener)

Removes the provided event listener.

Parameters

type
The type of the event to stop listening for.
listener
The listener function to remove.
void com.​mi.​rs.​ImageRenderTarget.prototype.renderURLLoadAborted()

Must be called when an external render URL has been aborted. Event processing is halted until one of the methods renderURLLoadError, renderURLLoadAborted, or renderURLLoadComplete methods have been called.

void com.​mi.​rs.​ImageRenderTarget.prototype.renderURLLoadComplete()

Must be called when an external render URL has loaded successfully. Event processing is halted until one of the methods renderURLLoadError, renderURLLoadAborted, or renderURLLoadComplete methods have been called.

void com.​mi.​rs.​ImageRenderTarget.prototype.renderURLLoadError()

Must be called when an external render URL has experienced an error. Event processing is halted until one of the methods renderURLLoadError, renderURLLoadAborted, or renderURLLoadComplete methods have been called.

String com.​mi.​rs.​ImageRenderTarget.prototype.toString()

Returns a string describing this Object.

Returns

A String describing this Object.

Variables

Image com.​mi.​rs.​ImageRenderTarget.prototype.image

The image instance that will display the rendered image, or null if external render URL loading is used.