| Advanced Features > Nested Managers and Nested Graphers > Nested Graphers > Intergraph Links |
Intergraph Links |
INDEX
PREVIOUS
NEXT
|
An intergraph link is a link that crosses grapher boundaries. In other words, an intergraph link is a link whose origin and destination are not in the same grapher. Some examples are shown in Figure 1.7.
In this picture the red (darker) links are intergraph links and the yellow (light) links are regular links.
Given that the intergraph link has an origin and a destination in different graphers, the question is in which grapher the link itself is stored.
To be able to create intergraph links, you must have a hierarchy of nested graphers (IlvGrapher). The hierarchy should not contain a manager (IlvManager); otherwise the library will not let you create an intergraph link. The intergraph link between a node stored in grapher A and a node stored in grapher B must be stored in the first common ancestor of A and B, as shown in Figure 1.8.
In Figure 1.8 the red intergraph link that connects an object of A and an object of B must be stored in grapher C, the first common ancestor of A and B.
The IlvGrapher class provides a static utility method that allows you to determine the first common grapher:
static IlvGrapher getLowestCommonGrapher(IlvGraphic obja, IlvGraphic objb)
To create an intergraph link, the code will look like this (assuming that the origin and destination variables have been created and added in different graphers):
The IlvGrapher.addInterGraphLink static utility method allows you to directly add the link in the common parent grapher:
static void addInterGraphLink(IlvLinkImage link, boolean redraw)
The code shown in the previous example is the equivalent to:
IlvGraphic origin, destination; IlvLinkImage link; ... link = new IlvLinkImage(origin, destination, false); IlvGrapher.addInterGraphLink(link, false); |
The IlvGrapher class also provides methods that let you access intergraph links stored in a grapher in an efficient way:
IlvGraphicEnumeration getInterGraphLinks() int getInterGraphLinksCount()
Since an intergraph link is stored in the same way as other links in the grapher, it is also part of the list of all objects contained in this grapher returned by the getObjects method of the class IlvManager:
IlvGraphicEnumeration getObjects()
Nevertheless, calling the getInterGraphLinks method is much more efficient than traversing all objects of the grapher.
To distinguish an intergraph link from other objects in the grapher, you can use the following method of the IlvGrapher class:
boolean isInterGraphLink(IlvGraphic obj)
This method returns true if the specified graphic object is a link stored in the grapher instance with the origin or the destination stored somewhere else. That is, if the graphic object is an intergraph link.
The IlvGrapher class also gives you access to intergraph links that are leaving or entering a grapher. You can access such links using the methods:
IlvGraphicEnumeration getExternalInterGraphLinks() int getExternalInterGraphLinksCount()
The difference between the methods getInterGraphLinks and getExternalInterGraphLinks is that the first method returns the intergraph links stored in a grapher with an origin or destination in another grapher, and the second method returns the intergraph links stored in another grapher but with the origin or destination in this grapher.
If the grapher has no subgraphers, the external intergraph links obtained by getExternalInterGraphLinks() are all links that are leaving or entering the grapher.
If the grapher has subgraphers, links whose origin or destination is not stored directly in the grapher, but are stored in a subgrapher are not included. In this case, links that are leaving or entering the nesting hierarchy of the grapher could be obtained by examining all external intergraph links of the subgraphers recursively. To help in this task the following convenience methods are supplied:
IlvGraphicEnumeration getTreeExternalInterGraphLinks()int getTreeExternalInterGraphLinksCount()
When a grapher is moved, it is possible that the grapher and all its nested subgraphers appear at a new location on the screen. The grapher displacement causes the shape of the following links to change:
grapher.getTreeExternalInterGraphLinks().
Figure 1.9 illustrates interlinked nested graphers:
Grapher A contains two graphers, B and D. Grapher B contains another grapher, C. The intergraph link from an object of C to an object of D is then stored in A.
This link is an intergraph link of A (returned in getInterGraphLinks called on A) and is also an external intergraph link of C and D (returned by getExternalInterGraphLinks called on C or D).
Neither the origin nor destination of the intergraph link ends in grapher B, and thus is not returned by calling getExternalInterGraphLinks on B. However, the link is returned by calling getTreeExternalInterGraphLinks on B, since its origin node is nested inside B.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |