Options
Public/Protected
  • Public
  • Public/Protected
  • All
Menu

GoJS API 文档

Hierarchy

This provides an abstract view of a diagram as a network (graph) of vertexes and directed edges. The network contains vertexes and edges corresponding to Nodes and Links.

This class provides a framework for manipulating the state of nodes and links without modifying the structure of the diagram. Having a separate representation also permits adding or removing vertexes or edges from the network so that the graph that is laid out is not isomorphic to the diagram's graph.

For each kind of layout that uses a LayoutNetwork there is a subclass of LayoutVertex and a subclass of LayoutEdge:

Modifying a LayoutNetwork or a LayoutVertex or a LayoutEdge does not invalidate the Layout or raise any changed events.

Index

Constructors

constructor

  • This constructs an empty network. It is commonplace to call addParts to build up the network to have the same structure as a Diagram's or Group's nodes and links.

    Parameters

    Returns LayoutNetwork

Properties

Read-only edges : Set<LayoutEdge>

layout : Layout

Read-only vertexes : Set<LayoutVertex>

Methods

addEdge

  • Adds a LayoutEdge to the network. Although this method is provided for completeness, linkVertexes provides a more efficient manner of linking vertexes already in the network.

    Parameters

    Returns void

addLink

addNode

  • This convenience method makes sure there is a LayoutVertex in this network corresponding to a Node.

    Parameters

    Returns LayoutVertex

    a vertex in this network.

addParts

  • addParts(parts: Iterable<Part>, toplevelonly?: boolean, pred?: function(a: Part): boolean | null): void
  • Creates a network of LayoutVertexes and LayoutEdges corresponding to the given Nodes and Links. This is usually more convenient than repeatedly calling addNode and addLink. This method ignores all instances of Parts that are not Nodes or Links. This will recurse through Groups that have no Group.layout.

    Parameters

    • parts: Iterable<Part>

      A collection of Nodes or Links.

    • Optional toplevelonly: boolean

      whether to skip Parts in the given collection that are contained by Groups; default is false

    • Optional pred: function(a: Part): boolean | null

      optional predicate to apply to each Part -- if it returns false do not include Vertex or Edge in the network; default ignores link label nodes or links connecting with them

    Returns void

addVertex

Virtual createEdge

  • Allocate a new instance of LayoutEdge. This is overridden in LayoutNetwork subclasses to create instances of subclasses of LayoutEdge. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

    Returns LayoutEdge

Virtual createVertex

  • Allocate a new instance of LayoutVertex. This is overridden in LayoutNetwork subclasses to create instances of subclasses of LayoutVertex. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

    Returns LayoutVertex

Virtual deleteArtificialVertexes

  • deleteArtificialVertexes(): void
  • Deletes all vertexes and edges that have no Part associated with them.

    Returns void

deleteEdge

deleteLink

  • deleteLink(link: Link): void
  • This convenience method deletes from this network any LayoutEdge corresponding to a Link.

    Parameters

    Returns void

deleteNode

  • deleteNode(node: Node): void
  • This convenience method deletes any LayoutVertex corresponding to a Node.

    Parameters

    Returns void

deleteSelfEdges

  • deleteSelfEdges(): void
  • Deletes all LayoutEdges whose "to vertex" and "from vertex" are the same vertex.

    Returns void

deleteVertex

  • Removes a LayoutVertex from the network. This function also deletes all edges to or from the vertex.

    Parameters

    Returns void

findAllParts

findEdge

  • Returns the LayoutEdge that was constructed for the Link.

    Parameters

    Returns LayoutEdge | null

    an edge in this network, or null if no such edge exists.

findVertex

  • Returns the LayoutVertex that was constructed for the Node.

    Parameters

    Returns LayoutVertex | null

    a vertex in this network, or null if no such vertex exists.

linkVertexes

reverseEdge

splitIntoSubNetworks

  • Modify this network by splitting it up into separate subnetworks, each of which has all of its vertexes connected to each other, but not to any vertexes in any other subnetworks.

    This method will first delete from this network all artificial vertexes and all edges that do not connect two different vertexes. Afterwards, this original network may be empty or may contain all of the singleton vertexes, each of which had no edges connecting it to any other vertexes.

    Parameters

    • Optional clean: boolean

      whether to delete artificial vertexes and edges, disconnected edges, and reflexive edges; default is true

    Returns List<LayoutNetwork>

    a collection of LayoutNetworks, sorted in order of decreasing vertex count.

加入 GoJS 交流群
GoJS 交流群 (769862113)