cytoscape-cose-bilkent.js 202 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710
  1. import {
  2. __commonJS
  3. } from "./chunk-DC5AMYBS.js";
  4. // node_modules/layout-base/layout-base.js
  5. var require_layout_base = __commonJS({
  6. "node_modules/layout-base/layout-base.js"(exports, module) {
  7. (function webpackUniversalModuleDefinition(root, factory) {
  8. if (typeof exports === "object" && typeof module === "object")
  9. module.exports = factory();
  10. else if (typeof define === "function" && define.amd)
  11. define([], factory);
  12. else if (typeof exports === "object")
  13. exports["layoutBase"] = factory();
  14. else
  15. root["layoutBase"] = factory();
  16. })(exports, function() {
  17. return (
  18. /******/
  19. (function(modules) {
  20. var installedModules = {};
  21. function __webpack_require__(moduleId) {
  22. if (installedModules[moduleId]) {
  23. return installedModules[moduleId].exports;
  24. }
  25. var module2 = installedModules[moduleId] = {
  26. /******/
  27. i: moduleId,
  28. /******/
  29. l: false,
  30. /******/
  31. exports: {}
  32. /******/
  33. };
  34. modules[moduleId].call(module2.exports, module2, module2.exports, __webpack_require__);
  35. module2.l = true;
  36. return module2.exports;
  37. }
  38. __webpack_require__.m = modules;
  39. __webpack_require__.c = installedModules;
  40. __webpack_require__.i = function(value) {
  41. return value;
  42. };
  43. __webpack_require__.d = function(exports2, name, getter) {
  44. if (!__webpack_require__.o(exports2, name)) {
  45. Object.defineProperty(exports2, name, {
  46. /******/
  47. configurable: false,
  48. /******/
  49. enumerable: true,
  50. /******/
  51. get: getter
  52. /******/
  53. });
  54. }
  55. };
  56. __webpack_require__.n = function(module2) {
  57. var getter = module2 && module2.__esModule ? (
  58. /******/
  59. function getDefault() {
  60. return module2["default"];
  61. }
  62. ) : (
  63. /******/
  64. function getModuleExports() {
  65. return module2;
  66. }
  67. );
  68. __webpack_require__.d(getter, "a", getter);
  69. return getter;
  70. };
  71. __webpack_require__.o = function(object, property) {
  72. return Object.prototype.hasOwnProperty.call(object, property);
  73. };
  74. __webpack_require__.p = "";
  75. return __webpack_require__(__webpack_require__.s = 26);
  76. })([
  77. /* 0 */
  78. /***/
  79. (function(module2, exports2, __webpack_require__) {
  80. "use strict";
  81. function LayoutConstants() {
  82. }
  83. LayoutConstants.QUALITY = 1;
  84. LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED = false;
  85. LayoutConstants.DEFAULT_INCREMENTAL = false;
  86. LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT = true;
  87. LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT = false;
  88. LayoutConstants.DEFAULT_ANIMATION_PERIOD = 50;
  89. LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = false;
  90. LayoutConstants.DEFAULT_GRAPH_MARGIN = 15;
  91. LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = false;
  92. LayoutConstants.SIMPLE_NODE_SIZE = 40;
  93. LayoutConstants.SIMPLE_NODE_HALF_SIZE = LayoutConstants.SIMPLE_NODE_SIZE / 2;
  94. LayoutConstants.EMPTY_COMPOUND_NODE_SIZE = 40;
  95. LayoutConstants.MIN_EDGE_LENGTH = 1;
  96. LayoutConstants.WORLD_BOUNDARY = 1e6;
  97. LayoutConstants.INITIAL_WORLD_BOUNDARY = LayoutConstants.WORLD_BOUNDARY / 1e3;
  98. LayoutConstants.WORLD_CENTER_X = 1200;
  99. LayoutConstants.WORLD_CENTER_Y = 900;
  100. module2.exports = LayoutConstants;
  101. }),
  102. /* 1 */
  103. /***/
  104. (function(module2, exports2, __webpack_require__) {
  105. "use strict";
  106. var LGraphObject = __webpack_require__(2);
  107. var IGeometry = __webpack_require__(8);
  108. var IMath = __webpack_require__(9);
  109. function LEdge(source, target, vEdge) {
  110. LGraphObject.call(this, vEdge);
  111. this.isOverlapingSourceAndTarget = false;
  112. this.vGraphObject = vEdge;
  113. this.bendpoints = [];
  114. this.source = source;
  115. this.target = target;
  116. }
  117. LEdge.prototype = Object.create(LGraphObject.prototype);
  118. for (var prop in LGraphObject) {
  119. LEdge[prop] = LGraphObject[prop];
  120. }
  121. LEdge.prototype.getSource = function() {
  122. return this.source;
  123. };
  124. LEdge.prototype.getTarget = function() {
  125. return this.target;
  126. };
  127. LEdge.prototype.isInterGraph = function() {
  128. return this.isInterGraph;
  129. };
  130. LEdge.prototype.getLength = function() {
  131. return this.length;
  132. };
  133. LEdge.prototype.isOverlapingSourceAndTarget = function() {
  134. return this.isOverlapingSourceAndTarget;
  135. };
  136. LEdge.prototype.getBendpoints = function() {
  137. return this.bendpoints;
  138. };
  139. LEdge.prototype.getLca = function() {
  140. return this.lca;
  141. };
  142. LEdge.prototype.getSourceInLca = function() {
  143. return this.sourceInLca;
  144. };
  145. LEdge.prototype.getTargetInLca = function() {
  146. return this.targetInLca;
  147. };
  148. LEdge.prototype.getOtherEnd = function(node) {
  149. if (this.source === node) {
  150. return this.target;
  151. } else if (this.target === node) {
  152. return this.source;
  153. } else {
  154. throw "Node is not incident with this edge";
  155. }
  156. };
  157. LEdge.prototype.getOtherEndInGraph = function(node, graph) {
  158. var otherEnd = this.getOtherEnd(node);
  159. var root = graph.getGraphManager().getRoot();
  160. while (true) {
  161. if (otherEnd.getOwner() == graph) {
  162. return otherEnd;
  163. }
  164. if (otherEnd.getOwner() == root) {
  165. break;
  166. }
  167. otherEnd = otherEnd.getOwner().getParent();
  168. }
  169. return null;
  170. };
  171. LEdge.prototype.updateLength = function() {
  172. var clipPointCoordinates = new Array(4);
  173. this.isOverlapingSourceAndTarget = IGeometry.getIntersection(this.target.getRect(), this.source.getRect(), clipPointCoordinates);
  174. if (!this.isOverlapingSourceAndTarget) {
  175. this.lengthX = clipPointCoordinates[0] - clipPointCoordinates[2];
  176. this.lengthY = clipPointCoordinates[1] - clipPointCoordinates[3];
  177. if (Math.abs(this.lengthX) < 1) {
  178. this.lengthX = IMath.sign(this.lengthX);
  179. }
  180. if (Math.abs(this.lengthY) < 1) {
  181. this.lengthY = IMath.sign(this.lengthY);
  182. }
  183. this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY);
  184. }
  185. };
  186. LEdge.prototype.updateLengthSimple = function() {
  187. this.lengthX = this.target.getCenterX() - this.source.getCenterX();
  188. this.lengthY = this.target.getCenterY() - this.source.getCenterY();
  189. if (Math.abs(this.lengthX) < 1) {
  190. this.lengthX = IMath.sign(this.lengthX);
  191. }
  192. if (Math.abs(this.lengthY) < 1) {
  193. this.lengthY = IMath.sign(this.lengthY);
  194. }
  195. this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY);
  196. };
  197. module2.exports = LEdge;
  198. }),
  199. /* 2 */
  200. /***/
  201. (function(module2, exports2, __webpack_require__) {
  202. "use strict";
  203. function LGraphObject(vGraphObject) {
  204. this.vGraphObject = vGraphObject;
  205. }
  206. module2.exports = LGraphObject;
  207. }),
  208. /* 3 */
  209. /***/
  210. (function(module2, exports2, __webpack_require__) {
  211. "use strict";
  212. var LGraphObject = __webpack_require__(2);
  213. var Integer = __webpack_require__(10);
  214. var RectangleD = __webpack_require__(13);
  215. var LayoutConstants = __webpack_require__(0);
  216. var RandomSeed = __webpack_require__(16);
  217. var PointD = __webpack_require__(4);
  218. function LNode(gm, loc, size, vNode) {
  219. if (size == null && vNode == null) {
  220. vNode = loc;
  221. }
  222. LGraphObject.call(this, vNode);
  223. if (gm.graphManager != null) gm = gm.graphManager;
  224. this.estimatedSize = Integer.MIN_VALUE;
  225. this.inclusionTreeDepth = Integer.MAX_VALUE;
  226. this.vGraphObject = vNode;
  227. this.edges = [];
  228. this.graphManager = gm;
  229. if (size != null && loc != null) this.rect = new RectangleD(loc.x, loc.y, size.width, size.height);
  230. else this.rect = new RectangleD();
  231. }
  232. LNode.prototype = Object.create(LGraphObject.prototype);
  233. for (var prop in LGraphObject) {
  234. LNode[prop] = LGraphObject[prop];
  235. }
  236. LNode.prototype.getEdges = function() {
  237. return this.edges;
  238. };
  239. LNode.prototype.getChild = function() {
  240. return this.child;
  241. };
  242. LNode.prototype.getOwner = function() {
  243. return this.owner;
  244. };
  245. LNode.prototype.getWidth = function() {
  246. return this.rect.width;
  247. };
  248. LNode.prototype.setWidth = function(width) {
  249. this.rect.width = width;
  250. };
  251. LNode.prototype.getHeight = function() {
  252. return this.rect.height;
  253. };
  254. LNode.prototype.setHeight = function(height) {
  255. this.rect.height = height;
  256. };
  257. LNode.prototype.getCenterX = function() {
  258. return this.rect.x + this.rect.width / 2;
  259. };
  260. LNode.prototype.getCenterY = function() {
  261. return this.rect.y + this.rect.height / 2;
  262. };
  263. LNode.prototype.getCenter = function() {
  264. return new PointD(this.rect.x + this.rect.width / 2, this.rect.y + this.rect.height / 2);
  265. };
  266. LNode.prototype.getLocation = function() {
  267. return new PointD(this.rect.x, this.rect.y);
  268. };
  269. LNode.prototype.getRect = function() {
  270. return this.rect;
  271. };
  272. LNode.prototype.getDiagonal = function() {
  273. return Math.sqrt(this.rect.width * this.rect.width + this.rect.height * this.rect.height);
  274. };
  275. LNode.prototype.getHalfTheDiagonal = function() {
  276. return Math.sqrt(this.rect.height * this.rect.height + this.rect.width * this.rect.width) / 2;
  277. };
  278. LNode.prototype.setRect = function(upperLeft, dimension) {
  279. this.rect.x = upperLeft.x;
  280. this.rect.y = upperLeft.y;
  281. this.rect.width = dimension.width;
  282. this.rect.height = dimension.height;
  283. };
  284. LNode.prototype.setCenter = function(cx, cy) {
  285. this.rect.x = cx - this.rect.width / 2;
  286. this.rect.y = cy - this.rect.height / 2;
  287. };
  288. LNode.prototype.setLocation = function(x, y) {
  289. this.rect.x = x;
  290. this.rect.y = y;
  291. };
  292. LNode.prototype.moveBy = function(dx, dy) {
  293. this.rect.x += dx;
  294. this.rect.y += dy;
  295. };
  296. LNode.prototype.getEdgeListToNode = function(to) {
  297. var edgeList = [];
  298. var edge;
  299. var self = this;
  300. self.edges.forEach(function(edge2) {
  301. if (edge2.target == to) {
  302. if (edge2.source != self) throw "Incorrect edge source!";
  303. edgeList.push(edge2);
  304. }
  305. });
  306. return edgeList;
  307. };
  308. LNode.prototype.getEdgesBetween = function(other) {
  309. var edgeList = [];
  310. var edge;
  311. var self = this;
  312. self.edges.forEach(function(edge2) {
  313. if (!(edge2.source == self || edge2.target == self)) throw "Incorrect edge source and/or target";
  314. if (edge2.target == other || edge2.source == other) {
  315. edgeList.push(edge2);
  316. }
  317. });
  318. return edgeList;
  319. };
  320. LNode.prototype.getNeighborsList = function() {
  321. var neighbors = /* @__PURE__ */ new Set();
  322. var self = this;
  323. self.edges.forEach(function(edge) {
  324. if (edge.source == self) {
  325. neighbors.add(edge.target);
  326. } else {
  327. if (edge.target != self) {
  328. throw "Incorrect incidency!";
  329. }
  330. neighbors.add(edge.source);
  331. }
  332. });
  333. return neighbors;
  334. };
  335. LNode.prototype.withChildren = function() {
  336. var withNeighborsList = /* @__PURE__ */ new Set();
  337. var childNode;
  338. var children;
  339. withNeighborsList.add(this);
  340. if (this.child != null) {
  341. var nodes = this.child.getNodes();
  342. for (var i = 0; i < nodes.length; i++) {
  343. childNode = nodes[i];
  344. children = childNode.withChildren();
  345. children.forEach(function(node) {
  346. withNeighborsList.add(node);
  347. });
  348. }
  349. }
  350. return withNeighborsList;
  351. };
  352. LNode.prototype.getNoOfChildren = function() {
  353. var noOfChildren = 0;
  354. var childNode;
  355. if (this.child == null) {
  356. noOfChildren = 1;
  357. } else {
  358. var nodes = this.child.getNodes();
  359. for (var i = 0; i < nodes.length; i++) {
  360. childNode = nodes[i];
  361. noOfChildren += childNode.getNoOfChildren();
  362. }
  363. }
  364. if (noOfChildren == 0) {
  365. noOfChildren = 1;
  366. }
  367. return noOfChildren;
  368. };
  369. LNode.prototype.getEstimatedSize = function() {
  370. if (this.estimatedSize == Integer.MIN_VALUE) {
  371. throw "assert failed";
  372. }
  373. return this.estimatedSize;
  374. };
  375. LNode.prototype.calcEstimatedSize = function() {
  376. if (this.child == null) {
  377. return this.estimatedSize = (this.rect.width + this.rect.height) / 2;
  378. } else {
  379. this.estimatedSize = this.child.calcEstimatedSize();
  380. this.rect.width = this.estimatedSize;
  381. this.rect.height = this.estimatedSize;
  382. return this.estimatedSize;
  383. }
  384. };
  385. LNode.prototype.scatter = function() {
  386. var randomCenterX;
  387. var randomCenterY;
  388. var minX = -LayoutConstants.INITIAL_WORLD_BOUNDARY;
  389. var maxX = LayoutConstants.INITIAL_WORLD_BOUNDARY;
  390. randomCenterX = LayoutConstants.WORLD_CENTER_X + RandomSeed.nextDouble() * (maxX - minX) + minX;
  391. var minY = -LayoutConstants.INITIAL_WORLD_BOUNDARY;
  392. var maxY = LayoutConstants.INITIAL_WORLD_BOUNDARY;
  393. randomCenterY = LayoutConstants.WORLD_CENTER_Y + RandomSeed.nextDouble() * (maxY - minY) + minY;
  394. this.rect.x = randomCenterX;
  395. this.rect.y = randomCenterY;
  396. };
  397. LNode.prototype.updateBounds = function() {
  398. if (this.getChild() == null) {
  399. throw "assert failed";
  400. }
  401. if (this.getChild().getNodes().length != 0) {
  402. var childGraph = this.getChild();
  403. childGraph.updateBounds(true);
  404. this.rect.x = childGraph.getLeft();
  405. this.rect.y = childGraph.getTop();
  406. this.setWidth(childGraph.getRight() - childGraph.getLeft());
  407. this.setHeight(childGraph.getBottom() - childGraph.getTop());
  408. if (LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS) {
  409. var width = childGraph.getRight() - childGraph.getLeft();
  410. var height = childGraph.getBottom() - childGraph.getTop();
  411. if (this.labelWidth > width) {
  412. this.rect.x -= (this.labelWidth - width) / 2;
  413. this.setWidth(this.labelWidth);
  414. }
  415. if (this.labelHeight > height) {
  416. if (this.labelPos == "center") {
  417. this.rect.y -= (this.labelHeight - height) / 2;
  418. } else if (this.labelPos == "top") {
  419. this.rect.y -= this.labelHeight - height;
  420. }
  421. this.setHeight(this.labelHeight);
  422. }
  423. }
  424. }
  425. };
  426. LNode.prototype.getInclusionTreeDepth = function() {
  427. if (this.inclusionTreeDepth == Integer.MAX_VALUE) {
  428. throw "assert failed";
  429. }
  430. return this.inclusionTreeDepth;
  431. };
  432. LNode.prototype.transform = function(trans) {
  433. var left = this.rect.x;
  434. if (left > LayoutConstants.WORLD_BOUNDARY) {
  435. left = LayoutConstants.WORLD_BOUNDARY;
  436. } else if (left < -LayoutConstants.WORLD_BOUNDARY) {
  437. left = -LayoutConstants.WORLD_BOUNDARY;
  438. }
  439. var top = this.rect.y;
  440. if (top > LayoutConstants.WORLD_BOUNDARY) {
  441. top = LayoutConstants.WORLD_BOUNDARY;
  442. } else if (top < -LayoutConstants.WORLD_BOUNDARY) {
  443. top = -LayoutConstants.WORLD_BOUNDARY;
  444. }
  445. var leftTop = new PointD(left, top);
  446. var vLeftTop = trans.inverseTransformPoint(leftTop);
  447. this.setLocation(vLeftTop.x, vLeftTop.y);
  448. };
  449. LNode.prototype.getLeft = function() {
  450. return this.rect.x;
  451. };
  452. LNode.prototype.getRight = function() {
  453. return this.rect.x + this.rect.width;
  454. };
  455. LNode.prototype.getTop = function() {
  456. return this.rect.y;
  457. };
  458. LNode.prototype.getBottom = function() {
  459. return this.rect.y + this.rect.height;
  460. };
  461. LNode.prototype.getParent = function() {
  462. if (this.owner == null) {
  463. return null;
  464. }
  465. return this.owner.getParent();
  466. };
  467. module2.exports = LNode;
  468. }),
  469. /* 4 */
  470. /***/
  471. (function(module2, exports2, __webpack_require__) {
  472. "use strict";
  473. function PointD(x, y) {
  474. if (x == null && y == null) {
  475. this.x = 0;
  476. this.y = 0;
  477. } else {
  478. this.x = x;
  479. this.y = y;
  480. }
  481. }
  482. PointD.prototype.getX = function() {
  483. return this.x;
  484. };
  485. PointD.prototype.getY = function() {
  486. return this.y;
  487. };
  488. PointD.prototype.setX = function(x) {
  489. this.x = x;
  490. };
  491. PointD.prototype.setY = function(y) {
  492. this.y = y;
  493. };
  494. PointD.prototype.getDifference = function(pt) {
  495. return new DimensionD(this.x - pt.x, this.y - pt.y);
  496. };
  497. PointD.prototype.getCopy = function() {
  498. return new PointD(this.x, this.y);
  499. };
  500. PointD.prototype.translate = function(dim) {
  501. this.x += dim.width;
  502. this.y += dim.height;
  503. return this;
  504. };
  505. module2.exports = PointD;
  506. }),
  507. /* 5 */
  508. /***/
  509. (function(module2, exports2, __webpack_require__) {
  510. "use strict";
  511. var LGraphObject = __webpack_require__(2);
  512. var Integer = __webpack_require__(10);
  513. var LayoutConstants = __webpack_require__(0);
  514. var LGraphManager = __webpack_require__(6);
  515. var LNode = __webpack_require__(3);
  516. var LEdge = __webpack_require__(1);
  517. var RectangleD = __webpack_require__(13);
  518. var Point2 = __webpack_require__(12);
  519. var LinkedList = __webpack_require__(11);
  520. function LGraph(parent, obj2, vGraph) {
  521. LGraphObject.call(this, vGraph);
  522. this.estimatedSize = Integer.MIN_VALUE;
  523. this.margin = LayoutConstants.DEFAULT_GRAPH_MARGIN;
  524. this.edges = [];
  525. this.nodes = [];
  526. this.isConnected = false;
  527. this.parent = parent;
  528. if (obj2 != null && obj2 instanceof LGraphManager) {
  529. this.graphManager = obj2;
  530. } else if (obj2 != null && obj2 instanceof Layout) {
  531. this.graphManager = obj2.graphManager;
  532. }
  533. }
  534. LGraph.prototype = Object.create(LGraphObject.prototype);
  535. for (var prop in LGraphObject) {
  536. LGraph[prop] = LGraphObject[prop];
  537. }
  538. LGraph.prototype.getNodes = function() {
  539. return this.nodes;
  540. };
  541. LGraph.prototype.getEdges = function() {
  542. return this.edges;
  543. };
  544. LGraph.prototype.getGraphManager = function() {
  545. return this.graphManager;
  546. };
  547. LGraph.prototype.getParent = function() {
  548. return this.parent;
  549. };
  550. LGraph.prototype.getLeft = function() {
  551. return this.left;
  552. };
  553. LGraph.prototype.getRight = function() {
  554. return this.right;
  555. };
  556. LGraph.prototype.getTop = function() {
  557. return this.top;
  558. };
  559. LGraph.prototype.getBottom = function() {
  560. return this.bottom;
  561. };
  562. LGraph.prototype.isConnected = function() {
  563. return this.isConnected;
  564. };
  565. LGraph.prototype.add = function(obj1, sourceNode, targetNode) {
  566. if (sourceNode == null && targetNode == null) {
  567. var newNode = obj1;
  568. if (this.graphManager == null) {
  569. throw "Graph has no graph mgr!";
  570. }
  571. if (this.getNodes().indexOf(newNode) > -1) {
  572. throw "Node already in graph!";
  573. }
  574. newNode.owner = this;
  575. this.getNodes().push(newNode);
  576. return newNode;
  577. } else {
  578. var newEdge = obj1;
  579. if (!(this.getNodes().indexOf(sourceNode) > -1 && this.getNodes().indexOf(targetNode) > -1)) {
  580. throw "Source or target not in graph!";
  581. }
  582. if (!(sourceNode.owner == targetNode.owner && sourceNode.owner == this)) {
  583. throw "Both owners must be this graph!";
  584. }
  585. if (sourceNode.owner != targetNode.owner) {
  586. return null;
  587. }
  588. newEdge.source = sourceNode;
  589. newEdge.target = targetNode;
  590. newEdge.isInterGraph = false;
  591. this.getEdges().push(newEdge);
  592. sourceNode.edges.push(newEdge);
  593. if (targetNode != sourceNode) {
  594. targetNode.edges.push(newEdge);
  595. }
  596. return newEdge;
  597. }
  598. };
  599. LGraph.prototype.remove = function(obj) {
  600. var node = obj;
  601. if (obj instanceof LNode) {
  602. if (node == null) {
  603. throw "Node is null!";
  604. }
  605. if (!(node.owner != null && node.owner == this)) {
  606. throw "Owner graph is invalid!";
  607. }
  608. if (this.graphManager == null) {
  609. throw "Owner graph manager is invalid!";
  610. }
  611. var edgesToBeRemoved = node.edges.slice();
  612. var edge;
  613. var s = edgesToBeRemoved.length;
  614. for (var i = 0; i < s; i++) {
  615. edge = edgesToBeRemoved[i];
  616. if (edge.isInterGraph) {
  617. this.graphManager.remove(edge);
  618. } else {
  619. edge.source.owner.remove(edge);
  620. }
  621. }
  622. var index = this.nodes.indexOf(node);
  623. if (index == -1) {
  624. throw "Node not in owner node list!";
  625. }
  626. this.nodes.splice(index, 1);
  627. } else if (obj instanceof LEdge) {
  628. var edge = obj;
  629. if (edge == null) {
  630. throw "Edge is null!";
  631. }
  632. if (!(edge.source != null && edge.target != null)) {
  633. throw "Source and/or target is null!";
  634. }
  635. if (!(edge.source.owner != null && edge.target.owner != null && edge.source.owner == this && edge.target.owner == this)) {
  636. throw "Source and/or target owner is invalid!";
  637. }
  638. var sourceIndex = edge.source.edges.indexOf(edge);
  639. var targetIndex = edge.target.edges.indexOf(edge);
  640. if (!(sourceIndex > -1 && targetIndex > -1)) {
  641. throw "Source and/or target doesn't know this edge!";
  642. }
  643. edge.source.edges.splice(sourceIndex, 1);
  644. if (edge.target != edge.source) {
  645. edge.target.edges.splice(targetIndex, 1);
  646. }
  647. var index = edge.source.owner.getEdges().indexOf(edge);
  648. if (index == -1) {
  649. throw "Not in owner's edge list!";
  650. }
  651. edge.source.owner.getEdges().splice(index, 1);
  652. }
  653. };
  654. LGraph.prototype.updateLeftTop = function() {
  655. var top = Integer.MAX_VALUE;
  656. var left = Integer.MAX_VALUE;
  657. var nodeTop;
  658. var nodeLeft;
  659. var margin;
  660. var nodes = this.getNodes();
  661. var s = nodes.length;
  662. for (var i = 0; i < s; i++) {
  663. var lNode = nodes[i];
  664. nodeTop = lNode.getTop();
  665. nodeLeft = lNode.getLeft();
  666. if (top > nodeTop) {
  667. top = nodeTop;
  668. }
  669. if (left > nodeLeft) {
  670. left = nodeLeft;
  671. }
  672. }
  673. if (top == Integer.MAX_VALUE) {
  674. return null;
  675. }
  676. if (nodes[0].getParent().paddingLeft != void 0) {
  677. margin = nodes[0].getParent().paddingLeft;
  678. } else {
  679. margin = this.margin;
  680. }
  681. this.left = left - margin;
  682. this.top = top - margin;
  683. return new Point2(this.left, this.top);
  684. };
  685. LGraph.prototype.updateBounds = function(recursive) {
  686. var left = Integer.MAX_VALUE;
  687. var right = -Integer.MAX_VALUE;
  688. var top = Integer.MAX_VALUE;
  689. var bottom = -Integer.MAX_VALUE;
  690. var nodeLeft;
  691. var nodeRight;
  692. var nodeTop;
  693. var nodeBottom;
  694. var margin;
  695. var nodes = this.nodes;
  696. var s = nodes.length;
  697. for (var i = 0; i < s; i++) {
  698. var lNode = nodes[i];
  699. if (recursive && lNode.child != null) {
  700. lNode.updateBounds();
  701. }
  702. nodeLeft = lNode.getLeft();
  703. nodeRight = lNode.getRight();
  704. nodeTop = lNode.getTop();
  705. nodeBottom = lNode.getBottom();
  706. if (left > nodeLeft) {
  707. left = nodeLeft;
  708. }
  709. if (right < nodeRight) {
  710. right = nodeRight;
  711. }
  712. if (top > nodeTop) {
  713. top = nodeTop;
  714. }
  715. if (bottom < nodeBottom) {
  716. bottom = nodeBottom;
  717. }
  718. }
  719. var boundingRect = new RectangleD(left, top, right - left, bottom - top);
  720. if (left == Integer.MAX_VALUE) {
  721. this.left = this.parent.getLeft();
  722. this.right = this.parent.getRight();
  723. this.top = this.parent.getTop();
  724. this.bottom = this.parent.getBottom();
  725. }
  726. if (nodes[0].getParent().paddingLeft != void 0) {
  727. margin = nodes[0].getParent().paddingLeft;
  728. } else {
  729. margin = this.margin;
  730. }
  731. this.left = boundingRect.x - margin;
  732. this.right = boundingRect.x + boundingRect.width + margin;
  733. this.top = boundingRect.y - margin;
  734. this.bottom = boundingRect.y + boundingRect.height + margin;
  735. };
  736. LGraph.calculateBounds = function(nodes) {
  737. var left = Integer.MAX_VALUE;
  738. var right = -Integer.MAX_VALUE;
  739. var top = Integer.MAX_VALUE;
  740. var bottom = -Integer.MAX_VALUE;
  741. var nodeLeft;
  742. var nodeRight;
  743. var nodeTop;
  744. var nodeBottom;
  745. var s = nodes.length;
  746. for (var i = 0; i < s; i++) {
  747. var lNode = nodes[i];
  748. nodeLeft = lNode.getLeft();
  749. nodeRight = lNode.getRight();
  750. nodeTop = lNode.getTop();
  751. nodeBottom = lNode.getBottom();
  752. if (left > nodeLeft) {
  753. left = nodeLeft;
  754. }
  755. if (right < nodeRight) {
  756. right = nodeRight;
  757. }
  758. if (top > nodeTop) {
  759. top = nodeTop;
  760. }
  761. if (bottom < nodeBottom) {
  762. bottom = nodeBottom;
  763. }
  764. }
  765. var boundingRect = new RectangleD(left, top, right - left, bottom - top);
  766. return boundingRect;
  767. };
  768. LGraph.prototype.getInclusionTreeDepth = function() {
  769. if (this == this.graphManager.getRoot()) {
  770. return 1;
  771. } else {
  772. return this.parent.getInclusionTreeDepth();
  773. }
  774. };
  775. LGraph.prototype.getEstimatedSize = function() {
  776. if (this.estimatedSize == Integer.MIN_VALUE) {
  777. throw "assert failed";
  778. }
  779. return this.estimatedSize;
  780. };
  781. LGraph.prototype.calcEstimatedSize = function() {
  782. var size = 0;
  783. var nodes = this.nodes;
  784. var s = nodes.length;
  785. for (var i = 0; i < s; i++) {
  786. var lNode = nodes[i];
  787. size += lNode.calcEstimatedSize();
  788. }
  789. if (size == 0) {
  790. this.estimatedSize = LayoutConstants.EMPTY_COMPOUND_NODE_SIZE;
  791. } else {
  792. this.estimatedSize = size / Math.sqrt(this.nodes.length);
  793. }
  794. return this.estimatedSize;
  795. };
  796. LGraph.prototype.updateConnected = function() {
  797. var self = this;
  798. if (this.nodes.length == 0) {
  799. this.isConnected = true;
  800. return;
  801. }
  802. var queue = new LinkedList();
  803. var visited = /* @__PURE__ */ new Set();
  804. var currentNode = this.nodes[0];
  805. var neighborEdges;
  806. var currentNeighbor;
  807. var childrenOfNode = currentNode.withChildren();
  808. childrenOfNode.forEach(function(node) {
  809. queue.push(node);
  810. visited.add(node);
  811. });
  812. while (queue.length !== 0) {
  813. currentNode = queue.shift();
  814. neighborEdges = currentNode.getEdges();
  815. var size = neighborEdges.length;
  816. for (var i = 0; i < size; i++) {
  817. var neighborEdge = neighborEdges[i];
  818. currentNeighbor = neighborEdge.getOtherEndInGraph(currentNode, this);
  819. if (currentNeighbor != null && !visited.has(currentNeighbor)) {
  820. var childrenOfNeighbor = currentNeighbor.withChildren();
  821. childrenOfNeighbor.forEach(function(node) {
  822. queue.push(node);
  823. visited.add(node);
  824. });
  825. }
  826. }
  827. }
  828. this.isConnected = false;
  829. if (visited.size >= this.nodes.length) {
  830. var noOfVisitedInThisGraph = 0;
  831. visited.forEach(function(visitedNode) {
  832. if (visitedNode.owner == self) {
  833. noOfVisitedInThisGraph++;
  834. }
  835. });
  836. if (noOfVisitedInThisGraph == this.nodes.length) {
  837. this.isConnected = true;
  838. }
  839. }
  840. };
  841. module2.exports = LGraph;
  842. }),
  843. /* 6 */
  844. /***/
  845. (function(module2, exports2, __webpack_require__) {
  846. "use strict";
  847. var LGraph;
  848. var LEdge = __webpack_require__(1);
  849. function LGraphManager(layout) {
  850. LGraph = __webpack_require__(5);
  851. this.layout = layout;
  852. this.graphs = [];
  853. this.edges = [];
  854. }
  855. LGraphManager.prototype.addRoot = function() {
  856. var ngraph = this.layout.newGraph();
  857. var nnode = this.layout.newNode(null);
  858. var root = this.add(ngraph, nnode);
  859. this.setRootGraph(root);
  860. return this.rootGraph;
  861. };
  862. LGraphManager.prototype.add = function(newGraph, parentNode, newEdge, sourceNode, targetNode) {
  863. if (newEdge == null && sourceNode == null && targetNode == null) {
  864. if (newGraph == null) {
  865. throw "Graph is null!";
  866. }
  867. if (parentNode == null) {
  868. throw "Parent node is null!";
  869. }
  870. if (this.graphs.indexOf(newGraph) > -1) {
  871. throw "Graph already in this graph mgr!";
  872. }
  873. this.graphs.push(newGraph);
  874. if (newGraph.parent != null) {
  875. throw "Already has a parent!";
  876. }
  877. if (parentNode.child != null) {
  878. throw "Already has a child!";
  879. }
  880. newGraph.parent = parentNode;
  881. parentNode.child = newGraph;
  882. return newGraph;
  883. } else {
  884. targetNode = newEdge;
  885. sourceNode = parentNode;
  886. newEdge = newGraph;
  887. var sourceGraph = sourceNode.getOwner();
  888. var targetGraph = targetNode.getOwner();
  889. if (!(sourceGraph != null && sourceGraph.getGraphManager() == this)) {
  890. throw "Source not in this graph mgr!";
  891. }
  892. if (!(targetGraph != null && targetGraph.getGraphManager() == this)) {
  893. throw "Target not in this graph mgr!";
  894. }
  895. if (sourceGraph == targetGraph) {
  896. newEdge.isInterGraph = false;
  897. return sourceGraph.add(newEdge, sourceNode, targetNode);
  898. } else {
  899. newEdge.isInterGraph = true;
  900. newEdge.source = sourceNode;
  901. newEdge.target = targetNode;
  902. if (this.edges.indexOf(newEdge) > -1) {
  903. throw "Edge already in inter-graph edge list!";
  904. }
  905. this.edges.push(newEdge);
  906. if (!(newEdge.source != null && newEdge.target != null)) {
  907. throw "Edge source and/or target is null!";
  908. }
  909. if (!(newEdge.source.edges.indexOf(newEdge) == -1 && newEdge.target.edges.indexOf(newEdge) == -1)) {
  910. throw "Edge already in source and/or target incidency list!";
  911. }
  912. newEdge.source.edges.push(newEdge);
  913. newEdge.target.edges.push(newEdge);
  914. return newEdge;
  915. }
  916. }
  917. };
  918. LGraphManager.prototype.remove = function(lObj) {
  919. if (lObj instanceof LGraph) {
  920. var graph = lObj;
  921. if (graph.getGraphManager() != this) {
  922. throw "Graph not in this graph mgr";
  923. }
  924. if (!(graph == this.rootGraph || graph.parent != null && graph.parent.graphManager == this)) {
  925. throw "Invalid parent node!";
  926. }
  927. var edgesToBeRemoved = [];
  928. edgesToBeRemoved = edgesToBeRemoved.concat(graph.getEdges());
  929. var edge;
  930. var s = edgesToBeRemoved.length;
  931. for (var i = 0; i < s; i++) {
  932. edge = edgesToBeRemoved[i];
  933. graph.remove(edge);
  934. }
  935. var nodesToBeRemoved = [];
  936. nodesToBeRemoved = nodesToBeRemoved.concat(graph.getNodes());
  937. var node;
  938. s = nodesToBeRemoved.length;
  939. for (var i = 0; i < s; i++) {
  940. node = nodesToBeRemoved[i];
  941. graph.remove(node);
  942. }
  943. if (graph == this.rootGraph) {
  944. this.setRootGraph(null);
  945. }
  946. var index = this.graphs.indexOf(graph);
  947. this.graphs.splice(index, 1);
  948. graph.parent = null;
  949. } else if (lObj instanceof LEdge) {
  950. edge = lObj;
  951. if (edge == null) {
  952. throw "Edge is null!";
  953. }
  954. if (!edge.isInterGraph) {
  955. throw "Not an inter-graph edge!";
  956. }
  957. if (!(edge.source != null && edge.target != null)) {
  958. throw "Source and/or target is null!";
  959. }
  960. if (!(edge.source.edges.indexOf(edge) != -1 && edge.target.edges.indexOf(edge) != -1)) {
  961. throw "Source and/or target doesn't know this edge!";
  962. }
  963. var index = edge.source.edges.indexOf(edge);
  964. edge.source.edges.splice(index, 1);
  965. index = edge.target.edges.indexOf(edge);
  966. edge.target.edges.splice(index, 1);
  967. if (!(edge.source.owner != null && edge.source.owner.getGraphManager() != null)) {
  968. throw "Edge owner graph or owner graph manager is null!";
  969. }
  970. if (edge.source.owner.getGraphManager().edges.indexOf(edge) == -1) {
  971. throw "Not in owner graph manager's edge list!";
  972. }
  973. var index = edge.source.owner.getGraphManager().edges.indexOf(edge);
  974. edge.source.owner.getGraphManager().edges.splice(index, 1);
  975. }
  976. };
  977. LGraphManager.prototype.updateBounds = function() {
  978. this.rootGraph.updateBounds(true);
  979. };
  980. LGraphManager.prototype.getGraphs = function() {
  981. return this.graphs;
  982. };
  983. LGraphManager.prototype.getAllNodes = function() {
  984. if (this.allNodes == null) {
  985. var nodeList = [];
  986. var graphs = this.getGraphs();
  987. var s = graphs.length;
  988. for (var i = 0; i < s; i++) {
  989. nodeList = nodeList.concat(graphs[i].getNodes());
  990. }
  991. this.allNodes = nodeList;
  992. }
  993. return this.allNodes;
  994. };
  995. LGraphManager.prototype.resetAllNodes = function() {
  996. this.allNodes = null;
  997. };
  998. LGraphManager.prototype.resetAllEdges = function() {
  999. this.allEdges = null;
  1000. };
  1001. LGraphManager.prototype.resetAllNodesToApplyGravitation = function() {
  1002. this.allNodesToApplyGravitation = null;
  1003. };
  1004. LGraphManager.prototype.getAllEdges = function() {
  1005. if (this.allEdges == null) {
  1006. var edgeList = [];
  1007. var graphs = this.getGraphs();
  1008. var s = graphs.length;
  1009. for (var i = 0; i < graphs.length; i++) {
  1010. edgeList = edgeList.concat(graphs[i].getEdges());
  1011. }
  1012. edgeList = edgeList.concat(this.edges);
  1013. this.allEdges = edgeList;
  1014. }
  1015. return this.allEdges;
  1016. };
  1017. LGraphManager.prototype.getAllNodesToApplyGravitation = function() {
  1018. return this.allNodesToApplyGravitation;
  1019. };
  1020. LGraphManager.prototype.setAllNodesToApplyGravitation = function(nodeList) {
  1021. if (this.allNodesToApplyGravitation != null) {
  1022. throw "assert failed";
  1023. }
  1024. this.allNodesToApplyGravitation = nodeList;
  1025. };
  1026. LGraphManager.prototype.getRoot = function() {
  1027. return this.rootGraph;
  1028. };
  1029. LGraphManager.prototype.setRootGraph = function(graph) {
  1030. if (graph.getGraphManager() != this) {
  1031. throw "Root not in this graph mgr!";
  1032. }
  1033. this.rootGraph = graph;
  1034. if (graph.parent == null) {
  1035. graph.parent = this.layout.newNode("Root node");
  1036. }
  1037. };
  1038. LGraphManager.prototype.getLayout = function() {
  1039. return this.layout;
  1040. };
  1041. LGraphManager.prototype.isOneAncestorOfOther = function(firstNode, secondNode) {
  1042. if (!(firstNode != null && secondNode != null)) {
  1043. throw "assert failed";
  1044. }
  1045. if (firstNode == secondNode) {
  1046. return true;
  1047. }
  1048. var ownerGraph = firstNode.getOwner();
  1049. var parentNode;
  1050. do {
  1051. parentNode = ownerGraph.getParent();
  1052. if (parentNode == null) {
  1053. break;
  1054. }
  1055. if (parentNode == secondNode) {
  1056. return true;
  1057. }
  1058. ownerGraph = parentNode.getOwner();
  1059. if (ownerGraph == null) {
  1060. break;
  1061. }
  1062. } while (true);
  1063. ownerGraph = secondNode.getOwner();
  1064. do {
  1065. parentNode = ownerGraph.getParent();
  1066. if (parentNode == null) {
  1067. break;
  1068. }
  1069. if (parentNode == firstNode) {
  1070. return true;
  1071. }
  1072. ownerGraph = parentNode.getOwner();
  1073. if (ownerGraph == null) {
  1074. break;
  1075. }
  1076. } while (true);
  1077. return false;
  1078. };
  1079. LGraphManager.prototype.calcLowestCommonAncestors = function() {
  1080. var edge;
  1081. var sourceNode;
  1082. var targetNode;
  1083. var sourceAncestorGraph;
  1084. var targetAncestorGraph;
  1085. var edges = this.getAllEdges();
  1086. var s = edges.length;
  1087. for (var i = 0; i < s; i++) {
  1088. edge = edges[i];
  1089. sourceNode = edge.source;
  1090. targetNode = edge.target;
  1091. edge.lca = null;
  1092. edge.sourceInLca = sourceNode;
  1093. edge.targetInLca = targetNode;
  1094. if (sourceNode == targetNode) {
  1095. edge.lca = sourceNode.getOwner();
  1096. continue;
  1097. }
  1098. sourceAncestorGraph = sourceNode.getOwner();
  1099. while (edge.lca == null) {
  1100. edge.targetInLca = targetNode;
  1101. targetAncestorGraph = targetNode.getOwner();
  1102. while (edge.lca == null) {
  1103. if (targetAncestorGraph == sourceAncestorGraph) {
  1104. edge.lca = targetAncestorGraph;
  1105. break;
  1106. }
  1107. if (targetAncestorGraph == this.rootGraph) {
  1108. break;
  1109. }
  1110. if (edge.lca != null) {
  1111. throw "assert failed";
  1112. }
  1113. edge.targetInLca = targetAncestorGraph.getParent();
  1114. targetAncestorGraph = edge.targetInLca.getOwner();
  1115. }
  1116. if (sourceAncestorGraph == this.rootGraph) {
  1117. break;
  1118. }
  1119. if (edge.lca == null) {
  1120. edge.sourceInLca = sourceAncestorGraph.getParent();
  1121. sourceAncestorGraph = edge.sourceInLca.getOwner();
  1122. }
  1123. }
  1124. if (edge.lca == null) {
  1125. throw "assert failed";
  1126. }
  1127. }
  1128. };
  1129. LGraphManager.prototype.calcLowestCommonAncestor = function(firstNode, secondNode) {
  1130. if (firstNode == secondNode) {
  1131. return firstNode.getOwner();
  1132. }
  1133. var firstOwnerGraph = firstNode.getOwner();
  1134. do {
  1135. if (firstOwnerGraph == null) {
  1136. break;
  1137. }
  1138. var secondOwnerGraph = secondNode.getOwner();
  1139. do {
  1140. if (secondOwnerGraph == null) {
  1141. break;
  1142. }
  1143. if (secondOwnerGraph == firstOwnerGraph) {
  1144. return secondOwnerGraph;
  1145. }
  1146. secondOwnerGraph = secondOwnerGraph.getParent().getOwner();
  1147. } while (true);
  1148. firstOwnerGraph = firstOwnerGraph.getParent().getOwner();
  1149. } while (true);
  1150. return firstOwnerGraph;
  1151. };
  1152. LGraphManager.prototype.calcInclusionTreeDepths = function(graph, depth) {
  1153. if (graph == null && depth == null) {
  1154. graph = this.rootGraph;
  1155. depth = 1;
  1156. }
  1157. var node;
  1158. var nodes = graph.getNodes();
  1159. var s = nodes.length;
  1160. for (var i = 0; i < s; i++) {
  1161. node = nodes[i];
  1162. node.inclusionTreeDepth = depth;
  1163. if (node.child != null) {
  1164. this.calcInclusionTreeDepths(node.child, depth + 1);
  1165. }
  1166. }
  1167. };
  1168. LGraphManager.prototype.includesInvalidEdge = function() {
  1169. var edge;
  1170. var s = this.edges.length;
  1171. for (var i = 0; i < s; i++) {
  1172. edge = this.edges[i];
  1173. if (this.isOneAncestorOfOther(edge.source, edge.target)) {
  1174. return true;
  1175. }
  1176. }
  1177. return false;
  1178. };
  1179. module2.exports = LGraphManager;
  1180. }),
  1181. /* 7 */
  1182. /***/
  1183. (function(module2, exports2, __webpack_require__) {
  1184. "use strict";
  1185. var LayoutConstants = __webpack_require__(0);
  1186. function FDLayoutConstants() {
  1187. }
  1188. for (var prop in LayoutConstants) {
  1189. FDLayoutConstants[prop] = LayoutConstants[prop];
  1190. }
  1191. FDLayoutConstants.MAX_ITERATIONS = 2500;
  1192. FDLayoutConstants.DEFAULT_EDGE_LENGTH = 50;
  1193. FDLayoutConstants.DEFAULT_SPRING_STRENGTH = 0.45;
  1194. FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = 4500;
  1195. FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = 0.4;
  1196. FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = 1;
  1197. FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = 3.8;
  1198. FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = 1.5;
  1199. FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION = true;
  1200. FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION = true;
  1201. FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = 0.3;
  1202. FDLayoutConstants.COOLING_ADAPTATION_FACTOR = 0.33;
  1203. FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT = 1e3;
  1204. FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT = 5e3;
  1205. FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL = 100;
  1206. FDLayoutConstants.MAX_NODE_DISPLACEMENT = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL * 3;
  1207. FDLayoutConstants.MIN_REPULSION_DIST = FDLayoutConstants.DEFAULT_EDGE_LENGTH / 10;
  1208. FDLayoutConstants.CONVERGENCE_CHECK_PERIOD = 100;
  1209. FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = 0.1;
  1210. FDLayoutConstants.MIN_EDGE_LENGTH = 1;
  1211. FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD = 10;
  1212. module2.exports = FDLayoutConstants;
  1213. }),
  1214. /* 8 */
  1215. /***/
  1216. (function(module2, exports2, __webpack_require__) {
  1217. "use strict";
  1218. var Point2 = __webpack_require__(12);
  1219. function IGeometry() {
  1220. }
  1221. IGeometry.calcSeparationAmount = function(rectA, rectB, overlapAmount, separationBuffer) {
  1222. if (!rectA.intersects(rectB)) {
  1223. throw "assert failed";
  1224. }
  1225. var directions = new Array(2);
  1226. this.decideDirectionsForOverlappingNodes(rectA, rectB, directions);
  1227. overlapAmount[0] = Math.min(rectA.getRight(), rectB.getRight()) - Math.max(rectA.x, rectB.x);
  1228. overlapAmount[1] = Math.min(rectA.getBottom(), rectB.getBottom()) - Math.max(rectA.y, rectB.y);
  1229. if (rectA.getX() <= rectB.getX() && rectA.getRight() >= rectB.getRight()) {
  1230. overlapAmount[0] += Math.min(rectB.getX() - rectA.getX(), rectA.getRight() - rectB.getRight());
  1231. } else if (rectB.getX() <= rectA.getX() && rectB.getRight() >= rectA.getRight()) {
  1232. overlapAmount[0] += Math.min(rectA.getX() - rectB.getX(), rectB.getRight() - rectA.getRight());
  1233. }
  1234. if (rectA.getY() <= rectB.getY() && rectA.getBottom() >= rectB.getBottom()) {
  1235. overlapAmount[1] += Math.min(rectB.getY() - rectA.getY(), rectA.getBottom() - rectB.getBottom());
  1236. } else if (rectB.getY() <= rectA.getY() && rectB.getBottom() >= rectA.getBottom()) {
  1237. overlapAmount[1] += Math.min(rectA.getY() - rectB.getY(), rectB.getBottom() - rectA.getBottom());
  1238. }
  1239. var slope = Math.abs((rectB.getCenterY() - rectA.getCenterY()) / (rectB.getCenterX() - rectA.getCenterX()));
  1240. if (rectB.getCenterY() === rectA.getCenterY() && rectB.getCenterX() === rectA.getCenterX()) {
  1241. slope = 1;
  1242. }
  1243. var moveByY = slope * overlapAmount[0];
  1244. var moveByX = overlapAmount[1] / slope;
  1245. if (overlapAmount[0] < moveByX) {
  1246. moveByX = overlapAmount[0];
  1247. } else {
  1248. moveByY = overlapAmount[1];
  1249. }
  1250. overlapAmount[0] = -1 * directions[0] * (moveByX / 2 + separationBuffer);
  1251. overlapAmount[1] = -1 * directions[1] * (moveByY / 2 + separationBuffer);
  1252. };
  1253. IGeometry.decideDirectionsForOverlappingNodes = function(rectA, rectB, directions) {
  1254. if (rectA.getCenterX() < rectB.getCenterX()) {
  1255. directions[0] = -1;
  1256. } else {
  1257. directions[0] = 1;
  1258. }
  1259. if (rectA.getCenterY() < rectB.getCenterY()) {
  1260. directions[1] = -1;
  1261. } else {
  1262. directions[1] = 1;
  1263. }
  1264. };
  1265. IGeometry.getIntersection2 = function(rectA, rectB, result) {
  1266. var p1x = rectA.getCenterX();
  1267. var p1y = rectA.getCenterY();
  1268. var p2x = rectB.getCenterX();
  1269. var p2y = rectB.getCenterY();
  1270. if (rectA.intersects(rectB)) {
  1271. result[0] = p1x;
  1272. result[1] = p1y;
  1273. result[2] = p2x;
  1274. result[3] = p2y;
  1275. return true;
  1276. }
  1277. var topLeftAx = rectA.getX();
  1278. var topLeftAy = rectA.getY();
  1279. var topRightAx = rectA.getRight();
  1280. var bottomLeftAx = rectA.getX();
  1281. var bottomLeftAy = rectA.getBottom();
  1282. var bottomRightAx = rectA.getRight();
  1283. var halfWidthA = rectA.getWidthHalf();
  1284. var halfHeightA = rectA.getHeightHalf();
  1285. var topLeftBx = rectB.getX();
  1286. var topLeftBy = rectB.getY();
  1287. var topRightBx = rectB.getRight();
  1288. var bottomLeftBx = rectB.getX();
  1289. var bottomLeftBy = rectB.getBottom();
  1290. var bottomRightBx = rectB.getRight();
  1291. var halfWidthB = rectB.getWidthHalf();
  1292. var halfHeightB = rectB.getHeightHalf();
  1293. var clipPointAFound = false;
  1294. var clipPointBFound = false;
  1295. if (p1x === p2x) {
  1296. if (p1y > p2y) {
  1297. result[0] = p1x;
  1298. result[1] = topLeftAy;
  1299. result[2] = p2x;
  1300. result[3] = bottomLeftBy;
  1301. return false;
  1302. } else if (p1y < p2y) {
  1303. result[0] = p1x;
  1304. result[1] = bottomLeftAy;
  1305. result[2] = p2x;
  1306. result[3] = topLeftBy;
  1307. return false;
  1308. } else {
  1309. }
  1310. } else if (p1y === p2y) {
  1311. if (p1x > p2x) {
  1312. result[0] = topLeftAx;
  1313. result[1] = p1y;
  1314. result[2] = topRightBx;
  1315. result[3] = p2y;
  1316. return false;
  1317. } else if (p1x < p2x) {
  1318. result[0] = topRightAx;
  1319. result[1] = p1y;
  1320. result[2] = topLeftBx;
  1321. result[3] = p2y;
  1322. return false;
  1323. } else {
  1324. }
  1325. } else {
  1326. var slopeA = rectA.height / rectA.width;
  1327. var slopeB = rectB.height / rectB.width;
  1328. var slopePrime = (p2y - p1y) / (p2x - p1x);
  1329. var cardinalDirectionA = void 0;
  1330. var cardinalDirectionB = void 0;
  1331. var tempPointAx = void 0;
  1332. var tempPointAy = void 0;
  1333. var tempPointBx = void 0;
  1334. var tempPointBy = void 0;
  1335. if (-slopeA === slopePrime) {
  1336. if (p1x > p2x) {
  1337. result[0] = bottomLeftAx;
  1338. result[1] = bottomLeftAy;
  1339. clipPointAFound = true;
  1340. } else {
  1341. result[0] = topRightAx;
  1342. result[1] = topLeftAy;
  1343. clipPointAFound = true;
  1344. }
  1345. } else if (slopeA === slopePrime) {
  1346. if (p1x > p2x) {
  1347. result[0] = topLeftAx;
  1348. result[1] = topLeftAy;
  1349. clipPointAFound = true;
  1350. } else {
  1351. result[0] = bottomRightAx;
  1352. result[1] = bottomLeftAy;
  1353. clipPointAFound = true;
  1354. }
  1355. }
  1356. if (-slopeB === slopePrime) {
  1357. if (p2x > p1x) {
  1358. result[2] = bottomLeftBx;
  1359. result[3] = bottomLeftBy;
  1360. clipPointBFound = true;
  1361. } else {
  1362. result[2] = topRightBx;
  1363. result[3] = topLeftBy;
  1364. clipPointBFound = true;
  1365. }
  1366. } else if (slopeB === slopePrime) {
  1367. if (p2x > p1x) {
  1368. result[2] = topLeftBx;
  1369. result[3] = topLeftBy;
  1370. clipPointBFound = true;
  1371. } else {
  1372. result[2] = bottomRightBx;
  1373. result[3] = bottomLeftBy;
  1374. clipPointBFound = true;
  1375. }
  1376. }
  1377. if (clipPointAFound && clipPointBFound) {
  1378. return false;
  1379. }
  1380. if (p1x > p2x) {
  1381. if (p1y > p2y) {
  1382. cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 4);
  1383. cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 2);
  1384. } else {
  1385. cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 3);
  1386. cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 1);
  1387. }
  1388. } else {
  1389. if (p1y > p2y) {
  1390. cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 1);
  1391. cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 3);
  1392. } else {
  1393. cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 2);
  1394. cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 4);
  1395. }
  1396. }
  1397. if (!clipPointAFound) {
  1398. switch (cardinalDirectionA) {
  1399. case 1:
  1400. tempPointAy = topLeftAy;
  1401. tempPointAx = p1x + -halfHeightA / slopePrime;
  1402. result[0] = tempPointAx;
  1403. result[1] = tempPointAy;
  1404. break;
  1405. case 2:
  1406. tempPointAx = bottomRightAx;
  1407. tempPointAy = p1y + halfWidthA * slopePrime;
  1408. result[0] = tempPointAx;
  1409. result[1] = tempPointAy;
  1410. break;
  1411. case 3:
  1412. tempPointAy = bottomLeftAy;
  1413. tempPointAx = p1x + halfHeightA / slopePrime;
  1414. result[0] = tempPointAx;
  1415. result[1] = tempPointAy;
  1416. break;
  1417. case 4:
  1418. tempPointAx = bottomLeftAx;
  1419. tempPointAy = p1y + -halfWidthA * slopePrime;
  1420. result[0] = tempPointAx;
  1421. result[1] = tempPointAy;
  1422. break;
  1423. }
  1424. }
  1425. if (!clipPointBFound) {
  1426. switch (cardinalDirectionB) {
  1427. case 1:
  1428. tempPointBy = topLeftBy;
  1429. tempPointBx = p2x + -halfHeightB / slopePrime;
  1430. result[2] = tempPointBx;
  1431. result[3] = tempPointBy;
  1432. break;
  1433. case 2:
  1434. tempPointBx = bottomRightBx;
  1435. tempPointBy = p2y + halfWidthB * slopePrime;
  1436. result[2] = tempPointBx;
  1437. result[3] = tempPointBy;
  1438. break;
  1439. case 3:
  1440. tempPointBy = bottomLeftBy;
  1441. tempPointBx = p2x + halfHeightB / slopePrime;
  1442. result[2] = tempPointBx;
  1443. result[3] = tempPointBy;
  1444. break;
  1445. case 4:
  1446. tempPointBx = bottomLeftBx;
  1447. tempPointBy = p2y + -halfWidthB * slopePrime;
  1448. result[2] = tempPointBx;
  1449. result[3] = tempPointBy;
  1450. break;
  1451. }
  1452. }
  1453. }
  1454. return false;
  1455. };
  1456. IGeometry.getCardinalDirection = function(slope, slopePrime, line) {
  1457. if (slope > slopePrime) {
  1458. return line;
  1459. } else {
  1460. return 1 + line % 4;
  1461. }
  1462. };
  1463. IGeometry.getIntersection = function(s1, s2, f1, f2) {
  1464. if (f2 == null) {
  1465. return this.getIntersection2(s1, s2, f1);
  1466. }
  1467. var x1 = s1.x;
  1468. var y1 = s1.y;
  1469. var x2 = s2.x;
  1470. var y2 = s2.y;
  1471. var x3 = f1.x;
  1472. var y3 = f1.y;
  1473. var x4 = f2.x;
  1474. var y4 = f2.y;
  1475. var x = void 0, y = void 0;
  1476. var a1 = void 0, a2 = void 0, b1 = void 0, b2 = void 0, c1 = void 0, c2 = void 0;
  1477. var denom = void 0;
  1478. a1 = y2 - y1;
  1479. b1 = x1 - x2;
  1480. c1 = x2 * y1 - x1 * y2;
  1481. a2 = y4 - y3;
  1482. b2 = x3 - x4;
  1483. c2 = x4 * y3 - x3 * y4;
  1484. denom = a1 * b2 - a2 * b1;
  1485. if (denom === 0) {
  1486. return null;
  1487. }
  1488. x = (b1 * c2 - b2 * c1) / denom;
  1489. y = (a2 * c1 - a1 * c2) / denom;
  1490. return new Point2(x, y);
  1491. };
  1492. IGeometry.angleOfVector = function(Cx, Cy, Nx, Ny) {
  1493. var C_angle = void 0;
  1494. if (Cx !== Nx) {
  1495. C_angle = Math.atan((Ny - Cy) / (Nx - Cx));
  1496. if (Nx < Cx) {
  1497. C_angle += Math.PI;
  1498. } else if (Ny < Cy) {
  1499. C_angle += this.TWO_PI;
  1500. }
  1501. } else if (Ny < Cy) {
  1502. C_angle = this.ONE_AND_HALF_PI;
  1503. } else {
  1504. C_angle = this.HALF_PI;
  1505. }
  1506. return C_angle;
  1507. };
  1508. IGeometry.doIntersect = function(p1, p2, p3, p4) {
  1509. var a = p1.x;
  1510. var b = p1.y;
  1511. var c = p2.x;
  1512. var d = p2.y;
  1513. var p = p3.x;
  1514. var q = p3.y;
  1515. var r = p4.x;
  1516. var s = p4.y;
  1517. var det = (c - a) * (s - q) - (r - p) * (d - b);
  1518. if (det === 0) {
  1519. return false;
  1520. } else {
  1521. var lambda = ((s - q) * (r - a) + (p - r) * (s - b)) / det;
  1522. var gamma = ((b - d) * (r - a) + (c - a) * (s - b)) / det;
  1523. return 0 < lambda && lambda < 1 && 0 < gamma && gamma < 1;
  1524. }
  1525. };
  1526. IGeometry.HALF_PI = 0.5 * Math.PI;
  1527. IGeometry.ONE_AND_HALF_PI = 1.5 * Math.PI;
  1528. IGeometry.TWO_PI = 2 * Math.PI;
  1529. IGeometry.THREE_PI = 3 * Math.PI;
  1530. module2.exports = IGeometry;
  1531. }),
  1532. /* 9 */
  1533. /***/
  1534. (function(module2, exports2, __webpack_require__) {
  1535. "use strict";
  1536. function IMath() {
  1537. }
  1538. IMath.sign = function(value) {
  1539. if (value > 0) {
  1540. return 1;
  1541. } else if (value < 0) {
  1542. return -1;
  1543. } else {
  1544. return 0;
  1545. }
  1546. };
  1547. IMath.floor = function(value) {
  1548. return value < 0 ? Math.ceil(value) : Math.floor(value);
  1549. };
  1550. IMath.ceil = function(value) {
  1551. return value < 0 ? Math.floor(value) : Math.ceil(value);
  1552. };
  1553. module2.exports = IMath;
  1554. }),
  1555. /* 10 */
  1556. /***/
  1557. (function(module2, exports2, __webpack_require__) {
  1558. "use strict";
  1559. function Integer() {
  1560. }
  1561. Integer.MAX_VALUE = 2147483647;
  1562. Integer.MIN_VALUE = -2147483648;
  1563. module2.exports = Integer;
  1564. }),
  1565. /* 11 */
  1566. /***/
  1567. (function(module2, exports2, __webpack_require__) {
  1568. "use strict";
  1569. var _createClass = /* @__PURE__ */ (function() {
  1570. function defineProperties(target, props) {
  1571. for (var i = 0; i < props.length; i++) {
  1572. var descriptor = props[i];
  1573. descriptor.enumerable = descriptor.enumerable || false;
  1574. descriptor.configurable = true;
  1575. if ("value" in descriptor) descriptor.writable = true;
  1576. Object.defineProperty(target, descriptor.key, descriptor);
  1577. }
  1578. }
  1579. return function(Constructor, protoProps, staticProps) {
  1580. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  1581. if (staticProps) defineProperties(Constructor, staticProps);
  1582. return Constructor;
  1583. };
  1584. })();
  1585. function _classCallCheck(instance2, Constructor) {
  1586. if (!(instance2 instanceof Constructor)) {
  1587. throw new TypeError("Cannot call a class as a function");
  1588. }
  1589. }
  1590. var nodeFrom = function nodeFrom2(value) {
  1591. return { value, next: null, prev: null };
  1592. };
  1593. var add = function add2(prev, node, next2, list) {
  1594. if (prev !== null) {
  1595. prev.next = node;
  1596. } else {
  1597. list.head = node;
  1598. }
  1599. if (next2 !== null) {
  1600. next2.prev = node;
  1601. } else {
  1602. list.tail = node;
  1603. }
  1604. node.prev = prev;
  1605. node.next = next2;
  1606. list.length++;
  1607. return node;
  1608. };
  1609. var _remove = function _remove2(node, list) {
  1610. var prev = node.prev, next2 = node.next;
  1611. if (prev !== null) {
  1612. prev.next = next2;
  1613. } else {
  1614. list.head = next2;
  1615. }
  1616. if (next2 !== null) {
  1617. next2.prev = prev;
  1618. } else {
  1619. list.tail = prev;
  1620. }
  1621. node.prev = node.next = null;
  1622. list.length--;
  1623. return node;
  1624. };
  1625. var LinkedList = (function() {
  1626. function LinkedList2(vals) {
  1627. var _this = this;
  1628. _classCallCheck(this, LinkedList2);
  1629. this.length = 0;
  1630. this.head = null;
  1631. this.tail = null;
  1632. if (vals != null) {
  1633. vals.forEach(function(v) {
  1634. return _this.push(v);
  1635. });
  1636. }
  1637. }
  1638. _createClass(LinkedList2, [{
  1639. key: "size",
  1640. value: function size() {
  1641. return this.length;
  1642. }
  1643. }, {
  1644. key: "insertBefore",
  1645. value: function insertBefore(val, otherNode) {
  1646. return add(otherNode.prev, nodeFrom(val), otherNode, this);
  1647. }
  1648. }, {
  1649. key: "insertAfter",
  1650. value: function insertAfter(val, otherNode) {
  1651. return add(otherNode, nodeFrom(val), otherNode.next, this);
  1652. }
  1653. }, {
  1654. key: "insertNodeBefore",
  1655. value: function insertNodeBefore(newNode, otherNode) {
  1656. return add(otherNode.prev, newNode, otherNode, this);
  1657. }
  1658. }, {
  1659. key: "insertNodeAfter",
  1660. value: function insertNodeAfter(newNode, otherNode) {
  1661. return add(otherNode, newNode, otherNode.next, this);
  1662. }
  1663. }, {
  1664. key: "push",
  1665. value: function push(val) {
  1666. return add(this.tail, nodeFrom(val), null, this);
  1667. }
  1668. }, {
  1669. key: "unshift",
  1670. value: function unshift(val) {
  1671. return add(null, nodeFrom(val), this.head, this);
  1672. }
  1673. }, {
  1674. key: "remove",
  1675. value: function remove(node) {
  1676. return _remove(node, this);
  1677. }
  1678. }, {
  1679. key: "pop",
  1680. value: function pop() {
  1681. return _remove(this.tail, this).value;
  1682. }
  1683. }, {
  1684. key: "popNode",
  1685. value: function popNode() {
  1686. return _remove(this.tail, this);
  1687. }
  1688. }, {
  1689. key: "shift",
  1690. value: function shift() {
  1691. return _remove(this.head, this).value;
  1692. }
  1693. }, {
  1694. key: "shiftNode",
  1695. value: function shiftNode() {
  1696. return _remove(this.head, this);
  1697. }
  1698. }, {
  1699. key: "get_object_at",
  1700. value: function get_object_at(index) {
  1701. if (index <= this.length()) {
  1702. var i = 1;
  1703. var current = this.head;
  1704. while (i < index) {
  1705. current = current.next;
  1706. i++;
  1707. }
  1708. return current.value;
  1709. }
  1710. }
  1711. }, {
  1712. key: "set_object_at",
  1713. value: function set_object_at(index, value) {
  1714. if (index <= this.length()) {
  1715. var i = 1;
  1716. var current = this.head;
  1717. while (i < index) {
  1718. current = current.next;
  1719. i++;
  1720. }
  1721. current.value = value;
  1722. }
  1723. }
  1724. }]);
  1725. return LinkedList2;
  1726. })();
  1727. module2.exports = LinkedList;
  1728. }),
  1729. /* 12 */
  1730. /***/
  1731. (function(module2, exports2, __webpack_require__) {
  1732. "use strict";
  1733. function Point2(x, y, p) {
  1734. this.x = null;
  1735. this.y = null;
  1736. if (x == null && y == null && p == null) {
  1737. this.x = 0;
  1738. this.y = 0;
  1739. } else if (typeof x == "number" && typeof y == "number" && p == null) {
  1740. this.x = x;
  1741. this.y = y;
  1742. } else if (x.constructor.name == "Point" && y == null && p == null) {
  1743. p = x;
  1744. this.x = p.x;
  1745. this.y = p.y;
  1746. }
  1747. }
  1748. Point2.prototype.getX = function() {
  1749. return this.x;
  1750. };
  1751. Point2.prototype.getY = function() {
  1752. return this.y;
  1753. };
  1754. Point2.prototype.getLocation = function() {
  1755. return new Point2(this.x, this.y);
  1756. };
  1757. Point2.prototype.setLocation = function(x, y, p) {
  1758. if (x.constructor.name == "Point" && y == null && p == null) {
  1759. p = x;
  1760. this.setLocation(p.x, p.y);
  1761. } else if (typeof x == "number" && typeof y == "number" && p == null) {
  1762. if (parseInt(x) == x && parseInt(y) == y) {
  1763. this.move(x, y);
  1764. } else {
  1765. this.x = Math.floor(x + 0.5);
  1766. this.y = Math.floor(y + 0.5);
  1767. }
  1768. }
  1769. };
  1770. Point2.prototype.move = function(x, y) {
  1771. this.x = x;
  1772. this.y = y;
  1773. };
  1774. Point2.prototype.translate = function(dx, dy) {
  1775. this.x += dx;
  1776. this.y += dy;
  1777. };
  1778. Point2.prototype.equals = function(obj) {
  1779. if (obj.constructor.name == "Point") {
  1780. var pt = obj;
  1781. return this.x == pt.x && this.y == pt.y;
  1782. }
  1783. return this == obj;
  1784. };
  1785. Point2.prototype.toString = function() {
  1786. return new Point2().constructor.name + "[x=" + this.x + ",y=" + this.y + "]";
  1787. };
  1788. module2.exports = Point2;
  1789. }),
  1790. /* 13 */
  1791. /***/
  1792. (function(module2, exports2, __webpack_require__) {
  1793. "use strict";
  1794. function RectangleD(x, y, width, height) {
  1795. this.x = 0;
  1796. this.y = 0;
  1797. this.width = 0;
  1798. this.height = 0;
  1799. if (x != null && y != null && width != null && height != null) {
  1800. this.x = x;
  1801. this.y = y;
  1802. this.width = width;
  1803. this.height = height;
  1804. }
  1805. }
  1806. RectangleD.prototype.getX = function() {
  1807. return this.x;
  1808. };
  1809. RectangleD.prototype.setX = function(x) {
  1810. this.x = x;
  1811. };
  1812. RectangleD.prototype.getY = function() {
  1813. return this.y;
  1814. };
  1815. RectangleD.prototype.setY = function(y) {
  1816. this.y = y;
  1817. };
  1818. RectangleD.prototype.getWidth = function() {
  1819. return this.width;
  1820. };
  1821. RectangleD.prototype.setWidth = function(width) {
  1822. this.width = width;
  1823. };
  1824. RectangleD.prototype.getHeight = function() {
  1825. return this.height;
  1826. };
  1827. RectangleD.prototype.setHeight = function(height) {
  1828. this.height = height;
  1829. };
  1830. RectangleD.prototype.getRight = function() {
  1831. return this.x + this.width;
  1832. };
  1833. RectangleD.prototype.getBottom = function() {
  1834. return this.y + this.height;
  1835. };
  1836. RectangleD.prototype.intersects = function(a) {
  1837. if (this.getRight() < a.x) {
  1838. return false;
  1839. }
  1840. if (this.getBottom() < a.y) {
  1841. return false;
  1842. }
  1843. if (a.getRight() < this.x) {
  1844. return false;
  1845. }
  1846. if (a.getBottom() < this.y) {
  1847. return false;
  1848. }
  1849. return true;
  1850. };
  1851. RectangleD.prototype.getCenterX = function() {
  1852. return this.x + this.width / 2;
  1853. };
  1854. RectangleD.prototype.getMinX = function() {
  1855. return this.getX();
  1856. };
  1857. RectangleD.prototype.getMaxX = function() {
  1858. return this.getX() + this.width;
  1859. };
  1860. RectangleD.prototype.getCenterY = function() {
  1861. return this.y + this.height / 2;
  1862. };
  1863. RectangleD.prototype.getMinY = function() {
  1864. return this.getY();
  1865. };
  1866. RectangleD.prototype.getMaxY = function() {
  1867. return this.getY() + this.height;
  1868. };
  1869. RectangleD.prototype.getWidthHalf = function() {
  1870. return this.width / 2;
  1871. };
  1872. RectangleD.prototype.getHeightHalf = function() {
  1873. return this.height / 2;
  1874. };
  1875. module2.exports = RectangleD;
  1876. }),
  1877. /* 14 */
  1878. /***/
  1879. (function(module2, exports2, __webpack_require__) {
  1880. "use strict";
  1881. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
  1882. return typeof obj;
  1883. } : function(obj) {
  1884. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  1885. };
  1886. function UniqueIDGeneretor() {
  1887. }
  1888. UniqueIDGeneretor.lastID = 0;
  1889. UniqueIDGeneretor.createID = function(obj) {
  1890. if (UniqueIDGeneretor.isPrimitive(obj)) {
  1891. return obj;
  1892. }
  1893. if (obj.uniqueID != null) {
  1894. return obj.uniqueID;
  1895. }
  1896. obj.uniqueID = UniqueIDGeneretor.getString();
  1897. UniqueIDGeneretor.lastID++;
  1898. return obj.uniqueID;
  1899. };
  1900. UniqueIDGeneretor.getString = function(id) {
  1901. if (id == null) id = UniqueIDGeneretor.lastID;
  1902. return "Object#" + id;
  1903. };
  1904. UniqueIDGeneretor.isPrimitive = function(arg) {
  1905. var type = typeof arg === "undefined" ? "undefined" : _typeof(arg);
  1906. return arg == null || type != "object" && type != "function";
  1907. };
  1908. module2.exports = UniqueIDGeneretor;
  1909. }),
  1910. /* 15 */
  1911. /***/
  1912. (function(module2, exports2, __webpack_require__) {
  1913. "use strict";
  1914. function _toConsumableArray(arr) {
  1915. if (Array.isArray(arr)) {
  1916. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
  1917. arr2[i] = arr[i];
  1918. }
  1919. return arr2;
  1920. } else {
  1921. return Array.from(arr);
  1922. }
  1923. }
  1924. var LayoutConstants = __webpack_require__(0);
  1925. var LGraphManager = __webpack_require__(6);
  1926. var LNode = __webpack_require__(3);
  1927. var LEdge = __webpack_require__(1);
  1928. var LGraph = __webpack_require__(5);
  1929. var PointD = __webpack_require__(4);
  1930. var Transform = __webpack_require__(17);
  1931. var Emitter = __webpack_require__(27);
  1932. function Layout2(isRemoteUse) {
  1933. Emitter.call(this);
  1934. this.layoutQuality = LayoutConstants.QUALITY;
  1935. this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED;
  1936. this.incremental = LayoutConstants.DEFAULT_INCREMENTAL;
  1937. this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT;
  1938. this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT;
  1939. this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD;
  1940. this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES;
  1941. this.edgeToDummyNodes = /* @__PURE__ */ new Map();
  1942. this.graphManager = new LGraphManager(this);
  1943. this.isLayoutFinished = false;
  1944. this.isSubLayout = false;
  1945. this.isRemoteUse = false;
  1946. if (isRemoteUse != null) {
  1947. this.isRemoteUse = isRemoteUse;
  1948. }
  1949. }
  1950. Layout2.RANDOM_SEED = 1;
  1951. Layout2.prototype = Object.create(Emitter.prototype);
  1952. Layout2.prototype.getGraphManager = function() {
  1953. return this.graphManager;
  1954. };
  1955. Layout2.prototype.getAllNodes = function() {
  1956. return this.graphManager.getAllNodes();
  1957. };
  1958. Layout2.prototype.getAllEdges = function() {
  1959. return this.graphManager.getAllEdges();
  1960. };
  1961. Layout2.prototype.getAllNodesToApplyGravitation = function() {
  1962. return this.graphManager.getAllNodesToApplyGravitation();
  1963. };
  1964. Layout2.prototype.newGraphManager = function() {
  1965. var gm = new LGraphManager(this);
  1966. this.graphManager = gm;
  1967. return gm;
  1968. };
  1969. Layout2.prototype.newGraph = function(vGraph) {
  1970. return new LGraph(null, this.graphManager, vGraph);
  1971. };
  1972. Layout2.prototype.newNode = function(vNode) {
  1973. return new LNode(this.graphManager, vNode);
  1974. };
  1975. Layout2.prototype.newEdge = function(vEdge) {
  1976. return new LEdge(null, null, vEdge);
  1977. };
  1978. Layout2.prototype.checkLayoutSuccess = function() {
  1979. return this.graphManager.getRoot() == null || this.graphManager.getRoot().getNodes().length == 0 || this.graphManager.includesInvalidEdge();
  1980. };
  1981. Layout2.prototype.runLayout = function() {
  1982. this.isLayoutFinished = false;
  1983. if (this.tilingPreLayout) {
  1984. this.tilingPreLayout();
  1985. }
  1986. this.initParameters();
  1987. var isLayoutSuccessfull;
  1988. if (this.checkLayoutSuccess()) {
  1989. isLayoutSuccessfull = false;
  1990. } else {
  1991. isLayoutSuccessfull = this.layout();
  1992. }
  1993. if (LayoutConstants.ANIMATE === "during") {
  1994. return false;
  1995. }
  1996. if (isLayoutSuccessfull) {
  1997. if (!this.isSubLayout) {
  1998. this.doPostLayout();
  1999. }
  2000. }
  2001. if (this.tilingPostLayout) {
  2002. this.tilingPostLayout();
  2003. }
  2004. this.isLayoutFinished = true;
  2005. return isLayoutSuccessfull;
  2006. };
  2007. Layout2.prototype.doPostLayout = function() {
  2008. if (!this.incremental) {
  2009. this.transform();
  2010. }
  2011. this.update();
  2012. };
  2013. Layout2.prototype.update2 = function() {
  2014. if (this.createBendsAsNeeded) {
  2015. this.createBendpointsFromDummyNodes();
  2016. this.graphManager.resetAllEdges();
  2017. }
  2018. if (!this.isRemoteUse) {
  2019. var edge;
  2020. var allEdges = this.graphManager.getAllEdges();
  2021. for (var i = 0; i < allEdges.length; i++) {
  2022. edge = allEdges[i];
  2023. }
  2024. var node;
  2025. var nodes = this.graphManager.getRoot().getNodes();
  2026. for (var i = 0; i < nodes.length; i++) {
  2027. node = nodes[i];
  2028. }
  2029. this.update(this.graphManager.getRoot());
  2030. }
  2031. };
  2032. Layout2.prototype.update = function(obj) {
  2033. if (obj == null) {
  2034. this.update2();
  2035. } else if (obj instanceof LNode) {
  2036. var node = obj;
  2037. if (node.getChild() != null) {
  2038. var nodes = node.getChild().getNodes();
  2039. for (var i = 0; i < nodes.length; i++) {
  2040. update(nodes[i]);
  2041. }
  2042. }
  2043. if (node.vGraphObject != null) {
  2044. var vNode = node.vGraphObject;
  2045. vNode.update(node);
  2046. }
  2047. } else if (obj instanceof LEdge) {
  2048. var edge = obj;
  2049. if (edge.vGraphObject != null) {
  2050. var vEdge = edge.vGraphObject;
  2051. vEdge.update(edge);
  2052. }
  2053. } else if (obj instanceof LGraph) {
  2054. var graph = obj;
  2055. if (graph.vGraphObject != null) {
  2056. var vGraph = graph.vGraphObject;
  2057. vGraph.update(graph);
  2058. }
  2059. }
  2060. };
  2061. Layout2.prototype.initParameters = function() {
  2062. if (!this.isSubLayout) {
  2063. this.layoutQuality = LayoutConstants.QUALITY;
  2064. this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT;
  2065. this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD;
  2066. this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT;
  2067. this.incremental = LayoutConstants.DEFAULT_INCREMENTAL;
  2068. this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED;
  2069. this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES;
  2070. }
  2071. if (this.animationDuringLayout) {
  2072. this.animationOnLayout = false;
  2073. }
  2074. };
  2075. Layout2.prototype.transform = function(newLeftTop) {
  2076. if (newLeftTop == void 0) {
  2077. this.transform(new PointD(0, 0));
  2078. } else {
  2079. var trans = new Transform();
  2080. var leftTop = this.graphManager.getRoot().updateLeftTop();
  2081. if (leftTop != null) {
  2082. trans.setWorldOrgX(newLeftTop.x);
  2083. trans.setWorldOrgY(newLeftTop.y);
  2084. trans.setDeviceOrgX(leftTop.x);
  2085. trans.setDeviceOrgY(leftTop.y);
  2086. var nodes = this.getAllNodes();
  2087. var node;
  2088. for (var i = 0; i < nodes.length; i++) {
  2089. node = nodes[i];
  2090. node.transform(trans);
  2091. }
  2092. }
  2093. }
  2094. };
  2095. Layout2.prototype.positionNodesRandomly = function(graph) {
  2096. if (graph == void 0) {
  2097. this.positionNodesRandomly(this.getGraphManager().getRoot());
  2098. this.getGraphManager().getRoot().updateBounds(true);
  2099. } else {
  2100. var lNode;
  2101. var childGraph;
  2102. var nodes = graph.getNodes();
  2103. for (var i = 0; i < nodes.length; i++) {
  2104. lNode = nodes[i];
  2105. childGraph = lNode.getChild();
  2106. if (childGraph == null) {
  2107. lNode.scatter();
  2108. } else if (childGraph.getNodes().length == 0) {
  2109. lNode.scatter();
  2110. } else {
  2111. this.positionNodesRandomly(childGraph);
  2112. lNode.updateBounds();
  2113. }
  2114. }
  2115. }
  2116. };
  2117. Layout2.prototype.getFlatForest = function() {
  2118. var flatForest = [];
  2119. var isForest = true;
  2120. var allNodes = this.graphManager.getRoot().getNodes();
  2121. var isFlat = true;
  2122. for (var i = 0; i < allNodes.length; i++) {
  2123. if (allNodes[i].getChild() != null) {
  2124. isFlat = false;
  2125. }
  2126. }
  2127. if (!isFlat) {
  2128. return flatForest;
  2129. }
  2130. var visited = /* @__PURE__ */ new Set();
  2131. var toBeVisited = [];
  2132. var parents = /* @__PURE__ */ new Map();
  2133. var unProcessedNodes = [];
  2134. unProcessedNodes = unProcessedNodes.concat(allNodes);
  2135. while (unProcessedNodes.length > 0 && isForest) {
  2136. toBeVisited.push(unProcessedNodes[0]);
  2137. while (toBeVisited.length > 0 && isForest) {
  2138. var currentNode = toBeVisited[0];
  2139. toBeVisited.splice(0, 1);
  2140. visited.add(currentNode);
  2141. var neighborEdges = currentNode.getEdges();
  2142. for (var i = 0; i < neighborEdges.length; i++) {
  2143. var currentNeighbor = neighborEdges[i].getOtherEnd(currentNode);
  2144. if (parents.get(currentNode) != currentNeighbor) {
  2145. if (!visited.has(currentNeighbor)) {
  2146. toBeVisited.push(currentNeighbor);
  2147. parents.set(currentNeighbor, currentNode);
  2148. } else {
  2149. isForest = false;
  2150. break;
  2151. }
  2152. }
  2153. }
  2154. }
  2155. if (!isForest) {
  2156. flatForest = [];
  2157. } else {
  2158. var temp = [].concat(_toConsumableArray(visited));
  2159. flatForest.push(temp);
  2160. for (var i = 0; i < temp.length; i++) {
  2161. var value = temp[i];
  2162. var index = unProcessedNodes.indexOf(value);
  2163. if (index > -1) {
  2164. unProcessedNodes.splice(index, 1);
  2165. }
  2166. }
  2167. visited = /* @__PURE__ */ new Set();
  2168. parents = /* @__PURE__ */ new Map();
  2169. }
  2170. }
  2171. return flatForest;
  2172. };
  2173. Layout2.prototype.createDummyNodesForBendpoints = function(edge) {
  2174. var dummyNodes = [];
  2175. var prev = edge.source;
  2176. var graph = this.graphManager.calcLowestCommonAncestor(edge.source, edge.target);
  2177. for (var i = 0; i < edge.bendpoints.length; i++) {
  2178. var dummyNode = this.newNode(null);
  2179. dummyNode.setRect(new Point(0, 0), new Dimension(1, 1));
  2180. graph.add(dummyNode);
  2181. var dummyEdge = this.newEdge(null);
  2182. this.graphManager.add(dummyEdge, prev, dummyNode);
  2183. dummyNodes.add(dummyNode);
  2184. prev = dummyNode;
  2185. }
  2186. var dummyEdge = this.newEdge(null);
  2187. this.graphManager.add(dummyEdge, prev, edge.target);
  2188. this.edgeToDummyNodes.set(edge, dummyNodes);
  2189. if (edge.isInterGraph()) {
  2190. this.graphManager.remove(edge);
  2191. } else {
  2192. graph.remove(edge);
  2193. }
  2194. return dummyNodes;
  2195. };
  2196. Layout2.prototype.createBendpointsFromDummyNodes = function() {
  2197. var edges = [];
  2198. edges = edges.concat(this.graphManager.getAllEdges());
  2199. edges = [].concat(_toConsumableArray(this.edgeToDummyNodes.keys())).concat(edges);
  2200. for (var k = 0; k < edges.length; k++) {
  2201. var lEdge = edges[k];
  2202. if (lEdge.bendpoints.length > 0) {
  2203. var path = this.edgeToDummyNodes.get(lEdge);
  2204. for (var i = 0; i < path.length; i++) {
  2205. var dummyNode = path[i];
  2206. var p = new PointD(dummyNode.getCenterX(), dummyNode.getCenterY());
  2207. var ebp = lEdge.bendpoints.get(i);
  2208. ebp.x = p.x;
  2209. ebp.y = p.y;
  2210. dummyNode.getOwner().remove(dummyNode);
  2211. }
  2212. this.graphManager.add(lEdge, lEdge.source, lEdge.target);
  2213. }
  2214. }
  2215. };
  2216. Layout2.transform = function(sliderValue, defaultValue, minDiv, maxMul) {
  2217. if (minDiv != void 0 && maxMul != void 0) {
  2218. var value = defaultValue;
  2219. if (sliderValue <= 50) {
  2220. var minValue = defaultValue / minDiv;
  2221. value -= (defaultValue - minValue) / 50 * (50 - sliderValue);
  2222. } else {
  2223. var maxValue = defaultValue * maxMul;
  2224. value += (maxValue - defaultValue) / 50 * (sliderValue - 50);
  2225. }
  2226. return value;
  2227. } else {
  2228. var a, b;
  2229. if (sliderValue <= 50) {
  2230. a = 9 * defaultValue / 500;
  2231. b = defaultValue / 10;
  2232. } else {
  2233. a = 9 * defaultValue / 50;
  2234. b = -8 * defaultValue;
  2235. }
  2236. return a * sliderValue + b;
  2237. }
  2238. };
  2239. Layout2.findCenterOfTree = function(nodes) {
  2240. var list = [];
  2241. list = list.concat(nodes);
  2242. var removedNodes = [];
  2243. var remainingDegrees = /* @__PURE__ */ new Map();
  2244. var foundCenter = false;
  2245. var centerNode = null;
  2246. if (list.length == 1 || list.length == 2) {
  2247. foundCenter = true;
  2248. centerNode = list[0];
  2249. }
  2250. for (var i = 0; i < list.length; i++) {
  2251. var node = list[i];
  2252. var degree = node.getNeighborsList().size;
  2253. remainingDegrees.set(node, node.getNeighborsList().size);
  2254. if (degree == 1) {
  2255. removedNodes.push(node);
  2256. }
  2257. }
  2258. var tempList = [];
  2259. tempList = tempList.concat(removedNodes);
  2260. while (!foundCenter) {
  2261. var tempList2 = [];
  2262. tempList2 = tempList2.concat(tempList);
  2263. tempList = [];
  2264. for (var i = 0; i < list.length; i++) {
  2265. var node = list[i];
  2266. var index = list.indexOf(node);
  2267. if (index >= 0) {
  2268. list.splice(index, 1);
  2269. }
  2270. var neighbours = node.getNeighborsList();
  2271. neighbours.forEach(function(neighbour) {
  2272. if (removedNodes.indexOf(neighbour) < 0) {
  2273. var otherDegree = remainingDegrees.get(neighbour);
  2274. var newDegree = otherDegree - 1;
  2275. if (newDegree == 1) {
  2276. tempList.push(neighbour);
  2277. }
  2278. remainingDegrees.set(neighbour, newDegree);
  2279. }
  2280. });
  2281. }
  2282. removedNodes = removedNodes.concat(tempList);
  2283. if (list.length == 1 || list.length == 2) {
  2284. foundCenter = true;
  2285. centerNode = list[0];
  2286. }
  2287. }
  2288. return centerNode;
  2289. };
  2290. Layout2.prototype.setGraphManager = function(gm) {
  2291. this.graphManager = gm;
  2292. };
  2293. module2.exports = Layout2;
  2294. }),
  2295. /* 16 */
  2296. /***/
  2297. (function(module2, exports2, __webpack_require__) {
  2298. "use strict";
  2299. function RandomSeed() {
  2300. }
  2301. RandomSeed.seed = 1;
  2302. RandomSeed.x = 0;
  2303. RandomSeed.nextDouble = function() {
  2304. RandomSeed.x = Math.sin(RandomSeed.seed++) * 1e4;
  2305. return RandomSeed.x - Math.floor(RandomSeed.x);
  2306. };
  2307. module2.exports = RandomSeed;
  2308. }),
  2309. /* 17 */
  2310. /***/
  2311. (function(module2, exports2, __webpack_require__) {
  2312. "use strict";
  2313. var PointD = __webpack_require__(4);
  2314. function Transform(x, y) {
  2315. this.lworldOrgX = 0;
  2316. this.lworldOrgY = 0;
  2317. this.ldeviceOrgX = 0;
  2318. this.ldeviceOrgY = 0;
  2319. this.lworldExtX = 1;
  2320. this.lworldExtY = 1;
  2321. this.ldeviceExtX = 1;
  2322. this.ldeviceExtY = 1;
  2323. }
  2324. Transform.prototype.getWorldOrgX = function() {
  2325. return this.lworldOrgX;
  2326. };
  2327. Transform.prototype.setWorldOrgX = function(wox) {
  2328. this.lworldOrgX = wox;
  2329. };
  2330. Transform.prototype.getWorldOrgY = function() {
  2331. return this.lworldOrgY;
  2332. };
  2333. Transform.prototype.setWorldOrgY = function(woy) {
  2334. this.lworldOrgY = woy;
  2335. };
  2336. Transform.prototype.getWorldExtX = function() {
  2337. return this.lworldExtX;
  2338. };
  2339. Transform.prototype.setWorldExtX = function(wex) {
  2340. this.lworldExtX = wex;
  2341. };
  2342. Transform.prototype.getWorldExtY = function() {
  2343. return this.lworldExtY;
  2344. };
  2345. Transform.prototype.setWorldExtY = function(wey) {
  2346. this.lworldExtY = wey;
  2347. };
  2348. Transform.prototype.getDeviceOrgX = function() {
  2349. return this.ldeviceOrgX;
  2350. };
  2351. Transform.prototype.setDeviceOrgX = function(dox) {
  2352. this.ldeviceOrgX = dox;
  2353. };
  2354. Transform.prototype.getDeviceOrgY = function() {
  2355. return this.ldeviceOrgY;
  2356. };
  2357. Transform.prototype.setDeviceOrgY = function(doy) {
  2358. this.ldeviceOrgY = doy;
  2359. };
  2360. Transform.prototype.getDeviceExtX = function() {
  2361. return this.ldeviceExtX;
  2362. };
  2363. Transform.prototype.setDeviceExtX = function(dex) {
  2364. this.ldeviceExtX = dex;
  2365. };
  2366. Transform.prototype.getDeviceExtY = function() {
  2367. return this.ldeviceExtY;
  2368. };
  2369. Transform.prototype.setDeviceExtY = function(dey) {
  2370. this.ldeviceExtY = dey;
  2371. };
  2372. Transform.prototype.transformX = function(x) {
  2373. var xDevice = 0;
  2374. var worldExtX = this.lworldExtX;
  2375. if (worldExtX != 0) {
  2376. xDevice = this.ldeviceOrgX + (x - this.lworldOrgX) * this.ldeviceExtX / worldExtX;
  2377. }
  2378. return xDevice;
  2379. };
  2380. Transform.prototype.transformY = function(y) {
  2381. var yDevice = 0;
  2382. var worldExtY = this.lworldExtY;
  2383. if (worldExtY != 0) {
  2384. yDevice = this.ldeviceOrgY + (y - this.lworldOrgY) * this.ldeviceExtY / worldExtY;
  2385. }
  2386. return yDevice;
  2387. };
  2388. Transform.prototype.inverseTransformX = function(x) {
  2389. var xWorld = 0;
  2390. var deviceExtX = this.ldeviceExtX;
  2391. if (deviceExtX != 0) {
  2392. xWorld = this.lworldOrgX + (x - this.ldeviceOrgX) * this.lworldExtX / deviceExtX;
  2393. }
  2394. return xWorld;
  2395. };
  2396. Transform.prototype.inverseTransformY = function(y) {
  2397. var yWorld = 0;
  2398. var deviceExtY = this.ldeviceExtY;
  2399. if (deviceExtY != 0) {
  2400. yWorld = this.lworldOrgY + (y - this.ldeviceOrgY) * this.lworldExtY / deviceExtY;
  2401. }
  2402. return yWorld;
  2403. };
  2404. Transform.prototype.inverseTransformPoint = function(inPoint) {
  2405. var outPoint = new PointD(this.inverseTransformX(inPoint.x), this.inverseTransformY(inPoint.y));
  2406. return outPoint;
  2407. };
  2408. module2.exports = Transform;
  2409. }),
  2410. /* 18 */
  2411. /***/
  2412. (function(module2, exports2, __webpack_require__) {
  2413. "use strict";
  2414. function _toConsumableArray(arr) {
  2415. if (Array.isArray(arr)) {
  2416. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
  2417. arr2[i] = arr[i];
  2418. }
  2419. return arr2;
  2420. } else {
  2421. return Array.from(arr);
  2422. }
  2423. }
  2424. var Layout2 = __webpack_require__(15);
  2425. var FDLayoutConstants = __webpack_require__(7);
  2426. var LayoutConstants = __webpack_require__(0);
  2427. var IGeometry = __webpack_require__(8);
  2428. var IMath = __webpack_require__(9);
  2429. function FDLayout() {
  2430. Layout2.call(this);
  2431. this.useSmartIdealEdgeLengthCalculation = FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION;
  2432. this.idealEdgeLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH;
  2433. this.springConstant = FDLayoutConstants.DEFAULT_SPRING_STRENGTH;
  2434. this.repulsionConstant = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH;
  2435. this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH;
  2436. this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH;
  2437. this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR;
  2438. this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR;
  2439. this.displacementThresholdPerNode = 3 * FDLayoutConstants.DEFAULT_EDGE_LENGTH / 100;
  2440. this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL;
  2441. this.initialCoolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL;
  2442. this.totalDisplacement = 0;
  2443. this.oldTotalDisplacement = 0;
  2444. this.maxIterations = FDLayoutConstants.MAX_ITERATIONS;
  2445. }
  2446. FDLayout.prototype = Object.create(Layout2.prototype);
  2447. for (var prop in Layout2) {
  2448. FDLayout[prop] = Layout2[prop];
  2449. }
  2450. FDLayout.prototype.initParameters = function() {
  2451. Layout2.prototype.initParameters.call(this, arguments);
  2452. this.totalIterations = 0;
  2453. this.notAnimatedIterations = 0;
  2454. this.useFRGridVariant = FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION;
  2455. this.grid = [];
  2456. };
  2457. FDLayout.prototype.calcIdealEdgeLengths = function() {
  2458. var edge;
  2459. var lcaDepth;
  2460. var source;
  2461. var target;
  2462. var sizeOfSourceInLca;
  2463. var sizeOfTargetInLca;
  2464. var allEdges = this.getGraphManager().getAllEdges();
  2465. for (var i = 0; i < allEdges.length; i++) {
  2466. edge = allEdges[i];
  2467. edge.idealLength = this.idealEdgeLength;
  2468. if (edge.isInterGraph) {
  2469. source = edge.getSource();
  2470. target = edge.getTarget();
  2471. sizeOfSourceInLca = edge.getSourceInLca().getEstimatedSize();
  2472. sizeOfTargetInLca = edge.getTargetInLca().getEstimatedSize();
  2473. if (this.useSmartIdealEdgeLengthCalculation) {
  2474. edge.idealLength += sizeOfSourceInLca + sizeOfTargetInLca - 2 * LayoutConstants.SIMPLE_NODE_SIZE;
  2475. }
  2476. lcaDepth = edge.getLca().getInclusionTreeDepth();
  2477. edge.idealLength += FDLayoutConstants.DEFAULT_EDGE_LENGTH * FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR * (source.getInclusionTreeDepth() + target.getInclusionTreeDepth() - 2 * lcaDepth);
  2478. }
  2479. }
  2480. };
  2481. FDLayout.prototype.initSpringEmbedder = function() {
  2482. var s = this.getAllNodes().length;
  2483. if (this.incremental) {
  2484. if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) {
  2485. this.coolingFactor = Math.max(this.coolingFactor * FDLayoutConstants.COOLING_ADAPTATION_FACTOR, this.coolingFactor - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * this.coolingFactor * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR));
  2486. }
  2487. this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL;
  2488. } else {
  2489. if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) {
  2490. this.coolingFactor = Math.max(FDLayoutConstants.COOLING_ADAPTATION_FACTOR, 1 - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR));
  2491. } else {
  2492. this.coolingFactor = 1;
  2493. }
  2494. this.initialCoolingFactor = this.coolingFactor;
  2495. this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT;
  2496. }
  2497. this.maxIterations = Math.max(this.getAllNodes().length * 5, this.maxIterations);
  2498. this.totalDisplacementThreshold = this.displacementThresholdPerNode * this.getAllNodes().length;
  2499. this.repulsionRange = this.calcRepulsionRange();
  2500. };
  2501. FDLayout.prototype.calcSpringForces = function() {
  2502. var lEdges = this.getAllEdges();
  2503. var edge;
  2504. for (var i = 0; i < lEdges.length; i++) {
  2505. edge = lEdges[i];
  2506. this.calcSpringForce(edge, edge.idealLength);
  2507. }
  2508. };
  2509. FDLayout.prototype.calcRepulsionForces = function() {
  2510. var gridUpdateAllowed = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
  2511. var forceToNodeSurroundingUpdate = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
  2512. var i, j;
  2513. var nodeA, nodeB;
  2514. var lNodes = this.getAllNodes();
  2515. var processedNodeSet;
  2516. if (this.useFRGridVariant) {
  2517. if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed) {
  2518. this.updateGrid();
  2519. }
  2520. processedNodeSet = /* @__PURE__ */ new Set();
  2521. for (i = 0; i < lNodes.length; i++) {
  2522. nodeA = lNodes[i];
  2523. this.calculateRepulsionForceOfANode(nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate);
  2524. processedNodeSet.add(nodeA);
  2525. }
  2526. } else {
  2527. for (i = 0; i < lNodes.length; i++) {
  2528. nodeA = lNodes[i];
  2529. for (j = i + 1; j < lNodes.length; j++) {
  2530. nodeB = lNodes[j];
  2531. if (nodeA.getOwner() != nodeB.getOwner()) {
  2532. continue;
  2533. }
  2534. this.calcRepulsionForce(nodeA, nodeB);
  2535. }
  2536. }
  2537. }
  2538. };
  2539. FDLayout.prototype.calcGravitationalForces = function() {
  2540. var node;
  2541. var lNodes = this.getAllNodesToApplyGravitation();
  2542. for (var i = 0; i < lNodes.length; i++) {
  2543. node = lNodes[i];
  2544. this.calcGravitationalForce(node);
  2545. }
  2546. };
  2547. FDLayout.prototype.moveNodes = function() {
  2548. var lNodes = this.getAllNodes();
  2549. var node;
  2550. for (var i = 0; i < lNodes.length; i++) {
  2551. node = lNodes[i];
  2552. node.move();
  2553. }
  2554. };
  2555. FDLayout.prototype.calcSpringForce = function(edge, idealLength) {
  2556. var sourceNode = edge.getSource();
  2557. var targetNode = edge.getTarget();
  2558. var length;
  2559. var springForce;
  2560. var springForceX;
  2561. var springForceY;
  2562. if (this.uniformLeafNodeSizes && sourceNode.getChild() == null && targetNode.getChild() == null) {
  2563. edge.updateLengthSimple();
  2564. } else {
  2565. edge.updateLength();
  2566. if (edge.isOverlapingSourceAndTarget) {
  2567. return;
  2568. }
  2569. }
  2570. length = edge.getLength();
  2571. if (length == 0) return;
  2572. springForce = this.springConstant * (length - idealLength);
  2573. springForceX = springForce * (edge.lengthX / length);
  2574. springForceY = springForce * (edge.lengthY / length);
  2575. sourceNode.springForceX += springForceX;
  2576. sourceNode.springForceY += springForceY;
  2577. targetNode.springForceX -= springForceX;
  2578. targetNode.springForceY -= springForceY;
  2579. };
  2580. FDLayout.prototype.calcRepulsionForce = function(nodeA, nodeB) {
  2581. var rectA = nodeA.getRect();
  2582. var rectB = nodeB.getRect();
  2583. var overlapAmount = new Array(2);
  2584. var clipPoints = new Array(4);
  2585. var distanceX;
  2586. var distanceY;
  2587. var distanceSquared;
  2588. var distance;
  2589. var repulsionForce;
  2590. var repulsionForceX;
  2591. var repulsionForceY;
  2592. if (rectA.intersects(rectB)) {
  2593. IGeometry.calcSeparationAmount(rectA, rectB, overlapAmount, FDLayoutConstants.DEFAULT_EDGE_LENGTH / 2);
  2594. repulsionForceX = 2 * overlapAmount[0];
  2595. repulsionForceY = 2 * overlapAmount[1];
  2596. var childrenConstant = nodeA.noOfChildren * nodeB.noOfChildren / (nodeA.noOfChildren + nodeB.noOfChildren);
  2597. nodeA.repulsionForceX -= childrenConstant * repulsionForceX;
  2598. nodeA.repulsionForceY -= childrenConstant * repulsionForceY;
  2599. nodeB.repulsionForceX += childrenConstant * repulsionForceX;
  2600. nodeB.repulsionForceY += childrenConstant * repulsionForceY;
  2601. } else {
  2602. if (this.uniformLeafNodeSizes && nodeA.getChild() == null && nodeB.getChild() == null) {
  2603. distanceX = rectB.getCenterX() - rectA.getCenterX();
  2604. distanceY = rectB.getCenterY() - rectA.getCenterY();
  2605. } else {
  2606. IGeometry.getIntersection(rectA, rectB, clipPoints);
  2607. distanceX = clipPoints[2] - clipPoints[0];
  2608. distanceY = clipPoints[3] - clipPoints[1];
  2609. }
  2610. if (Math.abs(distanceX) < FDLayoutConstants.MIN_REPULSION_DIST) {
  2611. distanceX = IMath.sign(distanceX) * FDLayoutConstants.MIN_REPULSION_DIST;
  2612. }
  2613. if (Math.abs(distanceY) < FDLayoutConstants.MIN_REPULSION_DIST) {
  2614. distanceY = IMath.sign(distanceY) * FDLayoutConstants.MIN_REPULSION_DIST;
  2615. }
  2616. distanceSquared = distanceX * distanceX + distanceY * distanceY;
  2617. distance = Math.sqrt(distanceSquared);
  2618. repulsionForce = this.repulsionConstant * nodeA.noOfChildren * nodeB.noOfChildren / distanceSquared;
  2619. repulsionForceX = repulsionForce * distanceX / distance;
  2620. repulsionForceY = repulsionForce * distanceY / distance;
  2621. nodeA.repulsionForceX -= repulsionForceX;
  2622. nodeA.repulsionForceY -= repulsionForceY;
  2623. nodeB.repulsionForceX += repulsionForceX;
  2624. nodeB.repulsionForceY += repulsionForceY;
  2625. }
  2626. };
  2627. FDLayout.prototype.calcGravitationalForce = function(node) {
  2628. var ownerGraph;
  2629. var ownerCenterX;
  2630. var ownerCenterY;
  2631. var distanceX;
  2632. var distanceY;
  2633. var absDistanceX;
  2634. var absDistanceY;
  2635. var estimatedSize;
  2636. ownerGraph = node.getOwner();
  2637. ownerCenterX = (ownerGraph.getRight() + ownerGraph.getLeft()) / 2;
  2638. ownerCenterY = (ownerGraph.getTop() + ownerGraph.getBottom()) / 2;
  2639. distanceX = node.getCenterX() - ownerCenterX;
  2640. distanceY = node.getCenterY() - ownerCenterY;
  2641. absDistanceX = Math.abs(distanceX) + node.getWidth() / 2;
  2642. absDistanceY = Math.abs(distanceY) + node.getHeight() / 2;
  2643. if (node.getOwner() == this.graphManager.getRoot()) {
  2644. estimatedSize = ownerGraph.getEstimatedSize() * this.gravityRangeFactor;
  2645. if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) {
  2646. node.gravitationForceX = -this.gravityConstant * distanceX;
  2647. node.gravitationForceY = -this.gravityConstant * distanceY;
  2648. }
  2649. } else {
  2650. estimatedSize = ownerGraph.getEstimatedSize() * this.compoundGravityRangeFactor;
  2651. if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) {
  2652. node.gravitationForceX = -this.gravityConstant * distanceX * this.compoundGravityConstant;
  2653. node.gravitationForceY = -this.gravityConstant * distanceY * this.compoundGravityConstant;
  2654. }
  2655. }
  2656. };
  2657. FDLayout.prototype.isConverged = function() {
  2658. var converged;
  2659. var oscilating = false;
  2660. if (this.totalIterations > this.maxIterations / 3) {
  2661. oscilating = Math.abs(this.totalDisplacement - this.oldTotalDisplacement) < 2;
  2662. }
  2663. converged = this.totalDisplacement < this.totalDisplacementThreshold;
  2664. this.oldTotalDisplacement = this.totalDisplacement;
  2665. return converged || oscilating;
  2666. };
  2667. FDLayout.prototype.animate = function() {
  2668. if (this.animationDuringLayout && !this.isSubLayout) {
  2669. if (this.notAnimatedIterations == this.animationPeriod) {
  2670. this.update();
  2671. this.notAnimatedIterations = 0;
  2672. } else {
  2673. this.notAnimatedIterations++;
  2674. }
  2675. }
  2676. };
  2677. FDLayout.prototype.calcNoOfChildrenForAllNodes = function() {
  2678. var node;
  2679. var allNodes = this.graphManager.getAllNodes();
  2680. for (var i = 0; i < allNodes.length; i++) {
  2681. node = allNodes[i];
  2682. node.noOfChildren = node.getNoOfChildren();
  2683. }
  2684. };
  2685. FDLayout.prototype.calcGrid = function(graph) {
  2686. var sizeX = 0;
  2687. var sizeY = 0;
  2688. sizeX = parseInt(Math.ceil((graph.getRight() - graph.getLeft()) / this.repulsionRange));
  2689. sizeY = parseInt(Math.ceil((graph.getBottom() - graph.getTop()) / this.repulsionRange));
  2690. var grid = new Array(sizeX);
  2691. for (var i = 0; i < sizeX; i++) {
  2692. grid[i] = new Array(sizeY);
  2693. }
  2694. for (var i = 0; i < sizeX; i++) {
  2695. for (var j = 0; j < sizeY; j++) {
  2696. grid[i][j] = new Array();
  2697. }
  2698. }
  2699. return grid;
  2700. };
  2701. FDLayout.prototype.addNodeToGrid = function(v, left, top) {
  2702. var startX = 0;
  2703. var finishX = 0;
  2704. var startY = 0;
  2705. var finishY = 0;
  2706. startX = parseInt(Math.floor((v.getRect().x - left) / this.repulsionRange));
  2707. finishX = parseInt(Math.floor((v.getRect().width + v.getRect().x - left) / this.repulsionRange));
  2708. startY = parseInt(Math.floor((v.getRect().y - top) / this.repulsionRange));
  2709. finishY = parseInt(Math.floor((v.getRect().height + v.getRect().y - top) / this.repulsionRange));
  2710. for (var i = startX; i <= finishX; i++) {
  2711. for (var j = startY; j <= finishY; j++) {
  2712. this.grid[i][j].push(v);
  2713. v.setGridCoordinates(startX, finishX, startY, finishY);
  2714. }
  2715. }
  2716. };
  2717. FDLayout.prototype.updateGrid = function() {
  2718. var i;
  2719. var nodeA;
  2720. var lNodes = this.getAllNodes();
  2721. this.grid = this.calcGrid(this.graphManager.getRoot());
  2722. for (i = 0; i < lNodes.length; i++) {
  2723. nodeA = lNodes[i];
  2724. this.addNodeToGrid(nodeA, this.graphManager.getRoot().getLeft(), this.graphManager.getRoot().getTop());
  2725. }
  2726. };
  2727. FDLayout.prototype.calculateRepulsionForceOfANode = function(nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate) {
  2728. if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed || forceToNodeSurroundingUpdate) {
  2729. var surrounding = /* @__PURE__ */ new Set();
  2730. nodeA.surrounding = new Array();
  2731. var nodeB;
  2732. var grid = this.grid;
  2733. for (var i = nodeA.startX - 1; i < nodeA.finishX + 2; i++) {
  2734. for (var j = nodeA.startY - 1; j < nodeA.finishY + 2; j++) {
  2735. if (!(i < 0 || j < 0 || i >= grid.length || j >= grid[0].length)) {
  2736. for (var k = 0; k < grid[i][j].length; k++) {
  2737. nodeB = grid[i][j][k];
  2738. if (nodeA.getOwner() != nodeB.getOwner() || nodeA == nodeB) {
  2739. continue;
  2740. }
  2741. if (!processedNodeSet.has(nodeB) && !surrounding.has(nodeB)) {
  2742. var distanceX = Math.abs(nodeA.getCenterX() - nodeB.getCenterX()) - (nodeA.getWidth() / 2 + nodeB.getWidth() / 2);
  2743. var distanceY = Math.abs(nodeA.getCenterY() - nodeB.getCenterY()) - (nodeA.getHeight() / 2 + nodeB.getHeight() / 2);
  2744. if (distanceX <= this.repulsionRange && distanceY <= this.repulsionRange) {
  2745. surrounding.add(nodeB);
  2746. }
  2747. }
  2748. }
  2749. }
  2750. }
  2751. }
  2752. nodeA.surrounding = [].concat(_toConsumableArray(surrounding));
  2753. }
  2754. for (i = 0; i < nodeA.surrounding.length; i++) {
  2755. this.calcRepulsionForce(nodeA, nodeA.surrounding[i]);
  2756. }
  2757. };
  2758. FDLayout.prototype.calcRepulsionRange = function() {
  2759. return 0;
  2760. };
  2761. module2.exports = FDLayout;
  2762. }),
  2763. /* 19 */
  2764. /***/
  2765. (function(module2, exports2, __webpack_require__) {
  2766. "use strict";
  2767. var LEdge = __webpack_require__(1);
  2768. var FDLayoutConstants = __webpack_require__(7);
  2769. function FDLayoutEdge(source, target, vEdge) {
  2770. LEdge.call(this, source, target, vEdge);
  2771. this.idealLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH;
  2772. }
  2773. FDLayoutEdge.prototype = Object.create(LEdge.prototype);
  2774. for (var prop in LEdge) {
  2775. FDLayoutEdge[prop] = LEdge[prop];
  2776. }
  2777. module2.exports = FDLayoutEdge;
  2778. }),
  2779. /* 20 */
  2780. /***/
  2781. (function(module2, exports2, __webpack_require__) {
  2782. "use strict";
  2783. var LNode = __webpack_require__(3);
  2784. function FDLayoutNode(gm, loc, size, vNode) {
  2785. LNode.call(this, gm, loc, size, vNode);
  2786. this.springForceX = 0;
  2787. this.springForceY = 0;
  2788. this.repulsionForceX = 0;
  2789. this.repulsionForceY = 0;
  2790. this.gravitationForceX = 0;
  2791. this.gravitationForceY = 0;
  2792. this.displacementX = 0;
  2793. this.displacementY = 0;
  2794. this.startX = 0;
  2795. this.finishX = 0;
  2796. this.startY = 0;
  2797. this.finishY = 0;
  2798. this.surrounding = [];
  2799. }
  2800. FDLayoutNode.prototype = Object.create(LNode.prototype);
  2801. for (var prop in LNode) {
  2802. FDLayoutNode[prop] = LNode[prop];
  2803. }
  2804. FDLayoutNode.prototype.setGridCoordinates = function(_startX, _finishX, _startY, _finishY) {
  2805. this.startX = _startX;
  2806. this.finishX = _finishX;
  2807. this.startY = _startY;
  2808. this.finishY = _finishY;
  2809. };
  2810. module2.exports = FDLayoutNode;
  2811. }),
  2812. /* 21 */
  2813. /***/
  2814. (function(module2, exports2, __webpack_require__) {
  2815. "use strict";
  2816. function DimensionD2(width, height) {
  2817. this.width = 0;
  2818. this.height = 0;
  2819. if (width !== null && height !== null) {
  2820. this.height = height;
  2821. this.width = width;
  2822. }
  2823. }
  2824. DimensionD2.prototype.getWidth = function() {
  2825. return this.width;
  2826. };
  2827. DimensionD2.prototype.setWidth = function(width) {
  2828. this.width = width;
  2829. };
  2830. DimensionD2.prototype.getHeight = function() {
  2831. return this.height;
  2832. };
  2833. DimensionD2.prototype.setHeight = function(height) {
  2834. this.height = height;
  2835. };
  2836. module2.exports = DimensionD2;
  2837. }),
  2838. /* 22 */
  2839. /***/
  2840. (function(module2, exports2, __webpack_require__) {
  2841. "use strict";
  2842. var UniqueIDGeneretor = __webpack_require__(14);
  2843. function HashMap() {
  2844. this.map = {};
  2845. this.keys = [];
  2846. }
  2847. HashMap.prototype.put = function(key, value) {
  2848. var theId = UniqueIDGeneretor.createID(key);
  2849. if (!this.contains(theId)) {
  2850. this.map[theId] = value;
  2851. this.keys.push(key);
  2852. }
  2853. };
  2854. HashMap.prototype.contains = function(key) {
  2855. var theId = UniqueIDGeneretor.createID(key);
  2856. return this.map[key] != null;
  2857. };
  2858. HashMap.prototype.get = function(key) {
  2859. var theId = UniqueIDGeneretor.createID(key);
  2860. return this.map[theId];
  2861. };
  2862. HashMap.prototype.keySet = function() {
  2863. return this.keys;
  2864. };
  2865. module2.exports = HashMap;
  2866. }),
  2867. /* 23 */
  2868. /***/
  2869. (function(module2, exports2, __webpack_require__) {
  2870. "use strict";
  2871. var UniqueIDGeneretor = __webpack_require__(14);
  2872. function HashSet() {
  2873. this.set = {};
  2874. }
  2875. ;
  2876. HashSet.prototype.add = function(obj) {
  2877. var theId = UniqueIDGeneretor.createID(obj);
  2878. if (!this.contains(theId)) this.set[theId] = obj;
  2879. };
  2880. HashSet.prototype.remove = function(obj) {
  2881. delete this.set[UniqueIDGeneretor.createID(obj)];
  2882. };
  2883. HashSet.prototype.clear = function() {
  2884. this.set = {};
  2885. };
  2886. HashSet.prototype.contains = function(obj) {
  2887. return this.set[UniqueIDGeneretor.createID(obj)] == obj;
  2888. };
  2889. HashSet.prototype.isEmpty = function() {
  2890. return this.size() === 0;
  2891. };
  2892. HashSet.prototype.size = function() {
  2893. return Object.keys(this.set).length;
  2894. };
  2895. HashSet.prototype.addAllTo = function(list) {
  2896. var keys = Object.keys(this.set);
  2897. var length = keys.length;
  2898. for (var i = 0; i < length; i++) {
  2899. list.push(this.set[keys[i]]);
  2900. }
  2901. };
  2902. HashSet.prototype.size = function() {
  2903. return Object.keys(this.set).length;
  2904. };
  2905. HashSet.prototype.addAll = function(list) {
  2906. var s = list.length;
  2907. for (var i = 0; i < s; i++) {
  2908. var v = list[i];
  2909. this.add(v);
  2910. }
  2911. };
  2912. module2.exports = HashSet;
  2913. }),
  2914. /* 24 */
  2915. /***/
  2916. (function(module2, exports2, __webpack_require__) {
  2917. "use strict";
  2918. var _createClass = /* @__PURE__ */ (function() {
  2919. function defineProperties(target, props) {
  2920. for (var i = 0; i < props.length; i++) {
  2921. var descriptor = props[i];
  2922. descriptor.enumerable = descriptor.enumerable || false;
  2923. descriptor.configurable = true;
  2924. if ("value" in descriptor) descriptor.writable = true;
  2925. Object.defineProperty(target, descriptor.key, descriptor);
  2926. }
  2927. }
  2928. return function(Constructor, protoProps, staticProps) {
  2929. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  2930. if (staticProps) defineProperties(Constructor, staticProps);
  2931. return Constructor;
  2932. };
  2933. })();
  2934. function _classCallCheck(instance2, Constructor) {
  2935. if (!(instance2 instanceof Constructor)) {
  2936. throw new TypeError("Cannot call a class as a function");
  2937. }
  2938. }
  2939. var LinkedList = __webpack_require__(11);
  2940. var Quicksort = (function() {
  2941. function Quicksort2(A, compareFunction) {
  2942. _classCallCheck(this, Quicksort2);
  2943. if (compareFunction !== null || compareFunction !== void 0) this.compareFunction = this._defaultCompareFunction;
  2944. var length = void 0;
  2945. if (A instanceof LinkedList) length = A.size();
  2946. else length = A.length;
  2947. this._quicksort(A, 0, length - 1);
  2948. }
  2949. _createClass(Quicksort2, [{
  2950. key: "_quicksort",
  2951. value: function _quicksort(A, p, r) {
  2952. if (p < r) {
  2953. var q = this._partition(A, p, r);
  2954. this._quicksort(A, p, q);
  2955. this._quicksort(A, q + 1, r);
  2956. }
  2957. }
  2958. }, {
  2959. key: "_partition",
  2960. value: function _partition(A, p, r) {
  2961. var x = this._get(A, p);
  2962. var i = p;
  2963. var j = r;
  2964. while (true) {
  2965. while (this.compareFunction(x, this._get(A, j))) {
  2966. j--;
  2967. }
  2968. while (this.compareFunction(this._get(A, i), x)) {
  2969. i++;
  2970. }
  2971. if (i < j) {
  2972. this._swap(A, i, j);
  2973. i++;
  2974. j--;
  2975. } else return j;
  2976. }
  2977. }
  2978. }, {
  2979. key: "_get",
  2980. value: function _get(object, index) {
  2981. if (object instanceof LinkedList) return object.get_object_at(index);
  2982. else return object[index];
  2983. }
  2984. }, {
  2985. key: "_set",
  2986. value: function _set(object, index, value) {
  2987. if (object instanceof LinkedList) object.set_object_at(index, value);
  2988. else object[index] = value;
  2989. }
  2990. }, {
  2991. key: "_swap",
  2992. value: function _swap(A, i, j) {
  2993. var temp = this._get(A, i);
  2994. this._set(A, i, this._get(A, j));
  2995. this._set(A, j, temp);
  2996. }
  2997. }, {
  2998. key: "_defaultCompareFunction",
  2999. value: function _defaultCompareFunction(a, b) {
  3000. return b > a;
  3001. }
  3002. }]);
  3003. return Quicksort2;
  3004. })();
  3005. module2.exports = Quicksort;
  3006. }),
  3007. /* 25 */
  3008. /***/
  3009. (function(module2, exports2, __webpack_require__) {
  3010. "use strict";
  3011. var _createClass = /* @__PURE__ */ (function() {
  3012. function defineProperties(target, props) {
  3013. for (var i = 0; i < props.length; i++) {
  3014. var descriptor = props[i];
  3015. descriptor.enumerable = descriptor.enumerable || false;
  3016. descriptor.configurable = true;
  3017. if ("value" in descriptor) descriptor.writable = true;
  3018. Object.defineProperty(target, descriptor.key, descriptor);
  3019. }
  3020. }
  3021. return function(Constructor, protoProps, staticProps) {
  3022. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  3023. if (staticProps) defineProperties(Constructor, staticProps);
  3024. return Constructor;
  3025. };
  3026. })();
  3027. function _classCallCheck(instance2, Constructor) {
  3028. if (!(instance2 instanceof Constructor)) {
  3029. throw new TypeError("Cannot call a class as a function");
  3030. }
  3031. }
  3032. var NeedlemanWunsch = (function() {
  3033. function NeedlemanWunsch2(sequence1, sequence2) {
  3034. var match_score = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
  3035. var mismatch_penalty = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : -1;
  3036. var gap_penalty = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : -1;
  3037. _classCallCheck(this, NeedlemanWunsch2);
  3038. this.sequence1 = sequence1;
  3039. this.sequence2 = sequence2;
  3040. this.match_score = match_score;
  3041. this.mismatch_penalty = mismatch_penalty;
  3042. this.gap_penalty = gap_penalty;
  3043. this.iMax = sequence1.length + 1;
  3044. this.jMax = sequence2.length + 1;
  3045. this.grid = new Array(this.iMax);
  3046. for (var i = 0; i < this.iMax; i++) {
  3047. this.grid[i] = new Array(this.jMax);
  3048. for (var j = 0; j < this.jMax; j++) {
  3049. this.grid[i][j] = 0;
  3050. }
  3051. }
  3052. this.tracebackGrid = new Array(this.iMax);
  3053. for (var _i = 0; _i < this.iMax; _i++) {
  3054. this.tracebackGrid[_i] = new Array(this.jMax);
  3055. for (var _j = 0; _j < this.jMax; _j++) {
  3056. this.tracebackGrid[_i][_j] = [null, null, null];
  3057. }
  3058. }
  3059. this.alignments = [];
  3060. this.score = -1;
  3061. this.computeGrids();
  3062. }
  3063. _createClass(NeedlemanWunsch2, [{
  3064. key: "getScore",
  3065. value: function getScore() {
  3066. return this.score;
  3067. }
  3068. }, {
  3069. key: "getAlignments",
  3070. value: function getAlignments() {
  3071. return this.alignments;
  3072. }
  3073. // Main dynamic programming procedure
  3074. }, {
  3075. key: "computeGrids",
  3076. value: function computeGrids() {
  3077. for (var j = 1; j < this.jMax; j++) {
  3078. this.grid[0][j] = this.grid[0][j - 1] + this.gap_penalty;
  3079. this.tracebackGrid[0][j] = [false, false, true];
  3080. }
  3081. for (var i = 1; i < this.iMax; i++) {
  3082. this.grid[i][0] = this.grid[i - 1][0] + this.gap_penalty;
  3083. this.tracebackGrid[i][0] = [false, true, false];
  3084. }
  3085. for (var _i2 = 1; _i2 < this.iMax; _i2++) {
  3086. for (var _j2 = 1; _j2 < this.jMax; _j2++) {
  3087. var diag = void 0;
  3088. if (this.sequence1[_i2 - 1] === this.sequence2[_j2 - 1]) diag = this.grid[_i2 - 1][_j2 - 1] + this.match_score;
  3089. else diag = this.grid[_i2 - 1][_j2 - 1] + this.mismatch_penalty;
  3090. var up = this.grid[_i2 - 1][_j2] + this.gap_penalty;
  3091. var left = this.grid[_i2][_j2 - 1] + this.gap_penalty;
  3092. var maxOf = [diag, up, left];
  3093. var indices = this.arrayAllMaxIndexes(maxOf);
  3094. this.grid[_i2][_j2] = maxOf[indices[0]];
  3095. this.tracebackGrid[_i2][_j2] = [indices.includes(0), indices.includes(1), indices.includes(2)];
  3096. }
  3097. }
  3098. this.score = this.grid[this.iMax - 1][this.jMax - 1];
  3099. }
  3100. // Gets all possible valid sequence combinations
  3101. }, {
  3102. key: "alignmentTraceback",
  3103. value: function alignmentTraceback() {
  3104. var inProcessAlignments = [];
  3105. inProcessAlignments.push({
  3106. pos: [this.sequence1.length, this.sequence2.length],
  3107. seq1: "",
  3108. seq2: ""
  3109. });
  3110. while (inProcessAlignments[0]) {
  3111. var current = inProcessAlignments[0];
  3112. var directions = this.tracebackGrid[current.pos[0]][current.pos[1]];
  3113. if (directions[0]) {
  3114. inProcessAlignments.push({
  3115. pos: [current.pos[0] - 1, current.pos[1] - 1],
  3116. seq1: this.sequence1[current.pos[0] - 1] + current.seq1,
  3117. seq2: this.sequence2[current.pos[1] - 1] + current.seq2
  3118. });
  3119. }
  3120. if (directions[1]) {
  3121. inProcessAlignments.push({
  3122. pos: [current.pos[0] - 1, current.pos[1]],
  3123. seq1: this.sequence1[current.pos[0] - 1] + current.seq1,
  3124. seq2: "-" + current.seq2
  3125. });
  3126. }
  3127. if (directions[2]) {
  3128. inProcessAlignments.push({
  3129. pos: [current.pos[0], current.pos[1] - 1],
  3130. seq1: "-" + current.seq1,
  3131. seq2: this.sequence2[current.pos[1] - 1] + current.seq2
  3132. });
  3133. }
  3134. if (current.pos[0] === 0 && current.pos[1] === 0) this.alignments.push({
  3135. sequence1: current.seq1,
  3136. sequence2: current.seq2
  3137. });
  3138. inProcessAlignments.shift();
  3139. }
  3140. return this.alignments;
  3141. }
  3142. // Helper Functions
  3143. }, {
  3144. key: "getAllIndexes",
  3145. value: function getAllIndexes(arr, val) {
  3146. var indexes = [], i = -1;
  3147. while ((i = arr.indexOf(val, i + 1)) !== -1) {
  3148. indexes.push(i);
  3149. }
  3150. return indexes;
  3151. }
  3152. }, {
  3153. key: "arrayAllMaxIndexes",
  3154. value: function arrayAllMaxIndexes(array) {
  3155. return this.getAllIndexes(array, Math.max.apply(null, array));
  3156. }
  3157. }]);
  3158. return NeedlemanWunsch2;
  3159. })();
  3160. module2.exports = NeedlemanWunsch;
  3161. }),
  3162. /* 26 */
  3163. /***/
  3164. (function(module2, exports2, __webpack_require__) {
  3165. "use strict";
  3166. var layoutBase = function layoutBase2() {
  3167. return;
  3168. };
  3169. layoutBase.FDLayout = __webpack_require__(18);
  3170. layoutBase.FDLayoutConstants = __webpack_require__(7);
  3171. layoutBase.FDLayoutEdge = __webpack_require__(19);
  3172. layoutBase.FDLayoutNode = __webpack_require__(20);
  3173. layoutBase.DimensionD = __webpack_require__(21);
  3174. layoutBase.HashMap = __webpack_require__(22);
  3175. layoutBase.HashSet = __webpack_require__(23);
  3176. layoutBase.IGeometry = __webpack_require__(8);
  3177. layoutBase.IMath = __webpack_require__(9);
  3178. layoutBase.Integer = __webpack_require__(10);
  3179. layoutBase.Point = __webpack_require__(12);
  3180. layoutBase.PointD = __webpack_require__(4);
  3181. layoutBase.RandomSeed = __webpack_require__(16);
  3182. layoutBase.RectangleD = __webpack_require__(13);
  3183. layoutBase.Transform = __webpack_require__(17);
  3184. layoutBase.UniqueIDGeneretor = __webpack_require__(14);
  3185. layoutBase.Quicksort = __webpack_require__(24);
  3186. layoutBase.LinkedList = __webpack_require__(11);
  3187. layoutBase.LGraphObject = __webpack_require__(2);
  3188. layoutBase.LGraph = __webpack_require__(5);
  3189. layoutBase.LEdge = __webpack_require__(1);
  3190. layoutBase.LGraphManager = __webpack_require__(6);
  3191. layoutBase.LNode = __webpack_require__(3);
  3192. layoutBase.Layout = __webpack_require__(15);
  3193. layoutBase.LayoutConstants = __webpack_require__(0);
  3194. layoutBase.NeedlemanWunsch = __webpack_require__(25);
  3195. module2.exports = layoutBase;
  3196. }),
  3197. /* 27 */
  3198. /***/
  3199. (function(module2, exports2, __webpack_require__) {
  3200. "use strict";
  3201. function Emitter() {
  3202. this.listeners = [];
  3203. }
  3204. var p = Emitter.prototype;
  3205. p.addListener = function(event, callback) {
  3206. this.listeners.push({
  3207. event,
  3208. callback
  3209. });
  3210. };
  3211. p.removeListener = function(event, callback) {
  3212. for (var i = this.listeners.length; i >= 0; i--) {
  3213. var l = this.listeners[i];
  3214. if (l.event === event && l.callback === callback) {
  3215. this.listeners.splice(i, 1);
  3216. }
  3217. }
  3218. };
  3219. p.emit = function(event, data) {
  3220. for (var i = 0; i < this.listeners.length; i++) {
  3221. var l = this.listeners[i];
  3222. if (event === l.event) {
  3223. l.callback(data);
  3224. }
  3225. }
  3226. };
  3227. module2.exports = Emitter;
  3228. })
  3229. /******/
  3230. ])
  3231. );
  3232. });
  3233. }
  3234. });
  3235. // node_modules/cose-base/cose-base.js
  3236. var require_cose_base = __commonJS({
  3237. "node_modules/cose-base/cose-base.js"(exports, module) {
  3238. (function webpackUniversalModuleDefinition(root, factory) {
  3239. if (typeof exports === "object" && typeof module === "object")
  3240. module.exports = factory(require_layout_base());
  3241. else if (typeof define === "function" && define.amd)
  3242. define(["layout-base"], factory);
  3243. else if (typeof exports === "object")
  3244. exports["coseBase"] = factory(require_layout_base());
  3245. else
  3246. root["coseBase"] = factory(root["layoutBase"]);
  3247. })(exports, function(__WEBPACK_EXTERNAL_MODULE_0__) {
  3248. return (
  3249. /******/
  3250. (function(modules) {
  3251. var installedModules = {};
  3252. function __webpack_require__(moduleId) {
  3253. if (installedModules[moduleId]) {
  3254. return installedModules[moduleId].exports;
  3255. }
  3256. var module2 = installedModules[moduleId] = {
  3257. /******/
  3258. i: moduleId,
  3259. /******/
  3260. l: false,
  3261. /******/
  3262. exports: {}
  3263. /******/
  3264. };
  3265. modules[moduleId].call(module2.exports, module2, module2.exports, __webpack_require__);
  3266. module2.l = true;
  3267. return module2.exports;
  3268. }
  3269. __webpack_require__.m = modules;
  3270. __webpack_require__.c = installedModules;
  3271. __webpack_require__.i = function(value) {
  3272. return value;
  3273. };
  3274. __webpack_require__.d = function(exports2, name, getter) {
  3275. if (!__webpack_require__.o(exports2, name)) {
  3276. Object.defineProperty(exports2, name, {
  3277. /******/
  3278. configurable: false,
  3279. /******/
  3280. enumerable: true,
  3281. /******/
  3282. get: getter
  3283. /******/
  3284. });
  3285. }
  3286. };
  3287. __webpack_require__.n = function(module2) {
  3288. var getter = module2 && module2.__esModule ? (
  3289. /******/
  3290. function getDefault() {
  3291. return module2["default"];
  3292. }
  3293. ) : (
  3294. /******/
  3295. function getModuleExports() {
  3296. return module2;
  3297. }
  3298. );
  3299. __webpack_require__.d(getter, "a", getter);
  3300. return getter;
  3301. };
  3302. __webpack_require__.o = function(object, property) {
  3303. return Object.prototype.hasOwnProperty.call(object, property);
  3304. };
  3305. __webpack_require__.p = "";
  3306. return __webpack_require__(__webpack_require__.s = 7);
  3307. })([
  3308. /* 0 */
  3309. /***/
  3310. (function(module2, exports2) {
  3311. module2.exports = __WEBPACK_EXTERNAL_MODULE_0__;
  3312. }),
  3313. /* 1 */
  3314. /***/
  3315. (function(module2, exports2, __webpack_require__) {
  3316. "use strict";
  3317. var FDLayoutConstants = __webpack_require__(0).FDLayoutConstants;
  3318. function CoSEConstants() {
  3319. }
  3320. for (var prop in FDLayoutConstants) {
  3321. CoSEConstants[prop] = FDLayoutConstants[prop];
  3322. }
  3323. CoSEConstants.DEFAULT_USE_MULTI_LEVEL_SCALING = false;
  3324. CoSEConstants.DEFAULT_RADIAL_SEPARATION = FDLayoutConstants.DEFAULT_EDGE_LENGTH;
  3325. CoSEConstants.DEFAULT_COMPONENT_SEPERATION = 60;
  3326. CoSEConstants.TILE = true;
  3327. CoSEConstants.TILING_PADDING_VERTICAL = 10;
  3328. CoSEConstants.TILING_PADDING_HORIZONTAL = 10;
  3329. CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL = false;
  3330. module2.exports = CoSEConstants;
  3331. }),
  3332. /* 2 */
  3333. /***/
  3334. (function(module2, exports2, __webpack_require__) {
  3335. "use strict";
  3336. var FDLayoutEdge = __webpack_require__(0).FDLayoutEdge;
  3337. function CoSEEdge(source, target, vEdge) {
  3338. FDLayoutEdge.call(this, source, target, vEdge);
  3339. }
  3340. CoSEEdge.prototype = Object.create(FDLayoutEdge.prototype);
  3341. for (var prop in FDLayoutEdge) {
  3342. CoSEEdge[prop] = FDLayoutEdge[prop];
  3343. }
  3344. module2.exports = CoSEEdge;
  3345. }),
  3346. /* 3 */
  3347. /***/
  3348. (function(module2, exports2, __webpack_require__) {
  3349. "use strict";
  3350. var LGraph = __webpack_require__(0).LGraph;
  3351. function CoSEGraph(parent, graphMgr, vGraph) {
  3352. LGraph.call(this, parent, graphMgr, vGraph);
  3353. }
  3354. CoSEGraph.prototype = Object.create(LGraph.prototype);
  3355. for (var prop in LGraph) {
  3356. CoSEGraph[prop] = LGraph[prop];
  3357. }
  3358. module2.exports = CoSEGraph;
  3359. }),
  3360. /* 4 */
  3361. /***/
  3362. (function(module2, exports2, __webpack_require__) {
  3363. "use strict";
  3364. var LGraphManager = __webpack_require__(0).LGraphManager;
  3365. function CoSEGraphManager(layout) {
  3366. LGraphManager.call(this, layout);
  3367. }
  3368. CoSEGraphManager.prototype = Object.create(LGraphManager.prototype);
  3369. for (var prop in LGraphManager) {
  3370. CoSEGraphManager[prop] = LGraphManager[prop];
  3371. }
  3372. module2.exports = CoSEGraphManager;
  3373. }),
  3374. /* 5 */
  3375. /***/
  3376. (function(module2, exports2, __webpack_require__) {
  3377. "use strict";
  3378. var FDLayoutNode = __webpack_require__(0).FDLayoutNode;
  3379. var IMath = __webpack_require__(0).IMath;
  3380. function CoSENode(gm, loc, size, vNode) {
  3381. FDLayoutNode.call(this, gm, loc, size, vNode);
  3382. }
  3383. CoSENode.prototype = Object.create(FDLayoutNode.prototype);
  3384. for (var prop in FDLayoutNode) {
  3385. CoSENode[prop] = FDLayoutNode[prop];
  3386. }
  3387. CoSENode.prototype.move = function() {
  3388. var layout = this.graphManager.getLayout();
  3389. this.displacementX = layout.coolingFactor * (this.springForceX + this.repulsionForceX + this.gravitationForceX) / this.noOfChildren;
  3390. this.displacementY = layout.coolingFactor * (this.springForceY + this.repulsionForceY + this.gravitationForceY) / this.noOfChildren;
  3391. if (Math.abs(this.displacementX) > layout.coolingFactor * layout.maxNodeDisplacement) {
  3392. this.displacementX = layout.coolingFactor * layout.maxNodeDisplacement * IMath.sign(this.displacementX);
  3393. }
  3394. if (Math.abs(this.displacementY) > layout.coolingFactor * layout.maxNodeDisplacement) {
  3395. this.displacementY = layout.coolingFactor * layout.maxNodeDisplacement * IMath.sign(this.displacementY);
  3396. }
  3397. if (this.child == null) {
  3398. this.moveBy(this.displacementX, this.displacementY);
  3399. } else if (this.child.getNodes().length == 0) {
  3400. this.moveBy(this.displacementX, this.displacementY);
  3401. } else {
  3402. this.propogateDisplacementToChildren(this.displacementX, this.displacementY);
  3403. }
  3404. layout.totalDisplacement += Math.abs(this.displacementX) + Math.abs(this.displacementY);
  3405. this.springForceX = 0;
  3406. this.springForceY = 0;
  3407. this.repulsionForceX = 0;
  3408. this.repulsionForceY = 0;
  3409. this.gravitationForceX = 0;
  3410. this.gravitationForceY = 0;
  3411. this.displacementX = 0;
  3412. this.displacementY = 0;
  3413. };
  3414. CoSENode.prototype.propogateDisplacementToChildren = function(dX, dY) {
  3415. var nodes = this.getChild().getNodes();
  3416. var node;
  3417. for (var i = 0; i < nodes.length; i++) {
  3418. node = nodes[i];
  3419. if (node.getChild() == null) {
  3420. node.moveBy(dX, dY);
  3421. node.displacementX += dX;
  3422. node.displacementY += dY;
  3423. } else {
  3424. node.propogateDisplacementToChildren(dX, dY);
  3425. }
  3426. }
  3427. };
  3428. CoSENode.prototype.setPred1 = function(pred12) {
  3429. this.pred1 = pred12;
  3430. };
  3431. CoSENode.prototype.getPred1 = function() {
  3432. return pred1;
  3433. };
  3434. CoSENode.prototype.getPred2 = function() {
  3435. return pred2;
  3436. };
  3437. CoSENode.prototype.setNext = function(next2) {
  3438. this.next = next2;
  3439. };
  3440. CoSENode.prototype.getNext = function() {
  3441. return next;
  3442. };
  3443. CoSENode.prototype.setProcessed = function(processed2) {
  3444. this.processed = processed2;
  3445. };
  3446. CoSENode.prototype.isProcessed = function() {
  3447. return processed;
  3448. };
  3449. module2.exports = CoSENode;
  3450. }),
  3451. /* 6 */
  3452. /***/
  3453. (function(module2, exports2, __webpack_require__) {
  3454. "use strict";
  3455. var FDLayout = __webpack_require__(0).FDLayout;
  3456. var CoSEGraphManager = __webpack_require__(4);
  3457. var CoSEGraph = __webpack_require__(3);
  3458. var CoSENode = __webpack_require__(5);
  3459. var CoSEEdge = __webpack_require__(2);
  3460. var CoSEConstants = __webpack_require__(1);
  3461. var FDLayoutConstants = __webpack_require__(0).FDLayoutConstants;
  3462. var LayoutConstants = __webpack_require__(0).LayoutConstants;
  3463. var Point2 = __webpack_require__(0).Point;
  3464. var PointD = __webpack_require__(0).PointD;
  3465. var Layout2 = __webpack_require__(0).Layout;
  3466. var Integer = __webpack_require__(0).Integer;
  3467. var IGeometry = __webpack_require__(0).IGeometry;
  3468. var LGraph = __webpack_require__(0).LGraph;
  3469. var Transform = __webpack_require__(0).Transform;
  3470. function CoSELayout() {
  3471. FDLayout.call(this);
  3472. this.toBeTiled = {};
  3473. }
  3474. CoSELayout.prototype = Object.create(FDLayout.prototype);
  3475. for (var prop in FDLayout) {
  3476. CoSELayout[prop] = FDLayout[prop];
  3477. }
  3478. CoSELayout.prototype.newGraphManager = function() {
  3479. var gm = new CoSEGraphManager(this);
  3480. this.graphManager = gm;
  3481. return gm;
  3482. };
  3483. CoSELayout.prototype.newGraph = function(vGraph) {
  3484. return new CoSEGraph(null, this.graphManager, vGraph);
  3485. };
  3486. CoSELayout.prototype.newNode = function(vNode) {
  3487. return new CoSENode(this.graphManager, vNode);
  3488. };
  3489. CoSELayout.prototype.newEdge = function(vEdge) {
  3490. return new CoSEEdge(null, null, vEdge);
  3491. };
  3492. CoSELayout.prototype.initParameters = function() {
  3493. FDLayout.prototype.initParameters.call(this, arguments);
  3494. if (!this.isSubLayout) {
  3495. if (CoSEConstants.DEFAULT_EDGE_LENGTH < 10) {
  3496. this.idealEdgeLength = 10;
  3497. } else {
  3498. this.idealEdgeLength = CoSEConstants.DEFAULT_EDGE_LENGTH;
  3499. }
  3500. this.useSmartIdealEdgeLengthCalculation = CoSEConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION;
  3501. this.springConstant = FDLayoutConstants.DEFAULT_SPRING_STRENGTH;
  3502. this.repulsionConstant = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH;
  3503. this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH;
  3504. this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH;
  3505. this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR;
  3506. this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR;
  3507. this.prunedNodesAll = [];
  3508. this.growTreeIterations = 0;
  3509. this.afterGrowthIterations = 0;
  3510. this.isTreeGrowing = false;
  3511. this.isGrowthFinished = false;
  3512. this.coolingCycle = 0;
  3513. this.maxCoolingCycle = this.maxIterations / FDLayoutConstants.CONVERGENCE_CHECK_PERIOD;
  3514. this.finalTemperature = FDLayoutConstants.CONVERGENCE_CHECK_PERIOD / this.maxIterations;
  3515. this.coolingAdjuster = 1;
  3516. }
  3517. };
  3518. CoSELayout.prototype.layout = function() {
  3519. var createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED;
  3520. if (createBendsAsNeeded) {
  3521. this.createBendpoints();
  3522. this.graphManager.resetAllEdges();
  3523. }
  3524. this.level = 0;
  3525. return this.classicLayout();
  3526. };
  3527. CoSELayout.prototype.classicLayout = function() {
  3528. this.nodesWithGravity = this.calculateNodesToApplyGravitationTo();
  3529. this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity);
  3530. this.calcNoOfChildrenForAllNodes();
  3531. this.graphManager.calcLowestCommonAncestors();
  3532. this.graphManager.calcInclusionTreeDepths();
  3533. this.graphManager.getRoot().calcEstimatedSize();
  3534. this.calcIdealEdgeLengths();
  3535. if (!this.incremental) {
  3536. var forest = this.getFlatForest();
  3537. if (forest.length > 0) {
  3538. this.positionNodesRadially(forest);
  3539. } else {
  3540. this.reduceTrees();
  3541. this.graphManager.resetAllNodesToApplyGravitation();
  3542. var allNodes = new Set(this.getAllNodes());
  3543. var intersection = this.nodesWithGravity.filter(function(x) {
  3544. return allNodes.has(x);
  3545. });
  3546. this.graphManager.setAllNodesToApplyGravitation(intersection);
  3547. this.positionNodesRandomly();
  3548. }
  3549. } else {
  3550. if (CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL) {
  3551. this.reduceTrees();
  3552. this.graphManager.resetAllNodesToApplyGravitation();
  3553. var allNodes = new Set(this.getAllNodes());
  3554. var intersection = this.nodesWithGravity.filter(function(x) {
  3555. return allNodes.has(x);
  3556. });
  3557. this.graphManager.setAllNodesToApplyGravitation(intersection);
  3558. }
  3559. }
  3560. this.initSpringEmbedder();
  3561. this.runSpringEmbedder();
  3562. return true;
  3563. };
  3564. CoSELayout.prototype.tick = function() {
  3565. this.totalIterations++;
  3566. if (this.totalIterations === this.maxIterations && !this.isTreeGrowing && !this.isGrowthFinished) {
  3567. if (this.prunedNodesAll.length > 0) {
  3568. this.isTreeGrowing = true;
  3569. } else {
  3570. return true;
  3571. }
  3572. }
  3573. if (this.totalIterations % FDLayoutConstants.CONVERGENCE_CHECK_PERIOD == 0 && !this.isTreeGrowing && !this.isGrowthFinished) {
  3574. if (this.isConverged()) {
  3575. if (this.prunedNodesAll.length > 0) {
  3576. this.isTreeGrowing = true;
  3577. } else {
  3578. return true;
  3579. }
  3580. }
  3581. this.coolingCycle++;
  3582. if (this.layoutQuality == 0) {
  3583. this.coolingAdjuster = this.coolingCycle;
  3584. } else if (this.layoutQuality == 1) {
  3585. this.coolingAdjuster = this.coolingCycle / 3;
  3586. }
  3587. this.coolingFactor = Math.max(this.initialCoolingFactor - Math.pow(this.coolingCycle, Math.log(100 * (this.initialCoolingFactor - this.finalTemperature)) / Math.log(this.maxCoolingCycle)) / 100 * this.coolingAdjuster, this.finalTemperature);
  3588. this.animationPeriod = Math.ceil(this.initialAnimationPeriod * Math.sqrt(this.coolingFactor));
  3589. }
  3590. if (this.isTreeGrowing) {
  3591. if (this.growTreeIterations % 10 == 0) {
  3592. if (this.prunedNodesAll.length > 0) {
  3593. this.graphManager.updateBounds();
  3594. this.updateGrid();
  3595. this.growTree(this.prunedNodesAll);
  3596. this.graphManager.resetAllNodesToApplyGravitation();
  3597. var allNodes = new Set(this.getAllNodes());
  3598. var intersection = this.nodesWithGravity.filter(function(x) {
  3599. return allNodes.has(x);
  3600. });
  3601. this.graphManager.setAllNodesToApplyGravitation(intersection);
  3602. this.graphManager.updateBounds();
  3603. this.updateGrid();
  3604. this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL;
  3605. } else {
  3606. this.isTreeGrowing = false;
  3607. this.isGrowthFinished = true;
  3608. }
  3609. }
  3610. this.growTreeIterations++;
  3611. }
  3612. if (this.isGrowthFinished) {
  3613. if (this.isConverged()) {
  3614. return true;
  3615. }
  3616. if (this.afterGrowthIterations % 10 == 0) {
  3617. this.graphManager.updateBounds();
  3618. this.updateGrid();
  3619. }
  3620. this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL * ((100 - this.afterGrowthIterations) / 100);
  3621. this.afterGrowthIterations++;
  3622. }
  3623. var gridUpdateAllowed = !this.isTreeGrowing && !this.isGrowthFinished;
  3624. var forceToNodeSurroundingUpdate = this.growTreeIterations % 10 == 1 && this.isTreeGrowing || this.afterGrowthIterations % 10 == 1 && this.isGrowthFinished;
  3625. this.totalDisplacement = 0;
  3626. this.graphManager.updateBounds();
  3627. this.calcSpringForces();
  3628. this.calcRepulsionForces(gridUpdateAllowed, forceToNodeSurroundingUpdate);
  3629. this.calcGravitationalForces();
  3630. this.moveNodes();
  3631. this.animate();
  3632. return false;
  3633. };
  3634. CoSELayout.prototype.getPositionsData = function() {
  3635. var allNodes = this.graphManager.getAllNodes();
  3636. var pData = {};
  3637. for (var i = 0; i < allNodes.length; i++) {
  3638. var rect = allNodes[i].rect;
  3639. var id = allNodes[i].id;
  3640. pData[id] = {
  3641. id,
  3642. x: rect.getCenterX(),
  3643. y: rect.getCenterY(),
  3644. w: rect.width,
  3645. h: rect.height
  3646. };
  3647. }
  3648. return pData;
  3649. };
  3650. CoSELayout.prototype.runSpringEmbedder = function() {
  3651. this.initialAnimationPeriod = 25;
  3652. this.animationPeriod = this.initialAnimationPeriod;
  3653. var layoutEnded = false;
  3654. if (FDLayoutConstants.ANIMATE === "during") {
  3655. this.emit("layoutstarted");
  3656. } else {
  3657. while (!layoutEnded) {
  3658. layoutEnded = this.tick();
  3659. }
  3660. this.graphManager.updateBounds();
  3661. }
  3662. };
  3663. CoSELayout.prototype.calculateNodesToApplyGravitationTo = function() {
  3664. var nodeList = [];
  3665. var graph;
  3666. var graphs = this.graphManager.getGraphs();
  3667. var size = graphs.length;
  3668. var i;
  3669. for (i = 0; i < size; i++) {
  3670. graph = graphs[i];
  3671. graph.updateConnected();
  3672. if (!graph.isConnected) {
  3673. nodeList = nodeList.concat(graph.getNodes());
  3674. }
  3675. }
  3676. return nodeList;
  3677. };
  3678. CoSELayout.prototype.createBendpoints = function() {
  3679. var edges = [];
  3680. edges = edges.concat(this.graphManager.getAllEdges());
  3681. var visited = /* @__PURE__ */ new Set();
  3682. var i;
  3683. for (i = 0; i < edges.length; i++) {
  3684. var edge = edges[i];
  3685. if (!visited.has(edge)) {
  3686. var source = edge.getSource();
  3687. var target = edge.getTarget();
  3688. if (source == target) {
  3689. edge.getBendpoints().push(new PointD());
  3690. edge.getBendpoints().push(new PointD());
  3691. this.createDummyNodesForBendpoints(edge);
  3692. visited.add(edge);
  3693. } else {
  3694. var edgeList = [];
  3695. edgeList = edgeList.concat(source.getEdgeListToNode(target));
  3696. edgeList = edgeList.concat(target.getEdgeListToNode(source));
  3697. if (!visited.has(edgeList[0])) {
  3698. if (edgeList.length > 1) {
  3699. var k;
  3700. for (k = 0; k < edgeList.length; k++) {
  3701. var multiEdge = edgeList[k];
  3702. multiEdge.getBendpoints().push(new PointD());
  3703. this.createDummyNodesForBendpoints(multiEdge);
  3704. }
  3705. }
  3706. edgeList.forEach(function(edge2) {
  3707. visited.add(edge2);
  3708. });
  3709. }
  3710. }
  3711. }
  3712. if (visited.size == edges.length) {
  3713. break;
  3714. }
  3715. }
  3716. };
  3717. CoSELayout.prototype.positionNodesRadially = function(forest) {
  3718. var currentStartingPoint = new Point2(0, 0);
  3719. var numberOfColumns = Math.ceil(Math.sqrt(forest.length));
  3720. var height = 0;
  3721. var currentY = 0;
  3722. var currentX = 0;
  3723. var point = new PointD(0, 0);
  3724. for (var i = 0; i < forest.length; i++) {
  3725. if (i % numberOfColumns == 0) {
  3726. currentX = 0;
  3727. currentY = height;
  3728. if (i != 0) {
  3729. currentY += CoSEConstants.DEFAULT_COMPONENT_SEPERATION;
  3730. }
  3731. height = 0;
  3732. }
  3733. var tree = forest[i];
  3734. var centerNode = Layout2.findCenterOfTree(tree);
  3735. currentStartingPoint.x = currentX;
  3736. currentStartingPoint.y = currentY;
  3737. point = CoSELayout.radialLayout(tree, centerNode, currentStartingPoint);
  3738. if (point.y > height) {
  3739. height = Math.floor(point.y);
  3740. }
  3741. currentX = Math.floor(point.x + CoSEConstants.DEFAULT_COMPONENT_SEPERATION);
  3742. }
  3743. this.transform(new PointD(LayoutConstants.WORLD_CENTER_X - point.x / 2, LayoutConstants.WORLD_CENTER_Y - point.y / 2));
  3744. };
  3745. CoSELayout.radialLayout = function(tree, centerNode, startingPoint) {
  3746. var radialSep = Math.max(this.maxDiagonalInTree(tree), CoSEConstants.DEFAULT_RADIAL_SEPARATION);
  3747. CoSELayout.branchRadialLayout(centerNode, null, 0, 359, 0, radialSep);
  3748. var bounds = LGraph.calculateBounds(tree);
  3749. var transform = new Transform();
  3750. transform.setDeviceOrgX(bounds.getMinX());
  3751. transform.setDeviceOrgY(bounds.getMinY());
  3752. transform.setWorldOrgX(startingPoint.x);
  3753. transform.setWorldOrgY(startingPoint.y);
  3754. for (var i = 0; i < tree.length; i++) {
  3755. var node = tree[i];
  3756. node.transform(transform);
  3757. }
  3758. var bottomRight = new PointD(bounds.getMaxX(), bounds.getMaxY());
  3759. return transform.inverseTransformPoint(bottomRight);
  3760. };
  3761. CoSELayout.branchRadialLayout = function(node, parentOfNode, startAngle, endAngle, distance, radialSeparation) {
  3762. var halfInterval = (endAngle - startAngle + 1) / 2;
  3763. if (halfInterval < 0) {
  3764. halfInterval += 180;
  3765. }
  3766. var nodeAngle = (halfInterval + startAngle) % 360;
  3767. var teta = nodeAngle * IGeometry.TWO_PI / 360;
  3768. var cos_teta = Math.cos(teta);
  3769. var x_ = distance * Math.cos(teta);
  3770. var y_ = distance * Math.sin(teta);
  3771. node.setCenter(x_, y_);
  3772. var neighborEdges = [];
  3773. neighborEdges = neighborEdges.concat(node.getEdges());
  3774. var childCount = neighborEdges.length;
  3775. if (parentOfNode != null) {
  3776. childCount--;
  3777. }
  3778. var branchCount = 0;
  3779. var incEdgesCount = neighborEdges.length;
  3780. var startIndex;
  3781. var edges = node.getEdgesBetween(parentOfNode);
  3782. while (edges.length > 1) {
  3783. var temp = edges[0];
  3784. edges.splice(0, 1);
  3785. var index = neighborEdges.indexOf(temp);
  3786. if (index >= 0) {
  3787. neighborEdges.splice(index, 1);
  3788. }
  3789. incEdgesCount--;
  3790. childCount--;
  3791. }
  3792. if (parentOfNode != null) {
  3793. startIndex = (neighborEdges.indexOf(edges[0]) + 1) % incEdgesCount;
  3794. } else {
  3795. startIndex = 0;
  3796. }
  3797. var stepAngle = Math.abs(endAngle - startAngle) / childCount;
  3798. for (var i = startIndex; branchCount != childCount; i = ++i % incEdgesCount) {
  3799. var currentNeighbor = neighborEdges[i].getOtherEnd(node);
  3800. if (currentNeighbor == parentOfNode) {
  3801. continue;
  3802. }
  3803. var childStartAngle = (startAngle + branchCount * stepAngle) % 360;
  3804. var childEndAngle = (childStartAngle + stepAngle) % 360;
  3805. CoSELayout.branchRadialLayout(currentNeighbor, node, childStartAngle, childEndAngle, distance + radialSeparation, radialSeparation);
  3806. branchCount++;
  3807. }
  3808. };
  3809. CoSELayout.maxDiagonalInTree = function(tree) {
  3810. var maxDiagonal = Integer.MIN_VALUE;
  3811. for (var i = 0; i < tree.length; i++) {
  3812. var node = tree[i];
  3813. var diagonal = node.getDiagonal();
  3814. if (diagonal > maxDiagonal) {
  3815. maxDiagonal = diagonal;
  3816. }
  3817. }
  3818. return maxDiagonal;
  3819. };
  3820. CoSELayout.prototype.calcRepulsionRange = function() {
  3821. return 2 * (this.level + 1) * this.idealEdgeLength;
  3822. };
  3823. CoSELayout.prototype.groupZeroDegreeMembers = function() {
  3824. var self = this;
  3825. var tempMemberGroups = {};
  3826. this.memberGroups = {};
  3827. this.idToDummyNode = {};
  3828. var zeroDegree = [];
  3829. var allNodes = this.graphManager.getAllNodes();
  3830. for (var i = 0; i < allNodes.length; i++) {
  3831. var node = allNodes[i];
  3832. var parent = node.getParent();
  3833. if (this.getNodeDegreeWithChildren(node) === 0 && (parent.id == void 0 || !this.getToBeTiled(parent))) {
  3834. zeroDegree.push(node);
  3835. }
  3836. }
  3837. for (var i = 0; i < zeroDegree.length; i++) {
  3838. var node = zeroDegree[i];
  3839. var p_id = node.getParent().id;
  3840. if (typeof tempMemberGroups[p_id] === "undefined") tempMemberGroups[p_id] = [];
  3841. tempMemberGroups[p_id] = tempMemberGroups[p_id].concat(node);
  3842. }
  3843. Object.keys(tempMemberGroups).forEach(function(p_id2) {
  3844. if (tempMemberGroups[p_id2].length > 1) {
  3845. var dummyCompoundId = "DummyCompound_" + p_id2;
  3846. self.memberGroups[dummyCompoundId] = tempMemberGroups[p_id2];
  3847. var parent2 = tempMemberGroups[p_id2][0].getParent();
  3848. var dummyCompound = new CoSENode(self.graphManager);
  3849. dummyCompound.id = dummyCompoundId;
  3850. dummyCompound.paddingLeft = parent2.paddingLeft || 0;
  3851. dummyCompound.paddingRight = parent2.paddingRight || 0;
  3852. dummyCompound.paddingBottom = parent2.paddingBottom || 0;
  3853. dummyCompound.paddingTop = parent2.paddingTop || 0;
  3854. self.idToDummyNode[dummyCompoundId] = dummyCompound;
  3855. var dummyParentGraph = self.getGraphManager().add(self.newGraph(), dummyCompound);
  3856. var parentGraph = parent2.getChild();
  3857. parentGraph.add(dummyCompound);
  3858. for (var i2 = 0; i2 < tempMemberGroups[p_id2].length; i2++) {
  3859. var node2 = tempMemberGroups[p_id2][i2];
  3860. parentGraph.remove(node2);
  3861. dummyParentGraph.add(node2);
  3862. }
  3863. }
  3864. });
  3865. };
  3866. CoSELayout.prototype.clearCompounds = function() {
  3867. var childGraphMap = {};
  3868. var idToNode = {};
  3869. this.performDFSOnCompounds();
  3870. for (var i = 0; i < this.compoundOrder.length; i++) {
  3871. idToNode[this.compoundOrder[i].id] = this.compoundOrder[i];
  3872. childGraphMap[this.compoundOrder[i].id] = [].concat(this.compoundOrder[i].getChild().getNodes());
  3873. this.graphManager.remove(this.compoundOrder[i].getChild());
  3874. this.compoundOrder[i].child = null;
  3875. }
  3876. this.graphManager.resetAllNodes();
  3877. this.tileCompoundMembers(childGraphMap, idToNode);
  3878. };
  3879. CoSELayout.prototype.clearZeroDegreeMembers = function() {
  3880. var self = this;
  3881. var tiledZeroDegreePack = this.tiledZeroDegreePack = [];
  3882. Object.keys(this.memberGroups).forEach(function(id) {
  3883. var compoundNode = self.idToDummyNode[id];
  3884. tiledZeroDegreePack[id] = self.tileNodes(self.memberGroups[id], compoundNode.paddingLeft + compoundNode.paddingRight);
  3885. compoundNode.rect.width = tiledZeroDegreePack[id].width;
  3886. compoundNode.rect.height = tiledZeroDegreePack[id].height;
  3887. });
  3888. };
  3889. CoSELayout.prototype.repopulateCompounds = function() {
  3890. for (var i = this.compoundOrder.length - 1; i >= 0; i--) {
  3891. var lCompoundNode = this.compoundOrder[i];
  3892. var id = lCompoundNode.id;
  3893. var horizontalMargin = lCompoundNode.paddingLeft;
  3894. var verticalMargin = lCompoundNode.paddingTop;
  3895. this.adjustLocations(this.tiledMemberPack[id], lCompoundNode.rect.x, lCompoundNode.rect.y, horizontalMargin, verticalMargin);
  3896. }
  3897. };
  3898. CoSELayout.prototype.repopulateZeroDegreeMembers = function() {
  3899. var self = this;
  3900. var tiledPack = this.tiledZeroDegreePack;
  3901. Object.keys(tiledPack).forEach(function(id) {
  3902. var compoundNode = self.idToDummyNode[id];
  3903. var horizontalMargin = compoundNode.paddingLeft;
  3904. var verticalMargin = compoundNode.paddingTop;
  3905. self.adjustLocations(tiledPack[id], compoundNode.rect.x, compoundNode.rect.y, horizontalMargin, verticalMargin);
  3906. });
  3907. };
  3908. CoSELayout.prototype.getToBeTiled = function(node) {
  3909. var id = node.id;
  3910. if (this.toBeTiled[id] != null) {
  3911. return this.toBeTiled[id];
  3912. }
  3913. var childGraph = node.getChild();
  3914. if (childGraph == null) {
  3915. this.toBeTiled[id] = false;
  3916. return false;
  3917. }
  3918. var children = childGraph.getNodes();
  3919. for (var i = 0; i < children.length; i++) {
  3920. var theChild = children[i];
  3921. if (this.getNodeDegree(theChild) > 0) {
  3922. this.toBeTiled[id] = false;
  3923. return false;
  3924. }
  3925. if (theChild.getChild() == null) {
  3926. this.toBeTiled[theChild.id] = false;
  3927. continue;
  3928. }
  3929. if (!this.getToBeTiled(theChild)) {
  3930. this.toBeTiled[id] = false;
  3931. return false;
  3932. }
  3933. }
  3934. this.toBeTiled[id] = true;
  3935. return true;
  3936. };
  3937. CoSELayout.prototype.getNodeDegree = function(node) {
  3938. var id = node.id;
  3939. var edges = node.getEdges();
  3940. var degree = 0;
  3941. for (var i = 0; i < edges.length; i++) {
  3942. var edge = edges[i];
  3943. if (edge.getSource().id !== edge.getTarget().id) {
  3944. degree = degree + 1;
  3945. }
  3946. }
  3947. return degree;
  3948. };
  3949. CoSELayout.prototype.getNodeDegreeWithChildren = function(node) {
  3950. var degree = this.getNodeDegree(node);
  3951. if (node.getChild() == null) {
  3952. return degree;
  3953. }
  3954. var children = node.getChild().getNodes();
  3955. for (var i = 0; i < children.length; i++) {
  3956. var child = children[i];
  3957. degree += this.getNodeDegreeWithChildren(child);
  3958. }
  3959. return degree;
  3960. };
  3961. CoSELayout.prototype.performDFSOnCompounds = function() {
  3962. this.compoundOrder = [];
  3963. this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes());
  3964. };
  3965. CoSELayout.prototype.fillCompexOrderByDFS = function(children) {
  3966. for (var i = 0; i < children.length; i++) {
  3967. var child = children[i];
  3968. if (child.getChild() != null) {
  3969. this.fillCompexOrderByDFS(child.getChild().getNodes());
  3970. }
  3971. if (this.getToBeTiled(child)) {
  3972. this.compoundOrder.push(child);
  3973. }
  3974. }
  3975. };
  3976. CoSELayout.prototype.adjustLocations = function(organization, x, y, compoundHorizontalMargin, compoundVerticalMargin) {
  3977. x += compoundHorizontalMargin;
  3978. y += compoundVerticalMargin;
  3979. var left = x;
  3980. for (var i = 0; i < organization.rows.length; i++) {
  3981. var row = organization.rows[i];
  3982. x = left;
  3983. var maxHeight = 0;
  3984. for (var j = 0; j < row.length; j++) {
  3985. var lnode = row[j];
  3986. lnode.rect.x = x;
  3987. lnode.rect.y = y;
  3988. x += lnode.rect.width + organization.horizontalPadding;
  3989. if (lnode.rect.height > maxHeight) maxHeight = lnode.rect.height;
  3990. }
  3991. y += maxHeight + organization.verticalPadding;
  3992. }
  3993. };
  3994. CoSELayout.prototype.tileCompoundMembers = function(childGraphMap, idToNode) {
  3995. var self = this;
  3996. this.tiledMemberPack = [];
  3997. Object.keys(childGraphMap).forEach(function(id) {
  3998. var compoundNode = idToNode[id];
  3999. self.tiledMemberPack[id] = self.tileNodes(childGraphMap[id], compoundNode.paddingLeft + compoundNode.paddingRight);
  4000. compoundNode.rect.width = self.tiledMemberPack[id].width;
  4001. compoundNode.rect.height = self.tiledMemberPack[id].height;
  4002. });
  4003. };
  4004. CoSELayout.prototype.tileNodes = function(nodes, minWidth) {
  4005. var verticalPadding = CoSEConstants.TILING_PADDING_VERTICAL;
  4006. var horizontalPadding = CoSEConstants.TILING_PADDING_HORIZONTAL;
  4007. var organization = {
  4008. rows: [],
  4009. rowWidth: [],
  4010. rowHeight: [],
  4011. width: 0,
  4012. height: minWidth,
  4013. // assume minHeight equals to minWidth
  4014. verticalPadding,
  4015. horizontalPadding
  4016. };
  4017. nodes.sort(function(n1, n2) {
  4018. if (n1.rect.width * n1.rect.height > n2.rect.width * n2.rect.height) return -1;
  4019. if (n1.rect.width * n1.rect.height < n2.rect.width * n2.rect.height) return 1;
  4020. return 0;
  4021. });
  4022. for (var i = 0; i < nodes.length; i++) {
  4023. var lNode = nodes[i];
  4024. if (organization.rows.length == 0) {
  4025. this.insertNodeToRow(organization, lNode, 0, minWidth);
  4026. } else if (this.canAddHorizontal(organization, lNode.rect.width, lNode.rect.height)) {
  4027. this.insertNodeToRow(organization, lNode, this.getShortestRowIndex(organization), minWidth);
  4028. } else {
  4029. this.insertNodeToRow(organization, lNode, organization.rows.length, minWidth);
  4030. }
  4031. this.shiftToLastRow(organization);
  4032. }
  4033. return organization;
  4034. };
  4035. CoSELayout.prototype.insertNodeToRow = function(organization, node, rowIndex, minWidth) {
  4036. var minCompoundSize = minWidth;
  4037. if (rowIndex == organization.rows.length) {
  4038. var secondDimension = [];
  4039. organization.rows.push(secondDimension);
  4040. organization.rowWidth.push(minCompoundSize);
  4041. organization.rowHeight.push(0);
  4042. }
  4043. var w = organization.rowWidth[rowIndex] + node.rect.width;
  4044. if (organization.rows[rowIndex].length > 0) {
  4045. w += organization.horizontalPadding;
  4046. }
  4047. organization.rowWidth[rowIndex] = w;
  4048. if (organization.width < w) {
  4049. organization.width = w;
  4050. }
  4051. var h = node.rect.height;
  4052. if (rowIndex > 0) h += organization.verticalPadding;
  4053. var extraHeight = 0;
  4054. if (h > organization.rowHeight[rowIndex]) {
  4055. extraHeight = organization.rowHeight[rowIndex];
  4056. organization.rowHeight[rowIndex] = h;
  4057. extraHeight = organization.rowHeight[rowIndex] - extraHeight;
  4058. }
  4059. organization.height += extraHeight;
  4060. organization.rows[rowIndex].push(node);
  4061. };
  4062. CoSELayout.prototype.getShortestRowIndex = function(organization) {
  4063. var r = -1;
  4064. var min = Number.MAX_VALUE;
  4065. for (var i = 0; i < organization.rows.length; i++) {
  4066. if (organization.rowWidth[i] < min) {
  4067. r = i;
  4068. min = organization.rowWidth[i];
  4069. }
  4070. }
  4071. return r;
  4072. };
  4073. CoSELayout.prototype.getLongestRowIndex = function(organization) {
  4074. var r = -1;
  4075. var max = Number.MIN_VALUE;
  4076. for (var i = 0; i < organization.rows.length; i++) {
  4077. if (organization.rowWidth[i] > max) {
  4078. r = i;
  4079. max = organization.rowWidth[i];
  4080. }
  4081. }
  4082. return r;
  4083. };
  4084. CoSELayout.prototype.canAddHorizontal = function(organization, extraWidth, extraHeight) {
  4085. var sri = this.getShortestRowIndex(organization);
  4086. if (sri < 0) {
  4087. return true;
  4088. }
  4089. var min = organization.rowWidth[sri];
  4090. if (min + organization.horizontalPadding + extraWidth <= organization.width) return true;
  4091. var hDiff = 0;
  4092. if (organization.rowHeight[sri] < extraHeight) {
  4093. if (sri > 0) hDiff = extraHeight + organization.verticalPadding - organization.rowHeight[sri];
  4094. }
  4095. var add_to_row_ratio;
  4096. if (organization.width - min >= extraWidth + organization.horizontalPadding) {
  4097. add_to_row_ratio = (organization.height + hDiff) / (min + extraWidth + organization.horizontalPadding);
  4098. } else {
  4099. add_to_row_ratio = (organization.height + hDiff) / organization.width;
  4100. }
  4101. hDiff = extraHeight + organization.verticalPadding;
  4102. var add_new_row_ratio;
  4103. if (organization.width < extraWidth) {
  4104. add_new_row_ratio = (organization.height + hDiff) / extraWidth;
  4105. } else {
  4106. add_new_row_ratio = (organization.height + hDiff) / organization.width;
  4107. }
  4108. if (add_new_row_ratio < 1) add_new_row_ratio = 1 / add_new_row_ratio;
  4109. if (add_to_row_ratio < 1) add_to_row_ratio = 1 / add_to_row_ratio;
  4110. return add_to_row_ratio < add_new_row_ratio;
  4111. };
  4112. CoSELayout.prototype.shiftToLastRow = function(organization) {
  4113. var longest = this.getLongestRowIndex(organization);
  4114. var last = organization.rowWidth.length - 1;
  4115. var row = organization.rows[longest];
  4116. var node = row[row.length - 1];
  4117. var diff = node.width + organization.horizontalPadding;
  4118. if (organization.width - organization.rowWidth[last] > diff && longest != last) {
  4119. row.splice(-1, 1);
  4120. organization.rows[last].push(node);
  4121. organization.rowWidth[longest] = organization.rowWidth[longest] - diff;
  4122. organization.rowWidth[last] = organization.rowWidth[last] + diff;
  4123. organization.width = organization.rowWidth[instance.getLongestRowIndex(organization)];
  4124. var maxHeight = Number.MIN_VALUE;
  4125. for (var i = 0; i < row.length; i++) {
  4126. if (row[i].height > maxHeight) maxHeight = row[i].height;
  4127. }
  4128. if (longest > 0) maxHeight += organization.verticalPadding;
  4129. var prevTotal = organization.rowHeight[longest] + organization.rowHeight[last];
  4130. organization.rowHeight[longest] = maxHeight;
  4131. if (organization.rowHeight[last] < node.height + organization.verticalPadding) organization.rowHeight[last] = node.height + organization.verticalPadding;
  4132. var finalTotal = organization.rowHeight[longest] + organization.rowHeight[last];
  4133. organization.height += finalTotal - prevTotal;
  4134. this.shiftToLastRow(organization);
  4135. }
  4136. };
  4137. CoSELayout.prototype.tilingPreLayout = function() {
  4138. if (CoSEConstants.TILE) {
  4139. this.groupZeroDegreeMembers();
  4140. this.clearCompounds();
  4141. this.clearZeroDegreeMembers();
  4142. }
  4143. };
  4144. CoSELayout.prototype.tilingPostLayout = function() {
  4145. if (CoSEConstants.TILE) {
  4146. this.repopulateZeroDegreeMembers();
  4147. this.repopulateCompounds();
  4148. }
  4149. };
  4150. CoSELayout.prototype.reduceTrees = function() {
  4151. var prunedNodesAll = [];
  4152. var containsLeaf = true;
  4153. var node;
  4154. while (containsLeaf) {
  4155. var allNodes = this.graphManager.getAllNodes();
  4156. var prunedNodesInStepTemp = [];
  4157. containsLeaf = false;
  4158. for (var i = 0; i < allNodes.length; i++) {
  4159. node = allNodes[i];
  4160. if (node.getEdges().length == 1 && !node.getEdges()[0].isInterGraph && node.getChild() == null) {
  4161. prunedNodesInStepTemp.push([node, node.getEdges()[0], node.getOwner()]);
  4162. containsLeaf = true;
  4163. }
  4164. }
  4165. if (containsLeaf == true) {
  4166. var prunedNodesInStep = [];
  4167. for (var j = 0; j < prunedNodesInStepTemp.length; j++) {
  4168. if (prunedNodesInStepTemp[j][0].getEdges().length == 1) {
  4169. prunedNodesInStep.push(prunedNodesInStepTemp[j]);
  4170. prunedNodesInStepTemp[j][0].getOwner().remove(prunedNodesInStepTemp[j][0]);
  4171. }
  4172. }
  4173. prunedNodesAll.push(prunedNodesInStep);
  4174. this.graphManager.resetAllNodes();
  4175. this.graphManager.resetAllEdges();
  4176. }
  4177. }
  4178. this.prunedNodesAll = prunedNodesAll;
  4179. };
  4180. CoSELayout.prototype.growTree = function(prunedNodesAll) {
  4181. var lengthOfPrunedNodesInStep = prunedNodesAll.length;
  4182. var prunedNodesInStep = prunedNodesAll[lengthOfPrunedNodesInStep - 1];
  4183. var nodeData;
  4184. for (var i = 0; i < prunedNodesInStep.length; i++) {
  4185. nodeData = prunedNodesInStep[i];
  4186. this.findPlaceforPrunedNode(nodeData);
  4187. nodeData[2].add(nodeData[0]);
  4188. nodeData[2].add(nodeData[1], nodeData[1].source, nodeData[1].target);
  4189. }
  4190. prunedNodesAll.splice(prunedNodesAll.length - 1, 1);
  4191. this.graphManager.resetAllNodes();
  4192. this.graphManager.resetAllEdges();
  4193. };
  4194. CoSELayout.prototype.findPlaceforPrunedNode = function(nodeData) {
  4195. var gridForPrunedNode;
  4196. var nodeToConnect;
  4197. var prunedNode = nodeData[0];
  4198. if (prunedNode == nodeData[1].source) {
  4199. nodeToConnect = nodeData[1].target;
  4200. } else {
  4201. nodeToConnect = nodeData[1].source;
  4202. }
  4203. var startGridX = nodeToConnect.startX;
  4204. var finishGridX = nodeToConnect.finishX;
  4205. var startGridY = nodeToConnect.startY;
  4206. var finishGridY = nodeToConnect.finishY;
  4207. var upNodeCount = 0;
  4208. var downNodeCount = 0;
  4209. var rightNodeCount = 0;
  4210. var leftNodeCount = 0;
  4211. var controlRegions = [upNodeCount, rightNodeCount, downNodeCount, leftNodeCount];
  4212. if (startGridY > 0) {
  4213. for (var i = startGridX; i <= finishGridX; i++) {
  4214. controlRegions[0] += this.grid[i][startGridY - 1].length + this.grid[i][startGridY].length - 1;
  4215. }
  4216. }
  4217. if (finishGridX < this.grid.length - 1) {
  4218. for (var i = startGridY; i <= finishGridY; i++) {
  4219. controlRegions[1] += this.grid[finishGridX + 1][i].length + this.grid[finishGridX][i].length - 1;
  4220. }
  4221. }
  4222. if (finishGridY < this.grid[0].length - 1) {
  4223. for (var i = startGridX; i <= finishGridX; i++) {
  4224. controlRegions[2] += this.grid[i][finishGridY + 1].length + this.grid[i][finishGridY].length - 1;
  4225. }
  4226. }
  4227. if (startGridX > 0) {
  4228. for (var i = startGridY; i <= finishGridY; i++) {
  4229. controlRegions[3] += this.grid[startGridX - 1][i].length + this.grid[startGridX][i].length - 1;
  4230. }
  4231. }
  4232. var min = Integer.MAX_VALUE;
  4233. var minCount;
  4234. var minIndex;
  4235. for (var j = 0; j < controlRegions.length; j++) {
  4236. if (controlRegions[j] < min) {
  4237. min = controlRegions[j];
  4238. minCount = 1;
  4239. minIndex = j;
  4240. } else if (controlRegions[j] == min) {
  4241. minCount++;
  4242. }
  4243. }
  4244. if (minCount == 3 && min == 0) {
  4245. if (controlRegions[0] == 0 && controlRegions[1] == 0 && controlRegions[2] == 0) {
  4246. gridForPrunedNode = 1;
  4247. } else if (controlRegions[0] == 0 && controlRegions[1] == 0 && controlRegions[3] == 0) {
  4248. gridForPrunedNode = 0;
  4249. } else if (controlRegions[0] == 0 && controlRegions[2] == 0 && controlRegions[3] == 0) {
  4250. gridForPrunedNode = 3;
  4251. } else if (controlRegions[1] == 0 && controlRegions[2] == 0 && controlRegions[3] == 0) {
  4252. gridForPrunedNode = 2;
  4253. }
  4254. } else if (minCount == 2 && min == 0) {
  4255. var random = Math.floor(Math.random() * 2);
  4256. if (controlRegions[0] == 0 && controlRegions[1] == 0) {
  4257. ;
  4258. if (random == 0) {
  4259. gridForPrunedNode = 0;
  4260. } else {
  4261. gridForPrunedNode = 1;
  4262. }
  4263. } else if (controlRegions[0] == 0 && controlRegions[2] == 0) {
  4264. if (random == 0) {
  4265. gridForPrunedNode = 0;
  4266. } else {
  4267. gridForPrunedNode = 2;
  4268. }
  4269. } else if (controlRegions[0] == 0 && controlRegions[3] == 0) {
  4270. if (random == 0) {
  4271. gridForPrunedNode = 0;
  4272. } else {
  4273. gridForPrunedNode = 3;
  4274. }
  4275. } else if (controlRegions[1] == 0 && controlRegions[2] == 0) {
  4276. if (random == 0) {
  4277. gridForPrunedNode = 1;
  4278. } else {
  4279. gridForPrunedNode = 2;
  4280. }
  4281. } else if (controlRegions[1] == 0 && controlRegions[3] == 0) {
  4282. if (random == 0) {
  4283. gridForPrunedNode = 1;
  4284. } else {
  4285. gridForPrunedNode = 3;
  4286. }
  4287. } else {
  4288. if (random == 0) {
  4289. gridForPrunedNode = 2;
  4290. } else {
  4291. gridForPrunedNode = 3;
  4292. }
  4293. }
  4294. } else if (minCount == 4 && min == 0) {
  4295. var random = Math.floor(Math.random() * 4);
  4296. gridForPrunedNode = random;
  4297. } else {
  4298. gridForPrunedNode = minIndex;
  4299. }
  4300. if (gridForPrunedNode == 0) {
  4301. prunedNode.setCenter(nodeToConnect.getCenterX(), nodeToConnect.getCenterY() - nodeToConnect.getHeight() / 2 - FDLayoutConstants.DEFAULT_EDGE_LENGTH - prunedNode.getHeight() / 2);
  4302. } else if (gridForPrunedNode == 1) {
  4303. prunedNode.setCenter(nodeToConnect.getCenterX() + nodeToConnect.getWidth() / 2 + FDLayoutConstants.DEFAULT_EDGE_LENGTH + prunedNode.getWidth() / 2, nodeToConnect.getCenterY());
  4304. } else if (gridForPrunedNode == 2) {
  4305. prunedNode.setCenter(nodeToConnect.getCenterX(), nodeToConnect.getCenterY() + nodeToConnect.getHeight() / 2 + FDLayoutConstants.DEFAULT_EDGE_LENGTH + prunedNode.getHeight() / 2);
  4306. } else {
  4307. prunedNode.setCenter(nodeToConnect.getCenterX() - nodeToConnect.getWidth() / 2 - FDLayoutConstants.DEFAULT_EDGE_LENGTH - prunedNode.getWidth() / 2, nodeToConnect.getCenterY());
  4308. }
  4309. };
  4310. module2.exports = CoSELayout;
  4311. }),
  4312. /* 7 */
  4313. /***/
  4314. (function(module2, exports2, __webpack_require__) {
  4315. "use strict";
  4316. var coseBase = {};
  4317. coseBase.layoutBase = __webpack_require__(0);
  4318. coseBase.CoSEConstants = __webpack_require__(1);
  4319. coseBase.CoSEEdge = __webpack_require__(2);
  4320. coseBase.CoSEGraph = __webpack_require__(3);
  4321. coseBase.CoSEGraphManager = __webpack_require__(4);
  4322. coseBase.CoSELayout = __webpack_require__(6);
  4323. coseBase.CoSENode = __webpack_require__(5);
  4324. module2.exports = coseBase;
  4325. })
  4326. /******/
  4327. ])
  4328. );
  4329. });
  4330. }
  4331. });
  4332. // node_modules/cytoscape-cose-bilkent/cytoscape-cose-bilkent.js
  4333. var require_cytoscape_cose_bilkent = __commonJS({
  4334. "node_modules/cytoscape-cose-bilkent/cytoscape-cose-bilkent.js"(exports, module) {
  4335. (function webpackUniversalModuleDefinition(root, factory) {
  4336. if (typeof exports === "object" && typeof module === "object")
  4337. module.exports = factory(require_cose_base());
  4338. else if (typeof define === "function" && define.amd)
  4339. define(["cose-base"], factory);
  4340. else if (typeof exports === "object")
  4341. exports["cytoscapeCoseBilkent"] = factory(require_cose_base());
  4342. else
  4343. root["cytoscapeCoseBilkent"] = factory(root["coseBase"]);
  4344. })(exports, function(__WEBPACK_EXTERNAL_MODULE_0__) {
  4345. return (
  4346. /******/
  4347. (function(modules) {
  4348. var installedModules = {};
  4349. function __webpack_require__(moduleId) {
  4350. if (installedModules[moduleId]) {
  4351. return installedModules[moduleId].exports;
  4352. }
  4353. var module2 = installedModules[moduleId] = {
  4354. /******/
  4355. i: moduleId,
  4356. /******/
  4357. l: false,
  4358. /******/
  4359. exports: {}
  4360. /******/
  4361. };
  4362. modules[moduleId].call(module2.exports, module2, module2.exports, __webpack_require__);
  4363. module2.l = true;
  4364. return module2.exports;
  4365. }
  4366. __webpack_require__.m = modules;
  4367. __webpack_require__.c = installedModules;
  4368. __webpack_require__.i = function(value) {
  4369. return value;
  4370. };
  4371. __webpack_require__.d = function(exports2, name, getter) {
  4372. if (!__webpack_require__.o(exports2, name)) {
  4373. Object.defineProperty(exports2, name, {
  4374. /******/
  4375. configurable: false,
  4376. /******/
  4377. enumerable: true,
  4378. /******/
  4379. get: getter
  4380. /******/
  4381. });
  4382. }
  4383. };
  4384. __webpack_require__.n = function(module2) {
  4385. var getter = module2 && module2.__esModule ? (
  4386. /******/
  4387. function getDefault() {
  4388. return module2["default"];
  4389. }
  4390. ) : (
  4391. /******/
  4392. function getModuleExports() {
  4393. return module2;
  4394. }
  4395. );
  4396. __webpack_require__.d(getter, "a", getter);
  4397. return getter;
  4398. };
  4399. __webpack_require__.o = function(object, property) {
  4400. return Object.prototype.hasOwnProperty.call(object, property);
  4401. };
  4402. __webpack_require__.p = "";
  4403. return __webpack_require__(__webpack_require__.s = 1);
  4404. })([
  4405. /* 0 */
  4406. /***/
  4407. (function(module2, exports2) {
  4408. module2.exports = __WEBPACK_EXTERNAL_MODULE_0__;
  4409. }),
  4410. /* 1 */
  4411. /***/
  4412. (function(module2, exports2, __webpack_require__) {
  4413. "use strict";
  4414. var LayoutConstants = __webpack_require__(0).layoutBase.LayoutConstants;
  4415. var FDLayoutConstants = __webpack_require__(0).layoutBase.FDLayoutConstants;
  4416. var CoSEConstants = __webpack_require__(0).CoSEConstants;
  4417. var CoSELayout = __webpack_require__(0).CoSELayout;
  4418. var CoSENode = __webpack_require__(0).CoSENode;
  4419. var PointD = __webpack_require__(0).layoutBase.PointD;
  4420. var DimensionD2 = __webpack_require__(0).layoutBase.DimensionD;
  4421. var defaults = {
  4422. // Called on `layoutready`
  4423. ready: function ready() {
  4424. },
  4425. // Called on `layoutstop`
  4426. stop: function stop() {
  4427. },
  4428. // 'draft', 'default' or 'proof"
  4429. // - 'draft' fast cooling rate
  4430. // - 'default' moderate cooling rate
  4431. // - "proof" slow cooling rate
  4432. quality: "default",
  4433. // include labels in node dimensions
  4434. nodeDimensionsIncludeLabels: false,
  4435. // number of ticks per frame; higher is faster but more jerky
  4436. refresh: 30,
  4437. // Whether to fit the network view after when done
  4438. fit: true,
  4439. // Padding on fit
  4440. padding: 10,
  4441. // Whether to enable incremental mode
  4442. randomize: true,
  4443. // Node repulsion (non overlapping) multiplier
  4444. nodeRepulsion: 4500,
  4445. // Ideal edge (non nested) length
  4446. idealEdgeLength: 50,
  4447. // Divisor to compute edge forces
  4448. edgeElasticity: 0.45,
  4449. // Nesting factor (multiplier) to compute ideal edge length for nested edges
  4450. nestingFactor: 0.1,
  4451. // Gravity force (constant)
  4452. gravity: 0.25,
  4453. // Maximum number of iterations to perform
  4454. numIter: 2500,
  4455. // For enabling tiling
  4456. tile: true,
  4457. // Type of layout animation. The option set is {'during', 'end', false}
  4458. animate: "end",
  4459. // Duration for animate:end
  4460. animationDuration: 500,
  4461. // Represents the amount of the vertical space to put between the zero degree members during the tiling operation(can also be a function)
  4462. tilingPaddingVertical: 10,
  4463. // Represents the amount of the horizontal space to put between the zero degree members during the tiling operation(can also be a function)
  4464. tilingPaddingHorizontal: 10,
  4465. // Gravity range (constant) for compounds
  4466. gravityRangeCompound: 1.5,
  4467. // Gravity force (constant) for compounds
  4468. gravityCompound: 1,
  4469. // Gravity range (constant)
  4470. gravityRange: 3.8,
  4471. // Initial cooling factor for incremental layout
  4472. initialEnergyOnIncremental: 0.5
  4473. };
  4474. function extend(defaults2, options) {
  4475. var obj = {};
  4476. for (var i in defaults2) {
  4477. obj[i] = defaults2[i];
  4478. }
  4479. for (var i in options) {
  4480. obj[i] = options[i];
  4481. }
  4482. return obj;
  4483. }
  4484. ;
  4485. function _CoSELayout(_options) {
  4486. this.options = extend(defaults, _options);
  4487. getUserOptions(this.options);
  4488. }
  4489. var getUserOptions = function getUserOptions2(options) {
  4490. if (options.nodeRepulsion != null) CoSEConstants.DEFAULT_REPULSION_STRENGTH = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = options.nodeRepulsion;
  4491. if (options.idealEdgeLength != null) CoSEConstants.DEFAULT_EDGE_LENGTH = FDLayoutConstants.DEFAULT_EDGE_LENGTH = options.idealEdgeLength;
  4492. if (options.edgeElasticity != null) CoSEConstants.DEFAULT_SPRING_STRENGTH = FDLayoutConstants.DEFAULT_SPRING_STRENGTH = options.edgeElasticity;
  4493. if (options.nestingFactor != null) CoSEConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = options.nestingFactor;
  4494. if (options.gravity != null) CoSEConstants.DEFAULT_GRAVITY_STRENGTH = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = options.gravity;
  4495. if (options.numIter != null) CoSEConstants.MAX_ITERATIONS = FDLayoutConstants.MAX_ITERATIONS = options.numIter;
  4496. if (options.gravityRange != null) CoSEConstants.DEFAULT_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = options.gravityRange;
  4497. if (options.gravityCompound != null) CoSEConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = options.gravityCompound;
  4498. if (options.gravityRangeCompound != null) CoSEConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = options.gravityRangeCompound;
  4499. if (options.initialEnergyOnIncremental != null) CoSEConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = options.initialEnergyOnIncremental;
  4500. if (options.quality == "draft") LayoutConstants.QUALITY = 0;
  4501. else if (options.quality == "proof") LayoutConstants.QUALITY = 2;
  4502. else LayoutConstants.QUALITY = 1;
  4503. CoSEConstants.NODE_DIMENSIONS_INCLUDE_LABELS = FDLayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = options.nodeDimensionsIncludeLabels;
  4504. CoSEConstants.DEFAULT_INCREMENTAL = FDLayoutConstants.DEFAULT_INCREMENTAL = LayoutConstants.DEFAULT_INCREMENTAL = !options.randomize;
  4505. CoSEConstants.ANIMATE = FDLayoutConstants.ANIMATE = LayoutConstants.ANIMATE = options.animate;
  4506. CoSEConstants.TILE = options.tile;
  4507. CoSEConstants.TILING_PADDING_VERTICAL = typeof options.tilingPaddingVertical === "function" ? options.tilingPaddingVertical.call() : options.tilingPaddingVertical;
  4508. CoSEConstants.TILING_PADDING_HORIZONTAL = typeof options.tilingPaddingHorizontal === "function" ? options.tilingPaddingHorizontal.call() : options.tilingPaddingHorizontal;
  4509. };
  4510. _CoSELayout.prototype.run = function() {
  4511. var ready;
  4512. var frameId;
  4513. var options = this.options;
  4514. var idToLNode = this.idToLNode = {};
  4515. var layout = this.layout = new CoSELayout();
  4516. var self = this;
  4517. self.stopped = false;
  4518. this.cy = this.options.cy;
  4519. this.cy.trigger({ type: "layoutstart", layout: this });
  4520. var gm = layout.newGraphManager();
  4521. this.gm = gm;
  4522. var nodes = this.options.eles.nodes();
  4523. var edges = this.options.eles.edges();
  4524. this.root = gm.addRoot();
  4525. this.processChildrenList(this.root, this.getTopMostNodes(nodes), layout);
  4526. for (var i = 0; i < edges.length; i++) {
  4527. var edge = edges[i];
  4528. var sourceNode = this.idToLNode[edge.data("source")];
  4529. var targetNode = this.idToLNode[edge.data("target")];
  4530. if (sourceNode !== targetNode && sourceNode.getEdgesBetween(targetNode).length == 0) {
  4531. var e1 = gm.add(layout.newEdge(), sourceNode, targetNode);
  4532. e1.id = edge.id();
  4533. }
  4534. }
  4535. var getPositions = function getPositions2(ele, i2) {
  4536. if (typeof ele === "number") {
  4537. ele = i2;
  4538. }
  4539. var theId = ele.data("id");
  4540. var lNode = self.idToLNode[theId];
  4541. return {
  4542. x: lNode.getRect().getCenterX(),
  4543. y: lNode.getRect().getCenterY()
  4544. };
  4545. };
  4546. var iterateAnimated = function iterateAnimated2() {
  4547. var afterReposition = function afterReposition2() {
  4548. if (options.fit) {
  4549. options.cy.fit(options.eles, options.padding);
  4550. }
  4551. if (!ready) {
  4552. ready = true;
  4553. self.cy.one("layoutready", options.ready);
  4554. self.cy.trigger({ type: "layoutready", layout: self });
  4555. }
  4556. };
  4557. var ticksPerFrame = self.options.refresh;
  4558. var isDone;
  4559. for (var i2 = 0; i2 < ticksPerFrame && !isDone; i2++) {
  4560. isDone = self.stopped || self.layout.tick();
  4561. }
  4562. if (isDone) {
  4563. if (layout.checkLayoutSuccess() && !layout.isSubLayout) {
  4564. layout.doPostLayout();
  4565. }
  4566. if (layout.tilingPostLayout) {
  4567. layout.tilingPostLayout();
  4568. }
  4569. layout.isLayoutFinished = true;
  4570. self.options.eles.nodes().positions(getPositions);
  4571. afterReposition();
  4572. self.cy.one("layoutstop", self.options.stop);
  4573. self.cy.trigger({ type: "layoutstop", layout: self });
  4574. if (frameId) {
  4575. cancelAnimationFrame(frameId);
  4576. }
  4577. ready = false;
  4578. return;
  4579. }
  4580. var animationData = self.layout.getPositionsData();
  4581. options.eles.nodes().positions(function(ele, i3) {
  4582. if (typeof ele === "number") {
  4583. ele = i3;
  4584. }
  4585. if (!ele.isParent()) {
  4586. var theId = ele.id();
  4587. var pNode = animationData[theId];
  4588. var temp = ele;
  4589. while (pNode == null) {
  4590. pNode = animationData[temp.data("parent")] || animationData["DummyCompound_" + temp.data("parent")];
  4591. animationData[theId] = pNode;
  4592. temp = temp.parent()[0];
  4593. if (temp == void 0) {
  4594. break;
  4595. }
  4596. }
  4597. if (pNode != null) {
  4598. return {
  4599. x: pNode.x,
  4600. y: pNode.y
  4601. };
  4602. } else {
  4603. return {
  4604. x: ele.position("x"),
  4605. y: ele.position("y")
  4606. };
  4607. }
  4608. }
  4609. });
  4610. afterReposition();
  4611. frameId = requestAnimationFrame(iterateAnimated2);
  4612. };
  4613. layout.addListener("layoutstarted", function() {
  4614. if (self.options.animate === "during") {
  4615. frameId = requestAnimationFrame(iterateAnimated);
  4616. }
  4617. });
  4618. layout.runLayout();
  4619. if (this.options.animate !== "during") {
  4620. self.options.eles.nodes().not(":parent").layoutPositions(self, self.options, getPositions);
  4621. ready = false;
  4622. }
  4623. return this;
  4624. };
  4625. _CoSELayout.prototype.getTopMostNodes = function(nodes) {
  4626. var nodesMap = {};
  4627. for (var i = 0; i < nodes.length; i++) {
  4628. nodesMap[nodes[i].id()] = true;
  4629. }
  4630. var roots = nodes.filter(function(ele, i2) {
  4631. if (typeof ele === "number") {
  4632. ele = i2;
  4633. }
  4634. var parent = ele.parent()[0];
  4635. while (parent != null) {
  4636. if (nodesMap[parent.id()]) {
  4637. return false;
  4638. }
  4639. parent = parent.parent()[0];
  4640. }
  4641. return true;
  4642. });
  4643. return roots;
  4644. };
  4645. _CoSELayout.prototype.processChildrenList = function(parent, children, layout) {
  4646. var size = children.length;
  4647. for (var i = 0; i < size; i++) {
  4648. var theChild = children[i];
  4649. var children_of_children = theChild.children();
  4650. var theNode;
  4651. var dimensions = theChild.layoutDimensions({
  4652. nodeDimensionsIncludeLabels: this.options.nodeDimensionsIncludeLabels
  4653. });
  4654. if (theChild.outerWidth() != null && theChild.outerHeight() != null) {
  4655. theNode = parent.add(new CoSENode(layout.graphManager, new PointD(theChild.position("x") - dimensions.w / 2, theChild.position("y") - dimensions.h / 2), new DimensionD2(parseFloat(dimensions.w), parseFloat(dimensions.h))));
  4656. } else {
  4657. theNode = parent.add(new CoSENode(this.graphManager));
  4658. }
  4659. theNode.id = theChild.data("id");
  4660. theNode.paddingLeft = parseInt(theChild.css("padding"));
  4661. theNode.paddingTop = parseInt(theChild.css("padding"));
  4662. theNode.paddingRight = parseInt(theChild.css("padding"));
  4663. theNode.paddingBottom = parseInt(theChild.css("padding"));
  4664. if (this.options.nodeDimensionsIncludeLabels) {
  4665. if (theChild.isParent()) {
  4666. var labelWidth = theChild.boundingBox({ includeLabels: true, includeNodes: false }).w;
  4667. var labelHeight = theChild.boundingBox({ includeLabels: true, includeNodes: false }).h;
  4668. var labelPos = theChild.css("text-halign");
  4669. theNode.labelWidth = labelWidth;
  4670. theNode.labelHeight = labelHeight;
  4671. theNode.labelPos = labelPos;
  4672. }
  4673. }
  4674. this.idToLNode[theChild.data("id")] = theNode;
  4675. if (isNaN(theNode.rect.x)) {
  4676. theNode.rect.x = 0;
  4677. }
  4678. if (isNaN(theNode.rect.y)) {
  4679. theNode.rect.y = 0;
  4680. }
  4681. if (children_of_children != null && children_of_children.length > 0) {
  4682. var theNewGraph;
  4683. theNewGraph = layout.getGraphManager().add(layout.newGraph(), theNode);
  4684. this.processChildrenList(theNewGraph, children_of_children, layout);
  4685. }
  4686. }
  4687. };
  4688. _CoSELayout.prototype.stop = function() {
  4689. this.stopped = true;
  4690. return this;
  4691. };
  4692. var register = function register2(cytoscape2) {
  4693. cytoscape2("layout", "cose-bilkent", _CoSELayout);
  4694. };
  4695. if (typeof cytoscape !== "undefined") {
  4696. register(cytoscape);
  4697. }
  4698. module2.exports = register;
  4699. })
  4700. /******/
  4701. ])
  4702. );
  4703. });
  4704. }
  4705. });
  4706. export default require_cytoscape_cose_bilkent();
  4707. //# sourceMappingURL=cytoscape-cose-bilkent.js.map