skip to main content
Defense > Programmer's documentation > Advanced Features > Link shape policies > Crossing link shape policy
 
Crossing link shape policy
The crossing link shape policy calculates the shape of a link that crosses other links. The crossing mode can be a tunnel or a bridge.
Tunnel crossing and bridge crossing
Setting the link shape policy
You can set the crossing link shape policy to links of class IlvCrossingAwareLinkImage. Use the following code:
 
IlvCrossingAwareLinkImage link =
    new IlvCrossingAwareLinkImage(node1, node2, true, null);
link.setLinkShapePolicy(new IlvCrossingLinkShapePolicy());
grapher.addLink(link, redraw);
...
This policy can be shared among several links. The policy parameters are valid for all links that share the same policy.
Crossing graphics
The crossing link shape policy calculates the positions of the crossings, but it is the crossing graphics that actually draw the crossings. If no crossing graphic is associated with a link, then the crossing is not displayed and a gap appears instead. A crossing graphic is an instance of a subclass of IlvGraphic that implements the IlvCrossingGraphic interface.
The package ilog.views.graphic.linkpolicy contains two predefined crossing graphics:
*IlvTunnelCrossings for tunnel crossings
*IlvBridgeCrossings for bridge crossings
Unlike the shape policy itself, crossing graphics cannot be shared by several links. Once a crossing graphic is associated with a link, it is fully maintained by the crossing link shape policy. Therefore, it is not necessary to move or to reshape the crossing graphic, as all this is done by the link shape policy automatically.
To set a tunnel crossing graphic, call:
 
link.setCrossingGraphic(new IlvTunnelCrossings(link));
To set a bridge crossing graphic, call
 
link.setCrossingGraphic(new IlvBridgeCrossings(link));
Example
The following code shows how to set the crossing link shape policy and the crossing graphics for two links.
 
IlvCrossingLinkShapePolicy policy = new IlvCrossingLinkShapePolicy();
IlvCrossingAwareLinkImage link1 =
    new IlvCrossingAwareLinkImage(node1, node2, true, null);
link1.setCrossingGraphic(new IlvTunnelCrossings(link1));
link1.setLinkShapePolicy(policy);
IlvCrossingAwareLinkImage link2 =
    new IlvCrossingAwareLinkImage(node3, node4, true, null);
link2.setCrossingGraphic(new IlvTunnelCrossings(link2));
link2.setLinkShapePolicy(policy);
...
// insert the links into the grapher only AFTER installing the policy
grapher.addLink(link1, redraw);
grapher.addLink(link2, redraw);
...

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