Class TabPreviewThread
- java.lang.Object
-
- java.lang.Thread
-
- org.pushingpixels.radiance.theming.internal.utils.TrackableThread
-
- org.pushingpixels.radiance.theming.extras.internal.tabbed.TabPreviewThread
-
- All Implemented Interfaces:
java.lang.Runnable
public class TabPreviewThread extends TrackableThread
Thread for running the tab preview requests.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TabPreviewThread.TabPreviewCallback
Interface for offering the tab preview image once it has been computed.static class
TabPreviewThread.TabPreviewInfo
Information for previewing a tabbed pane.
-
Field Summary
Fields Modifier and Type Field Description protected DeltaQueue
previewQueue
Queue of preview requests.private boolean
stopRequested
Indication whether a stop request has been issued onthis
thread.private static TabPreviewThread
tabPreviewThread
The preview thread.
-
Constructor Summary
Constructors Modifier Constructor Description private
TabPreviewThread()
Simple constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancelTabPreviewRequests(java.lang.Object initiator)
Cancels all tab preview requests that were initiated by the specified initiator.private java.util.List<DeltaQueue.Deltable>
dequeueTabPreviewRequest(int delay)
Removes the tab preview requests that have at most specified delay left.static TabPreviewThread
getInstance()
Returns the singleton instance of the tab preview thread.protected void
getSingleTabPreviewImage(javax.swing.JTabbedPane tabPane, TabPreviewPainter previewPainter, TabPreviewThread.TabPreviewInfo previewInfo, int tabIndex)
Computes and offers the preview thumbnail for a single tab.static boolean
instanceRunning()
Returns indication whether tab preview thread is running.void
queueTabPreviewRequest(TabPreviewThread.TabPreviewInfo previewInfo)
Queues the request to preview one or all tabs in the specified tabbed pane.protected void
requestStop()
Issues a stop request onthis
thread.void
run()
-
Methods inherited from class org.pushingpixels.radiance.theming.internal.utils.TrackableThread
requestStopAllThreads
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
stopRequested
private boolean stopRequested
Indication whether a stop request has been issued onthis
thread.
-
previewQueue
protected DeltaQueue previewQueue
Queue of preview requests. ContainsTabPreviewThread.TabPreviewInfo
s.
-
tabPreviewThread
private static TabPreviewThread tabPreviewThread
The preview thread.
-
-
Constructor Detail
-
TabPreviewThread
private TabPreviewThread()
Simple constructor. Defined private for singleton.- See Also:
getInstance()
-
-
Method Detail
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
getSingleTabPreviewImage
protected void getSingleTabPreviewImage(javax.swing.JTabbedPane tabPane, TabPreviewPainter previewPainter, TabPreviewThread.TabPreviewInfo previewInfo, int tabIndex)
Computes and offers the preview thumbnail for a single tab.- Parameters:
tabPane
- Tabbed pane.previewPainter
- Tab preview painter.previewInfo
- Preview info.tabIndex
- Index of the tab to preview.
-
queueTabPreviewRequest
public void queueTabPreviewRequest(TabPreviewThread.TabPreviewInfo previewInfo)
Queues the request to preview one or all tabs in the specified tabbed pane. Once the request is queued, the thread will pick it up from the queue (in at most 500 milliseconds in the current implementation) and start processing it. For each tab (if all tabs were requested to be previewed), the preview thumbnail will be offered to the relevant callback. This allows to maintain the interactivity of the application while generating the preview thumbnails for the tab overview dialog (seeTabOverviewDialog
).- Parameters:
previewInfo
- Tab preview info.
-
cancelTabPreviewRequests
public void cancelTabPreviewRequests(java.lang.Object initiator)
Cancels all tab preview requests that were initiated by the specified initiator.- Parameters:
initiator
- Initiator.
-
dequeueTabPreviewRequest
private java.util.List<DeltaQueue.Deltable> dequeueTabPreviewRequest(int delay)
Removes the tab preview requests that have at most specified delay left.- Parameters:
delay
- Delay.- Returns:
- The list of all tab preview requests that have at most specified delay left.
-
requestStop
protected void requestStop()
Description copied from class:TrackableThread
Issues a stop request onthis
thread.- Specified by:
requestStop
in classTrackableThread
-
getInstance
public static TabPreviewThread getInstance()
Returns the singleton instance of the tab preview thread.- Returns:
- The singleton instance of the tab preview thread.
-
instanceRunning
public static boolean instanceRunning()
Returns indication whether tab preview thread is running.- Returns:
true
if the tab preview thread is running,false
otherwise.
-
-