Class LoadImageTask
- All Implemented Interfaces:
Runnable, Future<BufferedImage>, RunnableFuture<BufferedImage>
A Task that loads an image from a URL. Loading and decoding
progress is reported via the Task
progress property
and messages are generated when the Task begins and when it
finishes. If errors occur then warnings are logged and the
Task's value is null.
Applications would typically use LoadImageTask by creating
a private subclass that overrode the done method.
See SingleFrameExample5.java for an example.
Resources for this class are in the
resources/LoadImageTask.properties ResourceBundle.
-
Nested Class Summary
Nested classes/interfaces inherited from class Task
Task.BlockingScope, Task.InputBlockerNested classes/interfaces inherited from class SwingWorker
SwingWorker.StateValueNested classes/interfaces inherited from interface Future
Future.State -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCalled when this Task has been cancelled bySwingWorker.cancel(boolean).protected BufferedImageprotected voidCalled when an execution of this Task fails and anExecutionExecptionis thrown byget.protected voidfinished()Called unconditionally (in afinallyclause) after one of the completion methods,succeeded,failed,cancelled, orinterrupted, runs.protected final URLprotected voidCalled if the Task's Thread is interrupted but not explicitly cancelled.protected voidsucceeded(BufferedImage image) Called when this Task has successfully completed, i.e.Methods inherited from class Task
addTaskListener, done, getApplication, getContext, getDescription, getExecutionDuration, getInputBlocker, getMessage, getMessageDuration, getResourceMap, getTaskListeners, getTaskService, getTitle, getUserCanCancel, isPending, isProgressPropertyValid, isStarted, message, process, removeTaskListener, resourceName, setDescription, setInputBlocker, setMessage, setProgress, setProgress, setProgress, setTitle, setUserCanCancelMethods inherited from class SwingWorker
addPropertyChangeListener, cancel, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, publish, removePropertyChangeListener, run, setProgressMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Future
exceptionNow, resultNow, state
-
Constructor Details
-
LoadImageTask
-
-
Method Details
-
getImageURL
-
doInBackground
- Specified by:
doInBackgroundin classSwingWorker<BufferedImage, Void>
-
cancelled
protected void cancelled()Description copied from class:TaskCalled when this Task has been cancelled bySwingWorker.cancel(boolean).This method runs on the EDT. It does nothing by default.
- Overrides:
cancelledin classTask<BufferedImage, Void>- See Also:
-
interrupted
Description copied from class:TaskCalled if the Task's Thread is interrupted but not explicitly cancelled.This method runs on the EDT. It does nothing by default.
- Overrides:
interruptedin classTask<BufferedImage, Void>- Parameters:
e- theInterruptedExceptionthrown byget- See Also:
-
succeeded
Description copied from class:TaskCalled when this Task has successfully completed, i.e. when itsgetmethod returns a value. Tasks that compute a value should override this method.This method runs on the EDT. It does nothing by default.
- Overrides:
succeededin classTask<BufferedImage, Void>- Parameters:
image- the value returned by thegetmethod- See Also:
-
failed
Description copied from class:TaskCalled when an execution of this Task fails and anExecutionExecptionis thrown byget.This method runs on the EDT. It Logs an error message by default.
- Overrides:
failedin classTask<BufferedImage, Void>- Parameters:
e- thecauseof theExecutionException- See Also:
-
finished
protected void finished()Description copied from class:TaskCalled unconditionally (in afinallyclause) after one of the completion methods,succeeded,failed,cancelled, orinterrupted, runs. Subclasses can override this method to cleanup before thedonemethod returns.This method runs on the EDT. It does nothing by default.
- Overrides:
finishedin classTask<BufferedImage, Void>- See Also:
-