gojs
Version:
Interactive diagrams, charts, and graphs, such as trees, flowcharts, orgcharts, UML, BPMN, or business diagrams
797 lines (796 loc) • 67.2 kB
HTML
<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>ForceDirectedLayout | GoJS API</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../assets/css/bootstrap.min.css">
<link rel="stylesheet" href="../assets/css/main.css">
</head>
<body>
<header>
<!-- non-fixed navbar -->
<nav id="non-fixed-nav" class="navbar navbar-inverse navbar-top">
<div class="container-fluid">
<div class="navbar-header">
<div class="navheader-container">
<div class="navheader-collapse" data-toggle="collapse" data-target="#navbar">
<a id="toplogo" class="navbar-brand" href="../../index.html">GoJS</a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
</div>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="../../index.html">Home</a></li>
<li><a href="../../learn/index.html">Learn</a></li>
<li><a href="../../samples/index.html">Samples</a></li>
<li><a href="../../intro/index.html">Intro</a></li>
<li><a href="../../api/index.html" target="api">API</a></li>
<li><a href="https://www.nwoods.com/components/evalform.htm">Register</a></li>
<li><a href="../../download.html">Download</a></li>
<li><a href="https://forum.nwoods.com/c/gojs">Forum</a></li>
<li><a href="https://www.nwoods.com/contact.html" onclick="ga('send','event','Outbound Link','click','contact');">Contact</a></li>
<li class="buy"><a href="https://www.nwoods.com/sales/index.html" onclick="ga('send','event','Outbound Link','click','buy');">Buy</a></li>
<li class="activate"><a href="https://www.nwoods.com/app/activate.aspx?sku=gojs">Activate</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="tsd-page-header">
<div class="tsd-page-toolbar">
<div class="container-fluid plr15">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="../assets/js/search.js" data-base="..">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="../index.html" class="title">GoJS API</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container-fluid plr15">
<div class="top-copyright">
<!--<b>GoJS</b>® Diagramming Components<br/>version <br/>version 2.1.18 for TypeScript/HTML<br/>by <a href="https://www.nwoods.com/">Northwoods Software®</a>-->
<b>GoJS</b>® Diagramming Components<br/>version 2.1.18<br/>by <a href="https://www.nwoods.com/">Northwoods Software®</a>
</div>
<div>
<h1>Class ForceDirectedLayout</h1>
</div>
</div>
</div>
</div>
</header>
<div class="container-fluid container-main plr15">
<div class="row">
<div class="col-8 col-content">
<section class="tsd-panel tsd-hierarchy">
<h3>Hierarchy</h3>
<ul class="tsd-hierarchy">
<li>
<a href="Layout.html" class="tsd-signature-type">Layout</a>
<ul class="tsd-hierarchy">
<li>
<span class="target">ForceDirectedLayout</span>
</li>
</ul>
</li>
</ul>
</section>
<section class="tsd-panel tsd-comment">
<div class="tsd-comment tsd-typography">
<p>Force-directed layout treats the graph as if it were a system of physical bodies
with repulsive electrical, attractional gravitational, and spring forces acting on them and between them.</p>
<p>Electrical forces come both from the field at the vertex's location as well as from neighboring vertexes and are quadratic by distance.
Gravitational forces come from the field at the vertex's location and are constant.
Spring forces are only exerted between two different vertexes that are connected by an edge and are linear by distance.</p>
<p>The electrical forces on a vertex are the sum of the electrical charge times the electrical field at that location
(<a href="ForceDirectedLayout.html#electricalCharge">electricalCharge</a>, <a href="ForceDirectedLayout.html#electricalFieldX">electricalFieldX</a>, <a href="ForceDirectedLayout.html#electricalFieldY">electricalFieldY</a>)
and the electrical forces of all nearby vertexes divided by the square of the distance between them.
You can easily assign the electrical charge for all vertexes by assigning <a href="ForceDirectedLayout.html#defaultElectricalCharge">defaultElectricalCharge</a>.
By default there is no electrical field, so all forces are due to nearby charged vertexes.
For efficiency, <a href="ForceDirectedLayout.html#infinityDistance">infinityDistance</a> determines a cut-off distance between vertexes for which to consider any influence.</p>
<p>The gravitational forces on a vertex are the sum of the gravitational mass times the gravitational field at that location
(<a href="ForceDirectedLayout.html#gravitationalMass">gravitationalMass</a>, <a href="ForceDirectedLayout.html#gravitationalFieldX">gravitationalFieldX</a>, <a href="ForceDirectedLayout.html#gravitationalFieldY">gravitationalFieldY</a>).
You can easily assign the gravitational mass for all vertexes by assigning <a href="ForceDirectedLayout.html#defaultGravitationalMass">defaultGravitationalMass</a>.
By default there is no gravitational field.</p>
<p>The spring forces on a vertex are only exerted by the edges connecting it with other vertexes.
The force along an edge is the stiffness of the spring times the difference of the distance between the vertexes and the nominal length of the spring
(<a href="ForceDirectedLayout.html#springStiffness">springStiffness</a>, <a href="ForceDirectedLayout.html#springLength">springLength</a>) divided by the distance between the vertexes.
When the distance is less than the nominal length, the force pushes the vertexes apart; when the distance is greater, the force pulls them together.
You can easily assign the spring length and stiffness for all edges by assigning <a href="ForceDirectedLayout.html#defaultSpringLength">defaultSpringLength</a> and <a href="ForceDirectedLayout.html#defaultSpringStiffness">defaultSpringStiffness</a>.</p>
<p>When the distance between two vertexes is less than one unit, this uses a random number generator to decide which direction the forces should go.
For layouts that start with all of the vertexes at the same location, this results in potentially dramatically different results.
Set <a href="ForceDirectedLayout.html#randomNumberGenerator">randomNumberGenerator</a> to null in order to produce reproducible results given the same initial vertex locations.</p>
<p>The algorithm seeks a configuration of the bodies with locally minimal energy,
i.e. vertex positions such that the sum of the forces on each vertex is zero.
This is achieved by repeatedly computing the forces on each vertex, moving them, and repeating.
Computations stop when no vertex moves more than <a href="ForceDirectedLayout.html#epsilonDistance">epsilonDistance</a> or when <a href="ForceDirectedLayout.html#maxIterations">maxIterations</a> have happened.</p>
<p>The layout cannot guarantee that it provides optimal positioning of nodes.
Nodes will normally not overlap each other, but when there is a dense interconnectivity overlaps might not be avoidable.</p>
<p class="boxrun">
If you want to experiment interactively with most of the properties, try the <a href="../../samples/fdLayout.html">Force Directed Layout</a> sample.
See samples that make use of ForceDirectedLayout in the <a href="../../samples/index.html#forcedirectedlayout">samples index</a>.
<p>This layout makes use of a <a href="LayoutNetwork.html">LayoutNetwork</a> of
<a href="ForceDirectedVertex.html">ForceDirectedVertex</a>es and <a href="ForceDirectedEdge.html">ForceDirectedEdge</a>s that normally
correspond to the <a href="Node.html">Node</a>s and <a href="Link.html">Link</a>s of the <a href="Diagram.html">Diagram</a>.</p>
</div>
</section>
<section class="tsd-panel-group tsd-index-group">
<h2>Index</h2>
<section class="tsd-panel tsd-index-panel">
<div class="tsd-index-content">
<section class="tsd-index-section ">
<h3>Constructors</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-constructor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#constructor" class="tsd-kind-icon">constructor</a></li>
</ul>
</section>
<section class="tsd-index-section ">
<h3>Properties</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#arrangementSpacing" class="tsd-kind-icon">arrangement<wbr>Spacing</a></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#arrangesToOrigin" class="tsd-kind-icon">arranges<wbr>ToOrigin</a></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#comments" class="tsd-kind-icon">comments</a></li>
<li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="ForceDirectedLayout.html#currentIteration" class="tsd-kind-icon">current<wbr>Iteration</a></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#defaultCommentElectricalCharge" class="tsd-kind-icon">default<wbr>Comment<wbr>Electrical<wbr>Charge</a></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#defaultCommentSpringLength" class="tsd-kind-icon">default<wbr>Comment<wbr>Spring<wbr>Length</a></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#defaultElectricalCharge" class="tsd-kind-icon">default<wbr>Electrical<wbr>Charge</a></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#defaultGravitationalMass" class="tsd-kind-icon">default<wbr>Gravitational<wbr>Mass</a></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#defaultSpringLength" class="tsd-kind-icon">default<wbr>Spring<wbr>Length</a></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#defaultSpringStiffness" class="tsd-kind-icon">default<wbr>Spring<wbr>Stiffness</a></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#epsilonDistance" class="tsd-kind-icon">epsilon<wbr>Distance</a></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#infinityDistance" class="tsd-kind-icon">infinity<wbr>Distance</a></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#maxIterations" class="tsd-kind-icon">max<wbr>Iterations</a></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#moveLimit" class="tsd-kind-icon">move<wbr>Limit</a></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#randomNumberGenerator" class="tsd-kind-icon">random<wbr>Number<wbr>Generator</a></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><a href="ForceDirectedLayout.html#setsPortSpots" class="tsd-kind-icon">sets<wbr>Port<wbr>Spots</a></li>
</ul>
</section>
<section class="tsd-index-section ">
<h3>Methods</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-method tsd-parent-kind-class"><a href="ForceDirectedLayout.html#addComments" class="tsd-kind-icon">add<wbr>Comments</a></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="ForceDirectedLayout.html#commitLayout" class="tsd-kind-icon">commit<wbr>Layout</a></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="ForceDirectedLayout.html#commitLinks" class="tsd-kind-icon">commit<wbr>Links</a></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><a href="ForceDirectedLayout.html#commitNodes" class="tsd-kind-icon">commit<wbr>Nodes</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="ForceDirectedLayout.html#createNetwork" class="tsd-kind-icon">create<wbr>Network</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="ForceDirectedLayout.html#doLayout" class="tsd-kind-icon">do<wbr>Layout</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="ForceDirectedLayout.html#electricalCharge" class="tsd-kind-icon">electrical<wbr>Charge</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="ForceDirectedLayout.html#electricalFieldX" class="tsd-kind-icon">electrical<wbr>FieldX</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="ForceDirectedLayout.html#electricalFieldY" class="tsd-kind-icon">electrical<wbr>FieldY</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="ForceDirectedLayout.html#gravitationalFieldX" class="tsd-kind-icon">gravitational<wbr>FieldX</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="ForceDirectedLayout.html#gravitationalFieldY" class="tsd-kind-icon">gravitational<wbr>FieldY</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="ForceDirectedLayout.html#gravitationalMass" class="tsd-kind-icon">gravitational<wbr>Mass</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="ForceDirectedLayout.html#isFixed" class="tsd-kind-icon">is<wbr>Fixed</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="ForceDirectedLayout.html#moveFixedVertex" class="tsd-kind-icon">move<wbr>Fixed<wbr>Vertex</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="ForceDirectedLayout.html#springLength" class="tsd-kind-icon">spring<wbr>Length</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="ForceDirectedLayout.html#springStiffness" class="tsd-kind-icon">spring<wbr>Stiffness</a></li>
</ul>
</section>
</div>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Constructors</h2>
<section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class">
<a name="constructor" class="tsd-anchor"></a>
<h3>
constructor
</h3>
<ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">new <wbr>Force<wbr>Directed<wbr>Layout<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="ForceDirectedLayout.html" class="tsd-signature-type">ForceDirectedLayout</a></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Constructs a <a href="ForceDirectedLayout.html">ForceDirectedLayout</a> with no <a href="Layout.html#network">Layout.network</a>
and with no owning <a href="Layout.html#diagram">Layout.diagram</a>.</p>
</div>
<h4 class="tsd-returns-title">Returns <a href="ForceDirectedLayout.html" class="tsd-signature-type">ForceDirectedLayout</a></h4>
</li>
</ul>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Properties</h2>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="arrangementSpacing" class="tsd-anchor"></a>
<h3>
arrangement<wbr>Spacing
<span class="tsd-signature-symbol">: </span><a href="Size.html" class="tsd-signature-type">Size</a> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets the space between which the layout
will position the connected graphs that together compose the network.
This defaults to Size(100, 100).
These distances are used during a clustered layout;
afterwards the normal force-directed layout
will likely cause the size of any space between connected graphs to change,
perhaps considerably.</p>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="arrangesToOrigin" class="tsd-anchor"></a>
<h3>
arranges<wbr>ToOrigin
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets whether <a href="ForceDirectedLayout.html#commitNodes">commitNodes</a> should move all of the
nodes so that the nodes all fit with the top-left corner at the
<a href="Layout.html#arrangementOrigin">Layout.arrangementOrigin</a>.
By default this is false -- the <a href="Layout.html#arrangementOrigin">Layout.arrangementOrigin</a> is ignored.
When this is true, nodes are moved even though <a href="ForceDirectedLayout.html#isFixed">isFixed</a> was true.</p>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="comments" class="tsd-anchor"></a>
<h3>
comments
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets whether this layout should find all <a href="Node.html">Node</a>s
whose category is "Comment" and
whose anchors are nodes represented in the network,
and add <a href="ForceDirectedVertex.html">ForceDirectedVertex</a>es representing those balloon comments
as nodes in the network.
The default value is false.</p>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class">
<a name="currentIteration" class="tsd-anchor"></a>
<h3>
<span class="tsd-flag ts-flagReadOnly">Read-only</span>
current<wbr>Iteration
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>This read-only property returns the current iteration count, valid during a call to <a href="ForceDirectedLayout.html#doLayout">doLayout</a>.</p>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="defaultCommentElectricalCharge" class="tsd-anchor"></a>
<h3>
default<wbr>Comment<wbr>Electrical<wbr>Charge
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets the default value computed by <a href="ForceDirectedLayout.html#electricalCharge">electricalCharge</a>.
The initial value is 5.</p>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="defaultCommentSpringLength" class="tsd-anchor"></a>
<h3>
default<wbr>Comment<wbr>Spring<wbr>Length
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets the default value computed by <a href="ForceDirectedLayout.html#springLength">springLength</a>.
The initial value is 10.</p>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="defaultElectricalCharge" class="tsd-anchor"></a>
<h3>
default<wbr>Electrical<wbr>Charge
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets the default value computed by <a href="ForceDirectedLayout.html#electricalCharge">electricalCharge</a>.
The initial value is 150.</p>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="defaultGravitationalMass" class="tsd-anchor"></a>
<h3>
default<wbr>Gravitational<wbr>Mass
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets the default value computed by <a href="ForceDirectedLayout.html#gravitationalMass">gravitationalMass</a>.
The initial value is zero.</p>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="defaultSpringLength" class="tsd-anchor"></a>
<h3>
default<wbr>Spring<wbr>Length
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets the default value computed by <a href="ForceDirectedLayout.html#springLength">springLength</a>.
The initial value is 50.</p>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="defaultSpringStiffness" class="tsd-anchor"></a>
<h3>
default<wbr>Spring<wbr>Stiffness
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets the default value computed by <a href="ForceDirectedLayout.html#springStiffness">springStiffness</a>.
The initial value is 0.05.</p>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="epsilonDistance" class="tsd-anchor"></a>
<h3>
epsilon<wbr>Distance
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets approximately how far a node must move in order for the iterations to continue.
The default value is 1.
The value must be larger than zero.</p>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="infinityDistance" class="tsd-anchor"></a>
<h3>
infinity<wbr>Distance
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets a threshold for the distance beyond which the electrical charge forces may be ignored.
The default value is 1000.
The value must be larger than 1.</p>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="maxIterations" class="tsd-anchor"></a>
<h3>
max<wbr>Iterations
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets the maximum number of iterations to perform when doing the
force-directed auto layout.
The value must be non-negative.
The default value is 100.</p>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="moveLimit" class="tsd-anchor"></a>
<h3>
move<wbr>Limit
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets how far a vertex may be moved in an iteration.
The default value is 10.
The value must be larger than 1.</p>
<dl class="tsd-comment-tags">
<dt>since</dt>
<dd><p>1.8</p>
</dd>
</dl>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="randomNumberGenerator" class="tsd-anchor"></a>
<h3>
random<wbr>Number<wbr>Generator
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">object</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets a random number generator.
The default value is Math, which results in calling Math.random().
Change this to null in order to use an instance of an internal repeatable pseudo-random number generator,
which will become the new value of this property.</p>
<p>The new value must be either null or an Object with a method named "random" taking zero arguments
and returning a random number between zero (inclusive) and one (exclusive).</p>
<dl class="tsd-comment-tags">
<dt>since</dt>
<dd><p>1.5</p>
</dd>
</dl>
</div>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-accessor tsd-parent-kind-class">
<a name="setsPortSpots" class="tsd-anchor"></a>
<h3>
sets<wbr>Port<wbr>Spots
<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span> </h3>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Gets or sets whether the fromSpot and the toSpot of every <a href="Link.html">Link</a>
should be set to <a href="Spot.html#static-Default">Spot.Default</a>.
The default value is true.</p>
</div>
</li>
</ul>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Methods</h2>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="addComments" class="tsd-anchor"></a>
<h3>
<span class="tsd-flag ts-flagVirtual">Virtual</span>
add<wbr>Comments
</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">add<wbr>Comments<span class="tsd-signature-symbol">(</span>v<span class="tsd-signature-symbol">: </span><a href="ForceDirectedVertex.html" class="tsd-signature-type">ForceDirectedVertex</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Find any associated objects to be positioned along with the <a href="LayoutVertex.html#node">LayoutVertex.node</a>.</p>
<p>This method is called for each vertex in the network, when <a href="ForceDirectedLayout.html#comments">comments</a> is true.
The standard behavior is to look for <a href="Node.html">Node</a>s whose <a href="Part.html#category">Part.category</a>
is "Comment" and that refer to the <a href="LayoutVertex.html#node">LayoutVertex.node</a>.
By default this method will not be called unless you set <a href="ForceDirectedLayout.html#comments">comments</a> to true.</p>
<p>You may want to override this method in order to customize how any
associated objects are found and how a new <a href="ForceDirectedVertex.html">ForceDirectedVertex</a>
and <a href="ForceDirectedEdge.html">ForceDirectedEdge</a>
may be added to the network to represent the (balloon?) comment.
This method sets the new vertex's <a href="ForceDirectedVertex.html#charge">ForceDirectedVertex.charge</a>
to the value of <a href="ForceDirectedLayout.html#defaultCommentElectricalCharge">defaultCommentElectricalCharge</a>,
and sets the new edge's <a href="ForceDirectedEdge.html#length">ForceDirectedEdge.length</a>
to the value of <a href="ForceDirectedLayout.html#defaultCommentSpringLength">defaultCommentSpringLength</a>.</p>
<dl class="tsd-comment-tags">
<dt>since</dt>
<dd><p>1.3</p>
</dd>
</dl>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>v: <a href="ForceDirectedVertex.html" class="tsd-signature-type">ForceDirectedVertex</a></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-protected">
<a name="commitLayout" class="tsd-anchor"></a>
<h3>
<span class="tsd-flag ts-flagProtected">Protected</span> <span class="tsd-flag ts-flagOverride">Override</span>
commit<wbr>Layout
</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-protected">
<li class="tsd-signature tsd-kind-icon">commit<wbr>Layout<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Set the fromSpot and toSpot on each Link, position each Node according
to the vertex position, and then position/route the Links.</p>
<p>This calls the <a href="ForceDirectedLayout.html#commitNodes">commitNodes</a> and <a href="ForceDirectedLayout.html#commitLinks">commitLinks</a> methods, the latter only if <a href="Layout.html#isRouting">isRouting</a> is true.
You should not call this method -- it is a "protected virtual" method.
Please read the Introduction page on <a href="../../intro/extensions.html">Extensions</a> for how to override methods and how to call this base method.</p>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-protected">
<a name="commitLinks" class="tsd-anchor"></a>
<h3>
<span class="tsd-flag ts-flagProtected">Protected</span> <span class="tsd-flag ts-flagVirtual">Virtual</span>
commit<wbr>Links
</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-protected">
<li class="tsd-signature tsd-kind-icon">commit<wbr>Links<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Routes the links.</p>
<p>This is called by <a href="ForceDirectedLayout.html#commitLayout">commitLayout</a>.
This is only called if <a href="Layout.html#isRouting">Layout.isRouting</a> is true.
See also <a href="ForceDirectedLayout.html#commitNodes">commitNodes</a>.
Please read the Introduction page on <a href="../../intro/extensions.html">Extensions</a> for how to override methods and how to call this base method.</p>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-protected">
<a name="commitNodes" class="tsd-anchor"></a>
<h3>
<span class="tsd-flag ts-flagProtected">Protected</span> <span class="tsd-flag ts-flagVirtual">Virtual</span>
commit<wbr>Nodes
</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-protected">
<li class="tsd-signature tsd-kind-icon">commit<wbr>Nodes<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Commit the position of all nodes.</p>
<p>This is called by <a href="ForceDirectedLayout.html#commitLayout">commitLayout</a>.
See also <a href="ForceDirectedLayout.html#commitLinks">commitLinks</a>.
Please read the Introduction page on <a href="../../intro/extensions.html">Extensions</a> for how to override methods and how to call this base method.</p>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="createNetwork" class="tsd-anchor"></a>
<h3>
<span class="tsd-flag ts-flagOverride">Override</span>
create<wbr>Network
</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">create<wbr>Network<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="ForceDirectedNetwork.html" class="tsd-signature-type">ForceDirectedNetwork</a></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Create a new <a href="LayoutNetwork.html">LayoutNetwork</a> of <a href="ForceDirectedVertex.html">ForceDirectedVertex</a>es and <a href="ForceDirectedEdge.html">ForceDirectedEdge</a>s.</p>
</div>
<h4 class="tsd-returns-title">Returns <a href="ForceDirectedNetwork.html" class="tsd-signature-type">ForceDirectedNetwork</a></h4>
<p>a new <a href="LayoutNetwork.html">LayoutNetwork</a>.</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="doLayout" class="tsd-anchor"></a>
<h3>
<span class="tsd-flag ts-flagOverride">Override</span>
do<wbr>Layout
</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">do<wbr>Layout<span class="tsd-signature-symbol">(</span>coll<span class="tsd-signature-symbol">: </span><a href="Diagram.html" class="tsd-signature-type">Diagram</a><span class="tsd-signature-symbol"> | </span><a href="Group.html" class="tsd-signature-type">Group</a><span class="tsd-signature-symbol"> | </span><a href="Iterable.html" class="tsd-signature-type">Iterable</a><span class="tsd-signature-symbol"><</span><a href="Part.html" class="tsd-signature-type">Part</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Perform the force-directed layout.</p>
<p>If there is no <a href="Layout.html#network">Layout.network</a>, this calls <a href="Layout.html#makeNetwork">makeNetwork</a> to create a <a href="LayoutNetwork.html">LayoutNetwork</a> from the given collection of Parts.
This removes any reflexive edges in the network, since they should be ignored.</p>
<p>For each vertex this calls and remembers the result of <a href="ForceDirectedLayout.html#electricalCharge">electricalCharge</a> as the <a href="ForceDirectedVertex.html#charge">ForceDirectedVertex.charge</a>
and the result of <a href="ForceDirectedLayout.html#gravitationalMass">gravitationalMass</a> as the <a href="ForceDirectedVertex.html#mass">ForceDirectedVertex.mass</a>.</p>
<p>For each edge this calls and remembers the result of <a href="ForceDirectedLayout.html#springStiffness">springStiffness</a> as the <a href="ForceDirectedEdge.html#stiffness">ForceDirectedEdge.stiffness</a>
and the result of <a href="ForceDirectedLayout.html#springLength">springLength</a> as the <a href="ForceDirectedEdge.html#length">ForceDirectedEdge.length</a>.</p>
<p>This then iterates, updating the position of each vertex according to the forces upon it,
until reaching <a href="ForceDirectedLayout.html#maxIterations">maxIterations</a> or until no vertex moves more than about <a href="ForceDirectedLayout.html#epsilonDistance">epsilonDistance</a>.</p>
<p>Finally this calls <a href="Layout.html#updateParts">Layout.updateParts</a> to commit the Node positions from the vertex positions.
<a href="Layout.html#updateParts">Layout.updateParts</a> calls <a href="ForceDirectedLayout.html#commitLayout">commitLayout</a> within a transaction.</p>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>coll: <a href="Diagram.html" class="tsd-signature-type">Diagram</a><span class="tsd-signature-symbol"> | </span><a href="Group.html" class="tsd-signature-type">Group</a><span class="tsd-signature-symbol"> | </span><a href="Iterable.html" class="tsd-signature-type">Iterable</a><span class="tsd-signature-symbol"><</span><a href="Part.html" class="tsd-signature-type">Part</a><span class="tsd-signature-symbol">></span></h5>
<div class="tsd-comment tsd-typography">
<p>A <a href="Diagram.html">Diagram</a> or a <a href="Group.html">Group</a> or a collection of <a href="Part.html">Part</a>s</p>
</div>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="electricalCharge" class="tsd-anchor"></a>
<h3>
<span class="tsd-flag ts-flagVirtual">Virtual</span>
electrical<wbr>Charge
</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">electrical<wbr>Charge<span class="tsd-signature-symbol">(</span>v<span class="tsd-signature-symbol">: </span><a href="ForceDirectedVertex.html" class="tsd-signature-type">ForceDirectedVertex</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Returns the charge of the vertex,
the value of <a href="ForceDirectedVertex.html#charge">ForceDirectedVertex.charge</a> if it's a number,
or else the value of <a href="ForceDirectedLayout.html#defaultElectricalCharge">defaultElectricalCharge</a>.</p>
<p>The electrical forces between two vertexes decrease by the square of the distance between them.
Vertexes that are more than <a href="ForceDirectedLayout.html#infinityDistance">infinityDistance</a> apart are assumed to have no electrical charge effect on each other.</p>
<p>Please read the Introduction page on <a href="../../intro/extensions.html">Extensions</a> for how to override methods and how to call this base method.</p>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>v: <a href="ForceDirectedVertex.html" class="tsd-signature-type">ForceDirectedVertex</a></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="electricalFieldX" class="tsd-anchor"></a>
<h3>
<span class="tsd-flag ts-flagVirtual">Virtual</span>
electrical<wbr>FieldX
</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">electrical<wbr>FieldX<span class="tsd-signature-symbol">(</span>x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, y<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Returns the electrical field in the X direction acting on a vertex at the given point.
By default there is no electrical field at any location.</p>
<p>Used to define an external electrical field at a point independent of the vertex charges.
A vertex L is acted upon by a force in the X direction of proportional to
<code>electricalFieldX(L.center.x, L.center.y) * electricalCharge(L)</code>.
Please read the Introduction page on <a href="../../intro/extensions.html">Extensions</a> for how to override methods and how to call this base method.</p>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>x: <span class="tsd-signature-type">number</span></h5>
</li>
<li>
<h5>y: <span class="tsd-signature-type">number</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4>
<p>the default implementation returns zero.</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="electricalFieldY" class="tsd-anchor"></a>
<h3>
<span class="tsd-flag ts-flagVirtual">Virtual</span>
electrical<wbr>FieldY
</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">electrical<wbr>FieldY<span class="tsd-signature-symbol">(</span>x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, y<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>Returns the electrical field in the Y direction acting on a vertex at the given point.
By default there is no electrical field at any location.</p>
<p>Used to define an external electrical field at a point independent of the vertex charges.
A vertex L is acted upon by a force in the Y direction of proportional to
<code>electricalFieldY(L.center.x, L.center.y) * electricalCharge(L)</code>.
Please read the Introduction page on <a href="../../intro/extensions.html">Extensions</a> for how to override methods and how to call this base method.</p>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>x: <span class="tsd-signature-type">number</span></h5>
</li>
<li>
<h5>y: <span class="tsd-signature-type">number</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4>
<p>the default implementation returns zero.</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="gravitationalFieldX" class="tsd-anchor"></a>
<h3>
<span class="tsd-flag ts-flagVirtual">Virtual</span>
gravitational<wbr>FieldX
</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">gravitational<wbr>FieldX<span class="tsd-signature-symbol">(</span>x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, y<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>This returns the gravitational field in the X direction acting on a vertex at the given point.
By default there is no gravitational field at any location.</p>
<p>Used to define an external gravitational field at a point independent of the vertex masses.
A vertex L is acted upon by a force in the X direction of proportional to
<code>gravitationalFieldX(L.center.x, L.center.y) * gravitationalMass(L)</code>.
Please read the Introduction page on <a href="../../intro/extensions.html">Extensions</a> for how to override methods and how to call this base method.</p>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>x: <span class="tsd-signature-type">number</span></h5>
</li>
<li>
<h5>y: <span class="tsd-signature-type">number</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4>
<p>the default implementation returns zero.</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="gravitationalFieldY" class="tsd-anchor"></a>
<h3>
<span class="tsd-flag ts-flagVirtual">Virtual</span>
gravitational<wbr>FieldY
</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">gravitational<wbr>FieldY<span class="tsd-signature-symbol">(</span>x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, y<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<div class="tsd-comment tsd-typography">
<p>This returns the gravitational field in the Y direction acting on a vertex at the given point.
By default there is no gravitational field at any location.</p>
<p>Used to define an external gravitational field at a point independent of the vertex masses.
A vertex L is acted upon by a force in the Y direction of proportional to
<code>gravitationalFieldY(L.center.x, L.center.y) * gravitationalMass(L)</code>.
Please read the Introduction page on <a href="../../intro/extensions.html">Extensions</a> for how to override methods and how to call this base method.</p>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">