C

EdgeLabelPreferredPlacement

An EdgeLabelPreferredPlacement describes the preferred placement of edge labels for automatic edge labeling algorithms.
Inheritance Hierarchy

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

NameDefaultDescription
addHalfRotationOnRightSidefalse
Labels are not rotated by an additional 180 degrees.
angle0
angleReferenceLabelAngleReferences.ABSOLUTE
angleRotationOnRightSideLabelAngleOnRightSideRotations.CLOCKWISE
distanceToEdge-1
edgeSideLabelEdgeSides.ON_EDGE
placementAlongEdgeLabelAlongEdgePlacements.AT_CENTER
sideReferenceLabelSideReferences.RELATIVE_TO_EDGE_FLOW

See Also

Developer's Guide

Members

Show:

Constructors

Creates a new EdgeLabelPreferredPlacement instance with default settings.

Parameters

Properties

Gets or sets whether labels that are placed on the right side should be rotated an additional 180 degrees.
final

Throws

Exception ({ name: 'InvalidOperationError' })
if this instance is immutable

Default Value

The default value is: false
Labels are not rotated by an additional 180 degrees.
Gets or sets the angle (in radians) for the label rotation.
How this angle is applied depends on the angleReference, the rotation and the offset for labels on the right side of the edge.
final

Property Value

the angle in radians

Throws

Exception ({ name: 'InvalidOperationError' })
if this instance is immutable

Default Value

The default value is: 0

Sample Graphs

ShownSetting: 0 radians (0 degree) with an absolute angle reference

See Also

Developer's Guide
API
angleReference, angleRotationOnRightSide, addHalfRotationOnRightSide
Gets or sets the reference of the angle given by angle.
conversionfinal

Throws

Exception ({ name: 'InvalidOperationError' })
if this instance is immutable

Default Value

The default value is: LabelAngleReferences.ABSOLUTE

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.
conversionfinal

Throws

Exception ({ name: 'InvalidOperationError' })
if this instance is immutable

Default Value

See Also

Developer's Guide
Gets or sets the preferred distance between a label and the corresponding edge segment.
If the given distance is < 0, the distance is not fixed, i.e., it is chosen by the automatic labeling algorithm.
final

Property Value

preferred distance between a label and the corresponding edge segment

Throws

Exception ({ name: 'InvalidOperationError' })
if this instance is immutable
Exception ({ name: 'ArgumentError' })
if the specified value is infinite or NaN

Default Value

The default value is: -1

Sample Graphs

ShownSetting: 0
Gets or sets the preferred side of the edge.
conversionfinal

Property Value

any combination of the valid sides of the edge

Throws

Exception ({ name: 'InvalidOperationError' })
if this instance is immutable

Default Value

The default value is: LabelEdgeSides.ON_EDGE
Gets or sets the preferred placement along the edge.
Placements AT_SOURCE_PORT and AT_TARGET_PORT that indicate a placement directly at the edge port are currently only supported by HierarchicalLayout.
conversionfinal

Property Value

any combination of the valid positions along the edge

Throws

Exception ({ name: 'InvalidOperationError' })
if this instance is immutable

Default Value

The default value is: LabelAlongEdgePlacements.AT_CENTER
Gets or sets how to interpret the preferred side as given by the edgeSide.
conversionfinal

Property Value

any combination of the valid side references

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

Clones this instance.
Determines whether another object is equal to this one.

Parameters

o: any
the other object to compare for equality

Return Value

boolean
true if o is considered equal to this instance.
Makes this EdgeLabelPreferredPlacement instance immutable.
If this instance is immutable, all setter methods will throw an InvalidOperationError when invoked.
final

See Also

API
isFrozen
Returns a hash code for this object.

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.
If this instance is immutable, all setter methods will throw an InvalidOperationError when invoked.
final

Return Value

boolean
true if this instance is immutable, false otherwise

See Also

API
freeze
Returns a string representation for this object.

Constants

All constants are filtered. Go to Filters.

Static Methods

Returns an immutable preferred placement instance for the specified settings.
Descriptor instances returned by this method will use default values for all properties but placementAlongEdge and edgeSide.
static

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.
This method is not available unless the module view-layout-bridge is loaded. Either load the module 'view-layout-bridge' explicitly or ensure that the LayoutExecutor type is available at runtime.
static

Parameters

labelModel: ILabelModel

Return Value

EdgeLabelPreferredPlacement
A EdgeLabelPreferredPlacement which matches the given ILabelModel as good as possible.

Examples

Configuring preferred placement using a label model
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.
This method is not available unless the module view-layout-bridge is loaded. Either load the module 'view-layout-bridge' explicitly or ensure that the LayoutExecutor type is available at runtime.
static

Parameters

parameter: ILabelModelParameter

Return Value

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 the parameter's type is not known.

Examples

Configuring preferred placement using a label model parameter
layoutData.edgeLabelPreferredPlacements =
  EdgeLabelPreferredPlacement.fromParameter(
    NinePositionsEdgeLabelModel.CENTER_CENTERED,
  )

See Also

Developer's Guide