I

IPortOwner

The common interface for items in an IGraph that may own ports.
ImplementsInheritance Hierarchy

Remarks

Typically this interface is actively implemented by INode's in an IGraph. To get to the edge instances that connect to the ports, the edgesAt method can be used. Alternatively, for each IPort in ports, one can use the edgesAt method provided by IGraph. Like all items in an IGraph, this item supports the lookup method that can be used to query additional aspects of the item.

Examples

Relationship between port and port owner
// add a port to the owner
const port = graph.addPort(owner)

// the port's Owner property is set to the owner
console.log(port.owner === owner) // true
// the port is in its owner's Ports collection
console.log(owner.ports.includes(port)) // true

See Also

Developer's Guide

API

INode, IEdge

Members

Show:

Properties

Gets a collection of ports that are owned by this instance.

This gives access to a read-only live view of the ports, i.e. the collection can change over time, as well as the ports contained in it. If a snapshot of the current state is needed, one needs to copy the collection.

To modify the port collection for instances of the default implementations that were created via the factory methods on IGraph, use addPort and remove.

readonlyabstract

Examples

Adding a port to a node.
// add a port at x,y with default style
const port1 = graph.addPortAt(node, new Point(x, y))

const portStyle = new ShapePortStyle({
  shape: ShapeNodeShape.ELLIPSE,
  renderSize: new Size(3, 3),
})

// add a port at x,y with the given style and tag (user object)
const port2 = graph.addPortAt(
  node,
  new Point(x, y),
  portStyle,
  userObject,
)

// add a port at the center of the node with default style
const port3 = graph.addPort(node, FreeNodePortLocationModel.CENTER)

// add a port at the center of the node with the given style and tag (user object)
const port4 = graph.addPort(
  node,
  FreeNodePortLocationModel.CENTER,
  portStyle,
  userObject,
)
Iterating over all ports of a node.
for (const port of node.ports) {
  // ...
}
Removing a port from a node.
graph.remove(port)

See Also

Developer's Guide
API
owner, addPort, remove
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