EdgeLabelCandidates provides candidates for LayoutEdgeLabels.
Remarks
The created candidates are used by the GenericLabeling algorithm and specify valid candidate positions for the label placement.
Different candidates can be assigned a weight value when adding them, which is propagated to the created candidate's custom weight property and is used to prioritize the candidates.
Type Details
- yFiles module
- algorithms
Constructors
Creates a new, empty EdgeLabelCandidates instance.
Methods
addDiscreteCandidates
(labelPositions: DiscreteEdgeLabelPositions, angle?: number, distance?: number, positionRelativeToEdge?: boolean, autoRotation?: boolean, weight?: number) : EdgeLabelCandidatesAdds a set of candidates that allow placement of rotated edge labels at predefined positions along the edge.
Parameters
A map of options to pass to the method.
- labelPositions - DiscreteEdgeLabelPositions
- The label positions specify the valid positions for the candidates. The positions are interpreted either relative to the edge or in a geometric sense, depending on the value specified for
positionRelativeToEdge
. - angle - number
- The angle (measured in radians) of the label candidates. The angle is applied in a clockwise direction and is interpreted either relative to the label's owner edge or to the horizontal axis, depending on the value specified for
autoRotation
. The default is0.0
. - distance - number
- The distance between the label candidate's bounds and the edge's path. The distance must be a non-negative value. The default is
2.0
. - positionRelativeToEdge - boolean
true
if the label positions should be interpreted relative to the edge,false
if they should be interpreted in a geometric sense. The default isfalse
.- autoRotation - boolean
true
if the label candidates should automatically be rotated relative to the corresponding edge segments,false
otherwise. The default istrue
.- weight - number
- The weight for the created candidates. The weight value can be used to specify priorities between different candidates. The default is
1.0
.
Returns
- ↪EdgeLabelCandidates
- The calling instance of EdgeLabelCandidates
Adds a candidate that describes a label placement at a single fixed position.
Parameters
A map of options to pass to the method.
- box - IOrientedRectangle
- the bounds of the generated edge label candidate
- weight - number
- the weight for the created candidate. The weight value can be used to specify priorities between different candidates. The default is
1.0
.
Returns
- ↪EdgeLabelCandidates
- the calling instance of EdgeLabelCandidates
Adds a set of candidates that describe label placements freely chosen from the area near the label's edge.
Parameters
A map of options to pass to the method.
- weight - number
- the weight for the candidates. The weight value can be used to specify priorities between different candidates. The default is
1.0
.
Returns
- ↪EdgeLabelCandidates
- the calling instance of EdgeLabelCandidates
addSliderCandidates
(mode: EdgeLabelSliderMode, angle?: number, distance?: number, distanceRelativeToEdge?: boolean, autoRotation?: boolean, weight?: number) : EdgeLabelCandidatesAdds a set of candidates that allow placement of edge labels at continuous rotated positions along both sides of an edge or directly on the edge path.
Parameters
A map of options to pass to the method.
- mode - EdgeLabelSliderMode
- the slider mode that determines whether the label slides on the edge, along both sides of the edge or along one side of the edge
- angle - number
- the angle (measured in radians) of the label candidates. The angle is applied in clockwise direction and is interpreted either relative to the label's owner edge or to the horizontal axis, depending on the value specified for
autoRotation
. The default is0.0
. - distance - number
- the distance between the label candidate's box and the edge's path. The interpretation of the distance's sign depends on
distanceRelativeToEdge
. The default is5.0
. - distanceRelativeToEdge - boolean
true
if the sign of thedistance
should be interpreted relative to the edge's path,false
otherwise. The default istrue
.- autoRotation - boolean
true
if the label candidates should automatically be rotated relative to the corresponding edge segments,false
otherwise. The default istrue
.- weight - number
- the weight for the candidates. The weight value can be used to specify priorities between different candidates. The default is
1.0
.
Returns
- ↪EdgeLabelCandidates
- the calling instance of EdgeLabelCandidates
Returns all LabelCandidates that describe valid label positions.
Remarks
Parameters
A map of options to pass to the method.
- label - LayoutEdgeLabel
- the label for which candidates should be generated
Returns
- ↪IEnumerable<LabelCandidate>
- a list of the LabelCandidates that describe valid label positions