au.com.zip.cs
Class ImageObserverThread
java.lang.Object
java.lang.Thread
au.com.zip.cs.ImageObserverThread
- All Implemented Interfaces:
- ImageObserver, Runnable
public class ImageObserverThread
- extends Thread
- implements ImageObserver
A Runnable object that will run until the desired Image properties
have been seen.
TODO: maybe I want to use a Channel instead of polling.
- Author:
- Cameron Simpson <cs@zip.com.au> 30apr2003
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
ImageObserverThread
public ImageObserverThread(Image im,
int infoflags)
- Return a new
Thread
to monitor the supplied Image
until the cited ImageObserver flags have been seen.
Usual use is:
// wait for the image height to be available
Thread th = ImageObserverThread.waitFor(image,HEIGHT);
th.join();
Alternatively,
one may want to wait for a drawing operation to finish.
In this case you don't supply the Image until the drawing has been dispatched
because Graphics.drawImage(Image,int,int,ImageObserver) wants an ImageObserver
to watch the updates, and we will supply this ImageObserverThread:
Graphics g = destImage.getGraphics(); // what to draw on
ImageObserverThread th = ImageObserverThread.waitFor(null,ALLBITS);
if (!g.drawImage(srcImage,0,0,th))
{ th.setImage(destImage); // start()s the Thread as side-effect
th.join();
}
- Parameters:
im - the Image to monitorinfoflags - the bitwise OR of the desired flags
setImage
public final void setImage(Image im)
- Set the image to monitor and
Thread.start() the Thread running.
- Parameters:
im - the Image to monitor
run
public final void run()
- Specified by:
run in interface Runnable- Overrides:
run in class Thread
imageUpdate
public final boolean imageUpdate(Image im,
int infoflags,
int x,
int y,
int width,
int height)
- Specified by:
imageUpdate in interface ImageObserver