SK.gnome.morena
Class MorenaImage

java.lang.Object
  extended by SK.gnome.morena.MorenaImage
All Implemented Interfaces:
java.awt.image.ImageConsumer, java.awt.image.ImageProducer

public class MorenaImage
extends java.lang.Object
implements java.awt.image.ImageConsumer, java.awt.image.ImageProducer

Simple image memory cache implementing both ImageConsumer and ImageProducer interfaces.


Field Summary
 
Fields inherited from interface java.awt.image.ImageConsumer
COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHT
 
Constructor Summary
MorenaImage(java.awt.image.ImageProducer producer)
          Create an buffered image from given image producer.
 
Method Summary
 void addConsumer(java.awt.image.ImageConsumer consumer)
          This method is used to register an ImageConsumer with the ImageProducer for access to the image data during a later reconstruction of the Image.
 java.awt.image.ColorModel getColorModel()
          Return color model of cached image.
 int getHeight()
          Return height of cached image.
 int getPixelSize()
          Return pixel size (or depth) of cached image.
 int getStatus()
          Return status supplied with imageComplete() call.
 int getWidth()
          Return width of cached image.
 void imageComplete(int status)
          Save final status.
 boolean isConsumer(java.awt.image.ImageConsumer consumer)
          This method determines if a given ImageConsumer object is currently registered with this ImageProducer as one of its consumers.
 void removeConsumer(java.awt.image.ImageConsumer consumer)
          This method removes the given ImageConsumer object from the list of consumers currently registered to receive image data.
 void requestTopDownLeftRightResend(java.awt.image.ImageConsumer consumer)
          Not used.
 void setColorModel(java.awt.image.ColorModel colorModel)
          The ColorModel object used for the majority of the pixels reported using the setPixels method calls.
 void setDimensions(int width, int height)
          The dimensions of the source image are reported using the setDimensions method call.
 void setHints(int hints)
          The ImageProducer can deliver the pixels in any order, but the ImageConsumer may be able to scale or convert the pixels to the destination ColorModel more efficiently or with higher quality if it knows some information about how the pixels will be delivered up front.
 void setPixels(int x, int y, int w, int h, java.awt.image.ColorModel model, byte[] pixels, int off, int scansize)
          The pixels of the image are delivered using one or more calls to the setPixels method.
 void setPixels(int x, int y, int w, int h, java.awt.image.ColorModel model, int[] pixels, int off, int scansize)
          The pixels of the image are delivered using one or more calls to the setPixels method.
 void setProperties(java.util.Hashtable props)
          Not used.
 void startProduction(java.awt.image.ImageConsumer consumer)
          This method both 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MorenaImage

public MorenaImage(java.awt.image.ImageProducer producer)
Create an buffered image from given image producer.

Method Detail

getWidth

public int getWidth()
Return width of cached image.


getHeight

public int getHeight()
Return height of cached image.


getColorModel

public java.awt.image.ColorModel getColorModel()
Return color model of cached image.


getPixelSize

public int getPixelSize()
Return pixel size (or depth) of cached image.


getStatus

public int getStatus()
Return status supplied with imageComplete() call.


imageComplete

public void imageComplete(int status)
Save final status.

Specified by:
imageComplete in interface java.awt.image.ImageConsumer

setColorModel

public void setColorModel(java.awt.image.ColorModel colorModel)
The ColorModel object used for the majority of the pixels reported using the setPixels method calls. Note that each set of pixels delivered using setPixels contains its own ColorModel object, so no assumption should be made that this model will be the only one used in delivering pixel values. A notable case where multiple ColorModel objects may be seen is a filtered image when for each set of pixels that it filters, the filter determines whether the pixels can be sent on untouched, using the original ColorModel, or whether the pixels should be modified (filtered) and passed on using a ColorModel more convenient for the filtering process.

Specified by:
setColorModel in interface java.awt.image.ImageConsumer

setDimensions

public void setDimensions(int width,
                          int height)
The dimensions of the source image are reported using the setDimensions method call.

Specified by:
setDimensions in interface java.awt.image.ImageConsumer

setHints

public void setHints(int hints)
The ImageProducer can deliver the pixels in any order, but the ImageConsumer may be able to scale or convert the pixels to the destination ColorModel more efficiently or with higher quality if it knows some information about how the pixels will be delivered up front. The setHints method should be called before any calls to any of the setPixels methods with a bit mask of hints about the manner in which the pixels will be delivered. If the ImageProducer does not follow the guidelines for the indicated hint, the results are undefined.

Specified by:
setHints in interface java.awt.image.ImageConsumer

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      java.awt.image.ColorModel model,
                      byte[] pixels,
                      int off,
                      int scansize)
The pixels of the image are delivered using one or more calls to the setPixels method. Each call specifies the location and size of the rectangle of source pixels that are contained in the array of pixels. The specified ColorModel object should be used to convert the pixels into their corresponding color and alpha components. Pixel (m,n) is stored in the pixels array at index (n * scansize + m + off). The pixels delivered using this method are all stored as bytes.

Specified by:
setPixels in interface java.awt.image.ImageConsumer

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      java.awt.image.ColorModel model,
                      int[] pixels,
                      int off,
                      int scansize)
The pixels of the image are delivered using one or more calls to the setPixels method. Each call specifies the location and size of the rectangle of source pixels that are contained in the array of pixels. The specified ColorModel object should be used to convert the pixels into their corresponding color and alpha components. Pixel (m,n) is stored in the pixels array at index (n * scansize + m + off). The pixels delivered using this method are all stored as ints.

Specified by:
setPixels in interface java.awt.image.ImageConsumer

setProperties

public void setProperties(java.util.Hashtable props)
Not used.

Specified by:
setProperties in interface java.awt.image.ImageConsumer

addConsumer

public void addConsumer(java.awt.image.ImageConsumer consumer)
This method is used to register an ImageConsumer with the ImageProducer for access to the image data during a later reconstruction of the Image. The ImageProducer may, at its discretion, start delivering the image data to the consumer using the ImageConsumer interface immediately, or when the next available image reconstruction is triggered by a call to the startProduction method.

Specified by:
addConsumer in interface java.awt.image.ImageProducer
See Also:
startProduction(java.awt.image.ImageConsumer)

isConsumer

public boolean isConsumer(java.awt.image.ImageConsumer consumer)
This method determines if a given ImageConsumer object is currently registered with this ImageProducer as one of its consumers.

Specified by:
isConsumer in interface java.awt.image.ImageProducer

removeConsumer

public void removeConsumer(java.awt.image.ImageConsumer consumer)
This method removes the given ImageConsumer object from the list of consumers currently registered to receive image data. It is not considered an error to remove a consumer that is not currently registered. The ImageProducer should stop sending data to this consumer as soon as is feasible.

Specified by:
removeConsumer in interface java.awt.image.ImageProducer

startProduction

public void startProduction(java.awt.image.ImageConsumer consumer)
This method both 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. This method differs from the addConsumer method in that a reproduction of the image data should be triggered as soon as possible.

Specified by:
startProduction in interface java.awt.image.ImageProducer
See Also:
addConsumer(java.awt.image.ImageConsumer)

requestTopDownLeftRightResend

public void requestTopDownLeftRightResend(java.awt.image.ImageConsumer consumer)
Not used.

Specified by:
requestTopDownLeftRightResend in interface java.awt.image.ImageProducer