UNPKG

create-gojs-kit

Version:

A CLI for downloading GoJS samples, extensions, and docs

126 lines (124 loc) 31.3 kB
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><link rel="stylesheet" href="../../assets/css/style.css"/><link rel="preconnect" href="https://rsms.me/"/><link rel="stylesheet" href="https://rsms.me/inter/inter.css"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Router | GoJS API</title><meta name="description" content="Documentation for GoJS API"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><link rel="stylesheet" href="../assets/custom.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script type="text/javascript">// formerly in api.js var hash = null; function changeHash() { var panels = document.getElementsByClassName("tsd-panel"); for (let i = 0; i < panels.length; i++) { var p = panels[i]; p.classList.remove("targeted"); } hash = window.location.hash.slice(1); if (hash) { var elt = document.getElementById(hash); if (elt) elt.parentNode.classList.add("targeted"); } } document.addEventListener("DOMContentLoaded", changeHash); window.addEventListener("hashchange", changeHash);</script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header><nav id="navTop" class="w-full h-[var(--topnav-h)] z-30 bg-[var(--color-background-secondary)] border-b border-b-[var(--color-accent)]"><div class="max-w-screen-xl mx-auto flex flex-wrap items-start justify-between px-4"><a class="!text-white bg-nwoods-primary font-bold !leading-[calc(var(--topnav-h)_-_1px)] my-0 px-2 text-4xl lg:text-5xl logo" href="../../index.html">GoJS</a><div class="relative"><button id="topnavButton" class="h-[calc(var(--topnav-h)_-_1px)] px-2 m-0 text-[var(--color-text)] bg-inherit shadow-none md:hidden hover:!bg-inherit hover:!text-nwoods-accent hover:!shadow-none" aria-label="Navigation"><svg class="h-7 w-7 block" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" stroke-linecap="round" stroke-linejoin="round"></path></svg></button><div id="topnavList" class="hidden md:block"><div class="absolute right-0 z-30 flex flex-col items-end rounded border border-[var(--color-accent)] p-4 pl-12 shadow bg-[var(--color-background-secondary)] text-[var(--color-text)] font-semibold md:flex-row md:space-x-4 md:items-start md:border-0 md:p-0 md:shadow-none md:!bg-inherit"><a href="../../learn/index.html">Learn</a><a href="../../samples/index.html">Samples</a><a href="../../intro/index.html">Intro</a><a class="active" href="../../api/index.html">API</a><a href="../../download.html">Download</a><a href="https://forum.nwoods.com/c/gojs/11" target="_blank" rel="noopener">Forum</a><a href="https://nwoods.com/contact.html" target="_blank" rel="noopener" id="contactBtn">Contact</a><a href="https://nwoods.com/sales/index.html" target="_blank" rel="noopener" id="buyBtn">Buy</a></div></div></div></div></nav><script>window.addEventListener("DOMContentLoaded", function () { // topnav var topButton = document.getElementById("topnavButton"); var topnavList = document.getElementById("topnavList"); if (topButton && topnavList) { topButton.addEventListener("click", function (e) { topnavList .classList .toggle("hidden"); e.stopPropagation(); }); document.addEventListener("click", function (e) { // if the clicked element isn't the list, close the list if (!topnavList.classList.contains("hidden") && !e.target.closest("#topnavList")) { topButton.click(); } }); // set active <a> element // done via active tag below, always API } });</script><div class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><div id="tsd-search-help"><code class="!text-lg">/</code> to search</div><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></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"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><div class="flex w-full max-w-screen-xl mx-auto px-2 items-center justify-between"><div><ul class="tsd-breadcrumb"><li><a href="../index.html">GoJS API</a></li><li><a href="Router.html">Router</a></li></ul><h1 class="flex items-center">Class Router<code class="tsd-tag ts-flagAbstract">Abstract</code> </h1></div><div class="text-xs"><b>GoJS</b>® Diagramming Components<br/>version 3.1.0<br/>by <a href="https://nwoods.com/">Northwoods Software®</a></div></div></div><section class="tsd-panel tsd-hierarchy"><h4>Hierarchy (<a class="link" href="../hierarchy.html#Router">view full</a>)</h4><ul class="tsd-hierarchy"><li><span class="target">Router</span><ul class="tsd-hierarchy"><li><a href="AvoidsLinksRouter.html" class="tsd-signature-type tsd-kind-class">AvoidsLinksRouter</a></li><li><a href="LinkLabelRouter.html" class="tsd-signature-type tsd-kind-class">LinkLabelRouter</a></li></ul></li></ul></section><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><p>A Router is a class that is responsible for the paths of a collection of Links.</p> <p>Some routers modify the <a href="Link.html#points" class="tsd-kind-accessor">Link.points</a> of some Links in ways that the default routing provided by <a href="Link.html#computePoints" class="tsd-kind-method">Link.computePoints</a> cannot, because the latter method only considers the properties of the Link and its connected ports -- not other Nodes or Links.</p> <p>Some routers modify other aspects of Links.</p> <p>The most commonly used Router is the <a href="AvoidsLinksRouter.html">AvoidsLinksRouter</a> extension in the extensions or extensionsJSM directories.</p> <p>The Router class is abstract and does not really provide any functionality of its own. You can install a Router subclass by constructing and initializing it and then inserting it into the <a href="Diagram.html#routers" class="tsd-kind-accessor">Diagram.routers</a> list.</p> <pre><code class="language-js"><span class="hl-4">myDiagram</span><span class="hl-2">.</span><span class="hl-4">routers</span><span class="hl-2">.</span><span class="hl-5">add</span><span class="hl-2">(</span><span class="hl-1">new</span><span class="hl-2"> </span><span class="hl-5">AvoidsLinksRouter</span><span class="hl-2">());</span> </code><button>Copy</button></pre> <p>A Router that has been installed will automatically operate on the Links of Groups or the top-level Links of the Diagram.</p> <p>You can disable a Router by setting its <a href="Router.html#isEnabled" class="tsd-kind-accessor">isEnabled</a> property to false, or by overriding <a href="Router.html#canRoute" class="tsd-kind-method">canRoute</a> to decide when it should operate.</p> <p>Your subclass of Router should override <a href="Router.html#routeLinks" class="tsd-kind-method">routeLinks</a> method in order to examine the Links implicitly given to the method.</p> </div><div class="tsd-comment-tags tsd-typography"><div class="flex items-center"><code class="tsd-tag">since</code><p>3.0</p> </div></div></section><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="true" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="Router.html#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a> </div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Accessors</h3><div class="tsd-index-list"><a href="Router.html#diagram" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-262144"></use></svg><span>diagram</span></a> <a href="Router.html#isEnabled" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-262144"></use></svg><span>is<wbr/>Enabled</span></a> <a href="Router.html#isRealtime" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-262144"></use></svg><span>is<wbr/>Realtime</span></a> <a href="Router.html#name" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-262144"></use></svg><span>name</span></a> </div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Methods</h3><div class="tsd-index-list"><a href="Router.html#canRoute" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>can<wbr/>Route</span></a> <a href="Router.html#invalidateRouter" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>invalidate<wbr/>Router</span></a> <a href="Router.html#isRoutable" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>is<wbr/>Routable</span></a> <a href="Router.html#routeLinks" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>route<wbr/>Links</span></a> </div></section></div></details></section></section><section class="tsd-panel-group tsd-member-group"><h2>Constructors</h2><section class="tsd-panel tsd-member"><a id="constructor" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="constructor.new_Router" class="tsd-anchor"></a><span class="tsd-kind-constructor-signature">new <wbr/>Router</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="Router.html" class="tsd-signature-type tsd-kind-class">Router</a><a href="#constructor.new_Router" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Don&#39;t construct this directly -- this is an abstract class.</p> </div><h4 class="tsd-returns-title">Returns <a href="Router.html" class="tsd-signature-type tsd-kind-class">Router</a></h4></li></ul></section></section><section class="tsd-panel-group tsd-member-group"><h2>Accessors</h2><section class="tsd-panel tsd-member"><a id="diagram" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>diagram</span><div class="membertype"><span class="tsd-signature-symbol">: </span><a href="Diagram.html" class="tsd-signature-type tsd-kind-class">Diagram</a></div><a href="#diagram" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Gets or sets the Diagram this router is associated with. Routers cannot be shared.</p> </div></li></ul></section><section class="tsd-panel tsd-member"><a id="isEnabled" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>is<wbr/>Enabled</span><div class="membertype"><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></div><a href="#isEnabled" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Gets or sets whether this router is enabled.</p> </div></li></ul></section><section class="tsd-panel tsd-member"><a id="isRealtime" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>is<wbr/>Realtime</span><div class="membertype"><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></div><a href="#isRealtime" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Gets or sets whether this router runs during real-time operations, such as dragging or resizing. The default is true.</p> </div></li></ul></section><section class="tsd-panel tsd-member"><a id="name" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>name</span><div class="membertype"><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></div><a href="#name" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Gets or sets the name of this router.</p> </div></li></ul></section></section><section class="tsd-panel-group tsd-member-group"><h2>Methods</h2><section class="tsd-panel tsd-member"><a id="canRoute" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagVirtual">Virtual</code><span>can<wbr/>Route</span><a href="#canRoute" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="canRoute.canRoute-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">can<wbr/>Route</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">container</span><span class="tsd-signature-symbol">: </span><a href="Diagram.html" class="tsd-signature-type tsd-kind-class">Diagram</a><span class="tsd-signature-symbol"> | </span><a href="Group.html" class="tsd-signature-type tsd-kind-class">Group</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><a href="#canRoute.canRoute-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Determine for the given collection if this router can route.</p> <p>Adding a Router to the Diagram will cause the Diagram to call <code>canRoute</code> for every group recursively, and finally for the Diagram itself.</p> <p>By default this returns <code>false</code> if <a href="Router.html#isRealtime" class="tsd-kind-accessor">isRealtime</a> is <code>false</code> and a realtime operation (such as dragging or resizing) is ongoing, or else <code>false</code> if a default animation is running, or else the value of <a href="Router.html#isEnabled" class="tsd-kind-accessor">isEnabled</a>.</p> <p>If <code>true</code>, <a href="Router.html#routeLinks" class="tsd-kind-method">routeLinks</a> will be called on each collection.</p> <p>An override of this method should return <code>false</code> if <a href="Router.html#isEnabled" class="tsd-kind-accessor">isEnabled</a> is false, or return <code>false</code> is if a call to the base method is <code>false</code>.</p> <p>This method is only called by the <a href="Diagram.html" class="tsd-kind-class">Diagram</a>. If using a Router without adding it to a Diagram, this method will never be called.</p> </div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><h5><span class="tsd-kind-parameter">container</span>: <a href="Diagram.html" class="tsd-signature-type tsd-kind-class">Diagram</a><span class="tsd-signature-symbol"> | </span><a href="Group.html" class="tsd-signature-type tsd-kind-class">Group</a></h5><div class="tsd-comment tsd-typography"><p>A Diagram or Group on which the Router will operate.</p> </div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4></li></ul></section><section class="tsd-panel tsd-member"><a id="invalidateRouter" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>invalidate<wbr/>Router</span><a href="#invalidateRouter" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="invalidateRouter.invalidateRouter-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">invalidate<wbr/>Router</span><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><a href="#invalidateRouter.invalidateRouter-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>If this router has been added to a diagram, calling this method will ensure the Diagram re-runs all routing.</p> <p>The router should call this method when setting properties that might require the router to re-run when values change.</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"><a id="isRoutable" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>is<wbr/>Routable</span><a href="#isRoutable" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="isRoutable.isRoutable-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">is<wbr/>Routable</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">link</span><span class="tsd-signature-symbol">: </span><a href="Link.html" class="tsd-signature-type tsd-kind-class">Link</a>, <span class="tsd-kind-parameter">container</span><span class="tsd-signature-symbol">: </span><a href="Diagram.html" class="tsd-signature-type tsd-kind-class">Diagram</a><span class="tsd-signature-symbol"> | </span><a href="Group.html" class="tsd-signature-type tsd-kind-class">Group</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><a href="#isRoutable.isRoutable-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Decide whether a given Link should be routed or ignored.</p> <p>By default this just returns true.</p> </div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><h5><span class="tsd-kind-parameter">link</span>: <a href="Link.html" class="tsd-signature-type tsd-kind-class">Link</a></h5></li><li><h5><span class="tsd-kind-parameter">container</span>: <a href="Diagram.html" class="tsd-signature-type tsd-kind-class">Diagram</a><span class="tsd-signature-symbol"> | </span><a href="Group.html" class="tsd-signature-type tsd-kind-class">Group</a></h5><div class="tsd-comment tsd-typography"><p>the containing Diagram or Group</p> </div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4><p>whether or not this Router should operate on the given Link</p> <div class="tsd-comment-tags tsd-typography"><div class="flex items-center"><code class="tsd-tag">since</code><p>3.1</p> </div></div></li></ul></section><section class="tsd-panel tsd-member"><a id="routeLinks" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagVirtual">Virtual</code><span>route<wbr/>Links</span><a href="#routeLinks" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="routeLinks.routeLinks-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">route<wbr/>Links</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">links</span><span class="tsd-signature-symbol">: </span><a href="Set.html" class="tsd-signature-type tsd-kind-class">Set</a><span class="tsd-signature-symbol">&lt;</span><a href="Link.html" class="tsd-signature-type tsd-kind-class">Link</a><span class="tsd-signature-symbol">&gt;</span>, <span class="tsd-kind-parameter">container</span><span class="tsd-signature-symbol">: </span><a href="Diagram.html" class="tsd-signature-type tsd-kind-class">Diagram</a><span class="tsd-signature-symbol"> | </span><a href="Group.html" class="tsd-signature-type tsd-kind-class">Group</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span><a href="#routeLinks.routeLinks-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Route the links for a given collection (Group or Diagram). By default this is called in a depth-first manner on every Group in the Diagram, and then the Diagram itself. If a layout occurred for a Group or a Diagram, this is called immediately afterwards if <a href="Router.html#canRoute" class="tsd-kind-method">canRoute</a> returns true.</p> <p>It is common to route all links in each Group&#39;s <a href="Group.html#memberParts" class="tsd-kind-accessor">Group.memberParts</a>, and then all top-level links in the <a href="Diagram.html#links" class="tsd-kind-accessor">Diagram.links</a> collection. (All Links that have <a href="Part.html#containingGroup" class="tsd-kind-accessor">Part.containingGroup</a> <code>=== null</code>)</p> <p>The first argument is a Set of Links that the Diagram has collected which it considers invalid. Typically, these are the only links that need routing. Since <code>routeLinks</code> is called with each Group and then the Diagram, you should check the <a href="Part.html#containingGroup" class="tsd-kind-accessor">Part.containingGroup</a> on each Link to ensure it matches:</p> <pre><code class="language-ts"><span class="hl-2"> </span><span class="hl-4">public</span><span class="hl-2"> </span><span class="hl-5">routeLinks</span><span class="hl-2">(</span><span class="hl-4">links</span><span class="hl-2">: </span><span class="hl-4">GSet</span><span class="hl-2">&lt;</span><span class="hl-4">Link</span><span class="hl-2">&gt;, </span><span class="hl-4">container</span><span class="hl-2">: </span><span class="hl-4">Diagram</span><span class="hl-2"> | </span><span class="hl-4">Group</span><span class="hl-2">): </span><span class="hl-1">void</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-1">const</span><span class="hl-2"> </span><span class="hl-3">grp</span><span class="hl-2"> = </span><span class="hl-4">container</span><span class="hl-2"> </span><span class="hl-1">instanceof</span><span class="hl-2"> </span><span class="hl-14">Diagram</span><span class="hl-2"> ? </span><span class="hl-1">null</span><span class="hl-2"> : </span><span class="hl-4">container</span><span class="hl-2">;</span><br/><span class="hl-2"> </span><span class="hl-1">const</span><span class="hl-2"> </span><span class="hl-3">it</span><span class="hl-2"> = </span><span class="hl-4">links</span><span class="hl-2">.</span><span class="hl-4">iterator</span><span class="hl-2">;</span><br/><span class="hl-2"> </span><span class="hl-8">while</span><span class="hl-2"> (</span><span class="hl-4">it</span><span class="hl-2">.</span><span class="hl-5">next</span><span class="hl-2">()) {</span><br/><span class="hl-2"> </span><span class="hl-1">const</span><span class="hl-2"> </span><span class="hl-3">link</span><span class="hl-2"> = </span><span class="hl-4">it</span><span class="hl-2">.</span><span class="hl-4">value</span><span class="hl-2">;</span><br/><span class="hl-2"> </span><span class="hl-0">// Only operate on links that are in the corresponding collection, if one is given</span><br/><span class="hl-2"> </span><span class="hl-8">if</span><span class="hl-2"> (</span><span class="hl-4">link</span><span class="hl-2">.</span><span class="hl-4">containingGroup</span><span class="hl-2"> !== </span><span class="hl-4">grp</span><span class="hl-2">) </span><span class="hl-8">continue</span><span class="hl-2">;</span><br/><span class="hl-2"> . . .</span> </code><button>Copy</button></pre> <p>However you may wish to design your router so that <a href="Router.html#canRoute" class="tsd-kind-method">canRoute</a> is false for Groups, in which case you will want to operate on each of the Links in the first argument, regardless of whether or not it is a top-level Link.</p> <p>This method should not check the <a href="Router.html#canRoute" class="tsd-kind-method">canRoute</a> predicate.</p> </div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><h5><span class="tsd-kind-parameter">links</span>: <a href="Set.html" class="tsd-signature-type tsd-kind-class">Set</a><span class="tsd-signature-symbol">&lt;</span><a href="Link.html" class="tsd-signature-type tsd-kind-class">Link</a><span class="tsd-signature-symbol">&gt;</span></h5><div class="tsd-comment tsd-typography"><p>The set of links that were recently recomputed, which may need routing.</p> </div></li><li><h5><span class="tsd-kind-parameter">container</span>: <a href="Diagram.html" class="tsd-signature-type tsd-kind-class">Diagram</a><span class="tsd-signature-symbol"> | </span><a href="Group.html" class="tsd-signature-type tsd-kind-class">Group</a></h5><div class="tsd-comment tsd-typography"><p>A Diagram or Group on which the Router will operate. When calling a router manually, this does not need to be specified.</p> </div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section></section></div><div class="col-sidebar"><div class="page-menu"><details open class="tsd-index-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><ul><li><a href="#constructor"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></li><li><a href="#diagram"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-262144"></use></svg><span>diagram</span></a></li><li><a href="#isEnabled"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-262144"></use></svg><span>is<wbr/>Enabled</span></a></li><li><a href="#isRealtime"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-262144"></use></svg><span>is<wbr/>Realtime</span></a></li><li><a href="#name"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-262144"></use></svg><span>name</span></a></li><li><a href="#canRoute"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>can<wbr/>Route</span></a></li><li><a href="#invalidateRouter"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>invalidate<wbr/>Router</span></a></li><li><a href="#isRoutable"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>is<wbr/>Routable</span></a></li><li><a href="#routeLinks"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>route<wbr/>Links</span></a></li></ul></div></details><div class="tsd-navigation settings"><div class="tsd-theme-toggle"><h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">System</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../index.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>GoJS API</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><div class="tsd w-full max-w-screen-xl mx-auto px-2"><div class="bottom-copyright">Copyright © 1998-2025 by Northwoods Software Corporation.</div></div><div class="overlay"></div><script async src="https://www.googletagmanager.com/gtag/js?id=G-S5QK8VSK84"></script><script>window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-S5QK8VSK84'); var getOutboundLink = function(url, label) { gtag('event', 'click', { 'event_category': 'outbound', 'event_label': label, 'transport_type': 'beacon' }); } document.getElementById("contactBtn").addEventListener("click", function() { getOutboundLink('https://nwoods.com/contact.html', 'contact'); }); document.getElementById("buyBtn").addEventListener("click", function() { getOutboundLink('https://nwoods.com/sales/index.html', 'buy'); });</script></body></html>