Class NetworkLayout<N, V, E, Y>

GoDiagram®
v10.0.12
by Northwoods Software®

NetworkLayouts can be used to create more complicated layouts using Network<V, E, Y>s.

Namespace: Northwoods.Go.Layouts
Assembly: Northwoods.GoDiagram.Avalonia.dll
Syntax
public abstract class NetworkLayout<N, V, E, Y> : Layout where N : Network<V, E, Y> where V : Network<V, E, Y>.Vertex where E : Network<V, E, Y>.Edge where Y : NetworkLayout<N, V, E, Y>
Type Parameters
Name Description
N
V
E
Y
Remarks

More complicated layouts make use of a separate Network<V, E, Y> - consisting of Network<V, E, Y>.Vertexes and Network<V, E, Y>.Edges - that normally holds a graph that is isomorphic to the graph consisting of Nodes and Links in the Diagram or Group. DoLayout(IEnumerable<Part>) will call MakeNetwork(IEnumerable<Part>) and remember the result as the Network. MakeNetwork(IEnumerable<Part>) will call CreateNetwork() and initialize it by adding new instances of vertexes and edges corresponding to the given collection of Nodes and Links.

When DoLayout(IEnumerable<Part>) is finished with its work it will call UpdateParts(), which will call CommitLayout() to set new node locations and route links. It then normally discards the Network.

The vertex and edge instances allow the layout to work with more information about each Node and Link without actually modifying those Nodes and Links until CommitLayout() is called to actually set the Node locations and route the Links. The use of a network also allows the layout to work with a graph that is not isomorphic to the given collection of Nodes and Links. This is useful when needing to use dummy vertexes and/or edges to achieve certain layout behaviors, or when one wants to ignore certain vertexes or edges, without actually modifying or adding or removing the diagram's nodes or links.

Constructors

NetworkLayout()

This constructs a NetworkLayout with no initial network.

Declaration
public NetworkLayout()

Properties

Network

Gets or sets the Network<V, E, Y> used by this Layout, if any.

Declaration
public N Network { get; set; }
Property Value
Type Description
N
Remarks

The default value is null. Setting this property does not invalidate this layout. Call CreateNetwork() or MakeNetwork(IEnumerable<Part>) to create a network.

Methods

CommitLayout()

Commit changes to the diagram by setting Node positions and by routing the Links. This is called by UpdateParts() within a transaction.

Declaration
protected virtual void CommitLayout()
Remarks

You should not call this method -- it is a "protected virtual" method. This may be overridden by subclasses of NetworkLayout. By default this method is implemented as follows:

protected virtual void CommitLayout() {
  if (Network == null) return;
  foreach (var vert in Network.Vertexes) {
    vert.Commit();
  }
  if (IsRouting) {
    foreach (var edge in Network.Edges) {
      edge.Commit();
    }
  }
}

Please read the Introduction page on Extensions for how to override methods and how to call this base method.

CreateNetwork()

Declaration
public virtual N CreateNetwork()
Returns
Type Description
N

a new instance of a Network<V, E, Y>.

Remarks

This may be overridden in subclasses to create instances of subclasses of Network<V, E, Y>. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

MakeNetwork(IEnumerable<Part>)

Create and initialize a Network<V, E, Y>. This is called by DoLayout(IEnumerable<Part>).

Declaration
public virtual N MakeNetwork(IEnumerable<Part> coll = null)
Parameters
Type Name Description
IEnumerable<Part> coll

the collection of Parts for initialization. If none is supplied, this will build a network from the Diagram, or Group, if one is set.

Returns
Type Description
N

the value of a call to CreateNetwork() initialized by vertexes and edges from the collection.

Remarks

This method calls CreateNetwork() to allocate the network. This may be overridden in NetworkLayout subclasses to customize the initialization. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

UpdateParts()

Update the "physical" node positionings and link routings. This should be called by DoLayout(IEnumerable<Part>).

Declaration
public virtual void UpdateParts()
Remarks

This calls CommitLayout() to actually set Node positions and route Links. This performs the changes within a transaction. Please read the Introduction page on Extensions for how to override methods and how to call this base method.