UNPKG

gojs

Version:

Interactive diagrams, charts, and graphs, such as trees, flowcharts, orgcharts, UML, BPMN, or business diagrams

845 lines 51.5 kB
<!doctype html> <html class="default no-js"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Quadtree | 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>&reg; Diagramming Components<br/>version &lt;br/&gt;version 2.1.18 for TypeScript/HTML<br/>by <a href="https://www.nwoods.com/">Northwoods Software&reg;</a>--> <b>GoJS</b>&reg; Diagramming Components<br/>version 2.1.18<br/>by <a href="https://www.nwoods.com/">Northwoods Software&reg;</a> </div> <div> <h1>Class Quadtree&lt;T&gt;</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-extension"> <p> This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. Extensions can be found in the GoJS kit under the <code>extensions</code> or <code>extensionsTS</code> folders. See the <a href="../../intro/extensions.html">Extensions intro page</a> for more information. </p> </section> <section class="tsd-panel tsd-hierarchy"> <h3>Hierarchy</h3> <ul class="tsd-hierarchy"> <li> <span class="target">Quadtree</span> </li> </ul> </section> <section class="tsd-panel tsd-comment"> <div class="tsd-comment tsd-typography"> <p>Implementation of the quadtree data structure using the <a href="Rect.html">Rect</a> class. Each Quadtree has defined bounds found at <a href="Quadtree.html#bounds">bounds</a>, an array of member rectangles, and an array of child nodes (Quadtrees themselves). If the Quadtree has no children, the nodes array will have four nulls. To construct a Quadtree, you can call its constructor with no arguments. Then, to insert a rectangle, call <a href="Quadtree.html#add">add</a>. This tree supports adding points (rectangles with 0 width and height), segments (rectangles with either 0 width or 0 height), and rectangles with nonzero widths and heights.</p> <p>Quadtrees can be used to calculate intersections extremely quickly between a given rectangle and all of the rectangles in the quadtree. Use of this data structure prevents having to do precise intersection calculations for every rectangle in the tree. To calculate all of the rectangular intersections for a given rectangle, use <a href="Quadtree.html#intersecting">intersecting</a>.</p> <p>Other common operations are detailed below.</p> </div> </section> <section class="tsd-panel tsd-type-parameters"> <h3>Type parameters</h3> <ul class="tsd-type-parameters"> <li> <h4>T</h4> </li> </ul> </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="Quadtree.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-get-signature tsd-parent-kind-class"><a href="Quadtree.html#bounds" class="tsd-kind-icon">bounds</a></li> <li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="Quadtree.html#maxLevels" class="tsd-kind-icon">max<wbr>Levels</a></li> <li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="Quadtree.html#nodeCapacity" class="tsd-kind-icon">node<wbr>Capacity</a></li> <li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="Quadtree.html#root" class="tsd-kind-icon">root</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="Quadtree.html#add" class="tsd-kind-icon">add</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="Quadtree.html#clear" class="tsd-kind-icon">clear</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="Quadtree.html#containing" class="tsd-kind-icon">containing</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="Quadtree.html#distanceSquared" class="tsd-kind-icon">distance<wbr>Squared</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="Quadtree.html#find" class="tsd-kind-icon">find</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="Quadtree.html#findBounds" class="tsd-kind-icon">find<wbr>Bounds</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="Quadtree.html#findExtremeObjects" class="tsd-kind-icon">find<wbr>Extreme<wbr>Objects</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="Quadtree.html#forEach" class="tsd-kind-icon">for<wbr>Each</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="Quadtree.html#has" class="tsd-kind-icon">has</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="Quadtree.html#intersecting" class="tsd-kind-icon">intersecting</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="Quadtree.html#move" class="tsd-kind-icon">move</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="Quadtree.html#remove" class="tsd-kind-icon">remove</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="Quadtree.html#resize" class="tsd-kind-icon">resize</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="Quadtree.html#setTo" class="tsd-kind-icon">set<wbr>To</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="Quadtree.html#walk" class="tsd-kind-icon">walk</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>Quadtree<span class="tsd-signature-symbol">(</span>nodeCapacity<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, maxLevel<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, bounds<span class="tsd-signature-symbol">?: </span><a href="Rect.html" class="tsd-signature-type">Rect</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="Quadtree.html" class="tsd-signature-type">Quadtree</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>In most cases, simply calling this constructor with no arguments will produce the desired behaviour.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> nodeCapacity: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>The node capacity of this quadtree. This is the number of objects a node can contain before it splits. Defaults to 1.</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> maxLevel: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>The maximum depth the Quadtree will allow before it will no longer split. Defaults to Infinity (no maximum depth).</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> bounds: <a href="Rect.html" class="tsd-signature-type">Rect</a></h5> <div class="tsd-comment tsd-typography"> <p>The bounding box surrounding the entire Quadtree. If the bounds are unset or a node is inserted outside of the bounds, the tree will automatically grow.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="Quadtree.html" class="tsd-signature-type">Quadtree</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-get-signature tsd-parent-kind-class"> <a name="bounds" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagReadOnly">Read-only</span> bounds <span class="tsd-signature-symbol">: </span><a href="Rect.html" class="tsd-signature-type">Rect</a> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets the boundaries of the node. All nodes should be square.</p> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class"> <a name="maxLevels" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagReadOnly">Read-only</span> max<wbr>Levels <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 the maximum depth the Quadtree will allow before it will no longer split..</p> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class"> <a name="nodeCapacity" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagReadOnly">Read-only</span> node<wbr>Capacity <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 the node capacity of this quadtree. This is the number of objects a node can contain before it splits.</p> </div> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class"> <a name="root" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagReadOnly">Read-only</span> root <span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">QuadNode</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span> </h3> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Gets the root node of the tree</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="add" class="tsd-anchor"></a> <h3> add </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">add<span class="tsd-signature-symbol">(</span>obj<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">TreeObject</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span>, x<span class="tsd-signature-symbol">?: </span><a href="Rect.html" class="tsd-signature-type">Rect</a><span class="tsd-signature-symbol"> | </span><a href="Point.html" class="tsd-signature-type">Point</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">number</span>, y<span class="tsd-signature-symbol">?: </span><a href="Point.html" class="tsd-signature-type">Point</a><span class="tsd-signature-symbol"> | </span><a href="Size.html" class="tsd-signature-type">Size</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">number</span>, w<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, h<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">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Insert the object into the quadtree. If the node exceeds the capacity, it will split and add all objects to their corresponding nodes. If the object is outside the bounds of the tree&#39;s root node, the tree will grow to accomodate it. Possibly restructures the tree if a more efficient configuration can be found with the new dimensions. Bounds can be given either as a single <a href="Rect.html">Rect</a> or as any combination of arguments which is valid for the <a href="Rect.html">Rect</a> constructor.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>obj: <span class="tsd-signature-type">T</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">TreeObject</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span></h5> <div class="tsd-comment tsd-typography"> <p>the object to insert</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> x: <a href="Rect.html" class="tsd-signature-type">Rect</a><span class="tsd-signature-symbol"> | </span><a href="Point.html" class="tsd-signature-type">Point</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>The Rect bounds of the object, or top-left Point, or x value.</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> y: <a href="Point.html" class="tsd-signature-type">Point</a><span class="tsd-signature-symbol"> | </span><a href="Size.html" class="tsd-signature-type">Size</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>Bottom-right Point or Size or y value.</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> w: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>Width to be used if x,y are specified; must be non-negative.</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> h: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>Height to be used if x,y are specified;</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="clear" class="tsd-anchor"></a> <h3> clear </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">clear<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>Clears the Quadtree, removing all objects and children nodes. Keeps the current bounds of the root node.</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="containing" class="tsd-anchor"></a> <h3> containing </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">containing<span class="tsd-signature-symbol">(</span>rect<span class="tsd-signature-symbol">: </span><a href="Rect.html" class="tsd-signature-type">Rect</a><span class="tsd-signature-symbol"> | </span><a href="Point.html" class="tsd-signature-type">Point</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Array</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Return all objects that fully contain the given <a href="Rect.html">Rect</a> or <a href="Point.html">Point</a>.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>rect: <a href="Rect.html" class="tsd-signature-type">Rect</a><span class="tsd-signature-symbol"> | </span><a href="Point.html" class="tsd-signature-type">Point</a></h5> <div class="tsd-comment tsd-typography"> <p>the Rect or Point to check containing for. If a point is given, a Rect with size (0, 0) is created for containment calculations.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Array</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span></h4> <p>array containing all containing objects</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="distanceSquared" class="tsd-anchor"></a> <h3> distance<wbr>Squared </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">distance<wbr>Squared<span class="tsd-signature-symbol">(</span>obj1<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span>, obj2<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</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 square of the distance from the centers of the given objects</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>obj1: <span class="tsd-signature-type">T</span></h5> </li> <li> <h5>obj2: <span class="tsd-signature-type">T</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4> <p>square of the distance between the centers of obj1 and obj2</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="find" class="tsd-anchor"></a> <h3> find </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">find<span class="tsd-signature-symbol">(</span>obj<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">QuadNode</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Return the node that contains the given object.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>obj: <span class="tsd-signature-type">T</span></h5> <div class="tsd-comment tsd-typography"> <p>the object to find</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">QuadNode</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span> <span class="tsd-signature-symbol"> | </span> <span class="tsd-signature-type">null</span> </h4> <p>the node containing the given object, null if the object is not found</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="findBounds" class="tsd-anchor"></a> <h3> find<wbr>Bounds </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">find<wbr>Bounds<span class="tsd-signature-symbol">(</span>bounds<span class="tsd-signature-symbol">: </span><a href="Rect.html" class="tsd-signature-type">Rect</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="Rect.html" class="tsd-signature-type">Rect</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Checks if any of the objects in the tree have the given boundaries</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>bounds: <a href="Rect.html" class="tsd-signature-type">Rect</a></h5> <div class="tsd-comment tsd-typography"> <p>the rectangle to check for</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="Rect.html" class="tsd-signature-type">Rect</a> <span class="tsd-signature-symbol"> | </span> <span class="tsd-signature-type">null</span> </h4> <p>the actual bounds object stored in the tree</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="findExtremeObjects" class="tsd-anchor"></a> <h3> find<wbr>Extreme<wbr>Objects </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">find<wbr>Extreme<wbr>Objects<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">]</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Finds the most furthest object in each direction stored in the tree. Bounds are tested using the center x and y coordinate.</p> </div> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">]</span></h4> <p>maximum and minimum objects in the tree, in the format [min x, max x, min y, max y].</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="forEach" class="tsd-anchor"></a> <h3> for<wbr>Each </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">for<wbr>Each<span class="tsd-signature-symbol">(</span>callback<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">function</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">obj</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</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>Visits every object stored in the tree (depth first)</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>callback: <span class="tsd-signature-type">function</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">obj</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></h5> <div class="tsd-comment tsd-typography"> <p>the callback to execute on each object.</p> </div> <ul class="tsd-parameters"> </ul> </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="has" class="tsd-anchor"></a> <h3> has </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">has<span class="tsd-signature-symbol">(</span>obj<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Convenience method, calls <a href="Quadtree.html#find">find</a> and returns a boolean indicating whether or not the tree contains the given object</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>obj: <span class="tsd-signature-type">T</span></h5> <div class="tsd-comment tsd-typography"> <p>the object to check for</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4> <p>whether or not the given object is present in the tree</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="intersecting" class="tsd-anchor"></a> <h3> intersecting </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">intersecting<span class="tsd-signature-symbol">(</span>rect<span class="tsd-signature-symbol">: </span><a href="Rect.html" class="tsd-signature-type">Rect</a><span class="tsd-signature-symbol"> | </span><a href="Point.html" class="tsd-signature-type">Point</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Array</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Return all objects that intersect (wholly or partially) with the given <a href="Rect.html">Rect</a> or <a href="Point.html">Point</a>. Touching edges and objects overlapping by 1e-7 or less (to account for floating point error) are both not considered intersections.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>rect: <a href="Rect.html" class="tsd-signature-type">Rect</a><span class="tsd-signature-symbol"> | </span><a href="Point.html" class="tsd-signature-type">Point</a></h5> <div class="tsd-comment tsd-typography"> <p>the Rect or Point to check intersections for. If a point is given, a Rect with size (0, 0) is created for intersection calculations.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Array</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span></h4> <p>array containing all intersecting objects</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="move" class="tsd-anchor"></a> <h3> move </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">move<span class="tsd-signature-symbol">(</span>obj<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span>, x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> | </span><a href="Point.html" class="tsd-signature-type">Point</a>, 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">boolean</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Can be called as either (obj, x, y) or (obj, point). Translate the given object to given x and y coordinates or to a given <a href="Point.html">Point</a>.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>obj: <span class="tsd-signature-type">T</span></h5> <div class="tsd-comment tsd-typography"> <p>the object to move</p> </div> </li> <li> <h5>x: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> | </span><a href="Point.html" class="tsd-signature-type">Point</a></h5> <div class="tsd-comment tsd-typography"> <p>the x coordinate or Point to move the object to</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> y: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>the y coordinate to move the object to</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4> <p>whether or not the move was successful. False if the object was not in the tree.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="remove" class="tsd-anchor"></a> <h3> remove </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">remove<span class="tsd-signature-symbol">(</span>obj<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Remove the given object from the tree, restructuring to get rid of empty nodes that are unneeded.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>obj: <span class="tsd-signature-type">T</span></h5> <div class="tsd-comment tsd-typography"> <p>the object to remove</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4> <p>whether or not the deletion was successful. False when the object is not in the tree.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="resize" class="tsd-anchor"></a> <h3> resize </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">resize<span class="tsd-signature-symbol">(</span>obj<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span>, width<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> | </span><a href="Size.html" class="tsd-signature-type">Size</a>, height<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">boolean</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Can be called as either (obj, width, height) or (obj, size). Resize the given object to given width and height or to a given <a href="Size.html">Size</a>.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>obj: <span class="tsd-signature-type">T</span></h5> <div class="tsd-comment tsd-typography"> <p>the object to resize</p> </div> </li> <li> <h5>width: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> | </span><a href="Size.html" class="tsd-signature-type">Size</a></h5> <div class="tsd-comment tsd-typography"> <p>the width or Size to resize the object to</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> height: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>the height to resize the object to</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4> <p>whether or not the resize was successful. False if the object was not in the tree.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="setTo" class="tsd-anchor"></a> <h3> set<wbr>To </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">set<wbr>To<span class="tsd-signature-symbol">(</span>obj<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span>, x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> | </span><a href="Rect.html" class="tsd-signature-type">Rect</a>, y<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, width<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, height<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">boolean</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Updates the given object to have the bounds given, provided as either a <a href="Rect.html">Rect</a> or x, y, width, and height.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>obj: <span class="tsd-signature-type">T</span></h5> <div class="tsd-comment tsd-typography"> <p>the object to change the bounds of</p> </div> </li> <li> <h5>x: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> | </span><a href="Rect.html" class="tsd-signature-type">Rect</a></h5> <div class="tsd-comment tsd-typography"> <p>the x-coordinate or Rect to set the object to</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> y: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>the y-coordinate to set the object to, unnecessary if a Rect was given</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> width: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>the width to set the object to, unnecessary if a Rect was given</p> </div> </li> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> height: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>the height to set the object to, unnecessary if a Rect was given</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="walk" class="tsd-anchor"></a> <h3> walk </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">walk<span class="tsd-signature-symbol">(</span>callback<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">function</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">n</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">QuadNode</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span>, node<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">QuadNode</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span>, root<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</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>Recursively traverses the tree (depth first) and executes the given callback on each node.</p> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>callback: <span class="tsd-signature-type">function</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">n</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">QuadNode</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></h5> <div class="tsd-comment tsd-typography"> <p>the callback to execute on each node. Takes the form of (n: Quadtree) =&gt; void</p> </div> <ul class="tsd-parameters"> </ul> </li> <li> <h5><span class="tsd-flag ts-flagDefault value">Default value</span> node: <span class="tsd-signature-type">QuadNode</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> =&nbsp;this._root</span></h5> </li> <li> <h5><span class="tsd-flag ts-flagDefault value">Default value</span> root: <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol"> =&nbsp;true</span></h5> <div class="tsd-comment tsd-typography"> <p>whether or not to execute the callback on the root node as well. Defaults to true</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> </section> </div> <div class="col-4 col-menu menu-sticky-wrap menu-highlight"> <nav class="tsd-navigation primary"> <ul> <li class="globals "> <a href="../index.html"><em>GoJS <wbr>Class <wbr>Index</em></a> </li> </ul> </nav> <nav class="tsd-navigation secondary menu-sticky"> <ul class="before-current"> </ul> <ul class="current"> <li class="current tsd-kind-class tsd-has-type-parameter tsd-is-extension"> <a href="Quadtree.html" class="tsd-kind-icon">Quadtree</a> <ul> <li class=" tsd-kind-constructor tsd-parent-kind-class"> <a href="Quadtree.html#constructor" class="tsd-kind-icon">constructor</a> </li> <li class=" tsd-kind-get-signature tsd-parent-kind-class"> <a href="Quadtree.html#bounds" class="tsd-kind-icon">bounds</a> </li> <li class=" tsd-kind-get-signature tsd-parent-kind-class"> <a href="Quadtree.html#maxLevels" class="tsd-kind-icon">max<wbr>Levels</a> </li> <li class=" tsd-kind-get-signature tsd-parent-kind-class"> <a href="Quadtree.html#nodeCapacity" class="tsd-kind-icon">node<wbr>Capacity</a> </li> <li class=" tsd-kind-get-signature tsd-parent-kind-class"> <a href="Quadtree.html#root" class="tsd-kind-icon">root</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="Quadtree.html#add" class="tsd-kind-icon">add</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="Quadtree.html#clear" class="tsd-kind-icon">clear</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="Quadtree.html#containing" class="tsd-kind-icon">containing</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="Quadtree.html#distanceSquared" class="tsd-kind-icon">distance<wbr>Squared</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="Quadtree.html#find" class="tsd-kind-icon">find</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="Quadtree.html#findBounds" class="tsd-kind-icon">find<wbr>Bounds</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="Quadtree.html#findExtremeObjects" class="tsd-kind-icon">find<wbr>Extreme<wbr>Objects</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="Quadtree.html#forEach" class="tsd-kind-icon">for<wbr>Each</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="Quadtree.html#has" class="tsd-kind-icon">has</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="Quadtree.html#intersecting" class="tsd-kind-icon">intersecting</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="Quadtree.html#move" class="tsd-kind-icon">move</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <