EdgeLabelOrientationSupport provides orientation and mirroring support for layout algorithms with integrated edge labeling.
Remarks
To calculate the position and orientation of edge labels whose placements are defined with the PreferredPlacementDescriptor, the OrientationLayout would need the direction of the associated edge. Since this direction is not available to the OrientationLayout, because it is a wrapper, the calculation must be done in the core layout algorithm itself with the help of the EdgeLabelOrientationSupport.
Important: Since layout algorithms with integrated edge labeling cannot deal with ambiguous preferred placement descriptors (combinations of the same setting, e.g., source or target for the placeAlongEdge), preProcessLabel removes combinations and replaces the original descriptor with a non-ambiguous one that is used during the layout calculation.
Type Details
- yfiles module
- layout-core
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.layout.EdgeLabelOrientationSupport
Constructors
Creates a new EdgeLabelOrientationSupport instance.
See Also
Methods
Creates and returns a non-ambiguous PreferredPlacementDescriptor of the given potentially ambiguous one.
Remarks
Parameters
A map of options to pass to the method.
- ambiguous - PreferredPlacementDescriptor
- an ambiguous PreferredPlacementDescriptor
Returns
- ↪PreferredPlacementDescriptor
- a non-ambiguous version of the given ambiguous PreferredPlacementDescriptor
Marks the given port label for a non-port placement (fallback).
Remarks
The given edge label's PreferredPlacementDescriptor will internally be changed such that its placement along edge is either AT_SOURCE or AT_TARGET.
Algorithms that are executed after this call and before resetAmbiguousLabelDescriptors will handle port labels like normal source or target labels.
Parameters
A map of options to pass to the method.
- portLabel - LabelLayoutData
- an edge label that had a AT_SOURCE_PORT or AT_TARGET_PORT placement preference
Throws
- Exception({ name: 'InvalidOperationError' })
- if replaceAmbiguousLabelDescriptors was never called for the graph containing the given label.
See Also
Restores the original preferred placement and updates the label rotation according to the layout orientation.
Remarks
The original preferredPlacementDescriptor that has been replaced in preProcessLabel gets restored. Then it moves and rotates the label box in respect of the orientation.
This method is called by the core layout algorithm with the integrated edge labeling for each edge label after the location of the label is determined.
Parameters
A map of options to pass to the method.
- graph - Graph
- the graph to get the orientation information from
- label - LabelLayoutData
- the information about the edge label whose location is determined
Prepares the label for the core layout algorithm.
Remarks
First, the preferred placement of the edge label is replaced by a non-ambiguous PreferredPlacementDescriptor that has only relative references. This descriptor is orientation independent and can be used in the core layout algorithm. Second, the method rotates the label box in respect of its PreferredPlacementDescriptor and the direction of the segment to which it belongs. After that call, the core layout algorithm can use the geometry (width and height) of the label to calculate its location.
This method is called by the core layout algorithm with the integrated edge labeling for each edge label before the layout algorithm uses the geometry of labels. It should be called as soon as the direction of the segment the label belongs to is determined.
Parameters
A map of options to pass to the method.
- graph - Graph
- the graph to get the orientation information from
- label - LabelLayoutData
- the information about the edge label whose segment direction is determined
- segmentDirection - Direction
- the direction of the segment the edge label belongs to
Replaces the PreferredPlacementDescriptors of all edge labels in the given graph with non-ambiguous descriptors.
Remarks
The non-ambiguous descriptors are retrieved from the original descriptors. They describe only one of the possible placements.
This method should be called by a layout algorithm at the beginning of the layout calculation to assure that the label's placement is handled consistently.
Parameters
A map of options to pass to the method.
- graph - Graph
- the input graph
Restores the PreferredPlacementDescriptors of all edge labels in the given graph with their original descriptors.
Remarks
Parameters
A map of options to pass to the method.
- graph - Graph
- the input graph
Static Methods
getEdgeLabelUpVector
(descriptor: PreferredPlacementDescriptor, segmentDirection: Direction) : YVectorCalculates the up vector of an edge label considering the preferred placement of the label as well as the direction of the edge segment the label is attached to.
Parameters
A map of options to pass to the method.
- descriptor - PreferredPlacementDescriptor
- the data describing the preferred label orientation
- segmentDirection - Direction
- the direction the edge segment is pointing to
Returns
- ↪YVector
- the up vector for the edge label that considers the preferred placement of the label as well as the direction of the edge segment the label is attached to
Calculates the up vector for a label whose right vector is rotated clockwise by the given angle.
Remarks
(0, -1)
. The right vector starts at the same point and points right. In a paraxial label it is (1, 0)
.Parameters
A map of options to pass to the method.
- rightVectorAngle - number
- the angle in radians the right vector is rotated by
Returns
- ↪YVector
- the up vector for a label whose right vector is rotated clockwise by the given angle
getOrientedDirection
(direction: Direction, orientation: LayoutOrientation, mirrorMask: MirrorModes) : DirectionTransforms a direction of the layout to the oriented layout direction.
Parameters
A map of options to pass to the method.
- direction - Direction
- direction in the layout
- orientation - LayoutOrientation
- the orientation of the layout
- mirrorMask - MirrorModes
- the mask to determine whether or not the orientation is mirrored
Returns
- ↪Direction
- the direction in the oriented layout
Returns whether or not the orientation is mirrored.
Parameters
A map of options to pass to the method.
- orientation - LayoutOrientation
- the orientation of the layout
- mirrorMask - MirrorModes
- the mask to determine whether or not the orientation is mirrored
Returns
- ↪boolean
true
if the orientation is mirrored,false
otherwise
Calculates and sets the up vector of an edge label considering the preferred placement of the label as well as the direction of the edge segment the label is attached to.
Parameters
A map of options to pass to the method.
- label - LabelLayoutData
- the data that describes the label orientation and is used for setting the new up vector
- segmentDirection - Direction
- the direction the edge segment is pointing to