org.scijava.command
Class InteractiveCommand

java.lang.Object
  extended by org.scijava.module.AbstractModule
      extended by org.scijava.module.DefaultMutableModule
          extended by org.scijava.command.DynamicCommand
              extended by org.scijava.command.InteractiveCommand
All Implemented Interfaces:
Runnable, Cancelable, Command, Interactive, Previewable, Contextual, Module, MutableModule, SciJavaPlugin

public abstract class InteractiveCommand
extends DynamicCommand
implements Interactive, Previewable

An ImageJ command intended to be run interactively.

It is Interactive and Previewable, with the previews used for interactive exploration.

Further, this class provides added convenience for keeping certain input parameters synced with active Displays. It listens for DisplayActivatedEvents, updating the inputs specified in the constructor when such events occur. Individual interactive commands can then add callback methods to affected inputs, for reacting to a change in the active display.

Author:
Curtis Rueden

Constructor Summary
InteractiveCommand(String... listenerNames)
          Creates a new interactive command.
 
Method Summary
protected
<T> ModuleItem<T>
asType(ModuleItem<?> item, Class<T> type)
           
 void cancel()
          Performs necessary cleanup in response to cancellation of the module execution.
protected  LogService log()
           
protected  void onEvent(DisplayActivatedEvent evt)
           
 void preview()
          Computes a preview of the module's execution results, if available.
protected
<T> void
update(ModuleItem<T> item, T newValue)
           
protected  void updateInput(ModuleItem<?> item)
           
 
Methods inherited from class org.scijava.command.DynamicCommand
cancel, context, getCancelReason, getContext, getInfo, getInput, getOutput, isCanceled, setContext, setInput, setOutput
 
Methods inherited from class org.scijava.module.DefaultMutableModule
addInput, addInput, addOutput, addOutput, removeInput, removeOutput, run
 
Methods inherited from class org.scijava.module.AbstractModule
getDelegateObject, getInputs, getOutputs, initialize, isResolved, setInputs, setOutputs, setResolved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 
Methods inherited from interface org.scijava.module.Module
getDelegateObject, getInputs, getOutputs, initialize, isResolved, setInputs, setOutputs, setResolved
 

Constructor Detail

InteractiveCommand

public InteractiveCommand(String... listenerNames)
Creates a new interactive command.

Parameters:
listenerNames - The list of names of inputs to keep in sync when the active display changes. Each input must be a Display.
Method Detail

preview

public void preview()
Description copied from interface: Module
Computes a preview of the module's execution results, if available. A preview is a quick approximation of the results that would be obtained by actually executing the module with Runnable.run(). Not all modules support previews.

Specified by:
preview in interface Previewable
Specified by:
preview in interface Module
Overrides:
preview in class AbstractModule
See Also:
ModuleInfo.canPreview()

cancel

public void cancel()
Description copied from interface: Module
Performs necessary cleanup in response to cancellation of the module execution. This is useful in conjunction with Module.preview() to undo any changes made as a result of the preview.

Specified by:
cancel in interface Previewable
Specified by:
cancel in interface Module
Overrides:
cancel in class AbstractModule
See Also:
ModuleInfo.canCancel()

updateInput

protected void updateInput(ModuleItem<?> item)

asType

protected <T> ModuleItem<T> asType(ModuleItem<?> item,
                                   Class<T> type)

update

protected <T> void update(ModuleItem<T> item,
                          T newValue)

log

protected LogService log()

onEvent

protected void onEvent(DisplayActivatedEvent evt)


Copyright © 2009–2014 SciJava. All rights reserved.