net.sourceforge.jsh3modtool.gui.imagetable.cache
Class ThumbnailLoader

java.lang.Object
  extended by java.lang.Thread
      extended by net.sourceforge.jsh3modtool.gui.imagetable.cache.ThumbnailLoader
All Implemented Interfaces:
java.lang.Runnable

public class ThumbnailLoader
extends java.lang.Thread

Thread to load thumbnails. To lessen the load of the thread that reads/creates ImageBoxes Singleton behaviour

Author:
erma

Nested Class Summary
protected  class ThumbnailLoader.ThumbnailQueueItem
          A queue item that contains a viewer and a image properties object.
 
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
protected ThumbnailLoader()
          Creates a thumbnail loader.
 
Method Summary
 void add(ImageModel imageProps, ThumbnailViewer viewer)
          Add an ImageProperties and a ThumbnailViewer to the queue.
 void addFirst(ImageModel imageProps, ThumbnailViewer viewer)
          Add an ImageProperties and a ThumbnailViewer to the the begining of the queue.
 void clear()
          Removes all ThumbnailViewers from the queue
 boolean contains(ImageModel imageProps)
          Returns true if the queue contains the specified object.
 void increasePriority(ImageModel imageProps)
          Increase the priority of the specified item.
 void increasePriority(ThumbnailViewer viewer)
          Increase the priority of the specified item
static ThumbnailLoader instance()
          Returns the singleton instance of this class.
 int queueSize()
          Returns the size of the queue.
 void remove(ImageModel imageProps)
          Removes the specified object from the queue.
 void remove(ThumbnailViewer viewer)
          Removes the specified object from the queue.
 void removeFirst()
          Removes the first queue item.
 void removeLast()
          Removes the last queue item.
 void run()
          Thread run method, waits for items on the queue, removes it and reads the thumbnail for it and returns it to the listener
 void startLoading()
          Starts the Thumbnail loading thread (if it hasnt been started
 void stopLoading()
          Stops the Thumbnail loading thread, does not wait until the thread is dead
 
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

ThumbnailLoader

protected ThumbnailLoader()
Creates a thumbnail loader.

Method Detail

instance

public static ThumbnailLoader instance()
Returns the singleton instance of this class.

Returns:
the singleton instance.

run

public void run()
Thread run method, waits for items on the queue, removes it and reads the thumbnail for it and returns it to the listener

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

startLoading

public void startLoading()
Starts the Thumbnail loading thread (if it hasnt been started


stopLoading

public void stopLoading()
Stops the Thumbnail loading thread, does not wait until the thread is dead


clear

public void clear()
Removes all ThumbnailViewers from the queue


add

public void add(ImageModel imageProps,
                ThumbnailViewer viewer)
Add an ImageProperties and a ThumbnailViewer to the queue.

Parameters:
imageProps - the image props.
viewer - the viewer.

addFirst

public void addFirst(ImageModel imageProps,
                     ThumbnailViewer viewer)
Add an ImageProperties and a ThumbnailViewer to the the begining of the queue.

Parameters:
imageProps - the image props.
viewer - the viewer.

removeFirst

public void removeFirst()
Removes the first queue item.


removeLast

public void removeLast()
Removes the last queue item.


increasePriority

public void increasePriority(ThumbnailViewer viewer)
Increase the priority of the specified item

Parameters:
viewer - the thumbnail viewer object to raise the priority for.

increasePriority

public void increasePriority(ImageModel imageProps)
Increase the priority of the specified item.

Parameters:
imageProps - the image properties object to raise the priority for.

contains

public boolean contains(ImageModel imageProps)
Returns true if the queue contains the specified object.

Parameters:
imageProps - the image properties to find.
Returns:
true if the queue contains the specified object.

queueSize

public int queueSize()
Returns the size of the queue. Note there may be one in the image handling method.

Returns:
the size of the queue.

remove

public void remove(ThumbnailViewer viewer)
Removes the specified object from the queue.

Parameters:
viewer - the thumbnail viewer.

remove

public void remove(ImageModel imageProps)
Removes the specified object from the queue.

Parameters:
imageProps - the image properties to remove.


Copyright © 2005 sourceforge.net. All Rights Reserved.