Cytoscape Plugin Tutorial
Cytoscape allows programmers to write plugins that access the core
data structures and windows of Cytoscape to do a wide variety of
operations. This tutorial explains how to write a plugin and how to get
Cytoscape to load and use your plugin.
It is assumed that the reader is familiar with the basics of the Java
programming language and has some kind of programming environment available.
See
the Java Tutorial
for an excellent introduction and handy reference guide for Java.
You will also want to check out the
Cytoscape core API documentation.
Each plugin tutorial includes the Java source code and a jar file containing
the compiled classes. To run Cytoscape via Java WebStart with all of these
plugins automatically loaded, click here:
WEB START.
(See the
Cytoscape Web Start documentation for information on running Cytoscape via Java Web Start).
Plugin license policy.
The CytoscapePlugin class is very simple. It defines a default constructor and
one instance method:
describe,
which can be overridden to describe what the plugin does. A static
method also exists that is used by Cytoscape to load plugins. Since
the constructor takes no arguments, it is not necessary to explicitly
call a parent constructor from your plugin's constructor. The only
requirement is that your plugin must have a default (no arguments)
constructor, as Cytoscape will call this constructor to instantiate
your plugin.
Java only allows a class to inherit from one parent. Since every plugin
must extend CytoscapePlugin, this seems to be a severe limitation. The way
around this is to define your Cytoscape plugin class as a simple wrapper
around your real code. For example:
public class PluginWrapper extends CytoscapePlugin {
public PluginWrapper() {
RealPlugin plugin = new RealPlugin();
}
}
This scheme can also be used to link to more complicated services, like a
web server, or to connect to code written in other languages via the JNI
mechanism (see the
JNI
section of the Java tutorial).