com.nerius.img
Class AnimBuffProducer

java.lang.Object
  extended by com.nerius.img.AnimBuffProducer
All Implemented Interfaces:
java.awt.image.ImageProducer

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

java.awt.image.MemoryImageSource wins the "worst class ever written" award; this class and BuffProducer intend to outrobustify MemoryImageSource.

See Also:
BuffProducer

Field Summary
protected  int[] m_pix
           
 
Constructor Summary
AnimBuffProducer(int[] pix, int width, int height, java.awt.image.ColorModel clrModel)
          Orientation: imagePixel(x, y) = pix[y * width + x].
 
Method Summary
 void addConsumer(java.awt.image.ImageConsumer ic)
           
 java.awt.image.ColorModel getColorModel()
           
 int getHeight()
           
 int getWidth()
           
 boolean isConsumer(java.awt.image.ImageConsumer ic)
           
 void removeConsumer(java.awt.image.ImageConsumer ic)
           
 void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
           
 void startProduction(java.awt.image.ImageConsumer ic)
           
 void triggerFrame(java.awt.Rectangle areaChanged)
          The current state of the image will be pushed through to all registered ImageConsumer objects as the next frame in a multi-frame image when this method is called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_pix

protected final int[] m_pix
Constructor Detail

AnimBuffProducer

public AnimBuffProducer(int[] pix,
                        int width,
                        int height,
                        java.awt.image.ColorModel clrModel)
Orientation: imagePixel(x, y) = pix[y * width + x].

Method Detail

triggerFrame

public void triggerFrame(java.awt.Rectangle areaChanged)
                  throws java.lang.IllegalMonitorStateException
The current state of the image will be pushed through to all registered ImageConsumer objects as the next frame in a multi-frame image when this method is called. The pixel information is delivered to all consumers in the same thread that calls this method. Only the specified rectangle of pixels will be delivered to listening consumers, leaving the area outside of the specified rectangle unchanged from the last frame. The first time a consumer receives pixel information, it gets the entire pixel buffer, no matter what rectangular region is specified.

If areaChanged == null, the entire pixel buffer will be delivered; it is equivalent to the call

 triggerFrame(new Rectangle(0, 0, getWidth(), getHeight()));
 

This method should only be called by a single thread.

Throws:
java.lang.IllegalMonitorStateException - if this method is called while another thread is still executing this method.

getWidth

public int getWidth()

getHeight

public int getHeight()

getColorModel

public java.awt.image.ColorModel getColorModel()

addConsumer

public void addConsumer(java.awt.image.ImageConsumer ic)
Specified by:
addConsumer in interface java.awt.image.ImageProducer

isConsumer

public boolean isConsumer(java.awt.image.ImageConsumer ic)
Specified by:
isConsumer in interface java.awt.image.ImageProducer

removeConsumer

public void removeConsumer(java.awt.image.ImageConsumer ic)
Specified by:
removeConsumer in interface java.awt.image.ImageProducer

startProduction

public void startProduction(java.awt.image.ImageConsumer ic)
Specified by:
startProduction in interface java.awt.image.ImageProducer

requestTopDownLeftRightResend

public void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
Specified by:
requestTopDownLeftRightResend in interface java.awt.image.ImageProducer