documentationfor yFiles for HTML 2.6

Ports

Ports are structural elements since edges connect to ports at their source and target end. They always have to belong to a node or edge, or, more generally, to a port owner. The port owner is modeled by the IPortOwner interface which is a super interface for both INode and IEdge.

IPorts and IPortOwner

Note that a port owner can hold an arbitrary number of ports. Also note that ports can exist without edges linking to them, e.g. to provide potential connection points in an interactive scenario.

Besides their structural role they also provide a geometry, i.e. a location, and a style (i.e. a visual information, although ports are invisible by default):

Property Setter Method Description
IPort.ownercannot be modified after creationThe node or edge with which this port is associated.
IPort.locationParameterIGraph.setPortLocationParameterThe IPortLocationModelParameter which defines the location of the port. See the section about port location models.
IPort.styleIGraph.setStyleThe port’s style. See section Visualization of Graph Elements: Styles.
IPort.labelsIGraph.addLabelThe collection of labels which are associated with this port.
IPort.tagIPort.tagAn object of arbitrary type which can be used to bind user data to this port. See Storing Business Data for Graph Elements.

Similar to the other graph items, you can only create or remove ports using methods provided by IGraph.

addPortAt
addPort
Creates a new port for the given owner. The new port’s properties will get the default values as defined in the port defaults if they are not passed as parameters.
remove(item: IModelItem): void
Removes the given port from the graph. Before the port is removed all adjacent edges are removed, too.

You can only modify or remove ports which are part of the current graph instance. Trying to modify or remove a port which already has been removed will result in an exception. Also, if your use case involves several IGraph instances (especially if you are using filtering or folding) take care to modify and remove ports only with the graph the port belongs to.