mirror of https://gitee.com/bigwinds/arangodb
added randomColor require
This commit is contained in:
parent
56d4610dca
commit
3c6772962e
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
!function(){function n(t,r,e){function u(n){var u=t(n),i=e>u,c=d3.extent(t.range()),o=c[0],a=c[1],f=i?e-o:a-e;return 0==f&&(f=a-o),(i?-1:1)*f*(r+1)/(r+f/Math.abs(u-e))+e}return u.distortion=function(n){return arguments.length?(r=+n,u):r},u.focus=function(n){return arguments.length?(e=+n,u):e},u.copy=function(){return n(t.copy(),r,e)},u.nice=t.nice,u.ticks=t.ticks,u.tickFormat=t.tickFormat,d3.rebind(u,t,"domain","range")}d3.fisheye={scale:function(t){return n(t(),3,0)},circular:function(){function n(n){var t=n.x-c[0],i=n.y-c[1],o=Math.sqrt(t*t+i*i);if(!o||o>=u)return{x:n.x,y:n.y,z:1};var a=r*(1-Math.exp(-o*e))/o*.75+.25;return{x:c[0]+t*a,y:c[1]+i*a,z:Math.min(a,10)}}function t(){return r=Math.exp(i),r=r/(r-1)*u,e=i/u,n}var r,e,u=200,i=2,c=[0,0];return n.radius=function(n){return arguments.length?(u=+n,t()):u},n.distortion=function(n){return arguments.length?(i=+n,t()):i},n.focus=function(t){return arguments.length?(c=t,n):c},t()}}}();
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
!function(e){e.contextMenu={shadow:!0,shadowOffset:0,shadowOffsetX:5,shadowOffsetY:5,shadowWidthAdjust:-3,shadowHeightAdjust:-3,shadowOpacity:.2,shadowClass:"context-menu-shadow",shadowColor:"black",offsetX:0,offsetY:0,appendTo:"body",direction:"down",constrainToScreen:!0,showTransition:"show",hideTransition:"hide",showSpeed:null,hideSpeed:null,showCallback:null,hideCallback:null,className:"context-menu",itemClassName:"context-menu-item",itemHoverClassName:"context-menu-item-hover",disabledItemClassName:"context-menu-item-disabled",disabledItemHoverClassName:"context-menu-item-disabled-hover",separatorClassName:"context-menu-separator",innerDivClassName:"context-menu-item-inner",themePrefix:"context-menu-theme-",theme:"default",separator:"context-menu-separator",target:null,menu:null,shadowObj:null,bgiframe:null,shown:!1,useIframe:!1,create:function(t,a){var s=e.extend({},this,a);return"string"==typeof t?s.menu=e(t):"function"==typeof t?s.menuFunction=t:s.menu=s.createMenu(t,s),s.menu&&(s.menu.css({display:"none"}),e(s.appendTo).append(s.menu)),s.shadow&&(s.createShadow(s),s.shadowOffset&&(s.shadowOffsetX=s.shadowOffsetY=s.shadowOffset)),e("body").bind("contextmenu",function(){s.hide()}),s},createIframe:function(){return e('<iframe frameborder="0" tabindex="-1" src="javascript:false" style="display:block;position:absolute;z-index:-1;filter:Alpha(Opacity=0);"/>')},createMenu:function(t,a){var s=a.className;e.each(a.theme.split(","),function(e,t){s+=" "+a.themePrefix+t});for(var n=e("<table cellspacing=0 cellpadding=0></table>").click(function(){return a.hide(),!1}),o=e("<tr></tr>"),i=e("<td></td>"),d=e('<div class="'+s+'"></div>'),r=0;r<t.length;r++){var h=t[r];if(h==e.contextMenu.separator)d.append(a.createSeparator());else for(var l in t[r])d.append(a.createMenuItem(l,t[r][l]))}return a.useIframe&&i.append(a.createIframe()),n.append(o.append(i.append(d))),n},createMenuItem:function(t,a){var s=this;"function"==typeof a&&(a={onclick:a});var n=e.extend({onclick:function(){},className:"",hoverClassName:s.itemHoverClassName,icon:"",disabled:!1,title:"",hoverItem:s.hoverItem,hoverItemOut:s.hoverItemOut},a),o=n.icon?"background-image:url("+n.icon+");":"",i=e('<div class="'+s.itemClassName+" "+n.className+(n.disabled?" "+s.disabledItemClassName:"")+'" title="'+n.title+'"></div>').click(function(e){return s.isItemDisabled(this)?!1:n.onclick.call(s.target,this,s,e)}).hover(function(){n.hoverItem.call(this,s.isItemDisabled(this)?s.disabledItemHoverClassName:n.hoverClassName)},function(){n.hoverItemOut.call(this,s.isItemDisabled(this)?s.disabledItemHoverClassName:n.hoverClassName)}),d=e('<div class="'+s.innerDivClassName+'" style="'+o+'">'+t+"</div>");return i.append(d),i},createSeparator:function(){return e('<div class="'+this.separatorClassName+'"></div>')},isItemDisabled:function(t){return e(t).is("."+this.disabledItemClassName)},hoverItem:function(t){e(this).addClass(t)},hoverItemOut:function(t){e(this).removeClass(t)},createShadow:function(t){t.shadowObj=e('<div class="'+t.shadowClass+'"></div>').css({display:"none",position:"absolute",zIndex:9998,opacity:t.shadowOpacity,backgroundColor:t.shadowColor}),e(t.appendTo).append(t.shadowObj)},showShadow:function(e,t,a){var s=this;s.shadow&&s.shadowObj.css({width:s.menu.width()+s.shadowWidthAdjust+"px",height:s.menu.height()+s.shadowHeightAdjust+"px",top:t+s.shadowOffsetY+"px",left:e+s.shadowOffsetX+"px"}).addClass(s.shadowClass)[s.showTransition](s.showSpeed)},beforeShow:function(){return!0},show:function(t,a){var s=this,n=a.pageX,o=a.pageY;if(s.target=t,s.beforeShow()!==!1){s.menuFunction&&(s.menu&&e(s.menu).remove(),s.menu=s.createMenu(s.menuFunction(s,t),s),s.menu.css({display:"none"}),e(s.appendTo).append(s.menu));var i=s.menu;n+=s.offsetX,o+=s.offsetY;var d=s.getPosition(n,o,s,a);s.showShadow(d.x,d.y,a),s.useIframe&&i.find("iframe").css({width:i.width()+s.shadowOffsetX+s.shadowWidthAdjust,height:i.height()+s.shadowOffsetY+s.shadowHeightAdjust}),i.css({top:d.y+"px",left:d.x+"px",position:"absolute",zIndex:9999})[s.showTransition](s.showSpeed,s.showCallback?function(){s.showCallback.call(s)}:null),s.shown=!0}},getPosition:function(t,a,s,n){var o=t+s.offsetX,i=a+s.offsetY,d=e(s.menu).height(),r=e(s.menu).width(),h=s.direction;if(s.constrainToScreen){var l=e(window),c=l.height(),u=l.width();"down"==h&&i+d-l.scrollTop()>c&&(h="up");var m=o+r-l.scrollLeft();m>u&&(o-=m-u)}return"up"==h&&(i-=d),{x:o,y:i}},hide:function(){var t=this;t.shown&&(t.iframe&&e(t.iframe).hide(),t.menu&&t.menu[t.hideTransition](t.hideSpeed,t.hideCallback?function(){t.hideCallback.call(t)}:null),t.shadow&&t.shadowObj[t.hideTransition](t.hideSpeed)),t.shown=!1}},e.fn.contextMenu=function(t,a){var s=e.contextMenu.create(t,a);return this.each(function(){e(this).bind("contextmenu",function(e){return s.show(this,e),!1})})}}(jQuery);
|
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
!function(e){function t(t){if("string"==typeof t.data&&(t.data={keys:t.data}),t.data&&t.data.keys&&"string"==typeof t.data.keys){var a=t.handler,s=t.data.keys.toLowerCase().split(" "),r=["text","password","number","email","url","range","date","month","week","time","datetime","datetime-local","search","color","tel"];t.handler=function(t){if(this===t.target||!(/textarea|select/i.test(t.target.nodeName)||e.inArray(t.target.type,r)>-1)){var i=e.hotkeys.specialKeys[t.keyCode],n=String.fromCharCode(t.which).toLowerCase(),o="",f={};e.each(["alt","ctrl","meta","shift"],function(e,a){t[a+"Key"]&&i!==a&&(o+=a+"+")}),o=o.replace("alt+ctrl+meta+shift","hyper"),i&&(f[o+i]=!0),n&&(f[o+n]=!0,f[o+e.hotkeys.shiftNums[n]]=!0,"shift+"===o&&(f[e.hotkeys.shiftNums[n]]=!0));for(var h=0,l=s.length;l>h;h++)if(f[s[h]])return a.apply(this,arguments)}}}}e.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",10:"return",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",59:";",61:"=",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},shiftNums:{"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}},e.each(["keydown","keyup","keypress"],function(){e.event.special[this]={add:t}})}(this.jQuery);
|
File diff suppressed because one or more lines are too long
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
textfill
|
||||
@name jquery.textfill.js
|
||||
@author Russ Painter
|
||||
@author Yu-Jie Lin
|
||||
@author Alexandre Dantas
|
||||
@version 0.6.0
|
||||
@date 2014-08-19
|
||||
@copyright (c) 2014 Alexandre Dantas
|
||||
@copyright (c) 2012-2013 Yu-Jie Lin
|
||||
@copyright (c) 2009 Russ Painter
|
||||
@license MIT License
|
||||
@homepage https://github.com/jquery-textfill/jquery-textfill
|
||||
@example http://jquery-textfill.github.io/jquery-textfill/index.html
|
||||
*/
|
||||
(function(m){m.fn.textfill=function(r){function f(){a.debug&&"undefined"!=typeof console&&"undefined"!=typeof console.debug&&console.debug.apply(console,arguments)}function s(){"undefined"!=typeof console&&"undefined"!=typeof console.warn&&console.warn.apply(console,arguments)}function p(a,b,e,k,n,g){function d(a,b){var c=" / ";a>b?c=" > ":a==b&&(c=" = ");return c}f("[TextFill] "+a+" { font-size: "+b.css("font-size")+",Height: "+b.height()+"px "+d(b.height(),e)+e+"px,Width: "+b.width()+d(b.width(),
|
||||
k)+k+",minFontPixels: "+n+"px, maxFontPixels: "+g+"px }")}function q(a,b,e,k,f,g,d,h){for(p(a,b,f,g,d,h);d<h-1;){var l=Math.floor((d+h)/2);b.css("font-size",l);if(e.call(b)<=k){if(d=l,e.call(b)==k)break}else h=l;p(a,b,f,g,d,h)}b.css("font-size",h);e.call(b)<=k&&(d=h,p(a+"* ",b,f,g,d,h));return d}var a=m.extend({debug:!1,maxFontPixels:40,minFontPixels:4,innerTag:"span",widthOnly:!1,success:null,callback:null,fail:null,complete:null,explicitWidth:null,explicitHeight:null,changeLineHeight:!1},r);f("[TextFill] Start Debug");
|
||||
this.each(function(){var c=m(a.innerTag+":visible:first",this),b=a.explicitHeight||m(this).height(),e=a.explicitWidth||m(this).width(),k=c.css("font-size"),n=parseFloat(c.css("line-height"))/parseFloat(k);f("[TextFill] Inner text: "+c.text());f("[TextFill] All options: ",a);f("[TextFill] Maximum sizes: { Height: "+b+"px, Width: "+e+"px }");var g=a.minFontPixels,d=0>=a.maxFontPixels?b:a.maxFontPixels,h=void 0;a.widthOnly||(h=q("Height",c,m.fn.height,b,b,e,g,d));var l=void 0,l=q("Width",c,m.fn.width,
|
||||
e,b,e,g,d);a.widthOnly?(c.css({"font-size":l,"white-space":"nowrap"}),a.changeLineHeight&&c.parent().css("line-height",n*l+"px")):(g=Math.min(h,l),c.css("font-size",g),a.changeLineHeight&&c.parent().css("line-height",n*g+"px"));f("[TextFill] Finished { Old font-size: "+k+", New font-size: "+c.css("font-size")+" }");c.width()>e||c.height()>b&&!a.widthOnly?(c.css("font-size",k),a.fail&&a.fail(this),f("[TextFill] Failure { Current Width: "+c.width()+", Maximum Width: "+e+", Current Height: "+c.height()+
|
||||
", Maximum Height: "+b+" }")):a.success?a.success(this):a.callback&&(s("callback is deprecated, use success, instead"),a.callback(this))});a.complete&&a.complete(this);f("[TextFill] End Debug");return this}})(window.jQuery);
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,8 +0,0 @@
|
|||
(function(){function i(c,a,b){return g(c,a,b)}function g(c,a,b,j){j=j||{};a&&!n(a)&&(b=a,a=void 0);a=a||new Date;b=b||o;b.formats=b.formats||{};var i=a.getTime(),h=j.timezone,e=typeof h;if(j.utc||e=="number"||e=="string")a=p(a);if(h){if(e=="string")var k=h[0]=="-"?-1:1,q=parseInt(h.slice(1,3),10),r=parseInt(h.slice(3,5),10),h=k*60*q+r;e&&(a=new Date(a.getTime()+h*6E4))}return c.replace(/%([-_0]?.)/g,function(c,e){var d;if(e.length==2){d=e[0];if(d=="-")d="";else if(d=="_")d=" ";else if(d=="0")d="0";
|
||||
else return c;e=e[1]}switch(e){case "A":return b.days[a.getDay()];case "a":return b.shortDays[a.getDay()];case "B":return b.months[a.getMonth()];case "b":return b.shortMonths[a.getMonth()];case "C":return f(Math.floor(a.getFullYear()/100),d);case "D":return g(b.formats.D||"%m/%d/%y",a,b);case "d":return f(a.getDate(),d);case "e":return a.getDate();case "F":return g(b.formats.F||"%Y-%m-%d",a,b);case "H":return f(a.getHours(),d);case "h":return b.shortMonths[a.getMonth()];case "I":return f(l(a),d);
|
||||
case "j":return d=new Date(a.getFullYear(),0,1),d=Math.ceil((a.getTime()-d.getTime())/864E5),f(d,3);case "k":return f(a.getHours(),d==null?" ":d);case "L":return f(Math.floor(i%1E3),3);case "l":return f(l(a),d==null?" ":d);case "M":return f(a.getMinutes(),d);case "m":return f(a.getMonth()+1,d);case "n":return"\n";case "o":return String(a.getDate())+s(a.getDate());case "P":return a.getHours()<12?b.am:b.pm;case "p":return a.getHours()<12?b.AM:b.PM;case "R":return g(b.formats.R||"%H:%M",a,b);case "r":return g(b.formats.r||
|
||||
"%I:%M:%S %p",a,b);case "S":return f(a.getSeconds(),d);case "s":return Math.floor(i/1E3);case "T":return g(b.formats.T||"%H:%M:%S",a,b);case "t":return"\t";case "U":return f(m(a,"sunday"),d);case "u":return d=a.getDay(),d==0?7:d;case "v":return g(b.formats.v||"%e-%b-%Y",a,b);case "W":return f(m(a,"monday"),d);case "w":return a.getDay();case "Y":return a.getFullYear();case "y":return d=String(a.getFullYear()),d.slice(d.length-2);case "Z":return j.utc?"GMT":(d=a.toString().match(/\((\w+)\)/))&&d[1]||
|
||||
"";case "z":return j.utc?"+0000":(d=typeof h=="number"?h:-a.getTimezoneOffset(),(d<0?"-":"+")+f(Math.abs(d/60))+f(d%60));default:return e}})}function p(c){var a=(c.getTimezoneOffset()||0)*6E4;return new Date(c.getTime()+a)}function n(c){for(var a=0,b=k.length,a=0;a<b;++a)if(typeof c[k[a]]!="function")return!1;return!0}function f(c,a,b){typeof a==="number"&&(b=a,a="0");a==null&&(a="0");b=b||2;c=String(c);if(a)for(;c.length<b;)c=a+c;return c}function l(c){c=c.getHours();c==0?c=12:c>12&&(c-=12);return c}
|
||||
function s(c){var a=c%10;c%=100;if(c>=11&&c<=13||a===0||a>=4)return"th";switch(a){case 1:return"st";case 2:return"nd";case 3:return"rd"}}function m(c,a){var a=a||"sunday",b=c.getDay();a=="monday"&&(b==0?b=6:b--);var e=new Date(c.getFullYear(),0,1);return Math.floor(((c-e)/864E5+7-b)/7)}var e;e=typeof module!=="undefined"?module.exports=i:function(){return this||(0,eval)("this")}();var o={days:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),shortDays:"Sun Mon Tue Wed Thu Fri Sat".split(" "),
|
||||
months:"January February March April May June July August September October November December".split(" "),shortMonths:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),AM:"AM",PM:"PM",am:"am",pm:"pm"};e.strftime=i;e.strftimeTZ=i.strftimeTZ=function(c,a,b,e){if((typeof b=="number"||typeof b=="string")&&e==null)e=b,b=void 0;return g(c,a,b,{timezone:e})};e.strftimeUTC=i.strftimeUTC=function(c,a,b){return g(c,a,b,{utc:!0})};e.localizedStrftime=i.localizedStrftime=function(c){return function(a,
|
||||
b){return g(a,b,c)}};var k=["getTime","getTimezoneOffset","getDay","getDate","getMonth","getFullYear","getYear","getHours","getMinutes","getSeconds"]})();
|
|
@ -1,340 +0,0 @@
|
|||
;(function(undefined) {
|
||||
'use strict';
|
||||
|
||||
if (typeof sigma === 'undefined')
|
||||
throw 'sigma is not declared';
|
||||
|
||||
/**
|
||||
* Sigma ForceAtlas2.5 Supervisor
|
||||
* ===============================
|
||||
*
|
||||
* Author: Guillaume Plique (Yomguithereal)
|
||||
* Version: 0.1
|
||||
*/
|
||||
var _root = this;
|
||||
|
||||
/**
|
||||
* Feature detection
|
||||
* ------------------
|
||||
*/
|
||||
var webWorkers = 'Worker' in _root;
|
||||
|
||||
/**
|
||||
* Supervisor Object
|
||||
* ------------------
|
||||
*/
|
||||
function Supervisor(sigInst, options) {
|
||||
var _this = this,
|
||||
workerFn = sigInst.getForceAtlas2Worker &&
|
||||
sigInst.getForceAtlas2Worker();
|
||||
|
||||
options = options || {};
|
||||
|
||||
// _root URL Polyfill
|
||||
_root.URL = _root.URL || _root.webkitURL;
|
||||
|
||||
// Properties
|
||||
this.sigInst = sigInst;
|
||||
this.graph = this.sigInst.graph;
|
||||
this.ppn = 10;
|
||||
this.ppe = 3;
|
||||
this.config = {};
|
||||
this.shouldUseWorker =
|
||||
options.worker === false ? false : true && webWorkers;
|
||||
this.workerUrl = options.workerUrl;
|
||||
|
||||
// State
|
||||
this.started = false;
|
||||
this.running = false;
|
||||
|
||||
// Web worker or classic DOM events?
|
||||
if (this.shouldUseWorker) {
|
||||
if (!this.workerUrl) {
|
||||
var blob = this.makeBlob(workerFn);
|
||||
this.worker = new Worker(URL.createObjectURL(blob));
|
||||
}
|
||||
else {
|
||||
this.worker = new Worker(this.workerUrl);
|
||||
}
|
||||
|
||||
// Post Message Polyfill
|
||||
this.worker.postMessage =
|
||||
this.worker.webkitPostMessage || this.worker.postMessage;
|
||||
}
|
||||
else {
|
||||
|
||||
eval(workerFn);
|
||||
}
|
||||
|
||||
// Worker message receiver
|
||||
this.msgName = (this.worker) ? 'message' : 'newCoords';
|
||||
this.listener = function(e) {
|
||||
|
||||
// Retrieving data
|
||||
_this.nodesByteArray = new Float32Array(e.data.nodes);
|
||||
|
||||
// If ForceAtlas2 is running, we act accordingly
|
||||
if (_this.running) {
|
||||
|
||||
// Applying layout
|
||||
_this.applyLayoutChanges();
|
||||
|
||||
// Send data back to worker and loop
|
||||
_this.sendByteArrayToWorker();
|
||||
|
||||
// Rendering graph
|
||||
_this.sigInst.refresh();
|
||||
}
|
||||
};
|
||||
|
||||
(this.worker || document).addEventListener(this.msgName, this.listener);
|
||||
|
||||
// Filling byteArrays
|
||||
this.graphToByteArrays();
|
||||
|
||||
// Binding on kill to properly terminate layout when parent is killed
|
||||
sigInst.bind('kill', function() {
|
||||
sigInst.killForceAtlas2();
|
||||
});
|
||||
}
|
||||
|
||||
Supervisor.prototype.makeBlob = function(workerFn) {
|
||||
var blob;
|
||||
|
||||
try {
|
||||
blob = new Blob([workerFn], {type: 'application/javascript'});
|
||||
}
|
||||
catch (e) {
|
||||
_root.BlobBuilder = _root.BlobBuilder ||
|
||||
_root.WebKitBlobBuilder ||
|
||||
_root.MozBlobBuilder;
|
||||
|
||||
blob = new BlobBuilder();
|
||||
blob.append(workerFn);
|
||||
blob = blob.getBlob();
|
||||
}
|
||||
|
||||
return blob;
|
||||
};
|
||||
|
||||
Supervisor.prototype.graphToByteArrays = function() {
|
||||
var nodes = this.graph.nodes(),
|
||||
edges = this.graph.edges(),
|
||||
nbytes = nodes.length * this.ppn,
|
||||
ebytes = edges.length * this.ppe,
|
||||
nIndex = {},
|
||||
i,
|
||||
j,
|
||||
l;
|
||||
|
||||
// Allocating Byte arrays with correct nb of bytes
|
||||
this.nodesByteArray = new Float32Array(nbytes);
|
||||
this.edgesByteArray = new Float32Array(ebytes);
|
||||
|
||||
// Iterate through nodes
|
||||
for (i = j = 0, l = nodes.length; i < l; i++) {
|
||||
|
||||
// Populating index
|
||||
nIndex[nodes[i].id] = j;
|
||||
|
||||
// Populating byte array
|
||||
this.nodesByteArray[j] = nodes[i].x;
|
||||
this.nodesByteArray[j + 1] = nodes[i].y;
|
||||
this.nodesByteArray[j + 2] = 0;
|
||||
this.nodesByteArray[j + 3] = 0;
|
||||
this.nodesByteArray[j + 4] = 0;
|
||||
this.nodesByteArray[j + 5] = 0;
|
||||
this.nodesByteArray[j + 6] = 1 + this.graph.degree(nodes[i].id);
|
||||
this.nodesByteArray[j + 7] = 1;
|
||||
this.nodesByteArray[j + 8] = nodes[i].size;
|
||||
this.nodesByteArray[j + 9] = 0;
|
||||
j += this.ppn;
|
||||
}
|
||||
|
||||
// Iterate through edges
|
||||
for (i = j = 0, l = edges.length; i < l; i++) {
|
||||
this.edgesByteArray[j] = nIndex[edges[i].source];
|
||||
this.edgesByteArray[j + 1] = nIndex[edges[i].target];
|
||||
this.edgesByteArray[j + 2] = edges[i].weight || 0;
|
||||
j += this.ppe;
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: make a better send function
|
||||
Supervisor.prototype.applyLayoutChanges = function() {
|
||||
var nodes = this.graph.nodes(),
|
||||
j = 0,
|
||||
realIndex;
|
||||
|
||||
// Moving nodes
|
||||
for (var i = 0, l = this.nodesByteArray.length; i < l; i += this.ppn) {
|
||||
nodes[j].x = this.nodesByteArray[i];
|
||||
nodes[j].y = this.nodesByteArray[i + 1];
|
||||
j++;
|
||||
}
|
||||
};
|
||||
|
||||
Supervisor.prototype.sendByteArrayToWorker = function(action) {
|
||||
var content = {
|
||||
action: action || 'loop',
|
||||
nodes: this.nodesByteArray.buffer
|
||||
};
|
||||
|
||||
var buffers = [this.nodesByteArray.buffer];
|
||||
|
||||
if (action === 'start') {
|
||||
content.config = this.config || {};
|
||||
content.edges = this.edgesByteArray.buffer;
|
||||
buffers.push(this.edgesByteArray.buffer);
|
||||
}
|
||||
|
||||
if (this.shouldUseWorker)
|
||||
this.worker.postMessage(content, buffers);
|
||||
else
|
||||
_root.postMessage(content, '*');
|
||||
};
|
||||
|
||||
Supervisor.prototype.start = function() {
|
||||
if (this.running)
|
||||
return;
|
||||
|
||||
this.running = true;
|
||||
|
||||
// Do not refresh edgequadtree during layout:
|
||||
var k,
|
||||
c;
|
||||
for (k in this.sigInst.cameras) {
|
||||
c = this.sigInst.cameras[k];
|
||||
c.edgequadtree._enabled = false;
|
||||
}
|
||||
|
||||
if (!this.started) {
|
||||
|
||||
// Sending init message to worker
|
||||
this.sendByteArrayToWorker('start');
|
||||
this.started = true;
|
||||
}
|
||||
else {
|
||||
this.sendByteArrayToWorker();
|
||||
}
|
||||
};
|
||||
|
||||
Supervisor.prototype.stop = function() {
|
||||
if (!this.running)
|
||||
return;
|
||||
|
||||
// Allow to refresh edgequadtree:
|
||||
var k,
|
||||
c,
|
||||
bounds;
|
||||
for (k in this.sigInst.cameras) {
|
||||
c = this.sigInst.cameras[k];
|
||||
c.edgequadtree._enabled = true;
|
||||
|
||||
// Find graph boundaries:
|
||||
bounds = sigma.utils.getBoundaries(
|
||||
this.graph,
|
||||
c.readPrefix
|
||||
);
|
||||
|
||||
// Refresh edgequadtree:
|
||||
if (c.settings('drawEdges') && c.settings('enableEdgeHovering'))
|
||||
c.edgequadtree.index(this.sigInst.graph, {
|
||||
prefix: c.readPrefix,
|
||||
bounds: {
|
||||
x: bounds.minX,
|
||||
y: bounds.minY,
|
||||
width: bounds.maxX - bounds.minX,
|
||||
height: bounds.maxY - bounds.minY
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.running = false;
|
||||
};
|
||||
|
||||
Supervisor.prototype.killWorker = function() {
|
||||
if (this.worker) {
|
||||
this.worker.terminate();
|
||||
}
|
||||
else {
|
||||
_root.postMessage({action: 'kill'}, '*');
|
||||
document.removeEventListener(this.msgName, this.listener);
|
||||
}
|
||||
};
|
||||
|
||||
Supervisor.prototype.configure = function(config) {
|
||||
|
||||
// Setting configuration
|
||||
this.config = config;
|
||||
|
||||
if (!this.started)
|
||||
return;
|
||||
|
||||
var data = {action: 'config', config: this.config};
|
||||
|
||||
if (this.shouldUseWorker)
|
||||
this.worker.postMessage(data);
|
||||
else
|
||||
_root.postMessage(data, '*');
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface
|
||||
* ----------
|
||||
*/
|
||||
sigma.prototype.startForceAtlas2 = function(config) {
|
||||
|
||||
// Create supervisor if undefined
|
||||
if (!this.supervisor)
|
||||
this.supervisor = new Supervisor(this, config);
|
||||
|
||||
// Configuration provided?
|
||||
if (config)
|
||||
this.supervisor.configure(config);
|
||||
|
||||
// Start algorithm
|
||||
this.supervisor.start();
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
sigma.prototype.stopForceAtlas2 = function() {
|
||||
if (!this.supervisor)
|
||||
return this;
|
||||
|
||||
// Pause algorithm
|
||||
this.supervisor.stop();
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
sigma.prototype.killForceAtlas2 = function() {
|
||||
if (!this.supervisor)
|
||||
return this;
|
||||
|
||||
// Stop Algorithm
|
||||
this.supervisor.stop();
|
||||
|
||||
// Kill Worker
|
||||
this.supervisor.killWorker();
|
||||
|
||||
// Kill supervisor
|
||||
this.supervisor = null;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
sigma.prototype.configForceAtlas2 = function(config) {
|
||||
if (!this.supervisor)
|
||||
this.supervisor = new Supervisor(this, config);
|
||||
|
||||
this.supervisor.configure(config);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
sigma.prototype.isForceAtlas2Running = function(config) {
|
||||
return !!this.supervisor && this.supervisor.running;
|
||||
};
|
||||
}).call(this);
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -162,6 +162,7 @@ require('../../frontend/js/lib/wheelnav.min.js');
|
|||
window.Raphael = require('../../frontend/js/lib/raphael.min.js');
|
||||
require('../../frontend/js/lib/raphael.icons.min.js');
|
||||
|
||||
require('../../frontend/js/lib/randomColor.js');
|
||||
//require('../../frontend/src/ace.js');
|
||||
//require('../../frontend/src/theme-textmate.js');
|
||||
//require('../../frontend/src/mode-json.js');
|
||||
|
|
Loading…
Reference in New Issue