Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Views User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

11.1 Introduction to Links

Link components are symbols that have a head and tail port. By default, the link component contains a single line as a child component and keeps the head and tail ports aligned with the endpoints of the line. However, other types of components can be used within the link component to render different shapes for the link.

The link component maintains a pointer to an interface called IODLinkShape. This interface provides the link with methods for positioning the head and tail ports to match the shape. It also provides methods for adjusting the shape when the head and tail ports are moved. This interface is mixed into classes derived from CODComponent. The implementation of the interface depends on the type of component with which it is combined. The following link shape classes are included with the library: CODLineLinkShape and CODOrthogonalLinkShape. The CODLineLinkShape class implements IODLinkShape for straight lines. The CODOrthogonalLinkShape implements IODLinkShape for orthogonal lines.

To implement your own custom link shapes, derive a class from an existing component class and mix in the IODLinkShape interface. Example 16 shows the IODLinkShape interface.

Example 16: The IODLinkShape interface

The GetTailPoint() and GetHeadPoint() methods return the tail and head points of the link shape. For a line, the tail and head points are the endpoints. The Dock() method adjusts the component so that it docks with the given ports. When the symbols that the link is connected to move, the Dock() method is called to adjust the shape so that it follows the symbols. The UpdateVertex() method is called when a vertex in the shape is moved or deleted. Updating a vertex in the shape may affect how the shape is docked with the connected symbols.

Use CODLineLinkShape and CODOrthogonalLinkShape as a guide to implementing the IODLinkShape interface. Example 17 shows the declaration of the CODLineLinkShape class.

Example 17: CODLineLinkShape class

The method CODLinkComponent::AssignShape() is used to assign a link shape to a link component. If you want to assign a custom link shape to the link component, call AssignShape() before calling the CODLinkComponent::Create() method. If a link shape has not been assigned by the time Create() is called, Create() assigns a CODLineLinkShape (a straight line) to the link. To use an orthogonal line for the link shape, you can call CODLinkComponent::CreateOrthogonal().



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.