Labels
A label adds information to a graph element by providing a caption. It is modeled by interface ILabel. It has to belong to (i.e. added to) a label owner, modeled by the ILabelOwner interface. The three interfaces INode, IEdge, and IPort extend this interface. In this manual we sometimes refer to labels at nodes, edges, and ports as node labels, edge labels, and port labels, respectively. Note that a label owner can have an arbitrary number of labels.
Interface ILabel exposes the following read-only properties which can be modified by IGraph’s methods:
Property | Setter Method | Description |
---|---|---|
The following image shows labels at nodes and edges with different styles and location model parameters. Note that edge labels can be axis-aligned or rotated with the edge, depending on their label model. See the section about label models.
Even though labels are kept in their owner’s labels collection, you can only add or remove them by using IGraph’s methods.
- addLabel
- Creates a new label for the given owner. The new label’s properties will get the default values as defined in the label defaults if they are not passed as parameters.
- remove(item: IModelItem): void
- Removes the given label from the graph.
You can only modify or remove labels which are part of the current graph instance. Trying to modify or remove a label 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 labels only with the graph the label belongs to.