A PortCalculator can be applied to move ports from the nodes' rectangular bounds to the actual outline.
Remarks
Layout algorithms only consider rectangular nodes even though the actual shape of a node is, for example, circular. Hence, without adding specific strong PortConstraints, the ports are usually placed at the border of the nodes' bounding boxes (except for some layout algorithms that produce straight-line edge routes and place the ports at the nodes' center). A PortCalculator may wrap a core layout algorithm to adjust the port assignment after the layout calculation. For the calculation of the new port offsets, the PortCalculator delegates to instances of interface IIntersectionCalculator. To specify such an instance for the source/target of an edge, use a IDataProvider that is registered to the graph with key SOURCE_INTERSECTION_CALCULATOR_DP_KEY and TARGET_INTERSECTION_CALCULATOR_DP_KEY, respectively. Note that the intersection point (i.e., port) of an edge and the associated source/target node provided by method calculateIntersectionPoint will be added to the edge's IEdgeLayout.
Default Values of Properties
coreLayout | null |
Type Details
- yfiles module
- layout-core
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.layout.PortCalculator
See Also
IIntersectionCalculator,
IntersectionCalculatorKeys.SOURCE_INTERSECTION_CALCULATOR_DP_KEY,
IntersectionCalculatorKeys.TARGET_INTERSECTION_CALCULATOR_DP_KEY,
PortConstraint
This class will not change the coordinates of a port if it is associated with a strong port constraint.
A PortCalculator will automatically be applied if the layout is executed using a LayoutExecutor and the portAdjustmentPolicy is set to another value than NEVER.
Constructors
Creates a new PortCalculator instance with an optional core layout algorithm.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- coreLayout - ILayoutAlgorithm
- The core layout algorithm.
Properties
Gets or sets the core layout algorithm that is wrapped by this stage.
Methods
Adjusts the ports after invoking the core layout algorithm.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Migrating from Synchronous to Asynchronous Layout Calculation,
Using Buffered Layout,
Writing a Custom Layout Stage
Implements
Invokes the layout process of the core layout algorithm.
Remarks
Overriding classes may call this method during applyLayout to delegate arranging the graph to the core layout algorithm. They can add pre- and post-processing code before and after this call.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Defined in
Performs the actual port calculation on the specified graph instance.
Determines whether two points are equal.
Remarks
This implementation uses Eps to add some tolerance to the comparison. It is called by calculatePorts and may be overridden to change the accuracy/tolerance of the comparison.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- x1 - number
- the x-coordinate of the first point
- y1 - number
- the y-coordinate of the first point
- x2 - number
- the x-coordinate of the second point
- y2 - number
- the y-coordinate of the second point
Returns
- ↪boolean
true
if both points are considered equal,false
otherwise
See Also
Fields
EPSILON used by equalsEps.
Remarks
By default this is
0.2d
.