The interface used in an IGraph implementation for labels.
ImplementsInheritance Hierarchy

Remarks

This interface provides read-only access to the properties of a label. In order to modify the state of an instance use the various methods provided by the IGraph this instance belongs to. Labels are stored in IListEnumerable<ILabel>s, that can be obtained from ILabelOwner implementations' labels property. Typical owners of a label are INode and IEdge instances. Like all items in an IGraph, this item supports the lookup method that can be used to query additional aspects of the item.

Examples

Working with a label in the graph
const graph = graphComponent.graph
const node = graph.createNodeAt(new Point(0, 0))

// add a label to the node
const label = graph.addLabel(
  node,
  'Some Text',
  ExteriorNodeLabelModel.BOTTOM,
)

// the newly created label is part of the graph
console.log(graph.contains(label)) // true
console.log(graph.labels.size) // 1

// the label belongs to its owner
console.log(label.owner === node) // true
console.log(node.labels.size) // 1
console.log(node.labels.get(0) === label) // true

// removing the label removes it from the graph
graph.remove(label)
console.log(graph.contains(label)) // false
console.log(graph.labels.size) // 0
// and from its owner
console.log(node.labels.size) // 0
console.log(label.owner === null) // throws Error!!
Labels cannot live without an owner in the graph
console.log(graph.contains(label)) // true
graph.remove(label.owner)
console.log(graph.contains(label)) // false

See Also

The graph model with all relevant types and their relationships is presented in detail in the section The Graph Model.

Using the look-up mechanism is explained in the section Service Locator Pattern: Lookup.

Developer's Guide

Members

Show:

Properties

Gets the index of the label at its owner.
Gets a snapshot of the current layout of the label.
Labels have a size and are anchored at a given location in world coordinate space. The anchor is the point around which the oriented rectangle is rotated in the world coordinate system. If the oriented rectangle has default orientation, i.e. its up vector points up (<0,-1>), it coincides with its lower left corner. The positioning of the label is determined using a pair of ILabelModel and ILabelModelParameter. In order to modify the layout of a label instance, set another layoutParameter for this label or modify its associated instance.
readonly

See Also

Developer's Guide
API
layoutParameter, getGeometry
Gets the label model's parameter that determines the positioning of this label.

Note that the label model parameter instance associated with a label instance may be shared between multiple label instances and that the modification of this instance or its model will result in a change of the positioning of all labels that are associated with the same parameter or model instance.

To change the layout parameter for instances of the default implementation that were created via the factory methods on IGraph, use the setLabelLayoutParameter method.

readonlyabstract

Examples

Setting the layout parameter of a label
graph.setLabelLayoutParameter(label, InteriorNodeLabelModel.CENTER)
Obtaining the layout parameter of a label
const parameter = label.layoutParameter
Obtaining the layout of a label
const layout = label.layout

See Also

Developer's Guide
API
setLabelLayoutParameter
Gets the owner of this label.
Note that for instances of the default implementation that were created via the factory methods on IGraph, the owner can't be changed after creation and the label has to be deleted and recreated with a new owner.
Labels which are not in a graph might have no owner. Attempting to read this property for those labels results in an exception.
readonlyabstract

Throws

Exception ({ name: 'InvalidOperationError' })
if the label has no owner.

Examples

Relationship between label and label owner
// add a label to the owner
const label = graph.addLabel(owner, 'Some Text')

// the label's Owner property is set to the owner
console.log(label.owner === owner) // true
// the label is in its owner's Labels collection
console.log(owner.labels.includes(label)) // true

See Also

Developer's Guide
API
labels, addLabel

Implemented in

SimpleLabel.owner
Gets the preferred size of the label with respect to its current contents and the implementation of the visualization.

Often the layout's size will be the same as the preferred size, but it's up to the implementation of the ILabelModel to interpret it differently.

To change the preferred size for instances of the default implementation that were created via the factory methods on IGraph, use the setLabelPreferredSize method.

readonlyabstract

Examples

Setting the preferred size of a label
graph.setLabelPreferredSize(label, new Size(width, height))
Obtaining the preferred size of a label
const size = label.preferredSize

See Also

Developer's Guide
API
setLabelPreferredSize, adjustLabelPreferredSize, calculateLabelPreferredSize
Gets the style that is responsible for the visual representation of this node in a CanvasComponent.

Note that the style instance associated with a label instance may be shared between multiple label instances and that the modification of this style will result in a change of the appearance of all labels that are associated with the same style instance.

To change the style for instances of the default implementation that were created via the factory methods on IGraph, use the setStyle method.

readonlyabstract

Examples

Setting the style of a label
graph.setStyle(label, new LabelStyle())
Obtaining the style of a label
const style = label.style

See Also

Developer's Guide
API
setStyle

Implemented in

SimpleLabel.style
Gets or sets the tag object associated with this item instance.
The tag is an optional user-defined object which can be used to store arbitrary data related to this item. The item itself just provides the storage for the object.
abstract

Property Value

The user object associated with this item instance.

Examples

Setting a model item's tag
owner.tag = newTag
Getting the tag from a model item
const tag = owner.tag

See Also

Tags are presented in detail in the section The Graph Model.
Developer's Guide

Defined in

ITagOwner.tag
Gets the text string associated with this label.

It is up to the visualization engine to interpret this property for the visualization of the label. Normally, it will render the text into the layout of this instance.

To change the text for instances of the default implementation that were created via the factory methods on IGraph, use the setLabelText method.

readonlyabstract

Examples

Setting the text of a label
graph.setLabelText(label, 'Some Text')
Obtaining the text of a label
const text = label.text

See Also

Developer's Guide
API
setLabelText

Implemented in

SimpleLabel.text

Methods

Returns an instance that implements the given type or null.
Typically, this method will be called to obtain a different view or aspect of the current instance. This is quite similar to casting or using a super type or interface of this instance, but is not limited to inheritance or compile-time constraints. An instance implementing this method is not required to return non-null implementations for the types, nor does it have to return the same instance any time. Also, it depends on the type and context whether the instance returned stays up to date or needs to be re-obtained for further use.
abstract

Parameters

type: Constructor<T>
the type for which an instance shall be returned

Return Value

T
an instance that is assignable to the type or null

See Also

Developer's Guide

Defined in

ILookup.lookup