Class AnimBuffProducer

  • All Implemented Interfaces:
    java.awt.image.ImageProducer

    public class AnimBuffProducer
    extends java.lang.Object
    implements java.awt.image.ImageProducer
    This ImageProducer represents an animated image. At one point in time java.awt.image.MemoryImageSource did not perform this duty to my satisfaction and so AnimBuffProducer was created.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int[] m_pix
      The pixel buffer which is passed into constructor is made accessible to subclasses which extend AnimBuffProducer.
    • Constructor Summary

      Constructors 
      Constructor Description
      AnimBuffProducer​(int[] pix, int width, int height, java.awt.image.ColorModel clrModel)
      Orientation: imagePixel(x,y) = pix[y*width + x].
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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
        The pixel buffer which is passed into constructor is made accessible to subclasses which extend AnimBuffProducer.
    • 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 which rectangular region is specified. However, pixel data is only pushed to ImageConsumer objects in this call, regardless of whether those consumers are new or preexisting.

        If areaChanged is 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