← Revision 9 as of 2012-03-19 22:40:58
6264
Comment:
|
← Revision 10 as of 2012-03-19 22:45:28 →
6211
|
Deletions are marked like this. | Additions are marked like this. |
Line 44: | Line 44: |
//1. Define a CytoPanel class public class MyCytoPanel extends JPanel implements CytoPanelComponent { |
//1. Define a CytoPanel class public class MyCytoPanel extends JPanel implements CytoPanelComponent { |
Line 47: | Line 47: |
... @Override public CytoPanelName getCytoPanelName() { return CytoPanelName.WEST; } |
|
Line 48: | Line 53: |
@Override public CytoPanelName getCytoPanelName() { return CytoPanelName.WEST; } ... } |
} |
Line 55: | Line 55: |
// 2. Create an instance of MyCytoPanel MyCytoPanel myPanel = new MyPanel(); |
// 2. Create an instance of MyCytoPanel MyCytoPanel myPanel = new MyPanel(); |
Line 58: | Line 58: |
//3. Register myPanel as a service | //3. Register myPanel as a service |
Line 60: | Line 60: |
Line 70: | Line 69: |
// Define a CyAction class public class AddImageIconAction extends AbstractCyAction { |
// Define a CyAction class public class AddImageIconAction extends AbstractCyAction { |
Line 73: | Line 72: |
public AddImageIconAction(CySwingApplication desktopApp){ | public AddImageIconAction(CySwingApplication desktopApp){ |
Line 75: | Line 74: |
ImageIcon icon = new ImageIcon(getClass().getResource("/images/tiger.jpg")); | ImageIcon icon = new ImageIcon(getClass().getResource("/images/tiger.jpg")); |
Line 77: | Line 76: |
// Add image icons on tool-bar and menu item putValue(LARGE_ICON_KEY, icon); |
putValue(LARGE_ICON_KEY, icon); |
Line 80: | Line 78: |
} public boolean isInToolBar() { return true; } |
} public boolean isInToolBar() { return true; } |
Line 86: | Line 84: |
} |
Contents
- About the cookbook
- How to use the cookbook?
-
The list of app examples in the cookbook
- Introduction
- How to add a tabbed Panel to Control panel?
- How to add an image icon (menu item) to the toolbar?
- How to create a submenu?
- How to create, modify, and destroy a network, nodes, and edges?
- How to create, modify, and destroy a network view?
- How to save/restore app states?
- How to determine which nodes are currently selected on a network?
- How to handle events from a network (and discuss each event type)?
- How to change the background color of a view?
- How to zoom a network view?
- How to load attribute data?
- How to remove attributes?
- How to use a web service client?
- How to write a web service client?
- How to use the VizMapper programmatically?
- How to apply a continuous color gradient to nodes according to their degree?
- How to load a visual properties file?
- How to write a layout algorithm?
- How to write a Group Viewer?
- How to add components to the node view, edge view, and attribute browser context menus?
- How to save/restore plugin states?
- How to use the Cytoscape task monitor to show the progress of my job?
- How to add new attribute functions via a Cytoscape plug-in?
- How to add plug-in specific help to the Cytoscape main help system?
- Trouble shooting
- Recommendations
- App Porting Hints
- Questions, suggestions
About the cookbook
To help app developers to develop their own app, the Cytoscape developer team developed the cookbook, a collection of small apps. The cookbook could be used to
- get your feet wet
- find a template project to extend
- find out how to do something in Cytoscape.
How to use the cookbook?
SVN repository: http://chianti.ucsd.edu/svn/core3/support/trunk/samples/
Steps:
- Check out sample project from SVN repository with the above URL
- Compile with “mvn clean install”
- Copy the jar in the project target directory to Cytoscape installation: bundles/apps
- Start Cytoscape 3.0
The list of app examples in the cookbook
The list of sample apps is basically the same as in the cookbook for Cytoscape 2.X. They are mostly Cytoscape Bundle apps, but also include a few Simple apps. Some of them are,
Introduction
This tutorial will show some code snippets about how to use Cytoscape APIs on plugin development. Each feature is included in a sample plugin, which can serve as a starting point or template for new plugin developers. The code snippets can also be used as reference for experienced developers.
Cytoscape plugin is usually packaged in a jar file and deployed to the plugins directory of Cytoscape. When Cytoscape starts up and initializes, its plugin manager will look up all the plugins in plugins directory. A plugin should have following three components.
A class, which extends CytoscapePlugin. This is the entry point to Cytoscape.
A manifest file, explicitly list the class, which extended CytoscapePlugin class
A plugin.props file, which list the information about the plugin, such as plugin name, author, release date and more. Although this file is not absolutely required, it is recommended to have one, since plugin manager will need the information to handle the plugin properly. See the page at http://www.cytoscape.org/cgi-bin/moin.cgi/Cytoscape_Plugin_Tutorial for detail about the definition of a plugin.props.
If plugin developer will share and publish their plugins, they are encouraged to submit their plugins to Cytoscape plugin website at http://cytoscape.org/plugins/index.php .
How to add a tabbed Panel to Control panel?
It takes three steps to add a tabbed panel to the control panel.
1 //1. Define a CytoPanel class
2 public class MyCytoPanel extends JPanel implements CytoPanelComponent {
3
4 ...
5 @Override
6 public CytoPanelName getCytoPanelName() {
7 return CytoPanelName.WEST;
8 }
9 ...
10 }
11
12 // 2. Create an instance of MyCytoPanel
13 MyCytoPanel myPanel = new MyPanel();
14
15 //3. Register myPanel as a service
16 registerService(bc,myCytoPanel,CytoPanelComponent.class, new Properties());
17
Download a sample plugin, here.
How to add an image icon (menu item) to the toolbar?
1 // Define a CyAction class
2 public class AddImageIconAction extends AbstractCyAction {
3
4 public AddImageIconAction(CySwingApplication desktopApp){
5 ...
6 ImageIcon icon = new ImageIcon(getClass().getResource("/images/tiger.jpg"));
7
8 putValue(LARGE_ICON_KEY, icon);
9 ...
10 }
11
12 public boolean isInToolBar() {
13 return true;
14 }
15 ...
16 }
17
1 // Register the CyAction as service
2 AddImageIconAction addImageIconAction = new AddImageIconAction(cytoscapeDesktopService);
3 registerService(bc,addImageIconAction,CyAction.class, new Properties());
4
How to create a submenu?
How to create, modify, and destroy a network, nodes, and edges?
How to create, modify, and destroy a network view?
How to save/restore app states?
How to determine which nodes are currently selected on a network?
How to handle events from a network (and discuss each event type)?
How to change the background color of a view?
How to zoom a network view?
How to load attribute data?
How to remove attributes?
How to use a web service client?
How to write a web service client?
How to use the VizMapper programmatically?
How to apply a continuous color gradient to nodes according to their degree?
How to load a visual properties file?
How to write a layout algorithm?
How to write a Group Viewer?
How to add components to the node view, edge view, and attribute browser context menus?
How to save/restore plugin states?
How to use the Cytoscape task monitor to show the progress of my job?
How to add new attribute functions via a Cytoscape plug-in?
How to add plug-in specific help to the Cytoscape main help system?
Trouble shooting
If you get compile error,
Check the version number of parent POM, the latest is at Cytoscape repository
If this is a dependency problem, check the version number of depended bundle at Cytoscape repository
Recommendations
- If you’re a beginner you probably want to use the Simple app type. see example02a, example03a
- If you want to port as quickly as possible, again, go with the Simple app type.
- If you want to publish an API you must use the Bundle app type
- If you experience version conflicts or anticipate future version conflicts, again you must use the Bundle app type.
- If you are in doubt, you should probably use the Simple app type. You can always port it to the Bundle app type later should that become necessary. Both styles are supported and will be until (at least) version 4.0.
App Porting Hints
How to
- get current network --- see sample app 5
- get attributes --- see sample app 11
- add a menu item --- see sample app 3
Questions, suggestions
Please send e-mail to cytoscape help desk or discussion group