2D Graphics > Grapher > Features of the Grapher Package > Grapher Links > Predefined Grapher Links
 
Predefined Grapher Links
Predefined link classes are available in the grapher library. Each of these classes adds a specific behavior or drawing functionality to the IlvLinkImage base class. You can either use these classes as they are or subclass them to create customized links. The following classes are available:
*IlvLinkHandle
*IlvLinkLabel
*IlvOneLinkImage
*IlvOneSplineLinkImage
*IlvDoubleLinkImage
*IlvDoubleSplineLinkImage
*IlvArcLinkImage
*IlvPolylineLinkImage
IlvLinkHandle
The IlvLinkHandle class is an example of a link class where the shape and behavior of the link are directly inherited from IlvLinkImage, and where only the drawing of the link has been redefined.
This class lets you reference any type of graphic object to make it behave as a grapher link. Also, a graphic object can be referenced by several IlvLinkHandle instances. This allows you to create very lightweight links with complex shapes. Figure 2.3 illustrates an example of an IlvLinkHandle instance referencing a polygon:
Figure 2.3    Graphic Objects Used as a Link
The constructor of this class is as follows:
IlvLinkHandle(IlvDisplay* display,
              IlvGraphic* object,
IlvGraphic* from,
IlvGraphic* to,
IlvDim width = 0,
IlBoolean owner = IlTrue
IlvPalette* palette=0);
Once added to the grapher, this instance will draw the graphic object object as a link between the nodes from and to, using the width width. The owner parameter describes the relationship between the handle and its referenced object. When a handle owns its referenced object, the handle is responsible for deleting this object. This means that you can safely share a referenced object as long as it is not owned by any of its handles.
An example showing how to use the IlvLinkHandle class is provided in the <ILVHOME>/samples/grapher/linkhand directory.
IlvLinkLabel
The IlvLinkLabel class also inherits the shape and behavior of the IlvLinkImage class. Links of the IlvLinkLabel type can be labelled with a user-defined character string.
This string can be specified by means of the label parameter of the constructor. It can also be specified once the link is created, by using the IlvLinkLabel::setLabel method.
Figure 2.4 shows two IlvLinkLabel objects:
Figure 2.4    Labelled Links
IlvOneLinkImage
The IlvOneLinkImage class derives from the IlvLinkImage class and defines a new shape and a new behavior. Instances of this class are composed of two perpendicular lines, as illustrated in Figure 2.5:
Figure 2.5    IlvOneLinkImage
The shape of the link depends on its orientation property, which indicates whether the link that leaves the from node starts out vertically (IlvVerticalLink) or horizontally (IlvHorizontalLink). This property can be specified in the constructor or it can be specified once the link is created, by using the setOrientation method.
IlvOneSplineLinkImage
This class is a subclass of IlvOneLinkImage that draws the link as a spline:
Figure 2.6    IlvOneSplineLinkImage
The position of the end points is similar to the one computed in the IlvOneLinkImage class. The two control points of the drawn spline are both at the intersection of the start and end tangents of the link. You can modify the position of the double-control point by using the setControlPoint method.
IlvDoubleLinkImage
The IlvDoubleLinkImage class derives from IlvLinkImage and defines a new shape and a new behavior. Instances of this class are composed of three connected lines intersecting at a 90° angle, as illustrated in Figure 2.7.
Figure 2.7    IlvDoubleLinkImage
The layout of the three segments follows two modes that are set with the setFixedOrientation method:
*Automatic - The orientation of the segments depends on the vertical and horizontal separation between the two nodes. The middle segment takes the orientation of the largest separation.
*Fixed - The orientation of the link is fixed and specifies the direction (horizontal or vertical) the link takes upon leaving the starting node.
IlvDoubleSplineLinkImage
The IlvDoubleSplineLinkImage class is a subclass of IlvDoubleLinkImage that draws the links with smooth curves instead of straight segments, as shown in Figure 2.8. The behavior of these links is the same as in the IlvDoubleLinkImage class.
Figure 2.8    IlvDoubleSplineLinkImage
IlvArcLinkImage
The IlvArcLinkImage class is a subclass of IlvLinkImage that defines a new shape and a new behavior. Links of this type are drawn as an arc joining the two nodes, as shown in Figure 2.9:
Figure 2.9    IlvArcLinkImage Joining Three Nodes
The arc is drawn as a spline with two control points. The distance between these control points and the segment joining the end points of the link (also called the arc offset) can be specified with one of the following:
*A fixed value, using the setFixedOffset method,
*A value proportional to the length of the segment, using the setOffsetRatio method.
This arc offset can take negative values, in which case the control points are located on the right of the oriented segment joining the start and end points. You can therefore connect two nodes with several links without any overlapping, by using different arc offsets.
IlvPolylineLinkImage
This class lets you dynamically define the intermediate points of a link. These points are stored in each IlvPolylineLinkImage instance and can be specified using several methods:
*setPoints
*addPoints
*removePoints
*movePoint
As with all link classes, the resulting shape is computed in the IlvPolylineLinkImage::getLinkPoints method. You can also specify whether the link is to be drawn with straight segments or with curves by calling the drawSpline method. Figure 2.10 shows an example of the free-form links created by IlvPolylineLinkImage instances:
Figure 2.10    IlvPolylineLinkImage

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.