org.jrabbit.base.data.thread
Class ImageLoadingThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.jrabbit.base.data.thread.WatchableThread
          extended by org.jrabbit.base.data.thread.WatchableGLThread
              extended by org.jrabbit.base.data.thread.ImageLoadingThread
All Implemented Interfaces:
java.lang.Runnable

public final class ImageLoadingThread
extends WatchableGLThread

A class that provides an easy way to load Images in a separate Thread. This is bound by the same problems as with a WatchableGLThread. It's quite easy to make one's own loading Thread, and in fact, this is a recommended way of loading things in the background - you can more closely tie the functionality with your needs. However, this class illustrates a simple way to load images while keeping track of the total progress, and if you simply want a fast and easy method to create some Images from file references, then this is for you.

Author:
Chris Molini

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  java.lang.String[] filepaths
          The supplied list of filepaths that are used to load images.
private  Image[] images
          The list of constructed Images.
 
Fields inherited from class org.jrabbit.base.data.thread.WatchableGLThread
CONTEXT_SHARING_FAILURE, CONTEXT_SHARING_SUCCESS, CONTEXT_SHARING_UNDECIDED, sharedDrawable
 
Fields inherited from class org.jrabbit.base.data.thread.WatchableThread
progress, total
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ImageLoadingThread(java.lang.String[] filepaths)
          Instantiates a Thread that will load images from the list of filepaths.
 
Method Summary
protected  void act()
          Loads the images, and increments the progress counter.
 Image[] images()
          Accesses a reference to the array of images in the loading Thread.
 
Methods inherited from class org.jrabbit.base.data.thread.WatchableGLThread
contextSharingFailed, contextSharingResult, contextSharingSuccess, releaseContext, run, shareContext
 
Methods inherited from class org.jrabbit.base.data.thread.WatchableThread
complete, percentComplete
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, 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
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

filepaths

private java.lang.String[] filepaths
The supplied list of filepaths that are used to load images.


images

private Image[] images
The list of constructed Images.

Constructor Detail

ImageLoadingThread

public ImageLoadingThread(java.lang.String[] filepaths)
Instantiates a Thread that will load images from the list of filepaths. NOTE: Each of these Images will have its appropriate filepath as a reference.

Parameters:
filepaths - The locations in the file system of the images to load.
Method Detail

act

protected void act()
Loads the images, and increments the progress counter.

Specified by:
act in class WatchableThread

images

public Image[] images()
Accesses a reference to the array of images in the loading Thread. This shouldn't be used until loading is complete.

Returns:
The list of created Images.