Differences between revisions 6 and 7
Revision 6 as of 2006-06-05 19:06:27
Size: 4032
Editor: barolo
Comment:
Revision 7 as of 2006-06-05 19:07:23
Size: 4033
Editor: barolo
Comment:
Deletions are marked like this. Additions are marked like this.
Line 13: Line 13:
 ...  ....

In versions of Cytoscape prior to 2.3 it was possible to create custom nodes (such as "pie nodes") using the underlying Piccolo architecture. In Cytoscape 2.3, with the introduction of a new rendering engine, the underlying Piccolo dependencies have been pulled out and it is no longer possible to create custom nodes using Piccolo. To make up for this shortcoming in 2.3, a simple makeshift API has been assembled to provide plugin writers the ability to once again create custom nodes. Of course, the new way of creating custom nodes is done through an API that is in no way related to the old method of making custom nodes; plugins that created custom nodes in prior versions of Cytoscape will need to be modified.

This new API consists of the ability to define an arbitrary number of specified shapes filled with specified paint on a node view. These shapes will be rendered relative to the node's center. The edge intersection computations for the node will still rely on the overall node's shape, which is independent of the custom graphic shapes specified. One strategy might be to define a node shape as rectangle, filled with completely transparent color, with no node border; then specify custom graphics that fit inside of the specified rectangular shape. Then edges would still be computed based on the outer [invisible] rectangular boundary.

To get started, first obtain an instance of giny.view.NodeView in the usual manner. But from here on things will be different from previous versions of Cytoscape. Cast this NodeView object to an instance of ding.view.DNodeView. Then apply the methods documented below.

Here is some sample code that demonstrates basic principles.

  • giny.view.NodeView nv;

    // Obtain an instance of NodeView using documented Cytoscape API.

  • ... ding.view.DNodeView dnv = (ding.view.DNodeView) nv;

    java.awt.geom.GeneralPath path = new java.awt.geom.GeneralPath(); path.moveTo(0.0f, 0.0f); path.lineTo(10.0f, 0.0f); path.lineTo(0.0f, 10.0f); path.closePath(); // Just made a triangle. dnv.addCustomGraphic(path, java.awt.Color.yellow, 0);

    path = new java.awt.geom.GeneralPath(); path.moveTo(0.0f, 0.0f); path.lineTo(0.0f, 10.0f); path.lineTo(-10.0f, 0.0f); path.closePath(); // Made another triangle not overlapping the first one. dnv.addCustomGraphic(path, java.awt.Color.red, 1);


Methods below are defined on an instance of ding.view.DNodeView.


getCustomGraphicCount

public int getCustomGraphicCount()

Returns the number of custom graphic objects currently set on this node view.


getCustomGraphicShape

public java.awt.Shape getCustomGraphicShape(int index)

Returns the shape of the custom graphic object at specified index on this node view. The index parameter must be in the range [0, getCustomGraphicCount()-1].


getCustomGraphicPaint

public java.awt.Paint getCustomGraphicPaint(int index)

Returns the paint on the custom graphic object at specified index on this node view. The index parameter must be in the range [0, getCustomGraphicCount()-1].


removeCustomGraphic

public void removeCustomGraphic(int index)

Removes the custom graphic object at specified index. The index parameter must be in the range [0, getCustomGraphicCount()-1]. Once the object at specified index is removed, all objects remaining and at a higher index will be shifted such that their index is decreased by one.


addCustomGraphic

public void addCustomGraphic(java.awt.Shape s, java.awt.Paint p, int index)

Adds a custom graphic object at specified index. The index of an object is only important in that objects with lower index are rendered before objects with higher index; if objects overlap, this order may be important to consider. A custom graphic object consists of the specified shape that is filled with the specified paint; the shape is placed relative to this node's location.

Custom_Node_Graphics (last edited 2010-02-04 20:29:10 by alsace)

Funding for Cytoscape is provided by a federal grant from the U.S. National Institute of General Medical Sciences (NIGMS) of the Na tional Institutes of Health (NIH) under award number GM070743-01. Corporate funding is provided through a contract from Unilever PLC.

MoinMoin Appliance - Powered by TurnKey Linux