lhmc.gui.thumbnail
Class ThumbnailsCreator

java.lang.Object
  extended by java.lang.Thread
      extended by lhmc.gui.thumbnail.ThumbnailsCreator
All Implemented Interfaces:
java.lang.Runnable

public class ThumbnailsCreator
extends java.lang.Thread

helper class to create image thumbnails in a background worker thread.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ThumbnailsCreator(ThumbnailsManager _manager)
          create a new background worker thread to create thumbnail images for the given thumbnails manager.
 
Method Summary
 void addThumbnailOrder(java.lang.String imageFilename, java.awt.image.BufferedImage[] thumbnailsArray, int thumbnailsIndex, javax.swing.JComponent target)
          add a new image to the worker's list of orders.
 void run()
          endless loop to process the orders posted by the clients.
 void setFinished(boolean b)
          tell the worker thread to finish at the next opportune moment, but wait until an ongoing thumbnail has been created.
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThumbnailsCreator

public ThumbnailsCreator(ThumbnailsManager _manager)
create a new background worker thread to create thumbnail images for the given thumbnails manager. Don't forget to call start() on the newly create ThumbnailsCreator to actually start the thread. You can later call setFinished(true) to stop the thread at the next opportune moment.

Method Detail

addThumbnailOrder

public void addThumbnailOrder(java.lang.String imageFilename,
                              java.awt.image.BufferedImage[] thumbnailsArray,
                              int thumbnailsIndex,
                              javax.swing.JComponent target)
add a new image to the worker's list of orders. The given image file will be converted to a image thumbnail, and then be stored into thumbnailsArray[thumbnailsIndex]. Finally, a repaint is requested for component target (if non-null).

A new order will be processed before existing orders, so that the currently visible thumbnails will be created first, when the user rapidly places multiple orders.


setFinished

public void setFinished(boolean b)
tell the worker thread to finish at the next opportune moment, but wait until an ongoing thumbnail has been created.


run

public void run()
endless loop to process the orders posted by the clients. Once started, the thread will awake every 100 milliseconds (DEFAULT_SLEEP_MILLS) and check whether new orders have been placed. The loop exists after setFinished(true) has been called.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread