moebiusViewer
Class SinglePixelGrabber

java.lang.Object
  extended bymoebiusViewer.SinglePixelGrabber
All Implemented Interfaces:
java.awt.image.ImageConsumer

public class SinglePixelGrabber
extends java.lang.Object
implements java.awt.image.ImageConsumer

The PixelGrabber class implements an ImageConsumer which can be attached to an Image or ImageProducer object to retrieve a single pixel of that image.


Field Summary
 
Fields inherited from interface java.awt.image.ImageConsumer
COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHT
 
Constructor Summary
SinglePixelGrabber(java.awt.Image img, int x, int y)
          Create a PixelGrabber object to grab the (x, y) pixel from the specified image.
SinglePixelGrabber(java.awt.image.ImageProducer ip, int x, int y)
          Create a PixelGrabber object to grab the (x, y) pixel from the image produced by the specified ImageProducer.
 
Method Summary
 void abortGrabbing()
          Request the PixelGrabber to abort the image fetch.
 int getStatus()
          Return the status of the pixels.
 int grabPixel()
          Request the Image or ImageProducer to start delivering pixels and wait for the pixel of interest to be delivered.
 int grabPixel(long ms)
          Request the Image or ImageProducer to start delivering pixels and wait for the pixel of interest to be delivered or until the specified timeout has elapsed.
 void imageComplete(int status)
          The imageComplete method is part of the ImageConsumer API which this class must implement to retrieve the pixels.
 void reset()
           
 void reset(java.awt.Image img)
           
 void reset(java.awt.image.ImageProducer ip)
           
 void reset(int x, int y)
           
 void setColorModel(java.awt.image.ColorModel model)
          The setColorModel method is part of the ImageConsumer API which this class must implement to retrieve the pixels.
 void setDimensions(int width, int height)
          The setDimensions method is part of the ImageConsumer API which this class must implement to retrieve the pixels.
 void setHints(int hints)
          The setHints method is part of the ImageConsumer API which this class must implement to retrieve the pixels.
 void setPixels(int srcX, int srcY, int srcW, int srcH, java.awt.image.ColorModel model, byte[] pixels, int srcOff, int srcScan)
          The setPixels method is part of the ImageConsumer API which this class must implement to retrieve the pixels.
 void setPixels(int srcX, int srcY, int srcW, int srcH, java.awt.image.ColorModel model, int[] pixels, int srcOff, int srcScan)
          The setPixels method is part of the ImageConsumer API which this class must implement to retrieve the pixels.
 void setProperties(java.util.Hashtable props)
          The setProperties method is part of the ImageConsumer API which this class must implement to retrieve the pixels.
 void startGrabbing()
          Request the PixelGrabber to start fetching the pixels.
 int status()
          Returns the status of the pixels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SinglePixelGrabber

public SinglePixelGrabber(java.awt.Image img,
                          int x,
                          int y)
Create a PixelGrabber object to grab the (x, y) pixel from the specified image.

Parameters:
img - the image to retrieve pixels from
x - the x coordinate of the upper left corner of the rectangle of pixels to retrieve from the image, relative to the default (unscaled) size of the image
y - the y coordinate of the upper left corner of the rectangle of pixels to retrieve from the image

SinglePixelGrabber

public SinglePixelGrabber(java.awt.image.ImageProducer ip,
                          int x,
                          int y)
Create a PixelGrabber object to grab the (x, y) pixel from the image produced by the specified ImageProducer.

Parameters:
ip - the ImageProducer to retrieve pixels from
x - the x coordinate of the upper left corner of the rectangle of pixels to retrieve from the image, relative to the default (unscaled) size of the image
y - the y coordinate of the upper left corner of the rectangle of pixels to retrieve from the image
Method Detail

reset

public void reset(int x,
                  int y)

reset

public void reset(java.awt.Image img)

reset

public void reset(java.awt.image.ImageProducer ip)

reset

public void reset()

startGrabbing

public void startGrabbing()
Request the PixelGrabber to start fetching the pixels.


abortGrabbing

public void abortGrabbing()
Request the PixelGrabber to abort the image fetch.


grabPixel

public int grabPixel()
              throws java.lang.InterruptedException
Request the Image or ImageProducer to start delivering pixels and wait for the pixel of interest to be delivered.

Returns:
value if the pixels were successfully grabbed, -1 on abort, error or timeout
Throws:
java.lang.InterruptedException - Another thread has interrupted this thread.

grabPixel

public int grabPixel(long ms)
              throws java.lang.InterruptedException
Request the Image or ImageProducer to start delivering pixels and wait for the pixel of interest to be delivered or until the specified timeout has elapsed. This method behaves in the following ways, depending on the value of ms:

Parameters:
ms - the number of milliseconds to wait for the image pixels to arrive before timing out
Returns:
pixValue if the pixel was successfully grabbed -1 on abort, error or timeout
Throws:
java.lang.InterruptedException - Another thread has interrupted this thread.

getStatus

public int getStatus()
Return the status of the pixels. The ImageObserver flags representing the available pixel information are returned.

Returns:
the bitwise OR of all relevant ImageObserver flags
See Also:
ImageObserver

setDimensions

public void setDimensions(int width,
                          int height)
The setDimensions method is part of the ImageConsumer API which this class must implement to retrieve the pixels.

Note: This method is intended to be called by the ImageProducer of the Image whose pixels are being grabbed. Developers using this class to retrieve pixels from an image should avoid calling this method directly since that operation could result in problems with retrieving the requested pixels.

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

setHints

public void setHints(int hints)
The setHints method is part of the ImageConsumer API which this class must implement to retrieve the pixels.

Note: This method is intended to be called by the ImageProducer of the Image whose pixels are being grabbed. Developers using this class to retrieve pixels from an image should avoid calling this method directly since that operation could result in problems with retrieving the requested pixels.

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

setProperties

public void setProperties(java.util.Hashtable props)
The setProperties method is part of the ImageConsumer API which this class must implement to retrieve the pixels.

Note: This method is intended to be called by the ImageProducer of the Image whose pixels are being grabbed. Developers using this class to retrieve pixels from an image should avoid calling this method directly since that operation could result in problems with retrieving the requested pixels.

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

setColorModel

public void setColorModel(java.awt.image.ColorModel model)
The setColorModel method is part of the ImageConsumer API which this class must implement to retrieve the pixels.

Note: This method is intended to be called by the ImageProducer of the Image whose pixels are being grabbed. Developers using this class to retrieve pixels from an image should avoid calling this method directly since that operation could result in problems with retrieving the requested pixels.

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

setPixels

public void setPixels(int srcX,
                      int srcY,
                      int srcW,
                      int srcH,
                      java.awt.image.ColorModel model,
                      byte[] pixels,
                      int srcOff,
                      int srcScan)
The setPixels method is part of the ImageConsumer API which this class must implement to retrieve the pixels.

Note: This method is intended to be called by the ImageProducer of the Image whose pixels are being grabbed. Developers using this class to retrieve pixels from an image should avoid calling this method directly since that operation could result in problems with retrieving the requested pixels.

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

setPixels

public void setPixels(int srcX,
                      int srcY,
                      int srcW,
                      int srcH,
                      java.awt.image.ColorModel model,
                      int[] pixels,
                      int srcOff,
                      int srcScan)
The setPixels method is part of the ImageConsumer API which this class must implement to retrieve the pixels.

Note: This method is intended to be called by the ImageProducer of the Image whose pixels are being grabbed. Developers using this class to retrieve pixels from an image should avoid calling this method directly since that operation could result in problems with retrieving the requested pixels.

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

imageComplete

public void imageComplete(int status)
The imageComplete method is part of the ImageConsumer API which this class must implement to retrieve the pixels.

Note: This method is intended to be called by the ImageProducer of the Image whose pixels are being grabbed. Developers using this class to retrieve pixels from an image should avoid calling this method directly since that operation could result in problems with retrieving the requested pixels.

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

status

public int status()
Returns the status of the pixels. The ImageObserver flags representing the available pixel information are returned. This method and getStatus have the same implementation, but getStatus is the preferred method because it conforms to the convention of naming information-retrieval methods with the form "getXXX".

Returns:
the bitwise OR of all relevant ImageObserver flags
See Also:
ImageObserver, getStatus()