public interface IlvLinkClipInterface
This interface is useful when a layout algorithm that supports this customization must place the connection points of the links by clipping the links at the node border. If the node border is the bounding box of the node, no link clip interface is required. However, if the node has a nonrectangular shape such as a triangle, rhombus, or circle, then a link clip interface can be used to correct the link connection point such that it is exactly at the border of the node shape.
Without Link Clipping | Clipping With the Link Clip Interface |
The layout algorithm calculates a proposed connection point. This
point is usually inside or on the border of the bounding box of the
node. The link can be considered as a ray that starts at the proposed
connection point and goes through an auxiliary control point. Then the
layout algorithm calls getConnectionPoint
which should return the point of the ray that is clipped at the node
border. The layout algorithm connects to this point instead of the
proposed connection point.
The following code is an example of the implementation of the method
getConnectionPoint
. In this example, the
shape of all nodes is an ellipse inside the bounding box of each node.
public IlvPoint getConnectionPoint( IlvGraphModel graphModel, Object node, IlvRect nodeBox, Object link, IlvPoint proposedConnectionPoint, IlvPoint auxControlPoint, boolean origin) { // get the intersections between the line through connect and control // point and the ellipse at currentNodeBox. IlvPoint[] intersectionPoints = new IlvPoint[2]; int numIntersections = IlvClippingUtil.LineIntersectsEllipse( proposedConnectionPoint, auxControlPoint, nodeBox, intersectionPoints); // choose the result from the intersections return IlvClippingUtil.BestClipPointOnRay( proposedConnectionPoint, auxControlPoint, intersectionPoints, numIntersections); }An example implementation of a link clip interface that handles many standard objects can be found in the source code of Composer.
IlvGraphLayout.setLinkClipInterface(ilog.views.graphlayout.IlvLinkClipInterface)
Modifier and Type | Method and Description |
---|---|
IlvPoint |
getConnectionPoint(IlvGraphModel graphModel,
Object node,
IlvRect currentNodeBox,
Object link,
IlvPoint proposedConnectionPoint,
IlvPoint auxControlPoint,
boolean origin)
Returns the clipped connection point of a link that starts at the
proposed connection point of the node and goes through the auxiliary
control point.
|
IlvPoint getConnectionPoint(IlvGraphModel graphModel, Object node, IlvRect currentNodeBox, Object link, IlvPoint proposedConnectionPoint, IlvPoint auxControlPoint, boolean origin)
graphModel
- The graph model to which the node belongs.node
- The source or target node of the link.currentNodeBox
- The current bounding box of the node. Note: During
layout the algorithm may test a connection point without actually
moving the node. Therefore, the current bounding box passed as a
parameter can be different from the box returned by
graphModel.boundingBox(node)
.link
- The link to be clipped.proposedConnectionPoint
- The proposed connection point of the
link.auxControlPoint
- The auxiliary control point. For clipping
purposes, the link can be considered as a ray that starts at the
proposed connection point and goes through the auxiliary control
point.origin
- true
if the node is the source of the link,
false
if it is the target of the link.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.