org.scijava.command
Class DynamicCommand

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

public abstract class DynamicCommand
extends DefaultMutableModule
implements Cancelable, Command, Contextual

An ImageJ command with a variable number of inputs and outputs. This class provides greater configurability, but also greater complexity, than implementing the Command interface and using only @Parameter annotations on instance fields.

Author:
Curtis Rueden

Constructor Summary
DynamicCommand()
           
 
Method Summary
 void cancel(String reason)
          Cancels the operation execution, with the given reason for doing so.
 Context context()
          Gets the application context to which the object belongs.
 String getCancelReason()
          Gets a message describing why the operation was canceled.
 Context getContext()
          Gets the application context to which the object belongs, or null if Contextual.setContext(Context) has not yet been called on this object.
 DynamicCommandInfo getInfo()
          Gets metadata about this module.
 Object getInput(String name)
          Gets the value of the input with the given name.
 Object getOutput(String name)
          Gets the value of the output with the given name.
 boolean isCanceled()
          Gets whether the operation has been canceled.
 void setContext(Context context)
          Sets the application context to which the object belongs.
 void setInput(String name, Object value)
          Sets the value of the input with the given name.
 void setOutput(String name, Object value)
          Sets the value of the output with the given name.
 
Methods inherited from class org.scijava.module.DefaultMutableModule
addInput, addInput, addOutput, addOutput, removeInput, removeOutput, run
 
Methods inherited from class org.scijava.module.AbstractModule
cancel, getDelegateObject, getInputs, getOutputs, initialize, isResolved, preview, 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
cancel, getDelegateObject, getInputs, getOutputs, initialize, isResolved, preview, setInputs, setOutputs, setResolved
 

Constructor Detail

DynamicCommand

public DynamicCommand()
Method Detail

getInfo

public DynamicCommandInfo getInfo()
Description copied from interface: Module
Gets metadata about this module.

Specified by:
getInfo in interface Module
Specified by:
getInfo in interface MutableModule
Overrides:
getInfo in class DefaultMutableModule

getInput

public Object getInput(String name)
Description copied from interface: Module
Gets the value of the input with the given name.

Specified by:
getInput in interface Module
Overrides:
getInput in class AbstractModule

getOutput

public Object getOutput(String name)
Description copied from interface: Module
Gets the value of the output with the given name.

Specified by:
getOutput in interface Module
Overrides:
getOutput in class AbstractModule

setInput

public void setInput(String name,
                     Object value)
Description copied from interface: Module
Sets the value of the input with the given name.

Specified by:
setInput in interface Module
Overrides:
setInput in class AbstractModule

setOutput

public void setOutput(String name,
                      Object value)
Description copied from interface: Module
Sets the value of the output with the given name.

Specified by:
setOutput in interface Module
Overrides:
setOutput in class AbstractModule

context

public Context context()
Description copied from interface: Contextual
Gets the application context to which the object belongs.

Specified by:
context in interface Contextual
See Also:
Contextual.getContext()

getContext

public Context getContext()
Description copied from interface: Contextual
Gets the application context to which the object belongs, or null if Contextual.setContext(Context) has not yet been called on this object.

Specified by:
getContext in interface Contextual
See Also:
Contextual.context()

setContext

public void setContext(Context context)
Description copied from interface: Contextual
Sets the application context to which the object belongs.

Typically this method simply delegates to Context.inject(Object), and should be called only once to populate the context. Most contextual objects do not support later alteration of the context, and will throw IllegalStateException if this method is invoked again.

Specified by:
setContext in interface Contextual
See Also:
Context.inject(Object), for an example of how to implement this interface

isCanceled

public boolean isCanceled()
Description copied from interface: Cancelable
Gets whether the operation has been canceled.

Specified by:
isCanceled in interface Cancelable

cancel

public void cancel(String reason)
Description copied from interface: Cancelable
Cancels the operation execution, with the given reason for doing so.

This method merely sets the operation status to canceled; it cannot necessarily stop the operation itself. That is, it is the responsibility of each individual operation to check Cancelable.isCanceled() in a timely manner during execution, and stop doing whatever it is doing if the flag has been tripped.

Specified by:
cancel in interface Cancelable
Parameters:
reason - A message describing why the operation is being canceled.

getCancelReason

public String getCancelReason()
Description copied from interface: Cancelable
Gets a message describing why the operation was canceled.

Specified by:
getCancelReason in interface Cancelable
Returns:
The reason for cancelation, which may be null if no reason was given, or if the operation was not in fact canceled.


Copyright © 2009–2014 SciJava. All rights reserved.