The Essential JViews Framework > Graphers > Managing Nodes and Links > Basic Grapher Link Class

Nodes in a grapher are connected with links. All links are instances of the class IlvLinkImage (or subclasses). The constructor of the class IlvLinkImage has two graphic objects as parameters, so, when creating a link, you always have to give the origin and destination of the link. Here is the constructor of IlvLinkImage:

IlvLinkImage(IlvGraphic from, IlvGraphic to, boolean oriented)

The oriented parameter specifies whether or not an arrowhead is to be drawn at one end of the link. Once a link is created, you can add it to the grapher using one of the following methods:

void addLink(IlvLinkImage obj, boolean redraw) 
void addLink(IlvLinkImage obj, int layer, boolean redraw)

Here is a small piece of code that creates a grapher, two nodes and a link:

IlvGrapher grapher = new IlvGrapher();
IlvGraphic node1 = new IlvLabel(new IlvPoint(0,0), "node 1");
grapher.addNode(node1, false);
IlvGraphic node2 = new IlvLabel(new IlvPoint(100, 0), "node 2");
grapher.addNode(node2, false);
IlvLinkImage link = new IlvLinkImage(node1, node2, true);
grapher.addLink(link, false);