Class AbstractPlugin<T>
- Type Parameters:
- T-
- All Implemented Interfaces:
- PathPlugin<T>
- Direct Known Subclasses:
- AbstractInteractivePlugin,- ImageJMacroRunner
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract voidaddRunnableTasks(ImageData<T> imageData, PathObject parentObject, List<Runnable> tasks) For a specified parent object, generate a task to run.protected voidaddWorkflowStep(ImageData<T> imageData, String arg) Add a workflow step to the ImageData indicating the argument that this plugin was run with.protected abstract Collection<? extends PathObject> getParentObjects(ImageData<T> imageData) Get a collection of objects to process, based on the contents of the PluginRunner.protected Collection<Runnable> Get a collection of tasks to perform.protected abstract booleanparseArgument(ImageData<T> imageData, String arg) Parse the input argument, returning 'true' if the argument is valid and it's possible to run the plugin.protected voidpostprocess(TaskRunner taskRunner, ImageData<T> imageData) Called immediately after running any generated tasks.protected voidpreprocess(TaskRunner taskRunner, ImageData<T> imageData) Called after parsing the argument String, and immediately before creating & running any generated tasks.protected static <T> booleanrearrangeByStride(Collection<T> input, T[] output, int stride) Test method for rearranging a collection so that entries are interleaved with a regularity given by stride.protected booleanOptionally request a hierarchy update after the tasks have run.booleanrunPlugin(TaskRunner taskRunner, ImageData<T> imageData, String arg) Run the plugin.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface qupath.lib.plugins.PathPlugingetDescription, getLastResultsDescription, getName
- 
Constructor Details- 
AbstractPluginpublic AbstractPlugin()
 
- 
- 
Method Details- 
getTasksGet a collection of tasks to perform. This will be called fromrunPlugin(TaskRunner, ImageData, String)after a call toparseArgument(ImageData, String). The default implementation simply callsgetParentObjects(ImageData), thenaddRunnableTasks(ImageData, PathObject, List)for every parent object that was returned.- Parameters:
- imageData-
- Returns:
 
- 
requestHierarchyUpdateprotected boolean requestHierarchyUpdate()Optionally request a hierarchy update after the tasks have run. Default implementation returns true.- Returns:
 
- 
parseArgumentParse the input argument, returning 'true' if the argument is valid and it's possible to run the plugin.This is called from within runPlugin. If it returns 'true', getTasks will be called and then runTasks will submit these to the plugin runner to run. If it returns 'false', runPlugin will immediately abort and return false as well. Since this could result in some internal variables changed (e.g. a ParameterList), implementing classes can't be assumed to be thread-safe; plugins should be created and called from a single thread, although they may use multiple threads (via a PluginRunner) to complete their tasks. - Parameters:
- imageData-
- arg-
- Returns:
 
- 
getParentObjectsGet a collection of objects to process, based on the contents of the PluginRunner. This could (for example) return the selected object, the root object, all detection objects... depending upon what the plugin does. Each object this returns will be passed to addRunnableTasks to create a task to run. In practice, this method can be overridden to return anything/nothing if getTasks is overridden instead.- Parameters:
- imageData-
- Returns:
 
- 
addRunnableTasksprotected abstract void addRunnableTasks(ImageData<T> imageData, PathObject parentObject, List<Runnable> tasks) For a specified parent object, generate a task to run. In practice, this method can be overridden to return anything/nothing if getTasks is overridden instead.- Parameters:
- imageData-
- parentObject-
- tasks-
 
- 
runPluginDescription copied from interface:PathPluginRun the plugin. A PluginRunner may be provided that this plugin can use to update the user on its progress.Note: This command should block until it has completed processing. - Specified by:
- runPluginin interface- PathPlugin<T>
- Parameters:
- taskRunner-
- arg-
- Returns:
 
- 
preprocessCalled after parsing the argument String, and immediately before creating & running any generated tasks. Does nothing by default.- Parameters:
- taskRunner-
- imageData-
 
- 
postprocessCalled immediately after running any generated tasks. Does nothing by default.- Parameters:
- taskRunner-
- imageData-
 
- 
addWorkflowStepAdd a workflow step to the ImageData indicating the argument that this plugin was run with. Subclasses may override this if a better workflow step should be logged. A subclass may also override this to avoid adding a workflow step at all.- Parameters:
- imageData-
- arg-
 
- 
rearrangeByStrideTest method for rearranging a collection so that entries are interleaved with a regularity given by stride.It can be used to rearrange tasks to try to make better use of cached image regions, by helping to ensure that all available processors are operating on distinct parts of the image - rather than all in the same region, where image tile requests could become a bottleneck. Intended use would be something like the following: int n = tasks.size(); Runnable[] tasks2 = new Runnable[n]; if (rearrangeByStride(tasks, tasks2, Runtime.getRuntime().availableProcessors())) tasks = Arrays.asList(tasks2);- Parameters:
- input-
- output-
- stride-
- Returns:
 
 
-