Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* |
| 18 | ONOS GUI -- Topology Layout Module. |
| 19 | Module that contains the d3.force.layout logic |
| 20 | */ |
| 21 | |
| 22 | (function () { |
| 23 | 'use strict'; |
| 24 | |
Steven Burrows | 42eb9e2 | 2017-02-06 14:20:24 +0000 | [diff] [blame] | 25 | var instance, |
| 26 | updateTimer; |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 27 | |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 28 | // default settings for force layout |
| 29 | var defaultSettings = { |
| 30 | gravity: 0.4, |
| 31 | friction: 0.7, |
| 32 | charge: { |
| 33 | // note: key is node.class |
| 34 | device: -8000, |
Steven Burrows | 583f4be | 2016-11-04 14:06:50 +0100 | [diff] [blame] | 35 | host: -20000, |
Steven Burrows | b11a8b8 | 2017-03-10 16:00:31 +0000 | [diff] [blame] | 36 | region: -8000, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 37 | _def_: -12000, |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 38 | }, |
| 39 | linkDistance: { |
| 40 | // note: key is link.type |
| 41 | direct: 100, |
| 42 | optical: 120, |
Steven Burrows | b11a8b8 | 2017-03-10 16:00:31 +0000 | [diff] [blame] | 43 | UiEdgeLink: 100, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 44 | _def_: 50, |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 45 | }, |
| 46 | linkStrength: { |
| 47 | // note: key is link.type |
| 48 | // range: {0.0 ... 1.0} |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 49 | _def_: 1.0, |
| 50 | }, |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | // configuration |
| 54 | var linkConfig = { |
| 55 | light: { |
| 56 | baseColor: '#939598', |
| 57 | inColor: '#66f', |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 58 | outColor: '#f00', |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 59 | }, |
| 60 | dark: { |
| 61 | // TODO : theme |
| 62 | baseColor: '#939598', |
| 63 | inColor: '#66f', |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 64 | outColor: '#f00', |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 65 | }, |
| 66 | inWidth: 12, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 67 | outWidth: 10, |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | // internal state |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 71 | var nodeLock = false; // whether nodes can be dragged or not (locked) |
Steven Burrows | 9edc7e0 | 2016-08-29 11:52:07 +0100 | [diff] [blame] | 72 | |
Steven Burrows | a3fca81 | 2016-10-14 15:11:04 -0500 | [diff] [blame] | 73 | // predicate that indicates when clicking is active |
| 74 | function clickEnabled() { |
| 75 | return true; |
| 76 | } |
| 77 | |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 78 | angular.module('ovTopo2') |
| 79 | .factory('Topo2LayoutService', |
| 80 | [ |
Steven Burrows | 42eb9e2 | 2017-02-06 14:20:24 +0000 | [diff] [blame] | 81 | '$log', '$timeout', 'WebSocketService', 'SvgUtilService', 'Topo2RegionService', |
Steven Burrows | 448468c | 2017-04-13 16:09:30 -0700 | [diff] [blame] | 82 | 'Topo2ViewService', 'Topo2SelectService', 'Topo2ZoomService', |
Steven Burrows | 6a4febe | 2017-04-20 11:45:33 -0400 | [diff] [blame] | 83 | 'Topo2ViewController', 'Topo2RegionNavigationService', |
Steven Burrows | 448468c | 2017-04-13 16:09:30 -0700 | [diff] [blame] | 84 | function ($log, $timeout, wss, sus, t2rs, t2vs, t2ss, t2zs, |
Steven Burrows | 6a4febe | 2017-04-20 11:45:33 -0400 | [diff] [blame] | 85 | ViewController, t2rns) { |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 86 | |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 87 | var Layout = ViewController.extend({ |
Steven Burrows | bd40284 | 2017-03-08 21:30:38 +0000 | [diff] [blame] | 88 | init: function (svg, forceG, uplink, dim, zoomer, opts) { |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 89 | instance = this; |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 90 | |
Steven Burrows | 6a4febe | 2017-04-20 11:45:33 -0400 | [diff] [blame] | 91 | var navToRegion = this.navigateToRegionHandler.bind(this); |
| 92 | t2rns.addListener('region:navigation-start', navToRegion); |
| 93 | |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 94 | this.svg = svg; |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 95 | |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 96 | // Append all the SVG Group elements to the forceG object |
| 97 | this.createForceElements(); |
| 98 | |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 99 | this.dim = dim; |
| 100 | this.zoomer = zoomer; |
| 101 | |
| 102 | this.settings = angular.extend({}, defaultSettings, opts); |
| 103 | |
| 104 | this.link = this.elements.linkG.selectAll('.link'); |
| 105 | this.elements.linkLabelG.selectAll('.linkLabel'); |
| 106 | this.node = this.elements.nodeG.selectAll('.node'); |
| 107 | }, |
| 108 | createForceElements: function () { |
| 109 | |
| 110 | this.prevForce = this.forceG; |
| 111 | |
Simon Hunt | 95f4b42 | 2017-03-03 13:49:05 -0800 | [diff] [blame] | 112 | this.forceG = d3.select('#topo2-zoomlayer') |
| 113 | .append('g').attr('class', 'topo2-force'); |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 114 | |
| 115 | this.elements = { |
Simon Hunt | 95f4b42 | 2017-03-03 13:49:05 -0800 | [diff] [blame] | 116 | linkG: this.addElement(this.forceG, 'topo2-links'), |
| 117 | linkLabelG: this.addElement(this.forceG, 'topo2-linkLabels'), |
| 118 | numLinksLabels: this.addElement(this.forceG, 'topo2-numLinkLabels'), |
| 119 | nodeG: this.addElement(this.forceG, 'topo2-nodes'), |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 120 | portLabels: this.addElement(this.forceG, 'topo2-portLabels'), |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 121 | }; |
| 122 | }, |
| 123 | addElement: function (parent, className) { |
| 124 | return parent.append('g').attr('class', className); |
| 125 | }, |
| 126 | settingOrDefault: function (settingName, node) { |
| 127 | var nodeType = node.get('nodeType'); |
| 128 | return this.settings[settingName][nodeType] || this.settings[settingName]._def_; |
| 129 | }, |
| 130 | createForceLayout: function () { |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 131 | |
| 132 | this.force = d3.layout.force() |
| 133 | .size(t2vs.getDimensions()) |
| 134 | .gravity(this.settings.gravity) |
| 135 | .friction(this.settings.friction) |
| 136 | .charge(this.settingOrDefault.bind(this, 'charge')) |
| 137 | .linkDistance(this.settingOrDefault.bind(this, 'linkDistance')) |
| 138 | .linkStrength(this.settingOrDefault.bind(this, 'linkStrength')) |
Steven Burrows | 6de27f4 | 2017-03-30 16:21:27 +0100 | [diff] [blame] | 139 | .nodes([]) |
| 140 | .links([]) |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 141 | .on('tick', this.tick.bind(this)) |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 142 | .start(); |
| 143 | |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 144 | this.drag = sus.createDragBehavior(this.force, |
Steven Burrows | 5fa057e | 2017-03-15 17:07:56 +0000 | [diff] [blame] | 145 | function () {}, // click event is no longer handled in the drag service |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 146 | this.atDragEnd, |
| 147 | this.dragEnabled.bind(this), |
Steven Burrows | 2b15ae7 | 2017-04-28 10:24:43 -0400 | [diff] [blame] | 148 | clickEnabled, |
| 149 | t2zs |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 150 | ); |
| 151 | |
| 152 | this.update(); |
| 153 | }, |
| 154 | centerLayout: function () { |
Simon Hunt | 95f4b42 | 2017-03-03 13:49:05 -0800 | [diff] [blame] | 155 | d3.select('#topo2-zoomlayer').attr('data-layout', t2rs.model.get('id')); |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 156 | |
Simon Hunt | 95f4b42 | 2017-03-03 13:49:05 -0800 | [diff] [blame] | 157 | var zoomer = d3.select('#topo2-zoomlayer').node().getBBox(), |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 158 | layoutBBox = this.forceG.node().getBBox(), |
| 159 | scale = (zoomer.height - 150) / layoutBBox.height, |
| 160 | x = (zoomer.width / 2) - ((layoutBBox.x + layoutBBox.width / 2) * scale), |
| 161 | y = (zoomer.height / 2) - ((layoutBBox.y + layoutBBox.height / 2) * scale); |
| 162 | |
| 163 | t2zs.panAndZoom([x, y], scale, 1000); |
| 164 | }, |
Steven Burrows | a31c5b0 | 2017-04-12 10:45:08 -0700 | [diff] [blame] | 165 | setLinkPosition: function (link) { |
| 166 | link.setPosition.bind(link)(); |
| 167 | }, |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 168 | tick: function () { |
Steven Burrows | 42eb9e2 | 2017-02-06 14:20:24 +0000 | [diff] [blame] | 169 | |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 170 | this.node |
| 171 | .attr({ |
| 172 | transform: function (d) { |
| 173 | var dx = isNaN(d.x) ? 0 : d.x, |
| 174 | dy = isNaN(d.y) ? 0 : d.y; |
| 175 | return sus.translate(dx, dy); |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 176 | }, |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 177 | }); |
Steven Burrows | a31c5b0 | 2017-04-12 10:45:08 -0700 | [diff] [blame] | 178 | |
| 179 | this.link |
| 180 | .each(this.setLinkPosition) |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 181 | .attr('x1', function (d) { return d.get('position').x1; }) |
| 182 | .attr('y1', function (d) { return d.get('position').y1; }) |
| 183 | .attr('x2', function (d) { return d.get('position').x2; }) |
| 184 | .attr('y2', function (d) { return d.get('position').y2; }); |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 185 | }, |
| 186 | |
| 187 | start: function () { |
| 188 | this.force.start(); |
| 189 | }, |
| 190 | update: function () { |
Steven Burrows | 42eb9e2 | 2017-02-06 14:20:24 +0000 | [diff] [blame] | 191 | |
| 192 | if (updateTimer) { |
| 193 | $timeout.cancel(updateTimer); |
| 194 | } |
| 195 | updateTimer = $timeout(this._update.bind(this), 150); |
| 196 | }, |
| 197 | _update: function () { |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 198 | this.updateNodes(); |
| 199 | this.updateLinks(); |
Steven Burrows | 3d8d933 | 2017-03-30 15:05:52 +0100 | [diff] [blame] | 200 | this.force.start(); |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 201 | }, |
| 202 | updateNodes: function () { |
| 203 | var regionNodes = t2rs.regionNodes(); |
| 204 | |
| 205 | // select all the nodes in the layout: |
| 206 | this.node = this.elements.nodeG.selectAll('.node') |
| 207 | .data(regionNodes, function (d) { return d.get('id'); }); |
| 208 | |
| 209 | var entering = this.node.enter() |
| 210 | .append('g') |
| 211 | .attr({ |
| 212 | id: function (d) { return sus.safeId(d.get('id')); }, |
| 213 | class: function (d) { return d.svgClassName(); }, |
| 214 | transform: function (d) { |
| 215 | // Need to guard against NaN here ?? |
| 216 | return sus.translate(d.node.x, d.node.y); |
| 217 | }, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 218 | opacity: 0, |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 219 | }) |
| 220 | .call(this.drag) |
| 221 | .transition() |
| 222 | .attr('opacity', 1); |
| 223 | |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 224 | entering.each(function (d) { d.onEnter(this, d); }); |
Steven Burrows | 3d8d933 | 2017-03-30 15:05:52 +0100 | [diff] [blame] | 225 | |
| 226 | this.force.nodes(regionNodes); |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 227 | }, |
| 228 | updateLinks: function () { |
| 229 | |
| 230 | var regionLinks = t2rs.regionLinks(); |
| 231 | |
| 232 | this.link = this.elements.linkG.selectAll('.link') |
Steven Burrows | 2b29ca4 | 2017-05-12 10:58:05 -0400 | [diff] [blame] | 233 | .data(regionLinks, function (d) { return d.get('id'); }); |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 234 | |
| 235 | // operate on entering links: |
| 236 | var entering = this.link.enter() |
| 237 | .append('line') |
| 238 | .call(this.calcPosition) |
| 239 | .attr({ |
| 240 | x1: function (d) { return d.get('position').x1; }, |
| 241 | y1: function (d) { return d.get('position').y1; }, |
| 242 | x2: function (d) { return d.get('position').x2; }, |
| 243 | y2: function (d) { return d.get('position').y2; }, |
| 244 | stroke: linkConfig.light.inColor, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 245 | 'stroke-width': linkConfig.inWidth, |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 246 | }); |
| 247 | |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 248 | entering.each(function (d) { d.onEnter(this, d); }); |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 249 | |
| 250 | // operate on exiting links: |
| 251 | this.link.exit() |
Steven Burrows | 42eb9e2 | 2017-02-06 14:20:24 +0000 | [diff] [blame] | 252 | .attr('stroke-dasharray', '3 3') |
| 253 | .style('opacity', 0.5) |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 254 | .transition() |
Steven Burrows | 42eb9e2 | 2017-02-06 14:20:24 +0000 | [diff] [blame] | 255 | .duration(1500) |
| 256 | .attr({ |
| 257 | 'stroke-dasharray': '3 12', |
| 258 | }) |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 259 | .style('opacity', 0.0) |
| 260 | .remove(); |
Steven Burrows | 3d8d933 | 2017-03-30 15:05:52 +0100 | [diff] [blame] | 261 | |
| 262 | this.force.links(regionLinks); |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 263 | }, |
| 264 | calcPosition: function () { |
| 265 | var lines = this; |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 266 | lines.each(function (d) { |
Steven Burrows | 32ce1d9 | 2017-04-13 13:18:44 -0700 | [diff] [blame] | 267 | d.setPosition.bind(d)(); |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 268 | }); |
| 269 | }, |
| 270 | sendUpdateMeta: function (d, clearPos) { |
| 271 | var metaUi = {}, |
| 272 | ll; |
| 273 | |
| 274 | // if we are not clearing the position data (unpinning), |
| 275 | // attach the x, y, (and equivalent longitude, latitude)... |
| 276 | if (!clearPos) { |
| 277 | ll = d.lngLatFromCoord([d.x, d.y]); |
| 278 | metaUi = { |
| 279 | x: d.x, |
| 280 | y: d.y, |
| 281 | equivLoc: { |
| 282 | lng: ll[0], |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 283 | lat: ll[1], |
| 284 | }, |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 285 | }; |
| 286 | } |
| 287 | d.metaUi = metaUi; |
| 288 | wss.sendEvent('updateMeta2', { |
| 289 | id: d.get('id'), |
| 290 | class: d.get('class'), |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 291 | memento: metaUi, |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 292 | }); |
| 293 | }, |
| 294 | setDimensions: function () { |
| 295 | if (this.force) { |
| 296 | this.force.size(t2vs.getDimensions()); |
| 297 | } |
| 298 | }, |
| 299 | dragEnabled: function () { |
| 300 | var ev = d3.event.sourceEvent; |
| 301 | // nodeLock means we aren't allowing nodes to be dragged... |
| 302 | return !nodeLock && !this.zoomingOrPanning(ev); |
| 303 | }, |
| 304 | zoomingOrPanning: function (ev) { |
| 305 | return ev.metaKey || ev.altKey; |
| 306 | }, |
| 307 | atDragEnd: function (d) { |
| 308 | // once we've finished moving, pin the node in position |
Steven Burrows | b11a8b8 | 2017-03-10 16:00:31 +0000 | [diff] [blame] | 309 | d.fix(true); |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 310 | instance.sendUpdateMeta(d); |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 311 | t2ss.clickConsumed(true); |
| 312 | }, |
| 313 | transitionDownRegion: function () { |
| 314 | |
| 315 | this.prevForce.transition() |
| 316 | .duration(1500) |
| 317 | .style('opacity', 0) |
| 318 | .remove(); |
| 319 | |
| 320 | this.forceG |
| 321 | .style('opacity', 0) |
| 322 | .transition() |
| 323 | .delay(500) |
| 324 | .duration(500) |
Steven Burrows | 6a4febe | 2017-04-20 11:45:33 -0400 | [diff] [blame] | 325 | .style('opacity', 1) |
| 326 | .each('end', function () { |
| 327 | t2rns.navigateToRegionComplete(); |
| 328 | }); |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 329 | }, |
| 330 | transitionUpRegion: function () { |
| 331 | this.prevForce.transition() |
| 332 | .duration(1000) |
| 333 | .style('opacity', 0) |
| 334 | .remove(); |
| 335 | |
| 336 | this.forceG |
| 337 | .style('opacity', 0) |
| 338 | .transition() |
| 339 | .delay(500) |
| 340 | .duration(500) |
Steven Burrows | 6a4febe | 2017-04-20 11:45:33 -0400 | [diff] [blame] | 341 | .style('opacity', 1) |
| 342 | .each('end', function () { |
| 343 | t2rns.navigateToRegionComplete(); |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 344 | }); ; |
Steven Burrows | 6a4febe | 2017-04-20 11:45:33 -0400 | [diff] [blame] | 345 | }, |
| 346 | navigateToRegionHandler: function () { |
| 347 | this.createForceElements(); |
| 348 | this.transitionDownRegion(); |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 349 | }, |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 350 | }); |
| 351 | |
| 352 | function getInstance(svg, forceG, uplink, dim, zoomer, opts) { |
| 353 | return instance || new Layout(svg, forceG, uplink, dim, zoomer, opts); |
| 354 | } |
| 355 | |
Steven Burrows | bd40284 | 2017-03-08 21:30:38 +0000 | [diff] [blame] | 356 | return getInstance(); |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 357 | }, |
Steven Burrows | ec1f45c | 2016-08-08 16:14:41 +0100 | [diff] [blame] | 358 | ] |
| 359 | ); |
| 360 | })(); |