|
Cytoscape 2.8.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface CyCommandHandler
The CyCommandHandler interface allows a Cytoscape plugin to make it's functions available to other plugins in a loosely-coupled manner (by passing command strings and arguments). It is intended as a stop-gap measure until the ability to directly call methods in other plugins (through OSGI services) is available in Cytoscape 3.0.
CyCommandHandler provide a simple method for a plugin to expose some functionality
that can be used by other plugins. The idea is simple: a plugin registers
one or more CyCommandHandlers with the CyCommandManager
. In the simplest
case, the plugin will directly implement CyCommandHandler:
public class MyPlugin extend CytoscapePlugin implements CyCommandHandler {
public MyPlugin() {
// Plugin initialization
try {
// You must reserve your namespace first
CyCommandNamespace ns = CyCommandManager.reserveNamespace("my namespace");
// Now register this handler as handling "command"
CyCommandManager.register(ns, command, this);
} catch (RuntimeException e) {
// Handle already registered exceptions
}
}
}
Alternatively, a plugin could implement multiple CyCommandHandlers, each one
handling a single command string. This has the advantage of providing a clear
separation where each class handles a single command, and is the recommended way
to structure new plugins.
Tunable
. It is recommended
that whenever possible, plugins use Tunables as they provide type information
that is useful to allow client plugins to perform some limited validation. In
either case, both signatures (maps and Tunables) should be supported.
CyCommandResult
. It is
expected that a command will provide some limited information in the CyCommandResult
message and the actual information in the results map.
CyCommandHandler handler = CyCommandManager.getCommand("view layout", "force-directed");
Map layoutTunables = handler.getTunables("force-directed");
Tunable t = layoutTunables.get("iterations");
t.setValue("100");
try {
CyCommandResult layoutResult = handler.execute("force-directed", layoutTunables);
} catch (CyCommandException e) {
}
Alternatively....
Map args = new HashMap();
args.put("iterations", new Integer(100));
try {
CyCommandResult layoutResult = CyCommandManager.execute("view layout", "force-directed", args);
} catch (CyCommandException e) {
}
Method Summary | |
---|---|
CyCommandResult |
execute(String command,
Collection<Tunable> arguments)
Execute a given command with a particular set of arguments. |
CyCommandResult |
execute(String command,
Map<String,Object> arguments)
Execute a given command with a particular set of arguments. |
List<String> |
getArguments(String command)
Return the list of arguments supported by a particular command. |
List<String> |
getCommands()
Return the list of commands supported by this CyCommandHandler. |
String |
getDescription(String command)
Get the description/documentation of the command. |
Map<String,Object> |
getSettings(String command)
Get the current values for all of the arguments for a specific command. |
Map<String,Tunable> |
getTunables(String command)
Get the current Tunables for all of the arguments for a specific command. |
Method Detail |
---|
List<String> getCommands()
List<String> getArguments(String command)
command
- the command we're inquiring about
Map<String,Object> getSettings(String command)
command
- the command we're inquiring about
Map<String,Tunable> getTunables(String command)
command
- the command we're inquiring about
String getDescription(String command)
command
- the command we're inquiring about
CyCommandResult execute(String command, Map<String,Object> arguments) throws CyCommandException
command
- the command we're executingarguments
- to map of key, value pairs for the arguments we want to pass
CyCommandException
CyCommandResult execute(String command, Collection<Tunable> arguments) throws CyCommandException
command
- the command we're executingarguments
- the list of Tunables
CyCommandException
|
Cytoscape 2.8.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |