jj2000.disp
Class BlkImgDataSrcImageProducer

java.lang.Object
  |
  +--jj2000.disp.BlkImgDataSrcImageProducer
All Implemented Interfaces:
java.awt.image.ImageProducer

public class BlkImgDataSrcImageProducer
extends java.lang.Object
implements java.awt.image.ImageProducer

This class provides an ImageProducer for the BlkImgDataSrc interface. It will request data from the BlkImgDataSrc source and deliver it to the registered image consumers. The data is requested line by line, starting at the top of each tile. The tiles are requested in raster-scan order.

The image data is not rescaled to fit the available dynamic range (not even the alpha values for RGBA data).

BlkImgDataSrc sources with 1, 3 and 4 components are supported. If 1, it is assumed to be gray-level data. If 3 it is assumed to be RGB data, in that order. If 4 it is assumed to be RGBA data (RGB plus alpha plane), in that order. All components must have the same size.

See Also:
ImageProducer, BlkImgDataSrc

Field Summary
private static java.awt.image.ColorModel cm
          The default color model (0xAARRGGBB) used in Java
private  java.util.Vector consumers
          The list of image consumers for this image producer
private static int GRAY
          The gray-level image type (256 levels).
private static int RGB
          The color image type (24 bits RGB).
private static int RGBA
          The color image type (32 bits RGBA).
private  BlkImgDataSrc src
          The source of image data
private  int type
          The type of image: GRAY, RGB or RGBA
 
Constructor Summary
BlkImgDataSrcImageProducer(BlkImgDataSrc src)
          Creates an image producer which uses 'src' as the source of image data.
 
Method Summary
 void addConsumer(java.awt.image.ImageConsumer ic)
          Registers an image consumer with this image producer.
static java.awt.Image createImage(BlkImgDataSrc src)
          Returns an Image object given an BlkImgDataSrc source.
static java.awt.Image createImage(BlkImgDataSrc src, java.awt.Component c)
          Returns an Image object given an BlkImgDataSrc source.
 boolean isConsumer(java.awt.image.ImageConsumer ic)
          This method determines if the given image consumer, 'ic', is registered with this image producer.
 void removeConsumer(java.awt.image.ImageConsumer ic)
          Removes the given image consumer 'ic' from the list of consumers registered with this producer.
 void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
          Starts the delivery of pixel data in the top-down letf-right order to the image consumer 'ic'.
 void startProduction(java.awt.image.ImageConsumer ic)
          Registers the given ImageConsumer object as a consumer and starts an immediate reconstruction of the image data which will then be delivered to this consumer and any other consumer which may have already been registered with the producer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

consumers

private volatile java.util.Vector consumers
The list of image consumers for this image producer


src

private BlkImgDataSrc src
The source of image data


type

private int type
The type of image: GRAY, RGB or RGBA


GRAY

private static final int GRAY
The gray-level image type (256 levels). For this type the source of image data must have only 1 component.

See Also:
Constant Field Values

RGB

private static final int RGB
The color image type (24 bits RGB). No alpha plane. For this type the source of image data must have 3 components, which are considered to be R, G and B, in that order

See Also:
Constant Field Values

RGBA

private static final int RGBA
The color image type (32 bits RGBA). For this type the source of image data must have 4 components, which are considered to be R, G, B and A, in that order.

See Also:
Constant Field Values

cm

private static final java.awt.image.ColorModel cm
The default color model (0xAARRGGBB) used in Java

Constructor Detail

BlkImgDataSrcImageProducer

public BlkImgDataSrcImageProducer(BlkImgDataSrc src)
Creates an image producer which uses 'src' as the source of image data. If 'once' is true then the image is produced only once.

Parameters:
src - The source of image data.
Method Detail

createImage

public static java.awt.Image createImage(BlkImgDataSrc src)
Returns an Image object given an BlkImgDataSrc source. It will use a new J2KImageProducer object as the underlying image producer.

This method uses the JVM default Toolkit, which might not be what it is desired.

Parameters:
src - The source of image data.
Returns:
An image which has a J2KImageProducer object as the underlying image producer.

createImage

public static java.awt.Image createImage(BlkImgDataSrc src,
                                         java.awt.Component c)
Returns an Image object given an BlkImgDataSrc source. It will use a new J2KImageProducer object as the underlying image producer.

This method uses the component's toolkit. The toolkit of a component may change if it is moved from one frame to another one, since it is the frame that controls which toolkit is used.

Parameters:
src - The source of image data.
c - The component to use to generate the 'Image' object from the 'ImageProducer'.
Returns:
An image which has a J2KImageProducer object as the underlying image producer.

addConsumer

public final void addConsumer(java.awt.image.ImageConsumer ic)
Registers an image consumer with this image producer. The delivery of image data does not start immediately. It will only start after the next call to the startProduction() method.

Specified by:
addConsumer in interface java.awt.image.ImageProducer
Parameters:
ic - The image consumer to which image data has to be delivered.
See Also:
startProduction(java.awt.image.ImageConsumer)

isConsumer

public boolean isConsumer(java.awt.image.ImageConsumer ic)
This method determines if the given image consumer, 'ic', is registered with this image producer.

Specified by:
isConsumer in interface java.awt.image.ImageProducer
Parameters:
ic - The image consumer to test.
Returns:
True if 'ic' is registered with this image producer, false otherwise.

removeConsumer

public void removeConsumer(java.awt.image.ImageConsumer ic)
Removes the given image consumer 'ic' from the list of consumers registered with this producer. This image producer will stop sending pixel data to 'ic' as soon as it is feasible. The method call is ignored if 'ic' has not been registered with this image producer.

Specified by:
removeConsumer in interface java.awt.image.ImageProducer
Parameters:
ic - The image consumer to be removed

startProduction

public void startProduction(java.awt.image.ImageConsumer ic)
Registers the given ImageConsumer object as a consumer and starts an immediate reconstruction of the image data which will then be delivered to this consumer and any other consumer which may have already been registered with the producer.

Delivery is performed in "parallel" to all the registered image consumers. By "parallel" it is meant that each line of the image is delivered to all consumers before delivering the next line.

If the data returned by the BlkImgDataSrc source happens to be progressive (see BlkImgDataSrc and DataBlk) then the abort condition is sent to the image consumers and no further data is delivered.

Once all the data is sent to a consumer this one is automatically removed from the list of registered ones, unless an abort happens.

To start the BlkImgDataSrc is set to tile (0,0), and the tiles are produced in raster sacn order. Once the last tile is produced, setTile(0,0) is called again, which signals that we are done with the current tile, which might free up resources.

Specified by:
startProduction in interface java.awt.image.ImageProducer
Parameters:
ic - The image consumer to register

requestTopDownLeftRightResend

public void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
Starts the delivery of pixel data in the top-down letf-right order to the image consumer 'ic'. The TOPDOWNLEFTRIGHT hint is set in the image consumer on delivery.

Currently this call is ignored (which is perfectly legal according to the ImageProducer interface specification).

Specified by:
requestTopDownLeftRightResend in interface java.awt.image.ImageProducer
Parameters:
ic - The image consumer to which the data is sent in top-down, left-right order.