public class SinglePixelGrabber extends Object implements ImageConsumer
COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHT
Constructor and Description |
---|
SinglePixelGrabber(Image img,
int x,
int y)
Create a PixelGrabber object to grab the (x, y) pixel from
the specified image.
|
SinglePixelGrabber(ImageProducer ip,
int x,
int y)
Create a PixelGrabber object to grab the (x, y) pixel from the
image produced by the specified ImageProducer.
|
Modifier and Type | Method and Description |
---|---|
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(Image img) |
void |
reset(ImageProducer ip) |
void |
reset(int x,
int y) |
void |
setColorModel(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,
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,
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(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.
|
public SinglePixelGrabber(Image img, int x, int y)
img
- the image to retrieve pixels fromx
- 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 imagey
- the y coordinate of the upper left corner of the rectangle
of pixels to retrieve from the imagepublic SinglePixelGrabber(ImageProducer ip, int x, int y)
ip
- the ImageProducer to retrieve pixels fromx
- 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 imagey
- the y coordinate of the upper left corner of the rectangle
of pixels to retrieve from the imagepublic void abortGrabbing()
public int getStatus()
ImageObserver
public int grabPixel() throws InterruptedException
InterruptedException
- Another thread has interrupted this thread.public int grabPixel(long ms) throws InterruptedException
ms
:
ms
== 0, waits until all pixels are delivered
ms
> 0, waits until all pixels are delivered
as timeout expires.
ms
< 0, returns pixValue
if the pixel
is grabbed, -1
otherwise and does not wait.
ms
- the number of milliseconds to wait for the image pixels
to arrive before timing outpixValue
if the pixel was successfully grabbed
-1 on abort, error or timeoutInterruptedException
- Another thread has interrupted this thread.public void imageComplete(int status)
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.
imageComplete
in interface ImageConsumer
public void reset()
public void reset(Image img)
public void reset(ImageProducer ip)
public void reset(int x, int y)
public void setColorModel(ColorModel model)
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.
setColorModel
in interface ImageConsumer
public void setDimensions(int width, int height)
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.
setDimensions
in interface ImageConsumer
public void setHints(int hints)
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.
setHints
in interface ImageConsumer
public void setPixels(int srcX, int srcY, int srcW, int srcH, ColorModel model, byte[] pixels, int srcOff, int srcScan)
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.
setPixels
in interface ImageConsumer
public void setPixels(int srcX, int srcY, int srcW, int srcH, ColorModel model, int[] pixels, int srcOff, int srcScan)
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.
setPixels
in interface ImageConsumer
public void setProperties(Hashtable props)
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.
setProperties
in interface ImageConsumer
public void startGrabbing()
public int status()
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".ImageObserver
,
getStatus()