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
| Name | Default | Description |
|---|---|---|
| addHalfRotationOnRightSide | false | Labels are not rotated by an additional 180 degrees. |
| angle | 0 | |
| angleReference | LabelAngleReferences.ABSOLUTE | |
| angleRotationOnRightSide | LabelAngleOnRightSideRotations.CLOCKWISE | |
| distanceToEdge | -1 | |
| edgeSide | LabelEdgeSides.ON_EDGE | |
| placementAlongEdge | LabelAlongEdgePlacements.AT_CENTER | |
| sideReference | LabelSideReferences.RELATIVE_TO_EDGE_FLOW |
See Also
Developer's Guide
Members
Constructors
Creates a new EdgeLabelPreferredPlacement instance with default settings.
Parameters
Properties
Property Value
Throws
Default Value
Sample Graphs
0 radians (0 degree) with an absolute angle referenceSee Also
Developer's Guide
API
- angleReference, angleRotationOnRightSide, addHalfRotationOnRightSide
Gets or sets the reference of the angle given by angle.
Throws
Default Value
See Also
Developer's Guide
Gets or sets how the angle is applied to labels on the right side with respect to the labels on the left side of the edge.
Throws
Default Value
See Also
Developer's Guide
< 0, the distance is not fixed, i.e., it is chosen by the automatic labeling algorithm.Property Value
Throws
- Exception ({ name: 'InvalidOperationError' })
- if this instance is immutable
- Exception ({ name: 'ArgumentError' })
- if the specified value is infinite or
NaN
Default Value
Sample Graphs
0Gets or sets the preferred side of the edge.
Property Value
Throws
Default Value
Gets or sets the preferred placement along the edge.
Property Value
Throws
Default Value
Gets or sets how to interpret the preferred side as given by the edgeSide.
Property Value
Throws
- Exception ({ name: 'InvalidOperationError' })
- if this instance is immutable
- Exception ({ name: 'ArgumentError' })
- if the specified side reference is invalid
Default Value
See Also
Developer's Guide
Methods
Parameters
- o: any
- the other object to compare for equality
Return Value
- boolean
trueifois considered equal to this instance.
Makes this EdgeLabelPreferredPlacement instance immutable.
setter methods will throw an InvalidOperationError when invoked.See Also
API
- isFrozen
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.
Return Value
- number
- the hash code for this object
Returns whether or not this is an immutable instance of EdgeLabelPreferredPlacement.
setter methods will throw an InvalidOperationError when invoked.Return Value
- boolean
trueif this instance is immutable,falseotherwise
See Also
API
- freeze
Constants
Static Methods
Parameters
- placementAlongEdge: LabelAlongEdgePlacements
- a combination of valid placements along the edge
- edgeSides: LabelEdgeSides
- the preferred sides of the edge
Return Value
- EdgeLabelPreferredPlacement
- an immutable descriptor instance for the specified placement
See Also
API
- isFrozen
Returns an EdgeLabelPreferredPlacement which matches positions supported by the given labelModel.
labelModel.LayoutExecutor type is available at runtime.Parameters
- labelModel: ILabelModel
- The ILabelModel to get an EdgeLabelPreferredPlacement for.
Return Value
- 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,
}),
)See Also
Developer's Guide
Returns an EdgeLabelPreferredPlacement which matches the given parameter best.
parameter best.LayoutExecutor type is available at runtime.Parameters
- parameter: ILabelModelParameter
- The ILabelModelParameter to get an EdgeLabelPreferredPlacement for.
Return Value
- EdgeLabelPreferredPlacement
- An EdgeLabelPreferredPlacement which matches the given ILabelModelParameter as good as possible.
Throws
- Exception ({ name: 'ArgumentError' })
Examples
layoutData.edgeLabelPreferredPlacements =
EdgeLabelPreferredPlacement.fromParameter(
NinePositionsEdgeLabelModel.CENTER_CENTERED,
)See Also
Developer's Guide