Provides costs that influence the GenericLabeling algorithm during the ranking of different label positions.
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
ambiguousPlacementCost | 0.0 | |
customPreferenceViolationCost | 1.0 | |
edgeOverlapCost | 1.0 | |
labelOverlapCost | 1.0 | |
layoutGridViolationCost | 1.0 | |
nodeOverlapCost | 1.0 | |
preferredPlacementViolationCost | 1.0 |
Type Details
- yFiles module
- algorithms
See Also
Constructors
Creates a new LabelingCosts instance with default settings.
Creates a new LabelingCosts instance, whose cost values are based on the specified LabelingOptimizationStrategy.
Parameters
A map of options to pass to the method.
- optimizationStrategy - LabelingOptimizationStrategy
- a cost configuration that optimizes for a particular layout quality.
Properties
Specifies the cost for a label position that is ambiguous with respect to its associated owner element.
Remarks
Default Value
0.0
.Specifies the cost for a label position that violates the custom preference specified by weight.
Remarks
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.
Default Value
1.0
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified value is outside of
[0,1]
Specifies the cost for a label position that overlaps with an edge.
Remarks
0
and 1
, where 0
means that an overlap is considered unimportant and 1
means that an overlap is considered severe.Default Value
1.0
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified value is outside of
[0,1]
Specifies the cost for a label position that overlaps with another label.
Remarks
0
and 1
, where 0
means that an overlap is considered unimportant and 1
means that an overlap is considered severe.Default Value
1.0
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified value is outside of
[0,1]
Specifies the cost for a label position that violates the LayoutGrid.
Remarks
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.
Default Value
1.0
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified value is outside of
[0,1]
Specifies the cost for a label position that overlaps the box of a node.
Remarks
0
and 1
, where 0
means that an overlap is considered unimportant and 1
means that an overlap is considered severe.Default Value
1.0
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified value is outside of
[0,1]
Specifies the cost for a label position that violates the associated EdgeLabelPreferredPlacement.
Remarks
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.
Default Value
1.0
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified value is outside of
[0,1]