com.alee.extended.list
Class ThumbnailGenerator

java.lang.Object
  extended by com.alee.extended.list.ThumbnailGenerator
All Implemented Interfaces:
java.lang.Runnable

public class ThumbnailGenerator
extends java.lang.Object
implements java.lang.Runnable

Author:
Mikle Garin

Field Summary
protected static java.util.concurrent.ExecutorService executorService
          Executor service for thumbnails generation.
protected static java.util.Map<FileElement,ThumbnailGenerator> generators
          Map containing references to running thumbnail generators.
protected static java.lang.Object generatorsLock
          Generator references map operations lock.
 
Constructor Summary
ThumbnailGenerator(WebFileList list, FileElement element, boolean disabled)
          Constructs thumbnail generator for the specified file element.
 
Method Summary
 void abort()
          Abort thumbnail generation.
static void abortThumbnailLoad(FileElement element)
          Forces thumbnail generation to be aborted for the specified element.
 FileElement getElement()
          Returns file element for which thumbnail is being generated.
 WebFileList getList()
          Returns file list this generator is working for.
 boolean isAborted()
          Returns whether this generator was aborted or not.
 boolean isDisabled()
          Returns whether disabled thumbnail will also be generated or not.
static void queueThumbnailLoad(WebFileList list, FileElement element, boolean disabled)
          Adds specified element into thumbnails generation queue.
 void run()
          Starts thumbnail generation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

executorService

protected static final java.util.concurrent.ExecutorService executorService
Executor service for thumbnails generation. It was made static to be shared by different file lists and avoid overload.


generators

protected static final java.util.Map<FileElement,ThumbnailGenerator> generators
Map containing references to running thumbnail generators. It is used to abort specific generation when needed.


generatorsLock

protected static final java.lang.Object generatorsLock
Generator references map operations lock.

Constructor Detail

ThumbnailGenerator

public ThumbnailGenerator(WebFileList list,
                          FileElement element,
                          boolean disabled)
Constructs thumbnail generator for the specified file element.

Parameters:
list - file list this generator is working for
element - element to queue thumbnail generation for
disabled - whether should generate disabled state thumbnail or not
Method Detail

getList

public WebFileList getList()
Returns file list this generator is working for.

Returns:
file list this generator is working for

getElement

public FileElement getElement()
Returns file element for which thumbnail is being generated.

Returns:
file element for which thumbnail is being generated

isDisabled

public boolean isDisabled()
Returns whether disabled thumbnail will also be generated or not.

Returns:
true if disabled thumbnail will also be generated, false otherwise

isAborted

public boolean isAborted()
Returns whether this generator was aborted or not.

Returns:
true if this generator was aborted, false otherwise

abort

public void abort()
Abort thumbnail generation. Note that actual abort might occur after long-running operations, but it will surely cancel thumbnail update.


run

public void run()
Starts thumbnail generation.

Specified by:
run in interface java.lang.Runnable

queueThumbnailLoad

public static void queueThumbnailLoad(WebFileList list,
                                      FileElement element,
                                      boolean disabled)
Adds specified element into thumbnails generation queue.

Parameters:
list - file list this generator is working for
element - element to queue thumbnail generation for
disabled - whether should generate disabled state thumbnail or not

abortThumbnailLoad

public static void abortThumbnailLoad(FileElement element)
Forces thumbnail generation to be aborted for the specified element.

Parameters:
element - element to abort thumbnail generation for