"Hello World" Cytoscape Plugin
Here is a simple "Hello World" example as a Cytoscape plugin where
a Java Swing utility class is used to display the message in a dialog window.
import javax.swing.JOptionPane;
import cytoscape.plugin.CytoscapePlugin;
import cytoscape.Cytoscape;
public class HelloWorld extends CytoscapePlugin {
public HelloWorld() {
String message = "Hello World!";
System.out.println(message);
JOptionPane.showMessageDialog(Cytoscape.getDesktop(), message);
}
}
HelloWorld.java
HelloWorld.jar
Looking at the Plugin
Imports:
import cytoscape.plugin.CytoscapePlugin;
import cytoscape.Cytoscape;
-
All plugins must extend the class
cytoscape.plugin.CytoscapePlugin.
The specific class that extends CytoscapePlugin
doesn't need to stand alone; it can reference any number of other
classes and libraries. This "main" class is simply Cytoscape's entry
point to your code.
-
The static class
cytoscape.Cytoscape provides
access the data objects and utilities of the Cytoscape core. Here, the
plugin gets a reference to a window created by Cytoscape for a parent
of a new dialog window.
Methods:
public HelloWorldPlugin ()
-
All plugins must have a default constructor (that is, a
constructor with no arguments). Cytoscape will call this constructor to
create an instance of your plugin class.
To load this plugin into Cytoscape, save the jar file at the above
link to your local disk in the Cytoscape plugins folder. Then start Cytoscape
which will then load the plugin from the jar. You should see the
"Hello World" dialog appear above your main Cytoscape window.