- java.lang.Object
-
- org.scijava.progress.Task
-
public class Task extends Object
Keeps track of progress associated with an execution of progressible code.Tasks should not be updated by the code itself, but rather updated viaProgress.update().- Author:
- Gabriel Selzer
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomplete()Records the completion of thisTaskvoiddefineTotal(long elements)Defines the total progress of thisTask.voiddefineTotal(long elements, long subTasks)Defines the total progress of thisTask.Stringdescription()The id of the progressibleObjectbooleanisComplete()Returnstrueiff thisTaskis complete.booleanisSubTask()protected Taskparent()Returns the parentTaskof thisTask.doubleprogress()Calculates and returns the progress of the associated progressibleObject.Objectprogressible()voidsetStatus(String status)Used by the progressibleObjectto set the status of its computation.Stringstatus()The status of the progressibleObjectStringtoString()protected voidupdate(long numElements)
-
-
-
Method Detail
-
complete
public void complete()
Records the completion of thisTask
-
defineTotal
public void defineTotal(long elements)
Defines the total progress of thisTask.This method must be called before
update(long)orprogress()are called, as otherwise total progress cannot be defined.Under the hood, this method calls
defineTotal(long, long)- Parameters:
elements- the number of discrete packets of computation.
-
defineTotal
public void defineTotal(long elements, long subTasks)Defines the total progress of thisTask.This method must be called before
update(long)orprogress()are called, as otherwise total progress cannot be defined.- Parameters:
elements- the number of discrete packets of computation.subTasks- the number of times subtasks are called upon within the task. This is not the same as the number of subtasks used (as one subtask may run multiple times).
-
isComplete
public boolean isComplete()
Returnstrueiff thisTaskis complete.- Returns:
trueiff thisTaskis complete.
-
progress
public double progress()
Calculates and returns the progress of the associated progressibleObject. If the total progress is defined usingdefineTotal(long, long), then this method will return adoublewithin the range [0, 1]. If the progress is not defined, then this task will return0untilcomplete()is called; after that call this method will return1..- Returns:
- the progress
-
setStatus
public void setStatus(String status)
Used by the progressibleObjectto set the status of its computation. This method should not used by any code not part of the progressibleObject- Parameters:
status- the status of the progressibleObject
-
update
protected void update(long numElements)
- Parameters:
numElements- the number of elements completed- See Also:
when a particular task must be updated
-
parent
protected Task parent()
Returns the parentTaskof thisTask.- Returns:
- the parent
Task, ornullif this Task has no parent
-
isSubTask
public boolean isSubTask()
-
-