You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4 lines
78 KiB

5 years ago
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.cola=a()}}(function(){return function(){function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){return e(b[g][1][a]||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}return a}()({1:[function(a,b,c){"use strict";function d(a){for(var b in a)c.hasOwnProperty(b)||(c[b]=a[b])}Object.defineProperty(c,"__esModule",{value:!0}),d(a("./src/adaptor")),d(a("./src/d3adaptor")),d(a("./src/descent")),d(a("./src/geom")),d(a("./src/gridrouter")),d(a("./src/handledisconnected")),d(a("./src/layout")),d(a("./src/layout3d")),d(a("./src/linklengths")),d(a("./src/powergraph")),d(a("./src/pqueue")),d(a("./src/rbtree")),d(a("./src/rectangle")),d(a("./src/shortestpaths")),d(a("./src/vpsc")),d(a("./src/batch"))},{"./src/adaptor":2,"./src/batch":3,"./src/d3adaptor":4,"./src/descent":7,"./src/geom":8,"./src/gridrouter":9,"./src/handledisconnected":10,"./src/layout":11,"./src/layout3d":12,"./src/linklengths":13,"./src/powergraph":14,"./src/pqueue":15,"./src/rbtree":16,"./src/rectangle":17,"./src/shortestpaths":18,"./src/vpsc":19}],2:[function(a,b,c){"use strict";function d(a){return new g(a)}var e=this&&this.__extends||function(){var a=function(b,c){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])})(b,c)};return function(b,c){function d(){this.constructor=b}a(b,c),b.prototype=null===c?Object.create(c):(d.prototype=c.prototype,new d)}}();Object.defineProperty(c,"__esModule",{value:!0});var f=a("./layout"),g=function(a){function b(b){var c=a.call(this)||this,d=b;return d.trigger&&(c.trigger=d.trigger),d.kick&&(c.kick=d.kick),d.drag&&(c.drag=d.drag),d.on&&(c.on=d.on),c.dragstart=c.dragStart=f.Layout.dragStart,c.dragend=c.dragEnd=f.Layout.dragEnd,c}return e(b,a),b.prototype.trigger=function(a){},b.prototype.kick=function(){},b.prototype.drag=function(){},b.prototype.on=function(a,b){return this},b}(f.Layout);c.LayoutAdaptor=g,c.adaptor=d},{"./layout":11}],3:[function(a,b,c){"use strict";function d(a,b,c,d){return a.cola.start(0,0,0,10,!1),e(a.cola.nodes(),a.cola.groups(),c,d).routeEdges(a.powerGraph.powerEdges,b,function(a){return a.source.routerNode.id},function(a){return a.target.routerNode.id})}function e(a,b,c,d){a.forEach(function(a){a.routerNode={name:a.name,bounds:a.bounds.inflate(-c)}}),b.forEach(function(b){b.routerNode={bounds:b.bounds.inflate(-d),children:(void 0!==b.groups?b.groups.map(function(b){return a.length+b.id}):[]).concat(void 0!==b.leaves?b.leaves.map(function(a){return a.index}):[])}});var e=a.concat(b).map(function(a,b){return a.routerNode.id=b,a.routerNode});return new h.GridRouter(e,{getChildren:function(a){return a.children},getBounds:function(a){return a.bounds}},c-d)}function f(a,b,c){var d;a.nodes.forEach(function(a,b){return a.index=b}),(new g.Layout).avoidOverlaps(!1).nodes(a.nodes).links(a.links).powerGraphGroups(function(a){d=a,d.groups.forEach(function(a){return a.padding=c})});var e=a.nodes.length,f=[],h=a.nodes.slice(0);return h.forEach(function(a,b){return a.index=b}),d.groups.forEach(function(a){var b=a.index=a.id+e;h.push(a),void 0!==a.leaves&&a.leaves.forEach(function(a){return f.push({source:b,target:a.index})}),void 0!==a.groups&&a.groups.forEach(function(a){return f.push({source:b,target:a.id+e})})}),d.powerEdges.forEach(function(a){f.push({source:a.source.index,target:a.target.index})}),(new g.Layout).size(b).nodes(h).links(f).avoidOverlaps(!1).linkDistance(30).symmetricDiffLinkLengths(5).convergenceThreshold(1e-4).start(100,0,0,0,!1),{cola:(new g.
this._groups=[],this._rootGroup=null,this._links=[],this._constraints=[],this._distanceMatrix=null,this._descent=null,this._directedLinkConstraints=null,this._threshold=.01,this._visibilityGraph=null,this._groupCompactness=1e-6,this.event=null,this.linkAccessor={getSourceIndex:a.getSourceIndex,getTargetIndex:a.getTargetIndex,setLength:a.setLinkLength,getType:function(a){return"function"==typeof b._linkType?b._linkType(a):0}}}return a.prototype.on=function(a,b){return this.event||(this.event={}),"string"==typeof a?this.event[e[a]]=b:this.event[a]=b,this},a.prototype.trigger=function(a){this.event&&void 0!==this.event[a.type]&&this.event[a.type](a)},a.prototype.kick=function(){for(;!this.tick(););},a.prototype.tick=function(){if(this._alpha<this._threshold)return this._running=!1,this.trigger({type:e.end,alpha:this._alpha=0,stress:this._lastStress}),!0;var a,b,c=this._nodes.length;this._links.length;for(this._descent.locks.clear(),b=0;b<c;++b)if(a=this._nodes[b],a.fixed){void 0!==a.px&&void 0!==a.py||(a.px=a.x,a.py=a.y);var d=[a.px,a.py];this._descent.locks.add(b,d)}var f=this._descent.rungeKutta();return 0===f?this._alpha=0:void 0!==this._lastStress&&(this._alpha=f),this._lastStress=f,this.updateNodePositions(),this.trigger({type:e.tick,alpha:this._alpha,stress:this._lastStress}),!1},a.prototype.updateNodePositions=function(){for(var a,b=this._descent.x[0],c=this._descent.x[1],d=this._nodes.length;d--;)a=this._nodes[d],a.x=b[d],a.y=c[d]},a.prototype.nodes=function(a){if(!a){if(0===this._nodes.length&&this._links.length>0){var b=0;this._links.forEach(function(a){b=Math.max(b,a.source,a.target)}),this._nodes=new Array(++b);for(var c=0;c<b;++c)this._nodes[c]={}}return this._nodes}return this._nodes=a,this},a.prototype.groups=function(a){var b=this;return a?(this._groups=a,this._rootGroup={},this._groups.forEach(function(a){void 0===a.padding&&(a.padding=1),void 0!==a.leaves&&a.leaves.forEach(function(c,d){"number"==typeof c&&((a.leaves[d]=b._nodes[c]).parent=a)}),void 0!==a.groups&&a.groups.forEach(function(c,d){"number"==typeof c&&((a.groups[d]=b._groups[c]).parent=a)})}),this._rootGroup.leaves=this._nodes.filter(function(a){return void 0===a.parent}),this._rootGroup.groups=this._groups.filter(function(a){return void 0===a.parent}),this):this._groups},a.prototype.powerGraphGroups=function(a){var b=f.getGroups(this._nodes,this._links,this.linkAccessor,this._rootGroup);return this.groups(b.groups),a(b),this},a.prototype.avoidOverlaps=function(a){return arguments.length?(this._avoidOverlaps=a,this):this._avoidOverlaps},a.prototype.handleDisconnected=function(a){return arguments.length?(this._handleDisconnected=a,this):this._handleDisconnected},a.prototype.flowLayout=function(a,b){return arguments.length||(a="y"),this._directedLinkConstraints={axis:a,getMinSeparation:"number"==typeof b?function(){return b}:b},this},a.prototype.links=function(a){return arguments.length?(this._links=a,this):this._links},a.prototype.constraints=function(a){return arguments.length?(this._constraints=a,this):this._constraints},a.prototype.distanceMatrix=function(a){return arguments.length?(this._distanceMatrix=a,this):this._distanceMatrix},a.prototype.size=function(a){return a?(this._canvasSize=a,this):this._canvasSize},a.prototype.defaultNodeSize=function(a){return a?(this._defaultNodeSize=a,this):this._defaultNodeSize},a.prototype.groupCompactness=function(a){return a?(this._groupCompactness=a,this):this._groupCompactness},a.prototype.linkDistance=function(a){return a?(this._linkDistance="function"==typeof a?a:+a,this._linkLengthCalculator=null,this):this._linkDistance},a.prototype.linkType=function(a){return this._linkType=a,this},a.prototype.convergenceThreshold=function(a){return a?(this._threshold="function"==typeof a?a:+a,this):this._threshold},a.prototype.alpha=function(a){return arguments.length?(a=+a,this._alpha?this._alpha=a>0?a:0:a>0&&(this._running||(this._running=!0,this.trigger({type:e.start,alpha:this._alpha=a}),this.kick())),this):this._alpha},a.prototype.getLinkLength=function(a){return"function"==typeof this._linkDistance?+this._
d.solve(),b.forEach(function(b,c){return a[c].setYCentre(b.position())})}var r=this&&this.__extends||function(){var a=function(b,c){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])})(b,c)};return function(b,c){function d(){this.constructor=b}a(b,c),b.prototype=null===c?Object.create(c):(d.prototype=c.prototype,new d)}}();Object.defineProperty(c,"__esModule",{value:!0});var s=a("./vpsc"),t=a("./rbtree");c.computeGroupBounds=d;var u=function(){function a(a,b,c,d){this.x=a,this.X=b,this.y=c,this.Y=d}return a.empty=function(){return new a(Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY)},a.prototype.cx=function(){return(this.x+this.X)/2},a.prototype.cy=function(){return(this.y+this.Y)/2},a.prototype.overlapX=function(a){var b=this.cx(),c=a.cx();return b<=c&&a.x<this.X?this.X-a.x:c<=b&&this.x<a.X?a.X-this.x:0},a.prototype.overlapY=function(a){var b=this.cy(),c=a.cy();return b<=c&&a.y<this.Y?this.Y-a.y:c<=b&&this.y<a.Y?a.Y-this.y:0},a.prototype.setXCentre=function(a){var b=a-this.cx();this.x+=b,this.X+=b},a.prototype.setYCentre=function(a){var b=a-this.cy();this.y+=b,this.Y+=b},a.prototype.width=function(){return this.X-this.x},a.prototype.height=function(){return this.Y-this.y},a.prototype.union=function(b){return new a(Math.min(this.x,b.x),Math.max(this.X,b.X),Math.min(this.y,b.y),Math.max(this.Y,b.Y))},a.prototype.lineIntersections=function(b,c,d,e){for(var f=[[this.x,this.y,this.X,this.y],[this.X,this.y,this.X,this.Y],[this.X,this.Y,this.x,this.Y],[this.x,this.Y,this.x,this.y]],g=[],h=0;h<4;++h){var i=a.lineIntersection(b,c,d,e,f[h][0],f[h][1],f[h][2],f[h][3]);null!==i&&g.push({x:i.x,y:i.y})}return g},a.prototype.rayIntersection=function(a,b){var c=this.lineIntersections(this.cx(),this.cy(),a,b);return c.length>0?c[0]:null},a.prototype.vertices=function(){return[{x:this.x,y:this.y},{x:this.X,y:this.y},{x:this.X,y:this.Y},{x:this.x,y:this.Y}]},a.lineIntersection=function(a,b,c,d,e,f,g,h){var i=c-a,j=g-e,k=d-b,l=h-f,m=l*i-j*k;if(0==m)return null;var n=a-e,o=b-f,p=j*o-l*n,q=p/m,r=i*o-k*n,s=r/m;return q>=0&&q<=1&&s>=0&&s<=1?{x:a+q*i,y:b+q*k}:null},a.prototype.inflate=function(b){return new a(this.x-b,this.X+b,this.y-b,this.Y+b)},a}();c.Rectangle=u,c.makeEdgeBetween=e,c.makeEdgeTo=f;var v=function(){function a(a,b,c){this.v=a,this.r=b,this.pos=c,this.prev=h(),this.next=h()}return a}(),w=function(){function a(a,b,c){this.isOpen=a,this.v=b,this.pos=c}return a}(),x={getCentre:function(a){return a.cx()},getOpen:function(a){return a.y},getClose:function(a){return a.Y},getSize:function(a){return a.width()},makeRect:function(a,b,c,d){return new u(c-d/2,c+d/2,a,b)},findNeighbours:k},y={getCentre:function(a){return a.cy()},getOpen:function(a){return a.x},getClose:function(a){return a.X},getSize:function(a){return a.height()},makeRect:function(a,b,c,d){return new u(a,b,c-d/2,c+d/2)},findNeighbours:l};c.generateXConstraints=m,c.generateYConstraints=n,c.generateXGroupConstraints=o,c.generateYGroupConstraints=p,c.removeOverlaps=q;var z=function(a){function b(b,c){var d=a.call(this,0,c)||this;return d.index=b,d}return r(b,a),b}(s.Variable);c.IndexedVariable=z;var A=function(){function a(a,b,c,e,f){var g=this;if(void 0===c&&(c=null),void 0===e&&(e=null),void 0===f&&(f=!1),this.nodes=a,this.groups=b,this.rootGroup=c,this.avoidOverlaps=f,this.variables=a.map(function(a,b){return a.variable=new z(b,1)}),e&&this.createConstraints(e),f&&c&&void 0!==c.groups){a.forEach(function(a){if(!a.width||!a.height)return void(a.bounds=new u(a.x,a.x,a.y,a.y));var b=a.width/2,c=a.height/2;a.bounds=new u(a.x-b,a.x+b,a.y-c,a.y+c)}),d(c);var h=a.length;b.forEach(function(a){g.variables[h]=a.minVar=new z(h++,void 0!==a.stiffness?a.stiffness:.01),g.variables[h]=a.maxVar=new z(h++,void 0!==a.stiffness?a.stiffness:.01)})}}return a.prototype.createSeparation=function(a){return new s.Constraint(this.nodes[a.left].variable,this.nodes[a.right].variable,a.gap,void 0!==a.equality&&a.equality)},a.prototype.makeFeasibl
//# sourceMappingURL=cola.min.js.map