Remarks
The GenericLabeling algorithm chooses from a set of valid label positions (specified by EdgeLabelCandidates and NodeLabelCandidates, respectively). The LabelingCosts allow specifying preferences on the costs for different types of positions. For example, whether a position where a label crosses an edge should have a high cost and, thus, is less likely chosen by the algorithm (see edgeOverlapCost).
Besides specifying custom LabelingCosts, this class contains several predefined cost configurations that realize different optimization strategies.
Default Values of Properties
| Name | Default |
|---|---|
| ambiguousPlacementCost | 0.0 |
| customPreferenceViolationCost | 1.0 |
| edgeOverlapCost | 1.0 |
| labelOverlapCost | 1.0 |
| layoutGridViolationCost | 1.0 |
| nodeOverlapCost | 1.0 |
| preferredPlacementViolationCost | 1.0 |
See Also
Members
Constructors
Creates a new LabelingCosts instance with default settings.
Creates a new LabelingCosts instance, whose cost values are based on the specified LabelingOptimizationStrategy.
Parameters
- optimizationStrategy: LabelingOptimizationStrategy
- a cost configuration that optimizes for a particular layout quality.
Properties
Default Value
Specifies the cost for a label position that violates the custom preference specified by weight.
If the specified cost is high, label positions with a higher custom preference/weight are more likely chosen by the labeling algorithm. There are multiple ways to specify the weight values, e.g., as a parameter of a predefined candidate set (see addDiscreteCandidates) or by means of property edge label candidate processor or node label candidate processor respectively.
The cost should be a factor between 0 and 1, where 0 means that a violation is considered unimportant and 1 means that an overlap is considered severe.
Throws
- Exception ({ name: 'ArgumentError' })
- if the specified value is outside of
[0,1]
Default Value
0 and 1, where 0 means that an overlap is considered unimportant and 1 means that an overlap is considered severe.Throws
- Exception ({ name: 'ArgumentError' })
- if the specified value is outside of
[0,1]
Default Value
0 and 1, where 0 means that an overlap is considered unimportant and 1 means that an overlap is considered severe.Throws
- Exception ({ name: 'ArgumentError' })
- if the specified value is outside of
[0,1]
Default Value
Specifies the cost for a label position that violates the LayoutGrid.
The cost should be a factor between 0 and 1, where 0 means that a violation is considered unimportant and 1 means that a violation is considered severe.
A label is considered to be violating the layout grid if it is overlapping either the grid lines or, to a lesser extent, the specified padding from those lines. Additionally, this cost applies to placements that lie completely outside the grid bounds.
Throws
- Exception ({ name: 'ArgumentError' })
- if the specified value is outside of
[0,1]
Default Value
0 and 1, where 0 means that an overlap is considered unimportant and 1 means that an overlap is considered severe.Throws
- Exception ({ name: 'ArgumentError' })
- if the specified value is outside of
[0,1]
Default Value
Specifies the cost for a label position that violates the associated EdgeLabelPreferredPlacement.
The cost should be a factor between 0 and 1, where 0 means that a violation is considered unimportant and 1 means that an overlap is considered severe.
As EdgeLabelPreferredPlacements only apply to edge labels, this cost has no effect on candidates for node labels.
Throws
- Exception ({ name: 'ArgumentError' })
- if the specified value is outside of
[0,1]