
demolib.vivagraph.min.js Maven / Gradle / Ivy
The newest version!
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.Viva=e()}}(function(){return function e(n,t,r){function o(a,u){if(!t[a]){if(!n[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(i)return i(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=t[a]={exports:{}};n[a][0].call(c.exports,function(e){var t=n[a][1][e];return o(t?t:e)},c,c.exports,e,n,t,r)}return t[a].exports}for(var i="function"==typeof require&&require,a=0;a=0==m>=4?null:(f=u-i,d=o-a,p=a*i-o*u,v=f*e+d*n+p,g=f*t+d*r+p,0!==v&&0!==g&&v>=0==g>=0?null:(y=s*d-f*c,0===y?null:(x=0>y?-y/2:y/2,x=0,w=c*p-d*l,b.x=(0>w?w-x:w+x)/y,w=f*l-s*p,b.y=(0>w?w-x:w+x)/y,b)))}n.exports=r},{}],3:[function(e,n,t){n.exports.degree=e("./src/degree.js"),n.exports.betweenness=e("./src/betweenness.js")},{"./src/betweenness.js":4,"./src/degree.js":5}],4:[function(e,n,t){function r(e,n){function t(e){g[e]/=2}function r(e){g[e.id]=0}function o(e){s=e.id,u(s),i()}function i(){for(e.forEachNode(a);c.length;){for(var n=c.pop(),t=(1+v[n])/p[n],r=d[n],o=0;o1&&(o=Array.prototype.splice.call(arguments,1));for(var i=0;ir;++r){var o=e.links[r],i=o.fromId!==e.id?w[o.fromId]:w[o.toId];i&&i.pos&&n.push(i)}return n}function v(e){var n=w[e];n.mass=m(e)}function g(e){return e&&(e.isPinned||e.data&&e.data.isPinned)}function h(e){var n=w[e];return n||(f(e),n=w[e]),n}function m(e){return 1+n.getLinks(e).length/3}if(!n)throw new Error("Graph structure cannot be undefined");var y=e("ngraph.physics.simulator"),x=y(t),w="function"==typeof Object.create?Object.create(null):{},b={},E=x.settings.springTransform||o;s(),a();var L={step:function(){return x.step()},getNodePosition:function(e){return h(e).pos},setNodePosition:function(e){var n=h(e);n.setPosition.apply(n,Array.prototype.slice.call(arguments,1))},getLinkPosition:function(e){var n=b[e];return n?{from:n.from.pos,to:n.to.pos}:void 0},getGraphRect:function(){return x.getBBox()},pinNode:function(e,n){var t=h(e.id);t.isPinned=!!n},isNodePinned:function(e){return h(e.id).isPinned},dispose:function(){n.off("changed",u)},getBody:i,getSpring:r,simulator:x};return L}function o(){}n.exports=r,n.exports.simulator=e("ngraph.physics.simulator")},{"ngraph.physics.simulator":8}],8:[function(e,n,t){function r(n){function t(){var e,n=l.length;if(n)for(v.insertBodies(l);n--;)e=l[n],e.isPinned||(e.force.reset(),v.updateBodyForce(e),m.update(e));for(n=p.length;n--;)h.update(p[n])}var r=e("./lib/spring"),o=e("ngraph.expose"),i=e("ngraph.merge");n=i(n,{springLength:30,springCoeff:8e-4,gravity:-1.2,theta:.8,dragCoeff:.02,timeStep:20,stableThreshold:.009});var a=n.createQuadTree||e("ngraph.quadtreebh"),u=n.createBounds||e("./lib/bounds"),s=n.createDragForce||e("./lib/dragForce"),f=n.createSpringForce||e("./lib/springForce"),c=n.integrator||e("./lib/eulerIntegrator"),d=n.createBody||e("./lib/createBody"),l=[],p=[],v=a(n),g=u(l,n),h=f(n),m=s(n),y={bodies:l,springs:p,settings:n,step:function(){t();var e=c(l,n.timeStep);return g.update(),en))return l.splice(n,1),0===l.length&&g.reset(),!0}},addSpring:function(e,n,t,o,i){if(!e||!n)throw new Error("Cannot add null spring to force simulator");"number"!=typeof t&&(t=-1);var a=new r(e,n,t,i>=0?i:-1,o);return p.push(a),a},removeSpring:function(e){if(e){var n=p.indexOf(e);return n>-1?(p.splice(n,1),!0):void 0}},getBestNewBodyPosition:function(e){return g.getBestNewPosition(e)},getBBox:function(){return g.box},gravity:function(e){return void 0!==e?(n.gravity=e,v.options({gravity:e}),this):n.gravity},theta:function(e){return void 0!==e?(n.theta=e,v.options({theta:e}),this):n.theta}};return o(n,y),y}n.exports=r},{"./lib/bounds":9,"./lib/createBody":10,"./lib/dragForce":11,"./lib/eulerIntegrator":12,"./lib/spring":13,"./lib/springForce":14,"ngraph.expose":15,"ngraph.merge":24,"ngraph.quadtreebh":17}],9:[function(e,n,t){n.exports=function(n,t){function r(){var e=n.length;if(0!==e){for(var t=Number.MAX_VALUE,r=Number.MAX_VALUE,o=Number.MIN_VALUE,a=Number.MIN_VALUE;e--;){var u=n[e];u.isPinned?(u.pos.x=u.prevPos.x,u.pos.y=u.prevPos.y):(u.prevPos.x=u.pos.x,u.prevPos.y=u.pos.y),u.pos.xo&&(o=u.pos.x),u.pos.ya&&(a=u.pos.y)}i.x1=t,i.x2=o,i.y1=r,i.y2=a}}var o=e("ngraph.random").random(42),i={x1:0,y1:0,x2:0,y2:0};return{box:i,update:r,reset:function(){i.x1=i.y1=0,i.x2=i.y2=0},getBestNewPosition:function(e){var n=i,r=0,a=0;if(e.length){for(var u=0;ut;++t){var s=e[t],f=n/s.mass;s.velocity.x+=f*s.force.x,s.velocity.y+=f*s.force.y;var c=s.velocity.x,d=s.velocity.y,l=Math.sqrt(c*c+d*d);l>1&&(s.velocity.x=c/l,s.velocity.y=d/l),r=n*s.velocity.x,i=n*s.velocity.y,s.pos.x+=r,s.pos.y+=i,o+=Math.abs(r),a+=Math.abs(i)}return(o*o+a*a)/e.length}n.exports=r},{}],13:[function(e,n,t){function r(e,n,t,r,o){this.from=e,this.to=n,this.length=t,this.coeff=r,this.weight="number"==typeof o?o:1}n.exports=r},{}],14:[function(e,n,t){n.exports=function(n){var t=e("ngraph.merge"),r=e("ngraph.random").random(42),o=e("ngraph.expose");n=t(n,{springCoeff:2e-4,springLength:80});var i={update:function(e){var t=e.from,o=e.to,i=e.length<0?n.springLength:e.length,a=o.pos.x-t.pos.x,u=o.pos.y-t.pos.y,s=Math.sqrt(a*a+u*u);0===s&&(a=(r.nextDouble()-.5)/50,u=(r.nextDouble()-.5)/50,s=Math.sqrt(a*a+u*u));var f=s-i,c=(!e.coeff||e.coeff<0?n.springCoeff:e.coeff)*f/s*e.weight;t.force.x+=c*a,t.force.y+=c*u,o.force.x-=c*a,o.force.y-=c*u}};return o(n,i,["springCoeff","springLength"]),i}},{"ngraph.expose":15,"ngraph.merge":24,"ngraph.random":25}],15:[function(e,n,t){function r(e,n,t){var r="[object Array]"===Object.prototype.toString.call(t);if(r)for(var i=0;i0&&u(s.pos,a.pos));if(0===f&&u(s.pos,a.pos))return}c.push(i,s),c.push(i,a)}else{var h=a.pos.x,m=a.pos.y;i.mass=i.mass+a.mass,i.massX=i.massX+a.mass*h,i.massY=i.massY+a.mass*m;var y=0,x=i.left,w=(i.right+x)/2,b=i.top,E=(i.bottom+b)/2;if(h>w){y+=1;var L=x;x=w,w+=w-L}if(m>E){y+=2;var P=b;b=E,E+=E-P}var N=r(i,y);N?c.push(N,a):(N=v(),N.left=x,N.top=b,N.right=w,N.bottom=E,N.body=a,o(i,y,N))}}},m=function(e){var n,r,o,i,a=f,u=0,c=0,l=1,p=0,v=1;for(a[0]=g;l;){var h=a[p],m=h.body;l-=1,p+=1;var y=m!==e;m&&y?(r=m.pos.x-e.pos.x,o=m.pos.y-e.pos.y,i=Math.sqrt(r*r+o*o),0===i&&(r=(t.nextDouble()-.5)/50,o=(t.nextDouble()-.5)/50,i=Math.sqrt(r*r+o*o)),n=s*m.mass*e.mass/(i*i*i),u+=n*r,c+=n*o):y&&(r=h.massX/h.mass-e.pos.x,o=h.massY/h.mass-e.pos.y,i=Math.sqrt(r*r+o*o),0===i&&(r=(t.nextDouble()-.5)/50,o=(t.nextDouble()-.5)/50,i=Math.sqrt(r*r+o*o)),(h.right-h.left)/iu&&(t=u),u>o&&(o=u),r>s&&(r=s),s>i&&(i=s)}var f=o-t,c=i-r;for(f>c?i=r+f:o=t+c,p=0,g=v(),g.left=t,g.right=o,g.top=r,g.bottom=i,n=a-1,n>0&&(g.body=e[n]);n--;)h(e[n],g)};return{insertBodies:y,updateBodyForce:m,options:function(e){return e?("number"==typeof e.gravity&&(s=e.gravity),"number"==typeof e.theta&&(d=e.theta),this):{gravity:s,theta:d}}}}},{"./insertStack":18,"./isSamePosition":19,"./node":20,"ngraph.random":25}],18:[function(e,n,t){function r(){this.stack=[],this.popIdx=0}function o(e,n){this.node=e,this.body=n}n.exports=r,r.prototype={isEmpty:function(){return 0===this.popIdx},push:function(e,n){var t=this.stack[this.popIdx];t?(t.node=e,t.body=n):this.stack[this.popIdx]=new o(e,n),++this.popIdx},pop:function(){return this.popIdx>0?this.stack[--this.popIdx]:void 0},reset:function(){this.popIdx=0}}},{}],19:[function(e,n,t){n.exports=function(e,n){var t=Math.abs(e.x-n.x),r=Math.abs(e.y-n.y);return 1e-8>t&&1e-8>r}},{}],20:[function(e,n,t){n.exports=function(){this.body=null,this.quad0=null,this.quad1=null,this.quad2=null,this.quad3=null,this.mass=0,this.massX=0,this.massY=0,this.left=0,this.top=0,this.bottom=0,this.right=0}},{}],21:[function(e,n,t){function r(e,n,t){var r;n=n||o,t=t||o,r="string"==typeof e?JSON.parse(e):e;var a,u=i();if(void 0===r.links||void 0===r.nodes)throw new Error("Cannot load graph without links and nodes");for(a=0;ae)throw new Error("Invalid number of nodes");var n,t=p();for(n=0;e-1>n;++n)t.addLink(n,n+1),t.addLink(e+n,e+n+1),t.addLink(n,e+n);return t.addLink(e-1,2*e-1),t}function o(e){if(!e||0>e)throw new Error("Invalid number of nodes");var n=r(e);return n.addLink(0,e-1),n.addLink(e,2*e-1),n}function i(e){if(!e||1>e)throw new Error("At least two nodes are expected for complete graph");var n,t,r=p();for(n=0;e>n;++n)for(t=n+1;e>t;++t)n!==t&&r.addLink(n,t);return r}function a(e,n){if(!e||!n||0>e||0>n)throw new Error("Graph dimensions are invalid. Number of nodes in each partition should be greater than 0");var t,r,o=p();for(t=0;e>t;++t)for(r=e;e+n>r;++r)o.addLink(t,r);return o}function u(e){if(!e||0>e)throw new Error("Invalid number of nodes");var n,t=p();for(t.addNode(0),n=1;e>n;++n)t.addLink(n-1,n);return t}function s(e,n){if(1>e||1>n)throw new Error("Invalid number of nodes in grid graph");var t,r,o=p();if(1===e&&1===n)return o.addNode(0),o;for(t=0;e>t;++t)for(r=0;n>r;++r){var i=t+r*e;t>0&&o.addLink(i,t-1+r*e),r>0&&o.addLink(i,t+(r-1)*e)}return o}function f(e,n,t){if(1>e||1>n||1>t)throw new Error("Invalid number of nodes in grid3 graph");var r,o,i,a=p();if(1===e&&1===n&&1===t)return a.addNode(0),a;for(i=0;t>i;++i)for(r=0;e>r;++r)for(o=0;n>o;++o){var u=i*e*n,s=r+o*e+u;r>0&&a.addLink(s,r-1+o*e+u),o>0&&a.addLink(s,r+(o-1)*e+u),i>0&&a.addLink(s,r+o*e+(i-1)*e*n)}return a}function c(e){if(0>e)throw new Error("Invalid number of nodes in balanced tree");var n,t=p(),r=Math.pow(2,e);for(0===e&&t.addNode(1),n=1;r>n;++n){var o=n,i=2*o,a=2*o+1;t.addLink(o,i),t.addLink(o,a)}return t}function d(e){if(0>e)throw new Error("Number of nodes shoul be >= 0");var n,t=p();for(n=0;e>n;++n)t.addNode(n);return t}function l(n,t,r,o){if(t>=n)throw new Error("Choose smaller `k`. It cannot be larger than number of nodes `n`");var i,a,u=e("ngraph.random").random(o||42),s=p();for(i=0;n>i;++i)s.addNode(i);for(var f=Math.floor(t/2+1),c=1;f>c;++c)for(i=0;n>i;++i)a=(c+i)%n,s.addLink(i,a);for(c=1;f>c;++c)for(i=0;n>i;++i)if(u.nextDouble()n)return!1;B(),_.splice(n,1);var t=f(e.fromId),r=f(e.toId);return t&&(n=o(e,t.links),n>=0&&t.links.splice(n,1)),r&&(n=o(e,r.links),n>=0&&r.links.splice(n,1)),U(e,"remove"),F(),!0}function h(e,n){var t,r=f(e);if(!r)return null;for(t=0;tn;++n)e(_[n])}function x(e,n,t){var r=f(e);return r&&r.links&&"function"==typeof n?t?b(r.links,e,n):w(r.links,e,n):void 0}function w(e,n,t){for(var r,o=0;o0&&(O.fire("changed",M),M.length=0)}function N(){return Object.keys?k:A}function k(e){if("function"==typeof e)for(var n=Object.keys(j),t=0;tt;t+=1)if(n[t]===e)return t;return-1}function i(e){this.id=e,this.links=[],this.data=null}function a(e,n,t,r){this.fromId=e,this.toId=n,this.data=t,this.id=r}n.exports=r;var u=e("ngraph.events")},{"ngraph.events":6}],24:[function(e,n,t){function r(e,n){var t;if(e||(e={}),n)for(t in n)if(n.hasOwnProperty(t)){var o=e.hasOwnProperty(t),i=typeof n[t],a=!o||typeof e[t]!==i;a?e[t]=n[t]:"object"===i&&(e[t]=r(e[t],n[t]))}return e}n.exports=r},{}],25:[function(e,n,t){function r(e){var n="number"==typeof e?e:+new Date,t=function(){return n=n+2127912214+(n<<12)&4294967295,n=4294967295&(3345072700^n^n>>>19),n=n+374761393+(n<<5)&4294967295,n=4294967295&(n+3550635116^n<<9),n=n+4251993797+(n<<3)&4294967295,n=4294967295&(3042594569^n^n>>>16),(268435455&n)/268435456};return{next:function(e){return Math.floor(t()*e)},nextDouble:function(){return t()}}}function o(e,n){var t=n||r();if("function"!=typeof t.next)throw new Error("customRandom does not match expected API: next() function is missing");return{forEach:function(n){var r,o,i;for(r=e.length-1;r>0;--r)o=t.next(r+1),i=e[o],e[o]=e[r],e[r]=i,n(i);e.length&&n(e[0])},shuffle:function(){var n,r,o;for(n=e.length-1;n>0;--n)r=t.next(n+1),o=e[r],e[r]=e[n],e[n]=o;return e}}}n.exports={random:r,randomIterator:o}},{}],26:[function(e,n,t){function r(e,n,t){function r(e){u.nodes.push(s(e))}function o(e){u.links.push(f(e))}function i(e){var n={id:e.id};return void 0!==e.data&&(n.data=e.data),n}function a(e){var n={fromId:e.fromId,toId:e.toId};return void 0!==e.data&&(n.data=e.data),n}var u={nodes:[],links:[]},s=n||i,f=t||a;return e.forEachNode(r),e.forEachLink(o),JSON.stringify(u)}n.exports=r},{}],27:[function(e,n,t){function r(e,n){var t=o(e);if(void 0===n)return t;for(var r=Object.keys(n),i=0;it?r=-1:t>v&&(r=1),u(e,r,{x:e.touches[0].clientX,y:e.touches[0].clientY}),v=t,m(e),y(e)}},A=function(e){p=!1,o.off("touchmove",k),o.off("touchend",A),o.off("touchcancel",A),c=null,r&&r(e)},j=function(e,t){m(e),y(e),d=t.clientX,l=t.clientY,c=e.target||e.srcElement,n&&n(e,{x:d,y:l}),p||(p=!0,o.on("touchmove",k),o.on("touchend",A),o.on("touchcancel",A))},_=function(e){return 1===e.touches.length?j(e,e.touches[0]):void(2===e.touches.length&&(m(e),y(e),v=N(e.touches[0],e.touches[1])))};return e.addEventListener("mousedown",b),e.addEventListener("touchstart",_),{onStart:function(e){return n=e,this},onDrag:function(e){return t=e,this},onStop:function(e){return r=e,this},onScroll:function(e){return P(e),this},release:function(){e.removeEventListener("mousedown",b),
e.removeEventListener("touchstart",_),o.off("mousemove",w),o.off("mouseup",E),o.off("touchmove",k),o.off("touchend",A),o.off("touchcancel",A),P(null)}}}n.exports=r;var o=e("../Utils/documentEvents.js"),i=e("../Utils/browserInfo.js"),a=e("../Utils/findElementPosition.js")},{"../Utils/browserInfo.js":39,"../Utils/documentEvents.js":40,"../Utils/findElementPosition.js":41}],36:[function(e,n,t){function r(e,n){var t=o(n),r=null,i={},a={x:0,y:0};return t.mouseDown(function(e,n){r=e,a.x=n.clientX,a.y=n.clientY,t.mouseCapture(r);var o=i[e.id];return o&&o.onStart&&o.onStart(n,a),!0}).mouseUp(function(e){t.releaseMouseCapture(r),r=null;var n=i[e.id];return n&&n.onStop&&n.onStop(),!0}).mouseMove(function(e,n){if(r){var t=i[r.id];return t&&t.onDrag&&t.onDrag(n,{x:n.clientX-a.x,y:n.clientY-a.y}),a.x=n.clientX,a.y=n.clientY,!0}}),{bindDragNDrop:function(e,n){i[e.id]=n,n||delete i[e.id]}}}n.exports=r;var o=e("../WebGL/webglInputEvents.js")},{"../WebGL/webglInputEvents.js":57}],37:[function(e,n,t){function r(e,n){function t(e){return d[e]}n=o(n,{maxX:1024,maxY:1024,seed:"Deterministic randomness made me do this"});var r=i(n.seed),u=new a(Number.MAX_VALUE,Number.MAX_VALUE,Number.MIN_VALUE,Number.MIN_VALUE),s={},f=function(e){return{x:r.next(n.maxX),y:r.next(n.maxY)}},c=function(e,n){e.xn.x2&&(n.x2=e.x),e.yn.y2&&(n.y2=e.y)},d="function"==typeof Object.create?Object.create(null):{},l=function(e){d[e.id]=f(e),c(d[e.id],u)},p=function(){0!==e.getNodesCount()&&(u.x1=Number.MAX_VALUE,u.y1=Number.MAX_VALUE,u.x2=Number.MIN_VALUE,u.y2=Number.MIN_VALUE,e.forEachNode(l))},v=function(e){s[e.id]=e},g=function(e){for(var n=0;n=0:"boolean"==typeof z?z:!0}function r(){G=G||window.document.body,F=F||i(e,{springLength:80,springCoeff:2e-4}),O=O||a(e,{container:G}),n.hasOwnProperty("renderLinks")||(n.renderLinks=!0),n.prerender=n.prerender||0,U=(O.inputManager||s)(e,O)}function l(){O.beginRender(),n.renderLinks&&O.renderLinks(),O.renderNodes(),O.endRender()}function p(){return W=F.step()&&!H,l(),!W}function v(e){return R?void(V+=e):void(e?(V+=e,R=f(function(){return p()},M)):(X=0,V=0,R=f(p,M)))}function g(){J||(W=!1,R.restart())}function h(){if("number"==typeof n.prerender&&n.prerender>0)for(var e=0;en,t)})),e.forEachNode(E),T(),e.on("changed",j)}function D(){q=!1,T(),I(),u.off("resize",_),K.off(),R.stop(),e.forEachLink(function(e){n.renderLinks&&b(e)}),e.forEachNode(function(e){L(e),x(e)}),F.dispose(),N()}var M=30;n=n||{};var U,R,B,F=n.layout,O=n.graphics,G=n.container,z=void 0!==n.interactive?n.interactive:!0,q=!1,Y=!0,X=0,V=0,W=!1,H=!1,J=!1,$={offsetX:0,offsetY:0,scale:1},K=o({});return{run:function(e){return q||(r(),h(),P(),m(),S(),q=!0),v(e),this},reset:function(){O.resetScale(),m(),$.scale=1},pause:function(){J=!0,R.stop()},resume:function(){J=!1,R.restart()},rerender:function(){return l(),this},zoomOut:function(){return C(!0)},zoomIn:function(){return C(!1)},moveTo:function(e,n){O.graphCenterChanged($.offsetX-e*$.scale,$.offsetY-n*$.scale),l()},getGraphics:function(){return O},dispose:function(){D()},on:function(e,n){return K.on(e,n),this},off:function(e,n){return K.off(e,n),this}}}n.exports=r;var o=e("ngraph.events"),i=e("ngraph.forcelayout"),a=e("./svgGraphics.js"),u=e("../Utils/windowEvents.js"),s=e("../Input/domInputManager.js"),f=e("../Utils/timer.js"),c=e("../Utils/getDimensions.js"),d=e("../Input/dragndrop.js")},{"../Input/domInputManager.js":34,"../Input/dragndrop.js":35,"../Utils/getDimensions.js":42,"../Utils/timer.js":46,"../Utils/windowEvents.js":47,"./svgGraphics.js":49,"ngraph.events":6,"ngraph.forcelayout":7}],49:[function(e,n,t){function r(){function e(){var e=o("svg");return n=o("g").attr("buffered-rendering","dynamic"),e.appendChild(n),e}var n,t,r,u=0,s=0,f=1,c={},d={},l=function(e){return o("rect").attr("width",10).attr("height",10).attr("fill","#00a2e8")},p=function(e,n){e.attr("x",n.x-5).attr("y",n.y-5)},v=function(e){return o("line").attr("stroke","#999")},g=function(e,n,t){e.attr("x1",n.x).attr("y1",n.y).attr("x2",t.x).attr("y2",t.y)},h=function(e){e.fire("rescaled")},m={x:0,y:0},y={x:0,y:0},x={x:0,y:0},w=function(){if(n){var e="matrix("+f+", 0, 0,"+f+","+u+","+s+")";n.attr("transform",e)}};t=e();var b={getNodeUI:function(e){return c[e]},getLinkUI:function(e){return d[e]},node:function(e){return"function"==typeof e?(l=e,this):void 0},link:function(e){return"function"==typeof e?(v=e,this):void 0},placeNode:function(e){return p=e,this},placeLink:function(e){return g=e,this},beginRender:function(){},endRender:function(){},graphCenterChanged:function(e,n){u=e,s=n,w()},inputManager:a,translateRel:function(e,r){var o=t.createSVGPoint(),i=n.getCTM(),a=t.createSVGPoint().matrixTransform(i.inverse());o.x=e,o.y=r,o=o.matrixTransform(i.inverse()),o.x=(o.x-a.x)*i.a,o.y=(o.y-a.y)*i.d,i.e+=o.x,i.f+=o.y;var u="matrix("+i.a+", 0, 0,"+i.d+","+i.e+","+i.f+")";n.attr("transform",u)},scale:function(e,r){var o=t.createSVGPoint();o.x=r.x,o.y=r.y,o=o.matrixTransform(n.getCTM().inverse());var i=t.createSVGMatrix().translate(o.x,o.y).scale(e).translate(-o.x,-o.y),a=n.getCTM().multiply(i);f=a.a,u=a.e,s=a.f;var c="matrix("+a.a+", 0, 0,"+a.d+","+a.e+","+a.f+")";return n.attr("transform",c),h(this),f},resetScale:function(){f=1;var e="matrix(1, 0, 0, 1, 0, 0)";return n.attr("transform",e),h(this),this},init:function(e){e.appendChild(t),w(),"function"==typeof r&&r(t)},release:function(e){t&&e&&e.removeChild(t)},addLink:function(e,t){var r=v(e);if(r)return r.position=t,r.link=e,d[e.id]=r,n.childElementCount>0?n.insertBefore(r,n.firstChild):n.appendChild(r),r},releaseLink:function(e){var t=d[e.id];t&&(n.removeChild(t),delete d[e.id])},addNode:function(e,t){var r=l(e);if(r)return r.position=t,r.node=e,c[e.id]=r,n.appendChild(r),r},releaseNode:function(e){var t=c[e.id];t&&(n.removeChild(t),delete c[e.id])},renderNodes:function(){for(var e in c)if(c.hasOwnProperty(e)){var n=c[e];m.x=n.position.x,m.y=n.position.y,p(n,m,n.node)}},renderLinks:function(){for(var e in d)if(d.hasOwnProperty(e)){var n=d[e];y.x=n.position.from.x,y.y=n.position.from.y,x.x=n.position.to.x,x.y=n.position.to.y,g(n,y,x,n.link)}},getGraphicsRoot:function(e){return"function"==typeof e&&(t?e(t):r=e),t},getSvgRoot:function(){return t}};return i(b),b}n.exports=r;var o=e("simplesvg"),i=e("ngraph.events"),a=e("../Input/domInputManager.js")},{"../Input/domInputManager.js":34,"ngraph.events":6,simplesvg:27}],50:[function(e,n,t){function r(e){e=c(e,{enableBlending:!0,preserveDrawingBuffer:!1,clearColor:!1,clearColorValue:{r:1,g:1,b:1,a:1}});var n,t,r,d,l,p,v,g,h=0,m=0,y=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],x=[],w=[],b={},E={},L=i(),P=a(),N=function(e){return u()},k=function(e){return s(3014898687)},A=function(){L.updateTransform(y),P.updateTransform(y)},j=function(){y=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]},_=function(){n&&t&&(d=t.width=Math.max(n.offsetWidth,1),l=t.height=Math.max(n.offsetHeight,1),r&&r.viewport(0,0,d,l),L&&L.updateSize(d/2,l/2),P&&P.updateSize(d/2,l/2))},I=function(e){e.fire("rescaled")};t=window.document.createElement("canvas");var T={getLinkUI:function(e){return E[e]},getNodeUI:function(e){return b[e]},node:function(e){return"function"==typeof e?(N=e,this):void 0},link:function(e){return"function"==typeof e?(k=e,this):void 0},placeNode:function(e){return p=e,this},placeLink:function(e){return v=e,this},inputManager:o,beginRender:function(){},endRender:function(){m>0&&L.render(),h>0&&P.render()},bringLinkToFront:function(e){var n,t,r=L.getFrontLinkId();L.bringToFront(e),r>e.id&&(n=e.id,t=w[r],w[r]=w[n],w[r].id=r,w[n]=t,w[n].id=n)},graphCenterChanged:function(e,n){y[12]=2*e/d-1,y[13]=1-2*n/l,A()},addLink:function(e,n){var t=m++,r=k(e);return r.id=t,r.pos=n,L.createLink(r),w[t]=r,E[e.id]=r,r},addNode:function(e,n){var t=h++,r=N(e);return r.id=t,r.position=n,r.node=e,P.createNode(r),x[t]=r,b[e.id]=r,r},translateRel:function(e,n){y[12]+=2*y[0]*e/d/y[0],y[13]-=2*y[5]*n/l/y[5],A()},scale:function(e,n){var t=2*n.x/d-1,r=1-2*n.y/l;return t-=y[12],r-=y[13],y[12]+=t*(1-e),y[13]+=r*(1-e),y[0]*=e,y[5]*=e,A(),I(this),y[0]},resetScale:function(){return j(),r&&(_(),A()),this},init:function(o){var i={};if(e.preserveDrawingBuffer&&(i.preserveDrawingBuffer=!0),n=o,_(),j(),n.appendChild(t),r=t.getContext("experimental-webgl",i),!r){var a="Could not initialize WebGL. Seems like the browser doesn't support it.";throw window.alert(a),a}if(e.enableBlending&&(r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),r.enable(r.BLEND)),e.clearColor){var u=e.clearColorValue;r.clearColor(u.r,u.g,u.b,u.a),this.beginRender=function(){r.clear(r.COLOR_BUFFER_BIT)}}L.load(r),L.updateSize(d/2,l/2),P.load(r),P.updateSize(d/2,l/2),A(),"function"==typeof g&&g(t)},release:function(e){t&&e&&e.removeChild(t)},isSupported:function(){var e=window.document.createElement("canvas"),n=e&&e.getContext&&e.getContext("experimental-webgl");return n},releaseLink:function(e){m>0&&(m-=1);var n=E[e.id];delete E[e.id],L.removeLink(n);var t=n.id;if(m>t){if(0===m||m===t)return;var r=w[m];w[t]=r,r.id=t}},releaseNode:function(e){h>0&&(h-=1);var n=b[e.id];delete b[e.id],P.removeNode(n);var t=n.id;if(h>t){if(0===h||h===t)return;var r=x[h];x[t]=r,r.id=t,P.replaceProperties(n,r)}},renderNodes:function(){for(var e={x:0,y:0},n=0;h>n;++n){var t=x[n];e.x=t.position.x,e.y=t.position.y,p&&p(t,e),P.position(t,e)}},renderLinks:function(){if(!this.omitLinksRendering)for(var e={x:0,y:0},n={x:0,y:0},t=0;m>t;++t){var r=w[t],o=r.pos.from;n.x=o.x,n.y=-o.y,o=r.pos.to,e.x=o.x,e.y=-o.y,v&&v(r,n,e),L.position(r,n,e)}},getGraphicsRoot:function(e){return"function"==typeof e&&(t?e(t):g=e),t},setNodeProgram:function(e){if(!r&&e)P=e;else if(e)throw"Not implemented. Cannot swap shader on the fly... Yet."},setLinkProgram:function(e){if(!r&&e)L=e;else if(e)throw"Not implemented. Cannot swap shader on the fly... Yet."},transformClientToGraphCoordinates:function(e){return e.x=2*e.x/d-1,e.y=1-2*e.y/l,e.x=(e.x-y[12])/y[0],e.y=(e.y-y[13])/y[5],e.x=e.x*(d/2),e.y=e.y*(-l/2),e},transformGraphToClientCoordinates:function(e){return e.x=e.x/(d/2),e.y=e.y/(-l/2),e.x=e.x*y[0]+y[12],e.y=e.y*y[5]+y[13],e.x=(e.x+1)*d/2,e.y=(1-e.y)*l/2,e},getNodeAtClientPos:function(e,n){if("function"!=typeof n)return null;this.transformClientToGraphCoordinates(e);for(var t=0;h>t;++t)if(n(x[t],e.x,e.y))return x[t].node;return null}};return f(T),T}n.exports=r;var o=e("../Input/webglInputManager.js"),i=e("../WebGL/webglLinkProgram.js"),a=e("../WebGL/webglNodeProgram.js"),u=e("../WebGL/webglSquare.js"),s=e("../WebGL/webglLine.js"),f=e("ngraph.events"),c=e("ngraph.merge")},{"../Input/webglInputManager.js":36,"../WebGL/webglLine.js":58,"../WebGL/webglLinkProgram.js":59,"../WebGL/webglNodeProgram.js":60,"../WebGL/webglSquare.js":61,"ngraph.events":6,"ngraph.merge":24}],51:[function(e,n,t){function r(e){var n=10414335;if("string"==typeof e&&e)if(4===e.length&&(e=e.replace(/([^#])/g,"$1$1")),9===e.length)n=parseInt(e.substr(1),16);else{if(7!==e.length)throw'Color expected in hex format with preceding "#". E.g. #00ff00. Got value: '+e;n=parseInt(e.substr(1),16)<<8|255}else"number"==typeof e&&(n=e);return n}n.exports=r},{}],52:[function(e,n,t){function r(e){this.canvas=window.document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.isDirty=!1,this.canvas.width=this.canvas.height=e}n.exports=r},{}],53:[function(e,n,t){function r(e){function n(n,t){var r=e.createShader(t);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){var o=e.getShaderInfoLog(r);throw window.alert(o),o}return r}function t(t,r){var o=e.createProgram(),i=n(t,e.VERTEX_SHADER),a=n(r,e.FRAGMENT_SHADER);if(e.attachShader(o,i),e.attachShader(o,a),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS)){var u=e.getShaderInfoLog(o);throw window.alert(u),u}return o}function r(e,n,t){if((n+1)*t>e.length){var r=new Float32Array(e.length*t*2);return r.set(e),r}return e}function a(n,t){for(var r={},o=0;oo;++o)e[n+o]=e[t+o]}function i(e,n,t,r){for(var o=0;r>o;++o){var i=e[n+o];e[n+o]=e[t+o],e[t+o]=i}}n.exports=r},{}],54:[function(e,n,t){function r(e){function n(){var e;for(E.isDirty=!1,e=0;e=w.length&&s();var i=w[r.textureNumber];i.ctx.drawImage(n,r.col*h,r.row*h,h,h),b[e]=n.src,y[n.src]=o,i.isDirty=!0,t(o)}function c(n){var t=n/e<<0,r=n%e,o=r/g<<0,i=r%g;return{textureNumber:t,row:o,col:i}}function d(){E.isDirty=!0,x=0,v=null}function l(){v&&(window.clearTimeout(v),x+=1,v=null),x>10?d():v=window.setTimeout(d,400)}function p(e,n){var t=w[e.textureNumber].canvas,r=w[n.textureNumber].ctx,o=n.col*h,i=n.row*h;r.drawImage(t,e.col*h,e.row*h,h,h,o,i,h,h),w[e.textureNumber].isDirty=!0,w[n.textureNumber].isDirty=!0}var v,g=Math.sqrt(e||1024)<<0,h=g,m=1,y={},x=0,w=[],b=[];if(!o(e))throw"Tiles per texture should be power of two.";var E={isDirty:!1,clearDirty:n,remove:t,getTextures:r,getCoordinates:a,load:u};return E}function o(e){return 0===(e&e-1)}var i=e("./texture.js");n.exports=r},{"./texture.js":52}],55:[function(e,n,t){function r(e,n){return{_texture:0,_offset:0,size:"number"==typeof e?e:32,src:n}}n.exports=r},{}],56:[function(e,n,t){function r(){function e(e,n){e.nativeObject&&h.deleteTexture(e.nativeObject);var t=h.createTexture();h.activeTexture(h["TEXTURE"+n]),h.bindTexture(h.TEXTURE_2D,t),h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,e.canvas),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.LINEAR),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.LINEAR_MIPMAP_NEAREST),h.generateMipmap(h.TEXTURE_2D),h.uniform1i(x["sampler"+n],n),e.nativeObject=t}function n(){if(v.isDirty){var n,t=v.getTextures();for(n=0;n0&&(j-=1),e.id0&&(e.src&&v.remove(e.src),y.copyArrayPart(_,e.id*P,j*P,P))}function c(e,n){n._offset=e._offset}function d(e){L=!0,E=e}function l(e,n){w=e,b=n,L=!0}function p(){h.useProgram(g),h.bindBuffer(h.ARRAY_BUFFER,m),h.bufferData(h.ARRAY_BUFFER,_,h.DYNAMIC_DRAW),L&&(L=!1,h.uniformMatrix4fv(x.transform,!1,E),h.uniform2f(x.screenSize,w,b)),h.vertexAttribPointer(x.vertexPos,2,h.FLOAT,!1,3*Float32Array.BYTES_PER_ELEMENT,0),h.vertexAttribPointer(x.customAttributes,1,h.FLOAT,!1,3*Float32Array.BYTES_PER_ELEMENT,8),n(),h.drawArrays(h.TRIANGLES,0,6*j)}var v,g,h,m,y,x,w,b,E,L,P=18,N=o(),k=i(),A=1024,j=0,_=new Float32Array(64);return{load:t,position:r,createNode:s,removeNode:f,replaceProperties:c,updateTransform:d,updateSize:l,render:p}}function o(){return["precision mediump float;","varying vec4 color;","varying vec3 vTextureCoord;","uniform sampler2D u_sampler0;","uniform sampler2D u_sampler1;","uniform sampler2D u_sampler2;","uniform sampler2D u_sampler3;","void main(void) {"," if (vTextureCoord.z == 0.) {"," gl_FragColor = texture2D(u_sampler0, vTextureCoord.xy);"," } else if (vTextureCoord.z == 1.) {"," gl_FragColor = texture2D(u_sampler1, vTextureCoord.xy);"," } else if (vTextureCoord.z == 2.) {"," gl_FragColor = texture2D(u_sampler2, vTextureCoord.xy);"," } else if (vTextureCoord.z == 3.) {"," gl_FragColor = texture2D(u_sampler3, vTextureCoord.xy);"," } else { gl_FragColor = vec4(0, 1, 0, 1); }","}"].join("\n")}function i(){return["attribute vec2 a_vertexPos;","attribute float a_customAttributes;","uniform vec2 u_screenSize;","uniform mat4 u_transform;","uniform float u_tilesPerTexture;","varying vec3 vTextureCoord;","void main(void) {"," gl_Position = u_transform * vec4(a_vertexPos/u_screenSize, 0, 1);","float corner = mod(a_customAttributes, 4.);","float tileIndex = mod(floor(a_customAttributes / 4.), u_tilesPerTexture);","float tilesPerRow = sqrt(u_tilesPerTexture);","float tileSize = 1./tilesPerRow;","float tileColumn = mod(tileIndex, tilesPerRow);","float tileRow = floor(tileIndex/tilesPerRow);","if(corner == 0.0) {"," vTextureCoord.xy = vec2(0, 1);","} else if(corner == 1.0) {"," vTextureCoord.xy = vec2(1, 1);","} else if(corner == 2.0) {"," vTextureCoord.xy = vec2(0, 0);","} else {"," vTextureCoord.xy = vec2(1, 0);","}","vTextureCoord *= tileSize;","vTextureCoord.x += tileColumn * tileSize;","vTextureCoord.y += tileRow * tileSize;","vTextureCoord.z = floor(floor(a_customAttributes / 4.)/u_tilesPerTexture);","}"].join("\n")}var a=e("./webglAtlas.js"),u=e("./webgl.js");n.exports=r},{"./webgl.js":53,"./webglAtlas.js":54}],57:[function(e,n,t){function r(e){function n(){x=null}function t(e){x=e}function r(e){return"function"==typeof e&&k.push(e),j}function i(e){return"function"==typeof e&&N.push(e),j}function a(e){return"function"==typeof e&&P.push(e),j}function u(e){return"function"==typeof e&&L.push(e),j}function s(e){return"function"==typeof e&&E.push(e),j}function f(e){return"function"==typeof e&&b.push(e),j}function c(e){return"function"==typeof e&&w.push(e),j}function d(e,n,t){if(e&&e.size){var r=e.position,o=e.size;return r.x-oo-i&&r[0]===t?g(k,r):g(N,r),i=o,g(L,r)&&p(e))})}if(e.webglInputEvents)return e.webglInputEvents;var m,y,x=null,w=[],b=[],E=[],L=[],P=[],N=[],k=[],A=e.getGraphicsRoot();h(A);var j={mouseEnter:c,mouseLeave:f,mouseDown:s,mouseUp:u,mouseMove:a,click:i,dblClick:r,mouseCapture:t,releaseMouseCapture:n};return e.webglInputEvents=j,j}var o=e("../Utils/documentEvents.js");n.exports=r},{"../Utils/documentEvents.js":40}],58:[function(e,n,t){function r(e){return{color:o(e)}}var o=e("./parseColor.js");n.exports=r},{"./parseColor.js":51}],59:[function(e,n,t){function r(){var e,n,t,r,i,a,u,s,f,c,d=6,l=2*(2*Float32Array.BYTES_PER_ELEMENT+Uint32Array.BYTES_PER_ELEMENT),p=["precision mediump float;","varying vec4 color;","void main(void) {"," gl_FragColor = color;","}"].join("\n"),v=["attribute vec2 a_vertexPos;","attribute vec4 a_color;","uniform vec2 u_screenSize;","uniform mat4 u_transform;","varying vec4 color;","void main(void) {"," gl_Position = u_transform * vec4(a_vertexPos/u_screenSize, 0.0, 1.0);"," color = a_color.abgr;","}"].join("\n"),g=0,h=new ArrayBuffer(16*l),m=new Float32Array(h),y=new Uint32Array(h),x=function(){if((g+1)*l>h.byteLength){var e=new ArrayBuffer(2*h.byteLength),n=new Float32Array(e),t=new Uint32Array(e);t.set(y),m=n,y=t,h=e}};return{load:function(a){n=a,r=o(a),e=r.createProgram(v,p),n.useProgram(e),i=r.getLocations(e,["a_vertexPos","a_color","u_screenSize","u_transform"]),n.enableVertexAttribArray(i.vertexPos),n.enableVertexAttribArray(i.color),t=n.createBuffer()},position:function(e,n,t){var r=e.id,o=r*d;m[o]=n.x,m[o+1]=n.y,y[o+2]=e.color,m[o+3]=t.x,m[o+4]=t.y,y[o+5]=e.color},createLink:function(e){x(),g+=1,a=e.id},removeLink:function(e){g>0&&(g-=1),e.id0&&r.copyArrayPart(y,e.id*d,g*d,d)},updateTransform:function(e){c=!0,f=e},updateSize:function(e,n){u=e,s=n,c=!0},render:function(){n.useProgram(e),n.bindBuffer(n.ARRAY_BUFFER,t),n.bufferData(n.ARRAY_BUFFER,h,n.DYNAMIC_DRAW),c&&(c=!1,n.uniformMatrix4fv(i.transform,!1,f),n.uniform2f(i.screenSize,u,s)),n.vertexAttribPointer(i.vertexPos,2,n.FLOAT,!1,3*Float32Array.BYTES_PER_ELEMENT,0),n.vertexAttribPointer(i.color,4,n.UNSIGNED_BYTE,!0,3*Float32Array.BYTES_PER_ELEMENT,8),n.drawArrays(n.LINES,0,2*g),a=g-1},bringToFront:function(e){a>e.id&&r.swapArrayPart(m,e.id*d,a*d,d),a>0&&(a-=1)},getFrontLinkId:function(){return a}}}var o=e("./webgl.js");n.exports=r},{"./webgl.js":53}],60:[function(e,n,t){function r(){function e(){if((k+1)*w>=L.byteLength){var e=new ArrayBuffer(2*L.byteLength),n=new Float32Array(e),t=new Uint32Array(e);t.set(N),P=n,N=t,L=e}}function n(e){d=e,v=o(e),c=v.createProgram(E,b),d.useProgram(c),p=v.getLocations(c,["a_vertexPos","a_color","u_screenSize","u_transform"]),d.enableVertexAttribArray(p.vertexPos),d.enableVertexAttribArray(p.color),l=d.createBuffer()}function t(e,n){var t=e.id;P[t*x]=n.x,P[t*x+1]=-n.y,P[t*x+2]=e.size,N[t*x+3]=e.color}function r(e){y=!0,m=e}function i(e,n){g=e,h=n,y=!0}function a(e){k>0&&(k-=1),e.id0&&v.copyArrayPart(N,e.id*x,k*x,x)}function u(){e(),k+=1}function s(){}function f(){d.useProgram(c),d.bindBuffer(d.ARRAY_BUFFER,l),d.bufferData(d.ARRAY_BUFFER,L,d.DYNAMIC_DRAW),y&&(y=!1,d.uniformMatrix4fv(p.transform,!1,m),d.uniform2f(p.screenSize,g,h)),d.vertexAttribPointer(p.vertexPos,3,d.FLOAT,!1,x*Float32Array.BYTES_PER_ELEMENT,0),d.vertexAttribPointer(p.color,4,d.UNSIGNED_BYTE,!0,x*Float32Array.BYTES_PER_ELEMENT,12),d.drawArrays(d.POINTS,0,k)}var c,d,l,p,v,g,h,m,y,x=4,w=3*Float32Array.BYTES_PER_ELEMENT+Uint32Array.BYTES_PER_ELEMENT,b=["precision mediump float;","varying vec4 color;","void main(void) {"," gl_FragColor = color;","}"].join("\n"),E=["attribute vec3 a_vertexPos;","attribute vec4 a_color;","uniform vec2 u_screenSize;","uniform mat4 u_transform;","varying vec4 color;","void main(void) {"," gl_Position = u_transform * vec4(a_vertexPos.xy/u_screenSize, 0, 1);"," gl_PointSize = a_vertexPos.z * u_transform[0][0];"," color = a_color.abgr;","}"].join("\n"),L=new ArrayBuffer(16*w),P=new Float32Array(L),N=new Uint32Array(L),k=0;return{load:n,position:t,updateTransform:r,updateSize:i,removeNode:a,createNode:u,replaceProperties:s,render:f}}var o=e("./webgl.js");n.exports=r},{"./webgl.js":53}],61:[function(e,n,t){function r(e,n){return{size:"number"==typeof e?e:10,color:o(n)}}var o=e("./parseColor.js");n.exports=r},{"./parseColor.js":51}],62:[function(e,n,t){n.exports="0.8.1"},{}]},{},[1])(1)});
© 2015 - 2025 Weber Informatics LLC | Privacy Policy