Implements
- I
- I
- I
Remarks
Like all items in an
IGraph, this item supports the lookup method that can be used to query additional aspects of the item.Examples
// 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)) // trueSee Also
Members
Show:
Properties
Gets a collection of labels that are owned by this instance.
Gets a collection of labels that are owned by this instance.
This gives access to a read-only live view of the labels, i.e. the collection can change over time, as well as the labels contained in it. If a snapshot of the current state is needed, one needs to copy the collection and its contents.
To modify the label collection for instances of the default implementations that were created via the factory methods on IGraph, use addLabel and remove.
readonlyabstract
Examples
// add label with given text, default style, and default placement
// and determine the preferred size automatically
const label1 = graph.addLabel(node, 'Some Label')
// add label with given text, placement, style, size, and tag (user object)
const label2 = graph.addLabel(
node,
'Some Label',
InteriorNodeLabelModel.CENTER,
new LabelStyle(),
new Size(10, 150),
userObject,
)
// add label with given text and style but default placement
// and determine the preferred size automatically
const label3 = graph.addLabel({
owner: node,
text: 'Some Label',
style: new LabelStyle(),
})for (const label of node.labels) {
// ...
}graph.remove(label)See Also
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
owner.tag = newTagconst tag = owner.tagSee Also
- Tags are presented in detail in the section The Graph Model.
Developer's Guide
Defined in
ITagOwner.tagMethods
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