Class ParallelEdgeLayout

Extends GraphLayout for arranging parallel edges. This layout works on edges for all pairs of vertices where there is more than one edge connecting the latter.

Example:

const layout = new ParallelEdgeLayout(graph);
layout.execute(graph.getDefaultParent());

To run the layout for the parallel edges of a changed edge only, the following code can be used.

const layout = new ParallelEdgeLayout(graph);

graph.addListener(mxEvent.CELL_CONNECTED, (sender, evt) =>
{
const model = graph.getDataModel();
const edge = evt.getProperty('edge');
const src = model.getTerminal(edge, true);
const trg = model.getTerminal(edge, false);

layout.isEdgeIgnored = (edge2) =>
{
const src2 = model.getTerminal(edge2, true);
const trg2 = model.getTerminal(edge2, false);

return !(model.isEdge(edge2) && ((src == src2 && trg == trg2) || (src == trg2 && trg == src2)));
};

layout.execute(graph.getDefaultParent());
});

Hierarchy (view full)

Constructors

Properties

checkOverlap: boolean = false

Specifies if only overlapping edges should be considered parallel. Default is false.

graph: Graph

Reference to the enclosing Graph.

parent: null | Cell = null

The parent cell of the layout, if any

null
spacing: number = 20

Defines the spacing between the parallels. Default is 20.

useBoundingBox: boolean = true

Boolean indicating if the bounding box of the label should be used if it iss available.

true.

Methods

  • Returns the constraint for the given key and cell. The optional edge and source arguments are used to return inbound and outgoing routing- constraints for the given edge and vertex. This implementation always returns the value for the given key in the style of the given cell.

    Parameters

    • key: string

      Key of the constraint to be returned.

    • cell: Cell

      Cell whose constraint should be returned.

    • Optionaledge: Cell

      Optional Cell that represents the connection whose constraint should be returned. Default is null.

    • Optionalsource: boolean

      Optional boolean that specifies if the connection is incoming or outgoing. Default is null.

    Returns any

  • Returns a unique ID for the given edge. The id is independent of the edge direction and is built using the visible terminal of the given edge.

    Parameters

    Returns null | string

  • Returns true if the given parent is an ancestor of the given child.

    Parameters

    • parent: Cell

      Cell that specifies the parent.

    • child: null | Cell

      Cell that specifies the child.

    • OptionaltraverseAncestors: boolean

      boolean whether to

    Returns boolean

  • Returns a boolean indicating if the given Cell is movable or bendable by the algorithm. This implementation returns true if the given cell is movable in the graph.

    Parameters

    • cell: Cell

      Cell whose movable state should be returned.

    Returns boolean

  • Notified when a cell is being moved in a parent that has automatic layout to update the cell state (eg. index) so that the outcome of the layout will position the vertex as close to the point (x, y) as possible.

    Empty implementation.

    Parameters

    • cell: Cell

      Cell which has been moved.

    • x: number

      X-coordinate of the new cell location.

    • y: number

      Y-coordinate of the new cell location.

    Returns void

  • Sets the new position of the given cell taking into account the size of the bounding box if useBoundingBox is true. The change is only carried out if the new location is not equal to the existing location, otherwise the geometry is not replaced with an updated instance. The new or old bounds are returned (including overlapping labels).

    Parameters

    • cell: Cell

      Cell whose geometry is to be set.

    • x: number

      Integer that defines the x-coordinate of the new location.

    • y: number

      Integer that defines the y-coordinate of the new location.

    Returns null | Rectangle

  • Traverses the (directed) graph invoking the given function for each visited vertex and edge. The function is invoked with the current vertex and the incoming edge as a parameter. This implementation makes sure each vertex is only visited once. The function may return false if the traversal should stop at the given vertex.

    Example:

    GlobalConfig.logger.show();
    const cell = graph.getSelectionCell();
    graph.traverse(cell, false, function(vertex, edge)
    {
    GlobalConfig.logger.debug(graph.getLabel(vertex));
    });

    Parameters

    • __namedParameters: GraphLayoutTraverseArgs

    Returns void