FileDocCategorySizeDatePackage
RenderableImageProducer.javaAPI DocAndroid 1.5 API4080Wed May 06 22:41:54 BST 2009java.awt.image.renderable

RenderableImageProducer

public class RenderableImageProducer extends Object implements ImageProducer, Runnable
The Class RenderableImageProducer provides the implementation for the image rendering.
since
Android 1.0

Fields Summary
RenderableImage
rbl
The rbl.
RenderContext
rc
The rc.
Vector
consumers
The consumers.
Constructors Summary
public RenderableImageProducer(RenderableImage rdblImage, RenderContext rc)
Instantiates a new renderable image producer.

param
rdblImage the rdbl image.
param
rc the rc.


                                               
         
        this.rbl = rdblImage;
        this.rc = rc;
    
Methods Summary
public synchronized voidaddConsumer(java.awt.image.ImageConsumer ic)

        if (ic != null && !consumers.contains(ic)) {
            consumers.addElement(ic);
        }
    
public synchronized booleanisConsumer(java.awt.image.ImageConsumer ic)

        return consumers.contains(ic);
    
public synchronized voidremoveConsumer(java.awt.image.ImageConsumer ic)

        if (ic != null) {
            consumers.removeElement(ic);
        }
    
public voidrequestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)

    
public voidrun()
Creates the rendered image in a new thread.

        if (rbl == null) {
            return;
        }

        RenderedImage rd;
        if (rc != null) {
            rd = rbl.createRendering(rc);
        } else {
            rd = rbl.createDefaultRendering();
        }

        ColorModel cm = rd.getColorModel();
        if (cm == null) {
            cm = ColorModel.getRGBdefault();
        }

        Raster r = rd.getData();
        int w = r.getWidth();
        int h = r.getHeight();

        for (ImageConsumer c : consumers) {
            c.setDimensions(w, h);
            c.setHints(ImageConsumer.TOPDOWNLEFTRIGHT | ImageConsumer.COMPLETESCANLINES
                    | ImageConsumer.SINGLEFRAME | ImageConsumer.SINGLEPASS);
        }

        int scanLine[] = new int[w];
        int pixel[] = null;

        for (int y = 0; y < h; y++) {
            for (int x = 0; x < w; x++) {
                pixel = r.getPixel(x, y, pixel);
                scanLine[x] = cm.getDataElement(pixel, 0);
            }

            for (ImageConsumer c : consumers) {
                c.setPixels(0, y, w, 1, cm, scanLine, 0, w);
            }
        }

        for (ImageConsumer c : consumers) {
            c.imageComplete(ImageConsumer.STATICIMAGEDONE);
        }
    
public synchronized voidsetRenderContext(java.awt.image.renderable.RenderContext rc)
Sets the render context.

param
rc the new render context.

        this.rc = rc;
    
public synchronized voidstartProduction(java.awt.image.ImageConsumer ic)

        addConsumer(ic);
        Thread t = new Thread(this, "RenderableImageProducer thread"); //$NON-NLS-1$
        t.start();