An EdgeLabelPreferredPlacement describes the preferred placement of edge labels for automatic edge labeling algorithms.
Remarks
It provides several options that influence the label placement in generic labeling algorithms and layout algorithms that support integrated label placement.
The preferred placement can describe multiple locations. For some options, like placementAlongEdge, it is possible to have a combination of the valid values. These values can be connected with a logical or
-operation.
The following options describe the preferred placement:
- the placement along the edge
- the side of the edge
- the reference of the side
- the distance between the label and its edge segment
- the rotation angle of the label
- the reference for the rotation angle
- the rotation behavior for labels on the right side of the edge
- the angle offset for labels on the right side of the edge
A EdgeLabelPreferredPlacement can be set for each label using layout data properties offered on the layout data instances of the respective layout algorithm, for example, edgeLabelPreferredPlacements, edgeLabelPreferredPlacements, edgeLabelPreferredPlacements.
When working without layout data instance and with LayoutGraph directly, instances can be defined via an IMapper<K,V> registered with key EDGE_LABEL_PREFERRED_PLACEMENT_DATA_KEY.
Default Values of Properties
addHalfRotationOnRightSide | false | Labels are not rotated by an additional 180 degrees. |
angle | 0 | |
angleReference | ABSOLUTE
| |
angleRotationOnRightSide | CLOCKWISE
| |
distanceToEdge | -1 | |
edgeSide | ON_EDGE
| |
placementAlongEdge | AT_CENTER
| |
sideReference | RELATIVE_TO_EDGE_FLOW
|
Type Details
- yFiles module
- algorithms
Constructors
Creates a new EdgeLabelPreferredPlacement instance with default settings.
Parameters
A map of options to pass to the method.
- placementAlongEdge - LabelAlongEdgePlacements
- The preferred placement along the edge. This option sets the placementAlongEdge property on the created object.
- edgeSide - LabelEdgeSides
- The preferred side of the edge. This option sets the edgeSide property on the created object.
- sideReference - LabelSideReferences
- How to interpret the preferred side as given by the edgeSide. This option sets the sideReference property on the created object.
- angle - number
- The angle (in radians) for the label rotation. This option sets the angle property on the created object.
- angleReference - LabelAngleReferences
- The reference of the angle given by angle. This option sets the angleReference property on the created object.
- angleRotationOnRightSide - LabelAngleOnRightSideRotations
- How the angle is applied to labels on the right side with respect to the labels on the left side of the edge. This option sets the angleRotationOnRightSide property on the created object.
- addHalfRotationOnRightSide - boolean
- Whether labels that are placed on the right side should be rotated an additional
180
degrees. This option sets the addHalfRotationOnRightSide property on the created object. - distanceToEdge - number
- The preferred distance between a label and the corresponding edge segment. This option sets the distanceToEdge property on the created object.
Properties
Gets or sets whether labels that are placed on the right side should be rotated an additional 180
degrees.
Default Value
false
.Labels are not rotated by an additional 180
degrees.
Throws
- Exception({ name: 'InvalidOperationError' })
- if this instance is
Gets or sets the angle (in radians) for the label rotation.
Remarks
Default Value
0
.Property Value
Throws
- Exception({ name: 'InvalidOperationError' })
- if this instance is
See Also
Sample Graphs
Gets or sets the preferred distance between a label and the corresponding edge segment.
Remarks
< 0
, the distance is not fixed, i.e., it is chosen by the automatic labeling algorithm.Default Value
-1
.Property Value
Throws
- Exception({ name: 'InvalidOperationError' })
- if this instance is
- Exception({ name: 'ArgumentError' })
- if the specified value is infinite or
NaN
Sample Graphs
Gets or sets the preferred placement along the edge.
Default Value
AT_CENTER.Property Value
Throws
- Exception({ name: 'InvalidOperationError' })
- if this instance is
Gets or sets how to interpret the preferred side as given by the edgeSide.
Default Value
RELATIVE_TO_EDGE_FLOW.Property Value
Throws
Methods
Clones this instance.
Returns
- ↪any
- A new member-wise clone, or
this
if this instance is already frozen.
Makes this EdgeLabelPreferredPlacement instance immutable.
Remarks
setter
methods will throw an InvalidOperationError when invoked.See Also
Returns a hash code for this object.
Remarks
The hash code is a numeric value that can be used to treat this object as a key in a hash table or similar data structure.
Two objects that are considered equal must have the same hash code. However, the reverse does not hold and two objects having the same hash code don't have to be equal. Ideally, the hash code should be roughly uniformly-distributed to prevent hash tables from performing poorly. Calculating the hash code is also a potentially frequent operation and should therefore be fast.
Returns
- ↪number
- the hash code for this object
Returns whether or not this is an immutable instance of EdgeLabelPreferredPlacement.
Remarks
setter
methods will throw an InvalidOperationError when invoked.Returns
- ↪boolean
true
if this instance is immutable,false
otherwise
See Also
Constants
A data key for specifying the preferred placement of the edge labels.
Remarks
See Also
Static Methods
Returns an EdgeLabelPreferredPlacement which matches positions supported by the given labelModel
.
Parameters
A map of options to pass to the method.
- labelModel - ILabelModel
- The ILabelModel to get an EdgeLabelPreferredPlacement for.
Returns
- ↪EdgeLabelPreferredPlacement
- A EdgeLabelPreferredPlacement which matches the given ILabelModel as good as possible.
Examples
layoutData.edgeLabelPreferredPlacements =
EdgeLabelPreferredPlacement.fromModel(
new EdgePathLabelModel({
distance: 10,
angle: Math.PI / 2,
autoRotation: true,
sideOfEdge: EdgeSides.LEFT_OF_EDGE | EdgeSides.RIGHT_OF_EDGE,
}),
)
LayoutExecutor
type is available at runtime.Returns an EdgeLabelPreferredPlacement which matches the given parameter
best.
Parameters
A map of options to pass to the method.
- parameter - ILabelModelParameter
- The ILabelModelParameter to get an EdgeLabelPreferredPlacement for.
Returns
- ↪EdgeLabelPreferredPlacement
- An EdgeLabelPreferredPlacement which matches the given ILabelModelParameter as good as possible.
Throws
- Exception({ name: 'ArgumentError' })
- If the given
parameter
has a known model but theparameter
's type is not known.
Examples
layoutData.edgeLabelPreferredPlacements =
EdgeLabelPreferredPlacement.fromParameter(
NinePositionsEdgeLabelModel.CENTER_CENTERED,
)
LayoutExecutor
type is available at runtime.