The interface used in an IGraph implementation to control the layout of edges.
ImplementsInheritance Hierarchy

Remarks

This interface provides read-only access to the properties of a bend. In order to modify the state of an instance use the various methods provided by the IGraph this instance belongs to. Bends are stored in IListEnumerable<T>s, that can be obtained from the IEdge implementation that owns this bend. 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 bend in the graph
const graph = graphComponent.graph
const node1 = graph.createNodeAt(new Point(0, 0))
const node2 = graph.createNodeAt(new Point(100, 0))
const edge = graph.createEdge(node1, node2)

// add a bend to the edge
const bend = graph.addBend(edge, new Point(50, 20))

// the newly created bend is part of the graph
console.log(graph.contains(bend)) // true

// the bend belongs to its owner
console.log(bend.owner === edge) // true
console.log(edge.bends.size) // 1
console.log(edge.bends.get(0) === bend) // true

// removing the bend removes it from the graph
graph.remove(bend)
console.log(graph.contains(bend)) // false
// and from its owner
console.log(edge.bends.size) // 0
console.log(bend.owner === null) // throws Error!!
Bends cannot live without an owner in the graph
console.log(graph.contains(bend)) // true
graph.remove(bend.owner)
console.log(graph.contains(bend)) // 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 bend at its owner.
readonly

See Also

API
addBend
Gets the location of the bend in the world coordinate system.

Provides a live view of the location which will be updated when the location changes. To keep the current state of the location, callers need to create a copy of it, e.g. by calling toPoint on it.

To change the location for instances of the default implementation that were created via the factory methods on IGraph, use setBendLocation

readonlyabstract

Property Value

The location of the bend.

Examples

Setting the location of a bend
graph.setBendLocation(bend, new Point(x, y))
Getting the location of a bend
const location = bend.location

See Also

API
toPoint, setBendLocation

Implemented in

SimpleBend.location
Gets the edge this bend instance belongs to.

This implies that Owner.Bends contains this instance.

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 bend has to be deleted and recreated with a new owner.

Bends which are not in a graph might have no owner. Attempting to read this property for those bends results in an exception.
readonlyabstract

Property Value

The edge this bend instance belongs to.

Throws

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

Examples

Relationship between bend and edge
// add a bend to the owner
const bend = graph.addBend(edge, new Point(x, y))

// the bend's Owner property is set to the owner
console.log(bend.owner === edge) // true
// the bend is in its owner's Bends collection
console.log(edge.bends.includes(bend)) // true

See Also

API
addBend, bends

Implemented in

SimpleBend.owner
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

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