An abstract base class for generic labeling algorithms which place labels of graphs.
Remarks
Labeling algorithms compute positions for labels in a given graph. The main goal is to place labels such that they do not overlap with other graph elements. Labeling algorithms do not modify positions of nodes and edges.
Concept
Generic labeling algorithms use the model associated with a label (i.e. node label model for nodes and edge label model for edges). The models are necessary to compute a set of LabelCandidates, i.e., candidate positions for a label. Then, one best matching candidate from the set will be selected. This selection depends on several preferences, e.g., if overlaps with nodes are not allowed, candidates encoding overlapping positions will be ignored.
After one LabelCandidate has been chosen, the label model's parameter is used for encoding the label position. Therefore, the result of a generic labeling algorithm is one model parameter per label. The parameter is stored with the label and expresses the label position with respect to the underlying label model.
Features
This class provides a general frame, offering functionality which can be shared by other generic labeling algorithms.
To only place labels or a subset of labels, the main labeling methods label, label and label are offered.
As this class represents an LayoutStageBase, it allows usage as a generic labeling stage. By combining it with a core layouter, the labeling will take place after the core layouter was executed (applyLayout). This is especially useful if the core layouter does not support label handling.
Default Values of Properties
affectedLabelsDpKey | null | All labels are considered to be selected. |
autoFlipping | false | Edge labels being upside-down keep their orientation. |
edgeGroupOverlapAllowed | false | Edge labels are not allowed to overlap with edges of the same edge group. |
placeEdgeLabels | true | Edge labels will be placed. |
placeNodeLabels | true | Node labels will be placed. |
profitModel | SimpleProfitModel
| |
removeEdgeOverlaps | false | Candidates overlapping with edges are allowed. |
removeNodeOverlaps | false | Candidates overlapping with nodes are allowed. |
Type Details
- yfiles module
- layout-core
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.labeling.LabelingBase
Constructors
Creates a new LabelingBase instance with default settings.
Properties
Gets or sets the IDataProvider key to mark labels as selected for placement.
Remarks
If a IDataProvider is registered with this key, only the selected labels will be placed, while all other labels are considered fixed.
The registered IDataProvider needs to map from ILabelLayout to boolean where true
indicates that a label should be placed and false
indicates that a label should be ignored.
Default Value
null
.All labels are considered to be selected.
See Also
Gets or sets whether or not edge labels are automatically flipped if otherwise they would be upside-down.
Default Value
false
.Edge labels being upside-down keep their orientation.
See Also
Sample Graphs
Gets or sets the core layout algorithm that is wrapped by this stage.
Gets or sets whether or not edge labels may overlap with edges belonging to the same edge group as the label's edge.
Remarks
Default Value
false
.Edge labels are not allowed to overlap with edges of the same edge group.
See Also
Sample Graphs
Gets or sets whether or not internal node labels are allowed to move.
Remarks
Default Value
false
.Internal node labels will not be moved.
Sample Graphs
Gets or sets whether or not labels assigned to edges are placed.
Default Value
true
.Edge labels will be placed.
See Also
Gets or sets whether or not labels assigned to nodes are placed.
Default Value
true
.Node labels will be placed.
See Also
Gets or sets the IProfitModel for ranking the LabelCandidates for labels.
Remarks
The profit model is used when calculating the profit of a candidate.
The higher the profit (rank) of a candidate is, the more likely it will be chosen as actual position by the algorithm.
Default Value
SimpleProfitModel.See Also
Gets or sets whether or not a post-processing step to further reduce the number of label overlaps is applied.
Default Value
false
.Post-processing to reduce overlaps is disabled.
Gets or sets whether or not label candidates that overlap with edges are removed.
Remarks
If overlapping candidates are not removed, they will be considered but get a penalty. Therefore, it is still less likely that an overlapping candidate is finally chosen.
The detection and removal of labels that overlap with edges may increase the runtime of this algorithm.
Default Value
false
.Candidates overlapping with edges are allowed.
Sample Graphs
Gets or sets whether or not label candidates that overlap with nodes are removed.
Remarks
If overlapping candidates are not removed, they will be considered but get a penalty. Therefore, it is still less likely that an overlapping candidate is finally chosen.
The detection and removal of labels that overlap with nodes may increase the runtime of this algorithm.
Default Value
false
.Candidates overlapping with nodes are allowed.
Sample Graphs
Methods
Places the labels in the graph after first executing the core layouter.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Implements
Invokes the layout process of the core layout algorithm.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Defined in
Returns the profit for placing a LabelCandidate with respect to the current profit model.
Remarks
Method getProfit on the current profit model will be invoked to compute the actual profit value.
The higher the profit (rank) of a candidate is, the more likely it will be chosen as actual position by the algorithm.
Parameters
A map of options to pass to the method.
- candidate - LabelCandidate
- a label candidate
Returns
- ↪number
- the profit value between
0
and1
Places the labels of the input graph using a IDataProvider registered to the input graph with the given key for determining which labels to place.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The input graph.
- key - Object
- The optional IDataProvider key for label selection. If not specified, the current selection key is used.
Places the labels of the input graph restricting the placement to labels contained in the given lists.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
- nodeLabels - YList
- a list of INodeLabelLayouts defining the set of node labels that will be placed
- edgeLabels - YList
- a list of IEdgeLabelLayouts defining the set of edge labels that will be placed
Constants
A data provider key for mapping models to edge/node labels.
Remarks
Domain | ILabelLayout | |
Values | Object | an null if the original model of a label should be used |