rave-layouts.js 92 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940
  1. // During the rave-layouts.js build, this file is added to the top.
  2. // Create an inner self-executing function that will be run with the global scope
  3. // On browsers, this is 'window'. Everywhere else should use 'this' if available.
  4. // Need to run eval('this') "indirectly" by having eval returned by (1,eval). OBVIOUSLY :)
  5. (function (global, factory) {
  6. // dynamically determine how 'rave' variable should be loaded depeneding on loader type
  7. var _rave;
  8. if (typeof module === "object" && typeof module.exports === "object" && typeof require == "function") {
  9. // CommonJS/node.js
  10. var rave = require("rave");
  11. var navigation = factory(global,rave);
  12. module.exports = rave;
  13. } else if (typeof define === "function" && define.amd) {
  14. // AMD
  15. define(['rave'], function(rave) {
  16. return factory(global,rave);
  17. });
  18. } else {
  19. // probably loading via script tag. run as is, setting stuff on rave
  20. factory(global,global['rave']);
  21. }
  22. }((1, eval)('this'), function (_global, _rave) {(function() {
  23. var $ = {};
  24. // $source: com/ibm/rave/ext/internal/layout/nativeImpl/ModuleHeader
  25. /************************************************************************
  26. ** IBM Confidential
  27. **
  28. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  29. **
  30. ** (C) Copyright IBM Corp. 2015
  31. **
  32. ** The source code for this program is not published or otherwise divested of its trade secrets,
  33. ** irrespective of what has been deposited with the U.S. Copyright Office.
  34. ************************************************************************/
  35. // setup
  36. var global = typeof _global !== "undefined" ? _global : (1, eval)('this');
  37. var rave = typeof _rave !== "undefined" ? _rave : global['rave'];
  38. com_ibm_rave_core_Rave = rave;
  39. rave["internal"]["Declare"] = rave["_"]["com_ibm_rave_core_nativeImpl_Declare"];
  40. // $source: com/ibm/rave/ext/layout/bubble/BubbleLayout
  41. /************************************************************************
  42. ** IBM Confidential
  43. **
  44. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  45. **
  46. ** (C) Copyright IBM Corp. 2017
  47. **
  48. ** The source code for this program is not published or otherwise divested of its trade secrets,
  49. ** irrespective of what has been deposited with the U.S. Copyright Office.
  50. ************************************************************************/
  51. // GENERATED
  52. //@import com/ibm/rave/ext/internal/layout/bubble/SquarePackMethod (runtime) // new
  53. //@import com/ibm/rave/ext/internal/layout/bubble/CirclePackMethod (runtime) // new
  54. /**
  55. * Bubble layout - circle packing into a shape specified by the layout method (circle being a default) Bubble layout returns sorted collection of nodes with calculated coordinates x,y, with radius set respective to the radius function or value. Collection of nodes will be sorted according to the sort function, however, sort order of the nodes does not influence coordinates calculated by bubble packing algorithm
  56. */
  57. var com_ibm_rave_ext_layout_bubble_BubbleLayout = rave['internal']['Declare'](rave['internal']['AbstractPackLayout'], {
  58. //methodVal : null,
  59. constructor : function() {
  60. this.methodVal = "circle";
  61. /**
  62. * constructor
  63. */
  64. {
  65. this.sort(null);
  66. }
  67. },
  68. /**
  69. * Runs the bubble layout, returning the array of nodes associated with the specified root node. The bubble layout is part of the family of hierarchical layouts. These layouts follow the same basic structure: the input argument to the layout is the root node of the hierarchy, and the output return value is an array representing the computed positions of all nodes. Several attributes are populated on each node: parent - the parent node, or null for the root. children - the array of child nodes, or null for leaf nodes. value - the node value, as returned by the value accessor. depth - the depth of the node, starting at 0 for the root. x - the computed x-coordinate of the node position. y - the computed y-coordinate of the node position. r - the computed node radius.
  70. * @param d the root node
  71. * @param i index
  72. * @return (Array) Array or positioned nodes
  73. */
  74. /** @expose */
  75. create : function(root) {
  76. var nodes = rave['internal']['HierarchyBase'].prototype.create.call(this, root);
  77. var localR;
  78. if (!this.radiusFn && this.radiusVal == null) {
  79. localR = com_ibm_rave_ext_layout_bubble_BubbleLayout.DEFAULT_FN;
  80. } else if (!this.radiusFn) {
  81. localR = new rave['internal']['ConstantSingleValueFunction'](this.radiusVal);
  82. } else {
  83. localR = this.radiusFn;
  84. }
  85. root["x"] = root["y"] = 0;
  86. rave['internal']['HierarchyUtil'].visitAfter(root, new (rave['internal']['Declare']({
  87. visit : function(node) {
  88. node["r"] = + (localR(node["value"]));
  89. }
  90. }))());
  91. var extent = [this.sizeVal[0], this.sizeVal[1]];
  92. var type = this.method();
  93. rave['internal']['HierarchyUtil'].visitAfter(root, new (rave['internal']['Declare']({
  94. visit : function(node) {
  95. var algorithm = "square" == type ? new com_ibm_rave_ext_internal_layout_bubble_SquarePackMethod(extent) : new com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod(extent);
  96. algorithm.pack(node);
  97. }
  98. }))());
  99. var x = extent[0] / 2, y = extent[1] / 2;
  100. var scale = (this.radiusFn || (this.radiusVal)) ? 1 : 1 / Math.max(2 * root["r"] / extent[0], 2 * root["r"] / extent[1]);
  101. var dr = (this.padding()) ? this.padding() / 2 : 0;
  102. this.layout_packTransform(root, x, y, scale, dr);
  103. return nodes;
  104. },
  105. /**
  106. * Sets the value of layout method variant(circle, square, etc).Packing algorithm will be chosen based on the method, e.g. <code>CIRCLE</code> method will produce packing bubbles into a circle, <code>SQUARE</code> will pack bubbles into a square. Some layout methods work best on flat data structures.
  107. * @param - value of layout method variant. If set to <code>SQUARE</code> for example, the layout will be done to fit a square rather than a circle. <code>CIRCLE</code> by default
  108. * @return (com.ibm.rave.ext.layout.bubble.BubbleLayout) this layout
  109. */
  110. method$0 : function(value) {
  111. var _method = value.toString();
  112. if ("circle" == _method) {
  113. this.methodVal = "circle";
  114. return this;
  115. }
  116. if ("square" == _method) {
  117. this.methodVal = "square";
  118. return this;
  119. }
  120. this.methodVal = "circle";
  121. return this;
  122. },
  123. /**
  124. * @return (String) - Return the value of layout method variant (e.g. circle, square, etc).
  125. */
  126. method$1 : function() {
  127. return this.methodVal;
  128. },
  129. /** @expose */
  130. layout_packTransform : function(node, x, y, scale, _padding) {
  131. var _x = x;
  132. var _y = y;
  133. var children = node["children"];
  134. node["x"] = (_x += scale * node["x"]);
  135. node["y"] = (_y += scale * node["y"]);
  136. node["r"] *= scale;
  137. node["r"] -= _padding;
  138. node["r"] = Math.max(0.0, node["r"]);
  139. if (children) {
  140. var i = -1, n = children.length;
  141. while (++i < n) {
  142. this.layout_packTransform(children[i], node["x"], node["y"], scale, _padding);
  143. }
  144. }
  145. },
  146. /** @expose */
  147. method : function(a0) {
  148. var args = arguments;
  149. if (args.length == 0) {
  150. return this.method$1();
  151. }
  152. return this.method$0(a0);
  153. }
  154. });
  155. /**
  156. * identifies packing method as packing all shapes into a circle shape
  157. */
  158. /** @expose */
  159. com_ibm_rave_ext_layout_bubble_BubbleLayout.CIRCLE = "circle";
  160. /**
  161. * identifies packing method as packing all shapes into a square shape, works best on flat data structures
  162. */
  163. /** @expose */
  164. com_ibm_rave_ext_layout_bubble_BubbleLayout.SQUARE = "square";
  165. com_ibm_rave_ext_layout_bubble_BubbleLayout.DEFAULT_FN = function(data) {
  166. return + (data);
  167. };
  168. // $source: com/ibm/rave/ext/internal/layout/bubble/BubblePackLayoutMethod
  169. /************************************************************************
  170. ** IBM Confidential
  171. **
  172. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  173. **
  174. ** (C) Copyright IBM Corp. 2017
  175. **
  176. ** The source code for this program is not published or otherwise divested of its trade secrets,
  177. ** irrespective of what has been deposited with the U.S. Copyright Office.
  178. ************************************************************************/
  179. // GENERATED
  180. /**
  181. * A bubble pack algorithm variant. Defines boundaries of the layout as a geometric shape - circle, square, etc
  182. */
  183. var com_ibm_rave_ext_internal_layout_bubble_BubblePackLayoutMethod = rave['internal']['Declare']({
  184. /**
  185. * Run algorithm and calculate x,y positions of each node
  186. * @param (Object) root root node
  187. */
  188. //pack : function(root) {}
  189. });
  190. com_ibm_rave_ext_internal_layout_bubble_BubblePackLayoutMethod.hypot = function(a, b) {
  191. return Math.sqrt(a * a + b * b);
  192. };
  193. com_ibm_rave_ext_internal_layout_bubble_BubblePackLayoutMethod.distance = function(p1, p2) {
  194. return com_ibm_rave_ext_internal_layout_bubble_BubblePackLayoutMethod.hypot(p1[0] - p2[0], p1[1] - p2[1]);
  195. };
  196. // $source: com/ibm/rave/ext/internal/layout/utils/Qtree
  197. /************************************************************************
  198. ** IBM Confidential
  199. **
  200. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  201. **
  202. ** (C) Copyright IBM Corp. 2017
  203. **
  204. ** The source code for this program is not published or otherwise divested of its trade secrets,
  205. ** irrespective of what has been deposited with the U.S. Copyright Office.
  206. ************************************************************************/
  207. // GENERATED
  208. /**
  209. * Spatial quad tree a homogeneous collection of objects of type T, each represented by a rectangular node with extent x,y,width,height
  210. * @param < (java.lang.Object) T > type of the item attached to qtree rectangle node
  211. * @see (Object) QTreeNode
  212. */
  213. var com_ibm_rave_ext_internal_layout_utils_Qtree = rave['internal']['Declare']({
  214. //objects : null,
  215. //bounds : null,
  216. //quadrants : null,
  217. /**
  218. * maximum number of objects for any level before it splits
  219. */
  220. max_objects : 30,
  221. /**
  222. * maximum number of levels this tree can handle
  223. */
  224. MAX_LEVELS : 15,
  225. size : 0,
  226. level : 0,
  227. subWidth : 0,
  228. subHeight : 0,
  229. xMidpoint : 0,
  230. yMidpoint : 0,
  231. constructor : function(pLevel, pBounds) {
  232. this.level = pLevel;
  233. this.objects = [];
  234. this.bounds = pBounds;
  235. this.subWidth = this.bounds["width"] / 2;
  236. this.subHeight = this.bounds["height"] / 2;
  237. this.xMidpoint = this.bounds["x"] + this.subWidth;
  238. this.yMidpoint = this.bounds["y"] + this.subHeight;
  239. },
  240. /**
  241. * Clears the quadtree
  242. */
  243. clear : function() {
  244. this.objects = [];
  245. this.quadrants = null;
  246. this.size = 0;
  247. },
  248. split : function() {
  249. this.quadrants = [];
  250. this.quadrants[1] = new com_ibm_rave_ext_internal_layout_utils_Qtree(this.level + 1, com_ibm_rave_ext_internal_layout_utils_Qtree.newQTreeNode(this.bounds["x"], this.bounds["y"] + this.subHeight, this.subWidth, this.subHeight, null));
  251. this.quadrants[0] = new com_ibm_rave_ext_internal_layout_utils_Qtree(this.level + 1, com_ibm_rave_ext_internal_layout_utils_Qtree.newQTreeNode(this.bounds["x"] + this.subWidth, this.bounds["y"] + this.subHeight, this.subWidth, this.subHeight, null));
  252. this.quadrants[2] = new com_ibm_rave_ext_internal_layout_utils_Qtree(this.level + 1, com_ibm_rave_ext_internal_layout_utils_Qtree.newQTreeNode(this.bounds["x"], this.bounds["y"], this.subWidth, this.subHeight, null));
  253. this.quadrants[3] = new com_ibm_rave_ext_internal_layout_utils_Qtree(this.level + 1, com_ibm_rave_ext_internal_layout_utils_Qtree.newQTreeNode(this.bounds["x"] + this.subWidth, this.bounds["y"], this.subWidth, this.subHeight, null));
  254. var new_objects = [];
  255. for (var __i_enFor0 = 0, __exp_enFor0 = this.objects, __len_enFor0 = __exp_enFor0.length;
  256. __i_enFor0 < __len_enFor0; ++__i_enFor0) {
  257. var node = __exp_enFor0[__i_enFor0];
  258. var index = this.getQuadrant(node);
  259. if (index != -1) {
  260. this.quadrants[index].insert(node);
  261. } else {
  262. new_objects.push(node);
  263. }
  264. }
  265. this.objects = new_objects;
  266. },
  267. getQuadrant : function(pRect) {
  268. if (pRect["width"] > this.subWidth || pRect["height"] > this.subHeight) {
  269. return -1;
  270. }
  271. var topQuadrant = pRect["y"] >= this.yMidpoint;
  272. var bottomQuadrant = pRect["y"] + pRect["height"] <= this.yMidpoint;
  273. if (pRect["x"] >= this.xMidpoint) {
  274. if (topQuadrant) {
  275. return 0;
  276. }
  277. if (bottomQuadrant) {
  278. return 3;
  279. }
  280. }
  281. if (pRect["x"] + pRect["width"] <= this.xMidpoint) {
  282. if (topQuadrant) {
  283. return 1;
  284. }
  285. if (bottomQuadrant) {
  286. return 2;
  287. }
  288. }
  289. return -1;
  290. },
  291. /**
  292. * Insert the object into the quadtree. If the node exceeds the capacity, the tree will split and add all objects to their corresponding quadrants.
  293. * @param (Object) pRect
  294. */
  295. insert : function(pRect) {
  296. this.size++;
  297. if (this.quadrants) {
  298. var index = this.getQuadrant(pRect);
  299. if (index != -1) {
  300. this.quadrants[index].insert(pRect);
  301. return;
  302. }
  303. }
  304. this.objects.push(pRect);
  305. if (!this.quadrants && this.objects.length > this.max_objects && this.level < this.MAX_LEVELS) {
  306. this.split();
  307. }
  308. },
  309. /**
  310. * Returns true if the test rectangle r intersects bounds of this tree, false otherwise
  311. * @param r rectangle to test for intersection with this tree
  312. * @return (boolean) true if the test rectangle r intersects bounds of this tree, false otherwise
  313. */
  314. intersectsRectangle : function(rect) {
  315. return this.intersects(rect["x"], rect["y"], rect["width"], rect["height"]);
  316. },
  317. intersects : function(x, y, width, height) {
  318. return (x < this.bounds["x"] + this.bounds["width"]) && (y < this.bounds["y"] + this.bounds["height"]) && (x + width > this.bounds["x"]) && (y + height > this.bounds["y"]);
  319. },
  320. /**
  321. * Evaluate collision tester function against all nodes that have the potential of colliding with the test rectangle. Return true, if test rectangle does collide with any of the nodes, false otherwise This method allows to test while iterating and bail out as soon as tester function returns true
  322. * @param (rave['internal']['SingleValueFunction']) tester a function to execute on each tree node to test wither or not it will collide with pRect
  323. * @param (Object) test a rectangle to test wither or not it will collide with any
  324. * @return (boolean) true if object does collide with any node in the tree, false otherwise
  325. */
  326. collide : function(tester, test) {
  327. if (this.quadrants) {
  328. for (var i = 0; i < 4; ++i) {
  329. if (this.quadrants[i].intersectsRectangle(test)) {
  330. if (this.quadrants[i].collide(tester, test)) {
  331. return true;
  332. }
  333. }
  334. }
  335. }
  336. for (var __i_enFor0 = 0, __exp_enFor0 = this.objects, __len_enFor0 = __exp_enFor0.length;
  337. __i_enFor0 < __len_enFor0; ++__i_enFor0) {
  338. var node = __exp_enFor0[__i_enFor0];
  339. if (tester(node)) {
  340. return true;
  341. }
  342. }
  343. return false;
  344. }
  345. });
  346. /**
  347. * Create new tree node with an rectangle extent x,y,width, height and an item it points to
  348. * @param (double) x rectangle x
  349. * @param (double) y rectangle y
  350. * @param (double) width rectangle width
  351. * @param (double) height rectangle height
  352. * @param (java.lang.Object) item an object represented by the rectangle
  353. * @return (Object) new rectangle node object
  354. */
  355. com_ibm_rave_ext_internal_layout_utils_Qtree.newQTreeNode = function(x, y, width, height, item) {
  356. var node = {};
  357. node["x"] = x;
  358. node["y"] = y;
  359. node["width"] = width;
  360. node["height"] = height;
  361. node["item"] = item;
  362. return node;
  363. };
  364. com_ibm_rave_ext_internal_layout_utils_Qtree.TOP_RIGHT = 0;
  365. com_ibm_rave_ext_internal_layout_utils_Qtree.TOP_LEFT = 1;
  366. com_ibm_rave_ext_internal_layout_utils_Qtree.BOTTOM_LEFT = 2;
  367. com_ibm_rave_ext_internal_layout_utils_Qtree.BOTTOM_RIGHT = 3;
  368. // $source: com/ibm/rave/ext/internal/layout/utils/DoubleUtils
  369. /************************************************************************
  370. ** IBM Confidential
  371. **
  372. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  373. **
  374. ** (C) Copyright IBM Corp. 2017
  375. **
  376. ** The source code for this program is not published or otherwise divested of its trade secrets,
  377. ** irrespective of what has been deposited with the U.S. Copyright Office.
  378. ************************************************************************/
  379. // GENERATED
  380. var com_ibm_rave_ext_internal_layout_utils_DoubleUtils = {
  381. };
  382. /**
  383. * Compares the two specified {@code double} values. The sign of the integer value returned is the same as that of the integer that would be returned by the call: <pre> new Double(d1).compareTo(new Double(d2)) </pre>
  384. * @param (double) d1 the first {@code double} to compare
  385. * @param (double) d2 the second {@code double} to compare
  386. * @return (int) the value {@code 0} if {@code d1} is numerically equal to {@code d2} ; a value less than {@code 0} if {@code d1} is numerically less than {@code d2} ; and a value greater than {@code 0} if {@code d1} is numerically greater than {@code d2} .
  387. */
  388. com_ibm_rave_ext_internal_layout_utils_DoubleUtils.compare = function(d1, d2) {
  389. if (d1 < d2) {
  390. return -1;
  391. }
  392. if (d1 > d2) {
  393. return 1;
  394. }
  395. return d1 == d2 ? 0 : isNaN(d1) ? -1 : 1;
  396. };
  397. // $source: com/ibm/rave/ext/layout/fill/FillLayout
  398. /************************************************************************
  399. ** IBM Confidential
  400. **
  401. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  402. **
  403. ** (C) Copyright IBM Corp. 2017
  404. **
  405. ** The source code for this program is not published or otherwise divested of its trade secrets,
  406. ** irrespective of what has been deposited with the U.S. Copyright Office.
  407. ************************************************************************/
  408. // GENERATED
  409. /**
  410. * Fill layout. This layout is similar to the bubble layout in that it packs shapes together and may be applied to shapes of different sizes. The order of the packing is not specified and there is no attempt to place the larger shapes at the beginning or in the center. The Fill layout treats shapes as rectangles and packs them in either column-major (the default) or row-major order. In the major direction the shapes all take the same width or height, equal to that of the largest shape. In the minor direction the shapes may either all have the same size equal to that of the largest shape, or each may use exactly their own size. Padding may be applied to the shapes with the padding property of the layout specification. If there is not enough room to fit all the shapes, a custom error callback can be attached to inform about details of the remaining shapes
  411. */
  412. var com_ibm_rave_ext_layout_fill_FillLayout = rave['internal']['Declare']({
  413. //hAlignVal : null,
  414. //vAlignVal : null,
  415. //methodVal : null,
  416. //directionVal : null,
  417. //rowOrderVal : null,
  418. //columnOrderVal : null,
  419. //sizeVal : null,
  420. //gridCellSize : null,
  421. //cellSizeFn : null,
  422. //errorCallback : null,
  423. rowsVal : 0,
  424. columnsVal : 0,
  425. paddingVal : 0,
  426. /**
  427. * The number of horizontal and vertical cells that are laid out by the grid
  428. */
  429. numberOfVerticalCellsVal : -1,
  430. numberOfHorizontalCellsVal : -1,
  431. _$functionClassMethod : function() {
  432. var _$self = /**
  433. * Layout the collection of data nodes
  434. * @param (Array) nodes data nodes collection
  435. * @return (Array) a collection of data nodes, which were successfully laid out , with calculated x,y
  436. */
  437. function(nodes) {
  438. if (!_$self.cellSizeFn) {
  439. var sizeLocal = _$self.size();
  440. var c = _$self.columns();
  441. var r = _$self.rows();
  442. var p = _$self.padding();
  443. _$self.cellSizeFn = function(node) {
  444. var width = sizeLocal[0];
  445. var height = sizeLocal[1];
  446. node["width"] = (width - p * c) / c;
  447. node["height"] = (height - p * r) / r;
  448. };
  449. }
  450. for (var __i_enFor0 = 0, __exp_enFor0 = nodes, __len_enFor0 = __exp_enFor0.length;
  451. __i_enFor0 < __len_enFor0; ++__i_enFor0) {
  452. var node = __exp_enFor0[__i_enFor0];
  453. node["x"] = 0;
  454. node["y"] = 0;
  455. _$self.cellSize()(node);
  456. }
  457. _$self.layout_computeCellSize(nodes);
  458. var numRows = Math.max(Math.floor(_$self.size()[1] / _$self.gridCellSize[1]), 1);
  459. var numColumns = Math.max(Math.floor(_$self.size()[0] / _$self.gridCellSize[0]), 1);
  460. if (_$self.rows() > 0) {
  461. numRows = Math.min(numRows, _$self.rows());
  462. }
  463. if (_$self.columns() > 0) {
  464. numColumns = Math.min(numColumns, _$self.columns());
  465. }
  466. if ("packed" == _$self.method()) {
  467. if ("row" == _$self.direction()) {
  468. numColumns = Math.max(0, _$self.columns());
  469. } else {
  470. numRows = Math.max(0, _$self.rows());
  471. }
  472. }
  473. return _$self.layout_packShapes(nodes, numRows, numColumns);
  474. };
  475. return _$self;
  476. },
  477. constructor : function() {
  478. this.hAlignVal = "start";
  479. this.vAlignVal = "middle";
  480. this.methodVal = "packed";
  481. this.directionVal = "column";
  482. this.rowOrderVal = "down";
  483. this.columnOrderVal = "left";
  484. this.sizeVal = [1.0, 1.0];
  485. },
  486. /**
  487. * Returns method which controls the spacing in the minor direction. "packed" (the default) makes each shape use its own size. "grid" makes all shapes use the same spacing.
  488. * @return (String) packing method
  489. */
  490. method$0 : function() {
  491. return this.methodVal;
  492. },
  493. /**
  494. * Set method, which controls the spacing in the minor direction. "packed" (the default) makes each shape use its own size. "grid" makes all shapes use the same spacing.
  495. * @return (com.ibm.rave.ext.layout.fill.FillLayout) this
  496. */
  497. method$1 : function(method) {
  498. if ("grid" == method) {
  499. this.methodVal = "grid";
  500. } else {
  501. this.methodVal = "packed";
  502. }
  503. return this;
  504. },
  505. /**
  506. * Return the packing major direction. "column" is the default, "row" is the other option.
  507. * @return (String) the packing major direction. "column" is the default, "row" is the other option.
  508. */
  509. direction$0 : function() {
  510. return this.directionVal;
  511. },
  512. /**
  513. * Sets the packing major direction. "column" is the default, "row" is the other option.
  514. * @param (String) direction "column" or "row"
  515. * @return (com.ibm.rave.ext.layout.fill.FillLayout) this
  516. */
  517. direction$1 : function(direction) {
  518. if ("row" == direction) {
  519. this.directionVal = "row";
  520. } else {
  521. this.directionVal = "column";
  522. }
  523. return this;
  524. },
  525. /**
  526. * Sets the number of rows. If the layout direction is row, the layout will expand to have the given number of rows. If the layout direction is column no more than this number of shapes will be placed in any column.
  527. * @param (Object) rows the number of rows
  528. * @return (com.ibm.rave.ext.layout.fill.FillLayout) this
  529. */
  530. rows$0 : function(rows) {
  531. this.rowsVal = ~~ (rows);
  532. return this;
  533. },
  534. /**
  535. * Returns the number of rows. If the layout direction is row, the layout will expand to have the given number of rows. If the layout direction is column no more than this number of shapes will be placed in any column.
  536. * @return (int) number of rows
  537. */
  538. rows$1 : function() {
  539. return this.rowsVal;
  540. },
  541. /**
  542. * Sets the number of columns. If the layout direction is column, the layout will expand to have the given number of columns. If the layout direction is row , no more than this number of shapes will be placed in any row.
  543. * @param (Object) columns number of columns
  544. * @return (com.ibm.rave.ext.layout.fill.FillLayout) this
  545. */
  546. columns$0 : function(columns) {
  547. this.columnsVal = ~~ (columns);
  548. return this;
  549. },
  550. /**
  551. * Returns the number of columns. If the layout direction is column, the layout will expand to have the given number of columns. If the layout direction is row , no more than this number of shapes will be placed in any row.
  552. * @return (int) number of columns
  553. */
  554. columns$1 : function() {
  555. return this.columnsVal;
  556. },
  557. /**
  558. * Sets the order used to determines whether the rows are filled from "top-to-bottom" (the default) or "bottom-to-top". Note that the direction within each row is controlled by the column order.
  559. * @param (String) order "top-to-bottom" (the default) or "bottom-to-top"
  560. * @return (com.ibm.rave.ext.layout.fill.FillLayout) this
  561. */
  562. rowOrder$0 : function(order) {
  563. if ("down" == order) {
  564. this.rowOrderVal = "down";
  565. } else {
  566. this.rowOrderVal = "up";
  567. }
  568. return this;
  569. },
  570. /**
  571. * Returns the order used to determines whether the rows are filled from "top-to-bottom" (the default) or "bottom-to-top". Note that the direction within each row is controlled by the column order.
  572. * @return (String) row order used to determines whether the rows are filled from "top-to-bottom" (the default) or "bottom-to-top".
  573. */
  574. rowOrder$1 : function() {
  575. return this.rowOrderVal;
  576. },
  577. /**
  578. * Sets the order used to determines whether the columns are filled from "left-to-right" (the default) or "right-to-left". Note that the direction within each row is controlled by the row order.
  579. * @param (String) order the order used to determines whether the columns are filled from "left-to-right" (the default) or "right-to-left".
  580. * @return (com.ibm.rave.ext.layout.fill.FillLayout) this
  581. */
  582. columnOrder$0 : function(order) {
  583. if ("right" == order) {
  584. this.columnOrderVal = "right";
  585. } else {
  586. this.columnOrderVal = "left";
  587. }
  588. return this;
  589. },
  590. /**
  591. * Returns the order used to determines whether the columns are filled from "left-to-right" (the default) or "right-to-left". Note that the direction within each row is controlled by the row order.
  592. * @return (String)
  593. */
  594. columnOrder$1 : function() {
  595. return this.columnOrderVal;
  596. },
  597. /**
  598. * Returns the current size, which defaults to 1x1
  599. * @return (double[]) return the current size
  600. */
  601. size$0 : function() {
  602. return this.sizeVal;
  603. },
  604. /**
  605. * Sets the available layout size to the specified two-element array of numbers representing width and height.
  606. * @param (double[]) newSize the size of the layout
  607. * @return (com.ibm.rave.ext.layout.fill.FillLayout) this Layout
  608. */
  609. size$1 : function(newSize) {
  610. this.sizeVal = newSize;
  611. return this;
  612. },
  613. /**
  614. * Set padding
  615. * @param (Object) padding layout padding between elements
  616. * @return (com.ibm.rave.ext.layout.fill.FillLayout) this
  617. */
  618. padding$0 : function(padding) {
  619. this.paddingVal = + (padding);
  620. return this;
  621. },
  622. /**
  623. * Return padding set for nodes
  624. * @return (double) layout padding value
  625. */
  626. padding$1 : function() {
  627. return this.paddingVal;
  628. },
  629. /**
  630. * Set vertical node alignment - "start", "end" or "middle"
  631. * @param (String) alignment vertical node alignment "start", "end" or "middle", "middle" being a default
  632. * @return (com.ibm.rave.ext.layout.fill.FillLayout) this
  633. */
  634. valign$0 : function(alignment) {
  635. if ("start" == alignment) {
  636. this.vAlignVal = "start";
  637. } else if ("end" == alignment) {
  638. this.vAlignVal = "end";
  639. } else {
  640. this.vAlignVal = "middle";
  641. }
  642. return this;
  643. },
  644. /**
  645. * @return (String) vertical node alignment ("start", "end" or "middle", "middle" being a default)
  646. */
  647. valign$1 : function() {
  648. return this.vAlignVal;
  649. },
  650. /**
  651. * Set horizontal node alignment to "start", "end" or "middle", "start" being a default
  652. * @param (String) alignment horizontal node alignment to "start", "end" or "middle", "start" being a default
  653. * @return (com.ibm.rave.ext.layout.fill.FillLayout) this
  654. */
  655. halign$0 : function(alignment) {
  656. if ("middle" == alignment) {
  657. this.hAlignVal = "middle";
  658. } else if ("end" == alignment) {
  659. this.hAlignVal = "end";
  660. } else {
  661. this.hAlignVal = "start";
  662. }
  663. return this;
  664. },
  665. /**
  666. * @return (String) horizontal node alignment ( "start", "end" or "middle", "start" being a default)
  667. */
  668. halign$1 : function() {
  669. return this.hAlignVal;
  670. },
  671. /**
  672. * Set function, which will assign width and height of an individual node
  673. * @param (com.ibm.rave.ext.layout.fill.SetValueFunction) fn function, which will assign width and height of an individual node
  674. * @return (com.ibm.rave.ext.layout.fill.FillLayout) this
  675. */
  676. cellSize$0 : function(fn) {
  677. this.cellSizeFn = fn;
  678. return this;
  679. },
  680. /**
  681. * Return function, which will assign width and height of an individual node
  682. * @return (com.ibm.rave.ext.layout.fill.SetValueFunction) function, which will assign width and height of an individual node
  683. */
  684. cellSize$1 : function() {
  685. return this.cellSizeFn;
  686. },
  687. /**
  688. * Set function, which will be invoked, when a node does not fit
  689. * @param function function, which will be invoked, when a node does not fit
  690. * @return (com.ibm.rave.ext.layout.fill.FillLayout) this
  691. * @see DoesNotFitCallback
  692. */
  693. error$0 : function(fn) {
  694. this.errorCallback = fn;
  695. return this;
  696. },
  697. /**
  698. * Return function, which will be invoked, when a node does not fit
  699. * @return (com.ibm.rave.ext.layout.fill.DoesNotFitCallback) function, which will be invoked, when a node does not fit
  700. * @see DoesNotFitCallback
  701. */
  702. error$1 : function() {
  703. return this.errorCallback;
  704. },
  705. layout_computeCellSize : function(nodes) {
  706. var maxW = 1.0;
  707. var maxH = 1.0;
  708. for (var __i_enFor0 = 0, __exp_enFor0 = nodes, __len_enFor0 = __exp_enFor0.length;
  709. __i_enFor0 < __len_enFor0; ++__i_enFor0) {
  710. var node = __exp_enFor0[__i_enFor0];
  711. maxW = Math.max(maxW, node["width"]);
  712. maxH = Math.max(maxH, node["height"]);
  713. }
  714. this.gridCellSize = [maxW + this.padding(), maxH + this.padding()];
  715. },
  716. layout_packShapes : function(nodes, numRows, numColumns) {
  717. var result = [];
  718. this.numberOfVerticalCellsVal = -1;
  719. this.numberOfHorizontalCellsVal = -1;
  720. var reportDoNotFit = this.error();
  721. var didNotFit;
  722. if (reportDoNotFit) {
  723. didNotFit = [];
  724. for (var __i_enFor0 = 0, __exp_enFor0 = nodes, __len_enFor0 = __exp_enFor0.length;
  725. __i_enFor0 < __len_enFor0; ++__i_enFor0) {
  726. var node = __exp_enFor0[__i_enFor0];
  727. didNotFit.push(node);
  728. }
  729. }
  730. var shapeCount = nodes.length;
  731. var shapeIndex = 0;
  732. var gridMethod = "grid" == this.method();
  733. var majorCount;
  734. var majorShapeSize;
  735. var majorChartSize;
  736. var minorCount;
  737. var minorShapeSize;
  738. var minorChartSize;
  739. if ("row" == this.direction()) {
  740. majorCount = numRows;
  741. minorCount = numColumns;
  742. majorShapeSize = this.gridCellSize[1];
  743. majorChartSize = this.size()[1];
  744. minorChartSize = this.size()[0];
  745. } else {
  746. majorCount = numColumns;
  747. minorCount = numRows;
  748. majorShapeSize = this.gridCellSize[0];
  749. majorChartSize = this.size()[0];
  750. minorChartSize = this.size()[1];
  751. }
  752. if (minorCount == 0) {
  753. minorCount = ~~minorChartSize;
  754. }
  755. var majorPosition = 0.0;
  756. var minorPosition = 0.0;
  757. var majorIndex = 0;
  758. var minorIndex = 0;
  759. var last;
  760. while (shapeIndex < shapeCount && majorIndex < majorCount) {
  761. majorPosition = majorIndex * majorShapeSize;
  762. minorPosition = 0.0;
  763. minorIndex = 0;
  764. while (shapeIndex < shapeCount && minorIndex < minorCount) {
  765. var node = nodes[shapeIndex];
  766. if (gridMethod) {
  767. minorShapeSize = ("row" == this.direction()) ? this.gridCellSize[0] : this.gridCellSize[1];
  768. } else {
  769. minorShapeSize = ("row" == this.direction()) ? node["width"] + this.padding() : node["height"] + this.padding();
  770. }
  771. if (!gridMethod && minorShapeSize > minorChartSize) {
  772. shapeIndex++;
  773. continue;
  774. }
  775. if (minorPosition + minorShapeSize <= minorChartSize && majorPosition <= majorChartSize) {
  776. this.layout_placeShape(node, majorPosition, minorPosition, majorShapeSize, minorShapeSize, 0);
  777. result.push(node);
  778. if (reportDoNotFit) {
  779. didNotFit[shapeIndex] = null;
  780. last = node;
  781. }
  782. shapeIndex++;
  783. minorIndex++;
  784. minorPosition += minorShapeSize;
  785. } else {
  786. break;
  787. }
  788. }
  789. if ("row" == this.direction()) {
  790. this.numberOfHorizontalCellsVal = Math.max(minorIndex, this.numberOfHorizontalCellsVal);
  791. } else {
  792. this.numberOfVerticalCellsVal = Math.max(minorIndex, this.numberOfVerticalCellsVal);
  793. }
  794. majorIndex++;
  795. }
  796. if ("row" == this.direction()) {
  797. this.numberOfVerticalCellsVal = majorIndex;
  798. } else {
  799. this.numberOfHorizontalCellsVal = majorIndex;
  800. }
  801. if (reportDoNotFit) {
  802. var orphans = [];
  803. for (var __i_enFor1 = 0, __exp_enFor1 = didNotFit, __len_enFor1 = __exp_enFor1.length;
  804. __i_enFor1 < __len_enFor1; ++__i_enFor1) {
  805. var node = __exp_enFor1[__i_enFor1];
  806. if (node) {
  807. orphans.push(node);
  808. }
  809. }
  810. if (shapeIndex < shapeCount || orphans.length > 0) {
  811. this.error()(!last ? NaN : last["x"], !last ? NaN : last["y"], orphans);
  812. }
  813. }
  814. return result;
  815. },
  816. layout_placeShape : function(node, majorPosition, minorPosition, majorSize, minorSize, deltaX) {
  817. var xpos;
  818. var ypos;
  819. var xsize;
  820. var ysize;
  821. if ("row" == this.direction()) {
  822. xpos = minorPosition;
  823. ypos = majorPosition;
  824. xsize = minorSize;
  825. ysize = majorSize;
  826. } else {
  827. xpos = majorPosition;
  828. ypos = minorPosition;
  829. xsize = majorSize;
  830. ysize = minorSize;
  831. }
  832. if ("up" == this.rowOrder()) {
  833. ypos = this.size()[1] - ypos - ysize;
  834. }
  835. if ("right" == this.columnOrder()) {
  836. xpos = this.size()[0] - xpos - xsize;
  837. }
  838. xpos += this.padding();
  839. ypos += this.padding();
  840. xpos += deltaX;
  841. var availableX = xsize - node["width"] - deltaX - this.padding();
  842. var availableY = ysize - node["height"] - this.padding();
  843. if ("middle" == this.halign()) {
  844. xpos += availableX / 2.0;
  845. } else if ("end" == this.halign()) {
  846. xpos += availableX;
  847. }
  848. if ("middle" == this.valign()) {
  849. ypos += availableY / 2.0;
  850. } else if ("end" == this.valign()) {
  851. ypos += availableY;
  852. }
  853. node["x"] = xpos - node["x"];
  854. node["y"] = ypos - node["y"];
  855. },
  856. /**
  857. * @return (int) -1 if the layout hasn't been run, otherwise return the number of vertical cells the layout lays out
  858. */
  859. /** @expose */
  860. numberOfVerticalCells : function() {
  861. return this.numberOfVerticalCellsVal;
  862. },
  863. /**
  864. * @return (int) -1 if the layout hasn't been run, otherwise return the number of horizontal cells the layout lays out
  865. */
  866. /** @expose */
  867. numberOfHorizontalCells : function() {
  868. return this.numberOfHorizontalCellsVal;
  869. },
  870. /** @expose */
  871. method : function(a0) {
  872. var args = arguments;
  873. if (args.length == 0) {
  874. return this.method$0();
  875. }
  876. return this.method$1(a0);
  877. },
  878. /** @expose */
  879. direction : function(a0) {
  880. var args = arguments;
  881. if (args.length == 0) {
  882. return this.direction$0();
  883. }
  884. return this.direction$1(a0);
  885. },
  886. /** @expose */
  887. rows : function(a0) {
  888. var args = arguments;
  889. if (args.length == 0) {
  890. return this.rows$1();
  891. }
  892. return this.rows$0(a0);
  893. },
  894. /** @expose */
  895. columns : function(a0) {
  896. var args = arguments;
  897. if (args.length == 0) {
  898. return this.columns$1();
  899. }
  900. return this.columns$0(a0);
  901. },
  902. /** @expose */
  903. rowOrder : function(a0) {
  904. var args = arguments;
  905. if (args.length == 0) {
  906. return this.rowOrder$1();
  907. }
  908. return this.rowOrder$0(a0);
  909. },
  910. /** @expose */
  911. columnOrder : function(a0) {
  912. var args = arguments;
  913. if (args.length == 0) {
  914. return this.columnOrder$1();
  915. }
  916. return this.columnOrder$0(a0);
  917. },
  918. /** @expose */
  919. size : function(a0) {
  920. var args = arguments;
  921. if (args.length == 0) {
  922. return this.size$0();
  923. }
  924. return this.size$1(a0);
  925. },
  926. /** @expose */
  927. padding : function(a0) {
  928. var args = arguments;
  929. if (args.length == 0) {
  930. return this.padding$1();
  931. }
  932. return this.padding$0(a0);
  933. },
  934. /** @expose */
  935. valign : function(a0) {
  936. var args = arguments;
  937. if (args.length == 0) {
  938. return this.valign$1();
  939. }
  940. return this.valign$0(a0);
  941. },
  942. /** @expose */
  943. halign : function(a0) {
  944. var args = arguments;
  945. if (args.length == 0) {
  946. return this.halign$1();
  947. }
  948. return this.halign$0(a0);
  949. },
  950. /** @expose */
  951. cellSize : function(a0) {
  952. var args = arguments;
  953. if (args.length == 0) {
  954. return this.cellSize$1();
  955. }
  956. return this.cellSize$0(a0);
  957. },
  958. /** @expose */
  959. error : function(a0) {
  960. var args = arguments;
  961. if (args.length == 0) {
  962. return this.error$1();
  963. }
  964. return this.error$0(a0);
  965. }
  966. });
  967. /**
  968. * packing method "packed" (default)
  969. */
  970. /** @expose */
  971. com_ibm_rave_ext_layout_fill_FillLayout.PACKED = "packed";
  972. /**
  973. * packing method "grid"
  974. */
  975. /** @expose */
  976. com_ibm_rave_ext_layout_fill_FillLayout.GRID = "grid";
  977. /**
  978. * packing direction row oriented
  979. */
  980. /** @expose */
  981. com_ibm_rave_ext_layout_fill_FillLayout.ROW = "row";
  982. /**
  983. * packing direction column oriented (default)
  984. */
  985. /** @expose */
  986. com_ibm_rave_ext_layout_fill_FillLayout.COLUMN = "column";
  987. /**
  988. * vertical alignment from top down to bottom (default)
  989. */
  990. /** @expose */
  991. com_ibm_rave_ext_layout_fill_FillLayout.DOWN = "down";
  992. /**
  993. * vertical alignment from bottom up to top
  994. */
  995. /** @expose */
  996. com_ibm_rave_ext_layout_fill_FillLayout.UP = "up";
  997. /**
  998. * horizontal alignment from left to right (default)
  999. */
  1000. /** @expose */
  1001. com_ibm_rave_ext_layout_fill_FillLayout.LEFT = "left";
  1002. /**
  1003. * horizontal alignment from right to left
  1004. */
  1005. /** @expose */
  1006. com_ibm_rave_ext_layout_fill_FillLayout.RIGHT = "right";
  1007. /**
  1008. * Shape alignment
  1009. */
  1010. /** @expose */
  1011. com_ibm_rave_ext_layout_fill_FillLayout.ALIGN_START = "start";
  1012. /** @expose */
  1013. com_ibm_rave_ext_layout_fill_FillLayout.ALIGN_END = "end";
  1014. /** @expose */
  1015. com_ibm_rave_ext_layout_fill_FillLayout.ALIGN_MIDDLE = "middle";
  1016. // $source: com/ibm/rave/ext/layout/hexbin/Hexbin
  1017. /************************************************************************
  1018. ** IBM Confidential
  1019. **
  1020. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  1021. **
  1022. ** (C) Copyright IBM Corp. 2017
  1023. **
  1024. ** The source code for this program is not published or otherwise divested of its trade secrets,
  1025. ** irrespective of what has been deposited with the U.S. Copyright Office.
  1026. ************************************************************************/
  1027. // GENERATED
  1028. /**
  1029. * The hexbin plugin implements hexagonal binning, which is useful for aggregating data into a more coarse representation suitable for display. Rather than displaying a scatterplot with tens of thousands of points, you can bin points into gridded hexagons, and then display the distribution using color or area.
  1030. */
  1031. var com_ibm_rave_ext_layout_hexbin_Hexbin = rave['internal']['Declare']({
  1032. //xFunc : null,
  1033. //yFunc : null,
  1034. width : 1,
  1035. height : 1,
  1036. r : 0,
  1037. dx : 0,
  1038. dy : 0,
  1039. _$functionClassMethod : function() {
  1040. var _$self = /**
  1041. * Evaluates the hexbin layout on the specified array of points, returning an array of hexagonal bins. Each bin is an array containing the bin's points, as well as some additional properties: x - the x-coordinate of the center of the associated bin's hexagon y - the y-coordinate of the center of the associated bin's hexagon Bins that are empty are not omitted. The origin bin at {0,0} is in the top-left. The returned bins are designed to work with the layouts point and hexagon methods.
  1042. * @param (Array) points An array of points to be binned.
  1043. * @return (Array) an array of hexagonal bins.
  1044. */
  1045. function(points) {
  1046. var binsById = rave['internal']['ES6Map'].create();
  1047. for (var i = 0; i < points.length; ++i) {
  1048. var point = points[i];
  1049. var py = _$self.yFunc(point, i) / _$self.dy;
  1050. var pj = Math.round(py);
  1051. var px = _$self.xFunc(point, i) / _$self.dx - ((~~pj & 1) == 1 ? 0.5 : 0.0);
  1052. var pi = Math.round(px);
  1053. var py1 = py - pj;
  1054. if (Math.abs(py1) * 3 > 1) {
  1055. var px1 = px - pi;
  1056. var pi2 = pi + (px < pi ? -1 : 1) / 2.0;
  1057. var pj2 = pj + (py < pj ? -1 : 1);
  1058. var px2 = px - pi2;
  1059. var py2 = py - pj2;
  1060. if (px1 * px1 + py1 * py1 > px2 * px2 + py2 * py2) {
  1061. pi = pi2 + ((~~pj & 1) == 1 ? 1 : -1) / 2.0;
  1062. pj = pj2;
  1063. }
  1064. }
  1065. var id = pi + "-" + pj;
  1066. var bin = binsById.get(id);
  1067. if (bin) {
  1068. bin.push(point);
  1069. } else {
  1070. bin = [];
  1071. bin.push(point);
  1072. binsById.set(id, bin);
  1073. bin["i"] = pi;
  1074. bin["j"] = pj;
  1075. bin["x"] = (pi + ((~~pj & 1) == 1 ? 0.5 : 0)) * _$self.dx;
  1076. bin["y"] = pj * _$self.dy;
  1077. }
  1078. }
  1079. return binsById.values();
  1080. };
  1081. return _$self;
  1082. },
  1083. constructor : function() {
  1084. this.xFunc = com_ibm_rave_ext_layout_hexbin_Hexbin.hexbinX;
  1085. this.yFunc = com_ibm_rave_ext_layout_hexbin_Hexbin.hexbinY;
  1086. {
  1087. this.radius(1);
  1088. }
  1089. },
  1090. /**
  1091. * Sets the x-accessor function for the hexbin layout.
  1092. * @param (com.ibm.rave.ext.layout.hexbin.Hexbin.HexbinFunction) accessor An x-accessor function.
  1093. * @return (com.ibm.rave.ext.layout.hexbin.Hexbin) this Hexbin instance.
  1094. */
  1095. x$0 : function(accessor) {
  1096. this.xFunc = accessor;
  1097. return this;
  1098. },
  1099. /**
  1100. * Gets the x-accessor function for the hexbin layout. The default is function(d) { return d[0]; }.
  1101. * @return (com.ibm.rave.ext.layout.hexbin.Hexbin.HexbinFunction) the x-accessor function.
  1102. */
  1103. x$1 : function() {
  1104. return this.xFunc;
  1105. },
  1106. /**
  1107. * Sets the y-accessor function for the hexbin layout.
  1108. * @param (com.ibm.rave.ext.layout.hexbin.Hexbin.HexbinFunction) accessor A y-accessor function.
  1109. * @return (com.ibm.rave.ext.layout.hexbin.Hexbin) this Hexbin instance.
  1110. */
  1111. y$0 : function(accessor) {
  1112. this.yFunc = accessor;
  1113. return this;
  1114. },
  1115. /**
  1116. * Gets the y-accessor function for the hexbin layout. The default is function(d) { return d[1]; }.
  1117. * @return (com.ibm.rave.ext.layout.hexbin.Hexbin.HexbinFunction) the y-accessor function.
  1118. */
  1119. y$1 : function() {
  1120. return this.yFunc;
  1121. },
  1122. /**
  1123. * Returns the SVG path string for the hexagon centered at the origin {0,0}. The path string is defined with relative coordinates such that you can easily translate the hexagon to the desired position.
  1124. * @param (double) radius Radius of the hexagon to be used.
  1125. * @return (String) a hexagon with the specified radius.
  1126. */
  1127. hexagon$0 : function(radius) {
  1128. return "m" + com_ibm_rave_ext_layout_hexbin_Hexbin._hexagon(radius).join("l") + "z";
  1129. },
  1130. /**
  1131. * Returns the SVG path string for the hexagon centered at the origin {0,0}. The path string is defined with relative coordinates such that you can easily translate the hexagon to the desired position.
  1132. * @return (String) a hexagon with the Hexbin's current radius, which defaults to 1.
  1133. */
  1134. hexagon$1 : function() {
  1135. return "m" + com_ibm_rave_ext_layout_hexbin_Hexbin._hexagon(this.r).join("l") + "z";
  1136. },
  1137. /**
  1138. * Returns an array of [x, y] points representing the centers of each hexagon. Each point also has properties i and j representing the grid column and row, respectively, of the hexagon.
  1139. * @return (Array) an array of hexbin centers.
  1140. */
  1141. /** @expose */
  1142. centers : function() {
  1143. var centers = [];
  1144. var odd = false;
  1145. for (var y = 0, j = 0; y < this.height + this.r; y += this.dy, odd = !odd, ++j) {
  1146. for (var x = odd ? this.dx / 2 : 0, i = 0; x < this.width + this.dx / 2; x += this.dx, ++i) {
  1147. var center = [];
  1148. center["x"] = x;
  1149. center["y"] = y;
  1150. center["i"] = i;
  1151. center["j"] = j;
  1152. centers.push(center);
  1153. }
  1154. }
  1155. return centers;
  1156. },
  1157. /**
  1158. * Returns the SVG path string for a hexagonal mesh that covers the area of the layout (as determined by the layout size). The returned mesh is designed to be stroked. The mesh may extend slightly beyond the layout's defined area, and thus may need to be clipped.
  1159. * @return (String) an SVG Path string.
  1160. */
  1161. /** @expose */
  1162. mesh : rave['internal']['Declare'].bind(function() {
  1163. var fragment = com_ibm_rave_ext_layout_hexbin_Hexbin._hexagon(this.r).slice(0, 4).join("l");
  1164. return this.centers().map(function(currentValue, index, array) {
  1165. var p = currentValue;
  1166. return "M" + p["x"] + "," + p["y"] + "m" + fragment;
  1167. }).join("");
  1168. }),
  1169. /**
  1170. * Sets the available layout size to the specified two-element array of numbers representing x and y.
  1171. * @param (Array) size An array of two elements representing x and y.
  1172. * @return (com.ibm.rave.ext.layout.hexbin.Hexbin) this Hexbin instance with the new size.
  1173. */
  1174. size$0 : function(size) {
  1175. this.width = size[0];
  1176. this.height = size[1];
  1177. return this;
  1178. },
  1179. /**
  1180. * Returns the current layout size of the Hexbin.
  1181. * @return (Array) the current size, which defaults to 1x1.
  1182. */
  1183. size$1 : function() {
  1184. return [this.width, this.height];
  1185. },
  1186. /**
  1187. * Sets the hexagon radius to the specified numeric value.
  1188. * @param (double) radius The new radius to set.
  1189. * @return (com.ibm.rave.ext.layout.hexbin.Hexbin) this Hexbin instance with the new radius.
  1190. */
  1191. radius$0 : function(radius) {
  1192. this.r = radius;
  1193. this.dx = this.r * 2 * Math.sin(Math.PI / 3);
  1194. this.dy = this.r * 1.5;
  1195. return this;
  1196. },
  1197. /**
  1198. * Returns the current radius, which defaults to 1.
  1199. * @return (double) this Hexbin instance.
  1200. */
  1201. radius$1 : function() {
  1202. return this.r;
  1203. },
  1204. /** @expose */
  1205. x : function(a0) {
  1206. var args = arguments;
  1207. if (args.length == 0) {
  1208. return this.x$1();
  1209. }
  1210. return this.x$0(a0);
  1211. },
  1212. /** @expose */
  1213. y : function(a0) {
  1214. var args = arguments;
  1215. if (args.length == 0) {
  1216. return this.y$1();
  1217. }
  1218. return this.y$0(a0);
  1219. },
  1220. /** @expose */
  1221. hexagon : function(a0) {
  1222. var args = arguments;
  1223. if (args.length == 0) {
  1224. return this.hexagon$1();
  1225. }
  1226. return this.hexagon$0(a0);
  1227. },
  1228. /** @expose */
  1229. size : function(a0) {
  1230. var args = arguments;
  1231. if (args.length == 0) {
  1232. return this.size$1();
  1233. }
  1234. return this.size$0(a0);
  1235. },
  1236. /** @expose */
  1237. radius : function(a0) {
  1238. var args = arguments;
  1239. if (args.length == 0) {
  1240. return this.radius$1();
  1241. }
  1242. return this.radius$0(a0);
  1243. }
  1244. });
  1245. com_ibm_rave_ext_layout_hexbin_Hexbin._hexagon = function(radius) {
  1246. return com_ibm_rave_ext_layout_hexbin_Hexbin.rave_hexbinAngles.map(new (rave['internal']['Declare']({
  1247. x0 : 0,
  1248. y0 : 0,
  1249. _$functionClassMethod : function() {
  1250. var _$self = function(currentValue, index, array) {
  1251. var angle = currentValue;
  1252. var x1 = Math.sin(angle) * radius;
  1253. var y1 = -Math.cos(angle) * radius;
  1254. var dx = x1 - _$self.x0;
  1255. var dy = y1 - _$self.y0;
  1256. _$self.x0 = x1;
  1257. _$self.y0 = y1;
  1258. return [dx, dy];
  1259. };
  1260. return _$self;
  1261. }
  1262. }))());
  1263. };
  1264. com_ibm_rave_ext_layout_hexbin_Hexbin.rave_hexbinAngles = rave.range(0, 2 * Math.PI, Math.PI / 3);
  1265. com_ibm_rave_ext_layout_hexbin_Hexbin.hexbinX = function(d, i) {
  1266. return d[0];
  1267. };
  1268. com_ibm_rave_ext_layout_hexbin_Hexbin.hexbinY = function(d, i) {
  1269. return d[1];
  1270. };
  1271. // $source: com/ibm/rave/ext/layout/cloud/CloudLayout
  1272. /************************************************************************
  1273. ** IBM Confidential
  1274. **
  1275. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  1276. **
  1277. ** (C) Copyright IBM Corp. 2020
  1278. **
  1279. ** The source code for this program is not published or otherwise divested of its trade secrets,
  1280. ** irrespective of what has been deposited with the U.S. Copyright Office.
  1281. ************************************************************************/
  1282. // GENERATED
  1283. //@import com/ibm/rave/ext/layout/cloud/nativeImpl/GraphicContextUtil (runtime) // isDocumentDefined
  1284. /**
  1285. * Word cloud layout by Jason Davies, http://www.jasondavies.com/word-cloud/ Algorithm due to Jonathan Feinberg, http://static.mrfeinberg.com/bv_ch03.pdf As word placement can be quite slow for more than a few hundred words, the layout algorithm can be run asynchronously, with a configurable time step size. This makes it possible to animate words as they are placed without stuttering. It is recommended to always use a time step even without animations as it prevents the browser's event loop from blocking while placing the words. This is how the layout is configured: <code> var fontSize = Rave.scale.log().range([10, 100]); var layout = rave.capability.cloud() .size([960, 600]) .timeInterval(10) .text(function(d) { return d.key; }) .font("Impact") .fontSize(function(d) { return fontSize(+d.value); }) .rotate(function(d) { return ~~( Rave.random.random().randomize() * 5) * 30 - 60; }) .padding(1) .on("word", progress) .on("end", draw) .words([...]) .start(); </code> The text, font, fontSize, rotate and padding options all take either constant values or accessor functions that are called for each datum. There are three events: "word", fired each time a word is successfully placed, "step" fired at each time interval(if interval is set), and "end", fired when all words have been placed. To stop a running layout, simply call layout.stop(). For synchronous operation, you can use timeInterval(Infinity).
  1286. */
  1287. var com_ibm_rave_ext_layout_cloud_CloudLayout = rave['internal']['Declare']({
  1288. //_step : null,
  1289. //cbounds : null,
  1290. /**
  1291. * area extent value (width and height)
  1292. */
  1293. //_size : null,
  1294. //_text : null,
  1295. //_font : null,
  1296. //_fontSize : null,
  1297. //_fontStyle : null,
  1298. //_fontWeight : null,
  1299. //_rotate : null,
  1300. //_padding : null,
  1301. //_spiral : null,
  1302. //_words : null,
  1303. //_event : null,
  1304. //_timer : null,
  1305. //_context : null,
  1306. //_paddingValue : null,
  1307. //_fontWeightValue : null,
  1308. //_rotateValue : null,
  1309. //_fontStyleValue : null,
  1310. //_fontValue : null,
  1311. //_fontSizeValue : null,
  1312. //_textValue : null,
  1313. ci : -1,
  1314. ratio : 1,
  1315. _timeInterval : Infinity,
  1316. constructor : function() {
  1317. this._size = [256, 256];
  1318. this._text = com_ibm_rave_ext_layout_cloud_CloudLayout.cloudText;
  1319. this._font = com_ibm_rave_ext_layout_cloud_CloudLayout.cloudFont;
  1320. this._fontSize = com_ibm_rave_ext_layout_cloud_CloudLayout.cloudFontSize;
  1321. this._fontStyle = com_ibm_rave_ext_layout_cloud_CloudLayout.cloudFontNormal;
  1322. this._fontWeight = com_ibm_rave_ext_layout_cloud_CloudLayout.cloudFontNormal;
  1323. this._rotate = com_ibm_rave_ext_layout_cloud_CloudLayout.cloudRotate;
  1324. this._padding = com_ibm_rave_ext_layout_cloud_CloudLayout.cloudPadding;
  1325. this._spiral = com_ibm_rave_ext_layout_cloud_CloudLayout._archimedeanSpiral();
  1326. this._event = rave.dispatch("word", "end", "step");
  1327. {
  1328. var canvas;
  1329. if (com_ibm_rave_ext_layout_cloud_nativeImpl_GraphicContextUtil.isDocumentDefined()) {
  1330. canvas = rave.canvas.create(1, 1);
  1331. this.ratio = Math.sqrt(canvas.getContext("2d").getImageData(0, 0, 1, 1).data.length >> 2);
  1332. canvas["width"] = (64 << 5) / this.ratio;
  1333. canvas["height"] = 2048 / this.ratio;
  1334. } else {
  1335. canvas = rave.canvas.create(64 << 5, 2048);
  1336. }
  1337. this._context = canvas.getContext("2d");
  1338. this._context.fillStyle = this._context.strokeStyle = "red";
  1339. this._context.textAlign = "center";
  1340. }
  1341. },
  1342. /**
  1343. * Even binding to "end" , "step" or "word" events. There are two events: - "step", fired each time a time interval has elapsed, - "word", fired each time a word is successfully placed, - "end", fired when all words have been placed. The event callback contains the following arguments: - "step" : arg[0] - collection of data nodes, representing words that had been placed, arg[1] - [[x0,y0][x1,y1]] coordinates describing rectangle of the actual bounds used by the layout - "word" : arg[0] - data node, representing the word, which has been placed - "end" : arg[0] - collection of data nodes, representing words that had been placed, arg[1] - [[x0,y0][x1,y1]] coordinates describing rectangle of the actual bounds used by the layout , arg[2] - collection of data nodes, representing words that did not fit (if any), arg[3] - scale required to increase the size to fit all words, e.g. scale of 1.5 means - increase size by 1.5 times to fit all words
  1344. * @param (String) type "end" | "word" | "step" event type
  1345. * @param (rave['internal']['RunFunction']) listener event listener , which will be notified
  1346. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1347. */
  1348. /** @expose */
  1349. on : function(type, listener) {
  1350. this._event.on(type, listener);
  1351. return this;
  1352. },
  1353. cloudCollide : function(tag, board, sw) {
  1354. var _sw = sw;
  1355. _sw >>= 5;
  1356. var sprite = tag["sprite"];
  1357. var w = ~~tag["width"] >> 5;
  1358. var lx = tag["x"] - (w << 4);
  1359. var sx = lx & 0x7f;
  1360. var msx = 32 - sx;
  1361. var h = ~~(tag["y1"] - tag["y0"]);
  1362. var x = ~~(tag["y"] + tag["y0"]) * _sw + (lx >> 5);
  1363. var last;
  1364. for (var j = 0; j < h; ++j) {
  1365. last = 0;
  1366. for (var i = 0; i <= w; ++i) {
  1367. var _board = x + i < board.length ? board[x + i] : 0;
  1368. var _sprite = (!sprite || j * w + i >= sprite.length) ? 0 : sprite[j * w + i];
  1369. if ((((last << msx) | (i < w ? (last = _sprite) >>> sx : 0)) & _board) != 0) {
  1370. return true;
  1371. }
  1372. }
  1373. x += _sw;
  1374. }
  1375. return false;
  1376. },
  1377. collideRects : function(a, bounds) {
  1378. var test1 = a["x"] + a["x1"] > bounds[0][0];
  1379. var test2 = a["x"] + a["x0"] < bounds[1][0];
  1380. var test3 = a["y"] + a["y1"] > bounds[0][1];
  1381. var test4 = a["y"] + a["y0"] < bounds[1][1];
  1382. return test1 && test2 && test3 && test4;
  1383. },
  1384. /**
  1385. * Starts the layout
  1386. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1387. */
  1388. /** @expose */
  1389. start : function() {
  1390. this.initContext();
  1391. var cloud = this;
  1392. this.cbounds = null;
  1393. this.ci = -1;
  1394. var n = this.words().length;
  1395. var tags = [];
  1396. var data = this.words().map(function(d, i, array) {
  1397. d["text"] = cloud._text.call(this, d, i, 0);
  1398. if (d["text"] != null && d["text"].length > 50) {
  1399. d["text"] = d["text"].substring(0, 50 - 1) + "...";
  1400. }
  1401. d["font"] = cloud._font.call(this, d, i, 0);
  1402. d["style"] = cloud._fontStyle.call(this, d, i, 0);
  1403. d["weight"] = cloud._fontWeight.call(this, d, i, 0);
  1404. d["rotate"] = cloud._rotate.call(this, d, i, 0);
  1405. d["size"] = cloud._fontSize.call(this, d, i, 0);
  1406. d["padding"] = cloud._padding.call(this, d, i, 0);
  1407. d["width"] = d["height"] = d["x0"] = d["y0"] = d["x1"] = d["y1"] = 0.0;
  1408. d["sprite"] = null;
  1409. d["x"] = d["y"] = d["xoff"] = d["yoff"] = 0;
  1410. return d;
  1411. });
  1412. this.cloudSprite(data);
  1413. data.sort(function(a, b) {
  1414. return ~~(Math.max(b["width"], b["height"]) - Math.max(a["width"], a["height"]));
  1415. });
  1416. var board = com_ibm_rave_ext_layout_cloud_CloudLayout.zeroArray((this._size[0] >> 5) * this._size[1]);
  1417. this._step = function() {
  1418. if (cloud._size[0] <= 0 || cloud._size[1] <= 0) {
  1419. return;
  1420. }
  1421. var d;
  1422. var start = Date.now();
  1423. while (Date.now() - start < cloud._timeInterval && ++cloud.ci < n && (cloud._timer != null)) {
  1424. d = data[cloud.ci];
  1425. d["x"] = (~~(cloud._size[0] * (com_ibm_rave_ext_layout_cloud_CloudLayout.getRandom() + .5))) >> 1;
  1426. d["y"] = (~~(cloud._size[1] * (com_ibm_rave_ext_layout_cloud_CloudLayout.getRandom() + .5))) >> 1;
  1427. if (d["hasText"] && cloud.place(board, d, cloud.cbounds)) {
  1428. tags.push(d);
  1429. cloud._event["word"].call(cloud, d);
  1430. if (cloud.cbounds) {
  1431. com_ibm_rave_ext_layout_cloud_CloudLayout.cloudBounds(cloud.cbounds, d);
  1432. } else {
  1433. cloud.cbounds = [[d["x"] + d["x0"], d["y"] + d["y0"]], [d["x"] + d["x1"], d["y"] + d["y1"]]];
  1434. }
  1435. d["x"] -= cloud._size[0] >> 1;
  1436. d["y"] -= cloud._size[1] >> 1;
  1437. }
  1438. }
  1439. cloud._event["step"].call(cloud, tags, cloud.cbounds);
  1440. if (cloud.ci >= n) {
  1441. cloud.stop();
  1442. cloud._event["end"].call(cloud, tags, cloud.cbounds);
  1443. }
  1444. };
  1445. if (this._timer != null) {
  1446. clearInterval(this._timer);
  1447. }
  1448. if (cloud._timeInterval != Infinity) {
  1449. this._timer = setInterval(this._step, 0);
  1450. } else {
  1451. this._timer = {};
  1452. this._step();
  1453. }
  1454. return cloud;
  1455. },
  1456. /**
  1457. * loops through all data nodes and creates the sprite for each while calculating the area needed to lay them all out
  1458. * @param (Array) data the data nodes
  1459. */
  1460. cloudSprite : function(data) {
  1461. var area = 0;
  1462. var maxHeight = 0;
  1463. var maxWidth = 0;
  1464. var startIndex = 0;
  1465. do {
  1466. var index = startIndex;
  1467. var maxIndex = index;
  1468. this._context.clearRect(0, 0, (64 << 5) / this.ratio, 2048 / this.ratio);
  1469. var x = 0;
  1470. var y = 0;
  1471. var n = data.length;
  1472. var maxh = 0;
  1473. --index;
  1474. while (++index < n) {
  1475. var d = data[index];
  1476. if (d["sprite"] || d["text"] == null || d["text"].length == 0) {
  1477. continue;
  1478. }
  1479. this._context.save();
  1480. this._context.font = d["style"] + " normal " + d["weight"] + " " + ~~((d["size"] + 1) / this.ratio) + "px/normal " + d["font"];
  1481. var w = this._context.measureText(d["text"])["width"] * this.ratio;
  1482. var h = d["size"] << 1;
  1483. if (d["rotate"] != 0) {
  1484. var sr = Math.sin(d["rotate"] * 0.017453292519943295);
  1485. var cr = Math.cos(d["rotate"] * 0.017453292519943295);
  1486. var wcr = w * cr;
  1487. var wsr = w * sr;
  1488. var hcr = h * cr;
  1489. var hsr = h * sr;
  1490. w = ((~~(Math.max(Math.abs(wcr + hsr), Math.abs(wcr - hsr)) + 0x1f)) >> 5) << 5;
  1491. h = ~~Math.max(Math.abs(wsr + hcr), Math.abs(wsr - hcr));
  1492. } else {
  1493. w = ((~~w + 0x1f) >> 5) << 5;
  1494. }
  1495. if (h > maxh) {
  1496. maxh = h;
  1497. }
  1498. if (x + w >= (64 << 5)) {
  1499. x = 0;
  1500. y += maxh;
  1501. maxh = 0;
  1502. }
  1503. if (y + h >= 2048) {
  1504. break;
  1505. }
  1506. this._context.translate((x + (~~w >> 1)) / this.ratio, (y + (~~h >> 1)) / this.ratio);
  1507. if (d["rotate"] != 0) {
  1508. this._context.rotate(d["rotate"] * 0.017453292519943295);
  1509. }
  1510. this._context.fillText(d["text"], 0, 0);
  1511. if (d["padding"] != 0) {
  1512. this._context.lineWidth = 2 * d["padding"];
  1513. this._context.strokeText(d["text"], 0, 0);
  1514. }
  1515. this._context.restore();
  1516. d["width"] = w;
  1517. d["height"] = h;
  1518. d["xoff"] = x;
  1519. d["yoff"] = y;
  1520. d["x1"] = ~~w >> 1;
  1521. d["y1"] = ~~h >> 1;
  1522. d["x0"] = -d["x1"];
  1523. d["y0"] = -d["y1"];
  1524. d["hasText"] = true;
  1525. x += w;
  1526. maxWidth = Math.max(maxWidth, w);
  1527. maxHeight = Math.max(maxHeight, h);
  1528. }
  1529. maxIndex = index;
  1530. var pixels = this._context.getImageData(0, 0, (64 << 5) / this.ratio, 2048 / this.ratio).data;
  1531. var sprite = [];
  1532. while (--index >= startIndex) {
  1533. var d = data[index];
  1534. if (!d["hasText"]) {
  1535. continue;
  1536. }
  1537. var w = d["width"];
  1538. var w32 = (~~w) >> 5;
  1539. var h = d["y1"] - d["y0"];
  1540. for (var i = 0; i < h * w32; ++i) {
  1541. sprite[i] = 0;
  1542. }
  1543. if (d["xoff"] == null) {
  1544. startIndex = maxIndex;
  1545. break;
  1546. }
  1547. x = d["xoff"];
  1548. y = d["yoff"];
  1549. var seen = 0, seenRow = -1;
  1550. for (var j = 0; j < h; ++j) {
  1551. for (var i = 0; i < w; ++i) {
  1552. var k = w32 * j + (i >> 5);
  1553. var m = (pixels[((y + j) * (64 << 5) + (x + i)) << 2] != 0) ? 1 << (31 - (i % 32)) : 0;
  1554. sprite[k] = sprite[k] | m;
  1555. seen |= m;
  1556. }
  1557. if (seen != 0) {
  1558. seenRow = j;
  1559. } else {
  1560. d["y0"]++;
  1561. h--;
  1562. j--;
  1563. y++;
  1564. }
  1565. }
  1566. d["y1"] = d["y0"] + seenRow;
  1567. d["sprite"] = sprite.slice(0, ~~((d["y1"] - d["y0"]) * w32));
  1568. area += (d["width"] * d["height"]) * 1.4;
  1569. }
  1570. startIndex = maxIndex;
  1571. } while (startIndex < data.length);
  1572. if (this._size[0] > 0 && this._size[1] > 0) {
  1573. var newWidth = Math.ceil(this._size[0] * Math.sqrt(+ (area) / (this._size[0] * this._size[1])));
  1574. var newHeight = Math.ceil(this._size[1] * Math.sqrt(+ (area) / (this._size[0] * this._size[1])));
  1575. if (newWidth > this._size[0] || newHeight > this._size[1]) {
  1576. this.size([newWidth, newHeight]);
  1577. }
  1578. if (maxWidth > this._size[0] || maxHeight > this._size[1]) {
  1579. var widthPercent = maxWidth / this._size[0];
  1580. var heightPercent = maxHeight / this._size[1];
  1581. var increasePercent = Math.max(widthPercent, heightPercent) * 1.4;
  1582. if (increasePercent > 1.0) {
  1583. this.size([Math.ceil(this._size[0] * increasePercent), Math.ceil(this._size[1] * increasePercent)]);
  1584. }
  1585. }
  1586. }
  1587. },
  1588. /**
  1589. * Stops the layout
  1590. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1591. */
  1592. /** @expose */
  1593. stop : function() {
  1594. if (this._timer != null) {
  1595. clearInterval(this._timer);
  1596. this._timer = null;
  1597. }
  1598. this.disposeContext();
  1599. return this;
  1600. },
  1601. place : function(board, tag, bounds) {
  1602. var startX = tag["x"];
  1603. var startY = tag["y"];
  1604. var maxDelta = Math.sqrt(this._size[0] * this._size[0] + this._size[1] * this._size[1]);
  1605. var s = this.__spiral(this._size);
  1606. var dt = com_ibm_rave_ext_layout_cloud_CloudLayout.getRandom() < .5 ? 1 : -1, t = -dt;
  1607. var dx, dy;
  1608. var dxdy;
  1609. while ((dxdy = s(t += dt))) {
  1610. dx = ~~(dxdy[0]);
  1611. dy = ~~(dxdy[1]);
  1612. if (Math.min(dx, dy) > maxDelta) {
  1613. break;
  1614. }
  1615. tag["x"] = startX + dx;
  1616. tag["y"] = startY + dy;
  1617. if (tag["x"] + tag["x0"] < 0 || tag["y"] + tag["y0"] < 0 || tag["x"] + tag["x1"] >= this._size[0] || tag["y"] + tag["y1"] >= this._size[1]) {
  1618. continue;
  1619. }
  1620. if (!bounds || !(this.cloudCollide(tag, board, this._size[0]))) {
  1621. if (!bounds || this.collideRects(tag, bounds)) {
  1622. var sprite = tag["sprite"];
  1623. var w = ~~tag["width"] >> 5, sw = this.size()[0] >> 5, lx = tag["x"] - (w << 4), sx = lx & 0x7f, msx = 32 - sx, h = ~~(tag["y1"] - tag["y0"]), x = ~~(tag["y"] + tag["y0"]) * sw + (lx >> 5), last;
  1624. for (var j = 0; j < h; ++j) {
  1625. last = 0;
  1626. for (var i = 0; i <= w; ++i) {
  1627. board[x + i] |= (last << msx) | (i < w ? (last = sprite[j * w + i]) >>> sx : 0);
  1628. }
  1629. x += sw;
  1630. }
  1631. tag["sprite"] = null;
  1632. return true;
  1633. }
  1634. }
  1635. }
  1636. return false;
  1637. },
  1638. /**
  1639. * As word placement can be quite slow for more than a few hundred words, the layout algorithm can be run asynchronously, with a configurable time step size. This makes it possible to animate words as they are placed without stuttering Sets step interrupt interval. When set to infinity layout step runs until all the nodes are laid out. Infinity is the default
  1640. * @param (Number) x time interval
  1641. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1642. */
  1643. timeInterval$0 : function(x) {
  1644. this._timeInterval = x == null ? Infinity : x;
  1645. return this;
  1646. },
  1647. /**
  1648. * As word placement can be quite slow for more than a few hundred words, the layout algorithm can be run asynchronously, with a configurable time step size. This makes it possible to animate words as they are placed without stuttering Returns step interrupt interval. When set to infinity layout step runs until all the nodes are laid out. Infinity is the default
  1649. * @return (Number) time step interval
  1650. */
  1651. timeInterval$1 : function() {
  1652. return this._timeInterval;
  1653. },
  1654. /**
  1655. * Sets data array of cloud data nodes
  1656. * @param (Array) nodes array of cloud data nodes
  1657. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1658. * @see (Object) CloudDataNode
  1659. */
  1660. words$0 : function(nodes) {
  1661. this._words = nodes;
  1662. return this;
  1663. },
  1664. /**
  1665. * Returns array of data nodes
  1666. * @return (Array) array of data nodes
  1667. * @see (Object) CloudDataNode
  1668. */
  1669. words$1 : function() {
  1670. return this._words;
  1671. },
  1672. /**
  1673. * Returns the current size, which defaults to 1x1
  1674. * @return (int[]) return the current size
  1675. */
  1676. size$0 : function() {
  1677. return this._size;
  1678. },
  1679. /**
  1680. * Sets the available layout size to the specified two-element array of numbers representing x and y.
  1681. * @param (int[]) newSize the size of the layout
  1682. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this Layout
  1683. */
  1684. size$1 : function(newSize) {
  1685. this._size = newSize;
  1686. return this;
  1687. },
  1688. /**
  1689. * Sets font family name same for all data nodes. This is a prioritized list of font family names and/or generic family names. It should be formatted as a comma-separated list and each family name should be single-quoted, for example: <code>"'Roboto', 'Helvetica', 'Arial', 'sans-serif'"</code>.
  1690. * @param (String) value string font family name list
  1691. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1692. */
  1693. font$0 : function(value) {
  1694. this._font = function(data, index, groupIndex) {
  1695. return value;
  1696. };
  1697. this._fontValue = value;
  1698. return this;
  1699. },
  1700. /**
  1701. * Sets font family name to a function. Function takes data node as a parameter and returns font family name string. Each returned string is a prioritized list of font family names and/or generic family names. It should be formatted as a comma-separated list and each family name should be single-quoted, for example: <code>"'Roboto', 'Helvetica', 'Arial', 'sans-serif'"</code>.
  1702. * @param (rave['internal']['ValueFunction']) value font family name function
  1703. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1704. */
  1705. font$1 : function(value) {
  1706. this._font = value;
  1707. this._fontValue = null;
  1708. return this;
  1709. },
  1710. /**
  1711. * Returns font family value or function.Function takes data node as a parameter and returns font family name string
  1712. * @return (Object) font family value or function
  1713. */
  1714. font$2 : function() {
  1715. return this._fontValue != null ? this._fontValue : this._font;
  1716. },
  1717. /**
  1718. * Returns font style value or function. The function takes cloud data node as a parameter and returns font style value for the given node. Valid font style values are "normal" | "italic" | "oblique"
  1719. * @return (Object) font style value or function
  1720. */
  1721. fontStyle$0 : function() {
  1722. return this._fontStyleValue != null ? this._fontStyleValue : this._fontStyle;
  1723. },
  1724. /**
  1725. * Sets font style for all data nodes to "normal" | "italic" | "oblique"
  1726. * @param (String) value font style value as "normal" | "italic" | "oblique"
  1727. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1728. */
  1729. fontStyle$1 : function(value) {
  1730. this._fontStyle = function(data, index, groupIndex) {
  1731. return value;
  1732. };
  1733. this._fontStyleValue = value;
  1734. return this;
  1735. },
  1736. /**
  1737. * Sets font style function. The function takes cloud data node as a parameter and returns font style value for the given node. Valid font style values are "normal" | "italic" | "oblique"
  1738. * @param (rave['internal']['ValueFunction']) fontStyleFn font style function
  1739. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1740. */
  1741. fontStyle$2 : function(fontStyleFn) {
  1742. this._fontStyle = fontStyleFn;
  1743. this._fontStyleValue = null;
  1744. return this;
  1745. },
  1746. /**
  1747. * Returns rotation function or rotation angle in degrees.
  1748. * @return (Object) rotation function or rotation angle in degrees
  1749. */
  1750. rotate$0 : function() {
  1751. return this._rotateValue != null ? this._rotateValue : this._rotate;
  1752. },
  1753. /**
  1754. * Sets rotation angle in degrees for all nodes
  1755. * @param (int) value rotation angle in degrees
  1756. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1757. */
  1758. rotate$1 : function(value) {
  1759. this._rotate = function(data, index, groupIndex) {
  1760. return value;
  1761. };
  1762. this._rotateValue = value;
  1763. return this;
  1764. },
  1765. /**
  1766. * Sets rotation function. The function takes cloud data node as a parameter and returns rotation angle in degrees for the given node
  1767. * @param (rave['internal']['ValueFunction']) _rotateFn rotation function
  1768. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1769. */
  1770. rotate$2 : function(_rotateFn) {
  1771. this._rotate = _rotateFn;
  1772. this._rotateValue = null;
  1773. return this;
  1774. },
  1775. /**
  1776. * Returns text function. Function takes cloud data node as a parameter and returns text string for the data node
  1777. * @return (Object) text function
  1778. */
  1779. text$0 : function() {
  1780. return this._textValue != null ? this._textValue : this._text;
  1781. },
  1782. /**
  1783. * Sets the same text string for all data nodes
  1784. * @param (String) value text string
  1785. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1786. */
  1787. text$1 : function(value) {
  1788. this._text = function(data, index, groupIndex) {
  1789. return value;
  1790. };
  1791. this._textValue = value;
  1792. return this;
  1793. },
  1794. /**
  1795. * Set text function. Function takes cloud data node as a parameter and returns text string
  1796. * @param (rave['internal']['ValueFunction']) value text function
  1797. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1798. */
  1799. text$2 : function(value) {
  1800. this._text = value;
  1801. this._textValue = null;
  1802. return this;
  1803. },
  1804. /**
  1805. * Return spiral function (e.g. archimedean or rectangular)
  1806. * @return (rave['internal']['SingleValueFunction']) current spiral function
  1807. */
  1808. spiral$0 : function() {
  1809. return this._spiral;
  1810. },
  1811. /**
  1812. * Sets spiral function to either archimedean or rectangular
  1813. * @param (String) name "archimedean" or "rectangular"
  1814. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1815. */
  1816. spiral$1 : function(name) {
  1817. if (com_ibm_rave_ext_layout_cloud_CloudLayout.ARCHIMEDEAN == name) {
  1818. this._spiral = com_ibm_rave_ext_layout_cloud_CloudLayout._archimedeanSpiral();
  1819. } else {
  1820. this._spiral = com_ibm_rave_ext_layout_cloud_CloudLayout._rectangularSpiral();
  1821. }
  1822. return this;
  1823. },
  1824. __spiral : function(arg) {
  1825. return this._spiral(arg);
  1826. },
  1827. /**
  1828. * Sets font size function. Function takes cloud data node as a parameter and returns font size for the data node
  1829. * @param (rave['internal']['ValueFunction']) fontSizeFn font size function
  1830. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1831. */
  1832. fontSize$0 : function(fontSizeFn) {
  1833. this._fontSize = fontSizeFn;
  1834. this._fontSizeValue = null;
  1835. return this;
  1836. },
  1837. /**
  1838. * Returns font size or font size function. Function takes cloud data node as a parameter and returns font size for the data node
  1839. * @return (Object) font size function
  1840. */
  1841. fontSize$1 : function() {
  1842. return this._fontSizeValue != null ? this._fontSizeValue : this._fontSize;
  1843. },
  1844. /**
  1845. * Sets uniform font size for all data nodes
  1846. * @param (Number) value font size for all data nodes
  1847. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1848. */
  1849. fontSize$2 : function(value) {
  1850. this._fontSize = function(data, index, groupIndex) {
  1851. return value;
  1852. };
  1853. this._fontSizeValue = + (value);
  1854. return this;
  1855. },
  1856. /**
  1857. * Returns padding - a function or integer value
  1858. * @return (Object) padding function or integer value
  1859. */
  1860. padding$0 : function() {
  1861. return this._paddingValue != null ? this._paddingValue : this._padding;
  1862. },
  1863. /**
  1864. * Set padding to an integer value, same for all data nodes
  1865. * @param (int) value padding integer value
  1866. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1867. */
  1868. padding$1 : function(value) {
  1869. this._padding = function(data, index, groupIndex) {
  1870. return value;
  1871. };
  1872. this._paddingValue = value;
  1873. return this;
  1874. },
  1875. /**
  1876. * Sets padding function. The function takes cloud data node as a parameter and returns padding for the given node
  1877. * @param (rave['internal']['ValueFunction']) paddingFn padding function
  1878. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1879. */
  1880. padding$2 : function(paddingFn) {
  1881. this._padding = paddingFn;
  1882. this._paddingValue = null;
  1883. return this;
  1884. },
  1885. /**
  1886. * Sets font weight function. The function takes cloud data node as a parameter and returns font weight string for the given node. Font weight string values are "normal" | "bold" | number
  1887. * @param (rave['internal']['ValueFunction']) fontWeightFn font weight function
  1888. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1889. */
  1890. fontWeight$0 : function(fontWeightFn) {
  1891. this._fontWeight = fontWeightFn;
  1892. this._fontWeightValue = null;
  1893. return this;
  1894. },
  1895. /**
  1896. * Returns font weight string or function. The function takes cloud data node as a parameter and returns font weight string for the given node. Font weight string values are "normal" | "bold" | number
  1897. * @return (Object) font weight - string or function
  1898. */
  1899. fontWeight$1 : function() {
  1900. return this._fontWeightValue != null ? this._fontWeightValue : this._fontWeight;
  1901. },
  1902. /**
  1903. * Sets font weight for all data nodes. Font weight values are "normal" | "bold" | number
  1904. * @param (String) value font weight as "normal" | "bold" | number string
  1905. * @return (com.ibm.rave.ext.layout.cloud.CloudLayout) this
  1906. */
  1907. fontWeight$2 : function(value) {
  1908. this._fontWeight = function(data, index, groupIndex) {
  1909. return value;
  1910. };
  1911. this._fontWeightValue = value;
  1912. return this;
  1913. },
  1914. initContext : function() {
  1915. if (!this._context) {
  1916. var canvas;
  1917. if (com_ibm_rave_ext_layout_cloud_nativeImpl_GraphicContextUtil.isDocumentDefined()) {
  1918. canvas = rave.canvas.create(1, 1);
  1919. this._context = canvas.getContext("2d");
  1920. this.ratio = Math.sqrt(this._context.getImageData(0, 0, 1, 1).data.length >> 2);
  1921. rave.canvas.disposeContext(this._context);
  1922. this._context = null;
  1923. canvas["width"] = (64 << 5) / this.ratio;
  1924. canvas["height"] = 2048 / this.ratio;
  1925. } else {
  1926. canvas = rave.canvas.create(64 << 5, 2048);
  1927. }
  1928. this._context = canvas.getContext("2d");
  1929. this._context.fillStyle = this._context.strokeStyle = "red";
  1930. this._context.textAlign = "center";
  1931. }
  1932. },
  1933. disposeContext : function() {
  1934. if (this._context) {
  1935. rave.canvas.disposeContext(this._context);
  1936. this._context = null;
  1937. }
  1938. },
  1939. /** @expose */
  1940. timeInterval : function(a0) {
  1941. var args = arguments;
  1942. if (args.length == 0) {
  1943. return this.timeInterval$1();
  1944. }
  1945. return this.timeInterval$0(a0);
  1946. },
  1947. /** @expose */
  1948. words : function(a0) {
  1949. var args = arguments;
  1950. if (args.length == 0) {
  1951. return this.words$1();
  1952. }
  1953. return this.words$0(a0);
  1954. },
  1955. /** @expose */
  1956. size : function(a0) {
  1957. var args = arguments;
  1958. if (args.length == 0) {
  1959. return this.size$0();
  1960. }
  1961. return this.size$1(a0);
  1962. },
  1963. /** @expose */
  1964. font : function(a0) {
  1965. var args = arguments;
  1966. if (args.length == 0) {
  1967. return this.font$2();
  1968. }
  1969. if (args.length == 1 && (a0 == null || typeof a0 === "string")) {
  1970. return this.font$0(a0);
  1971. }
  1972. return this.font$1(a0);
  1973. },
  1974. /** @expose */
  1975. fontStyle : function(a0) {
  1976. var args = arguments;
  1977. if (args.length == 0) {
  1978. return this.fontStyle$0();
  1979. }
  1980. if (args.length == 1 && (a0 == null || typeof a0 === "string")) {
  1981. return this.fontStyle$1(a0);
  1982. }
  1983. return this.fontStyle$2(a0);
  1984. },
  1985. /** @expose */
  1986. rotate : function(a0) {
  1987. var args = arguments;
  1988. if (args.length == 0) {
  1989. return this.rotate$0();
  1990. }
  1991. if (args.length == 1 && typeof a0 === "function") {
  1992. return this.rotate$2(a0);
  1993. }
  1994. return this.rotate$1(a0);
  1995. },
  1996. /** @expose */
  1997. text : function(a0) {
  1998. var args = arguments;
  1999. if (args.length == 0) {
  2000. return this.text$0();
  2001. }
  2002. if (args.length == 1 && (a0 == null || typeof a0 === "string")) {
  2003. return this.text$1(a0);
  2004. }
  2005. return this.text$2(a0);
  2006. },
  2007. /** @expose */
  2008. spiral : function(a0) {
  2009. var args = arguments;
  2010. if (args.length == 0) {
  2011. return this.spiral$0();
  2012. }
  2013. return this.spiral$1(a0);
  2014. },
  2015. /** @expose */
  2016. fontSize : function(a0) {
  2017. var args = arguments;
  2018. if (args.length == 0) {
  2019. return this.fontSize$1();
  2020. }
  2021. if (args.length == 1 && typeof a0 === "function") {
  2022. return this.fontSize$0(a0);
  2023. }
  2024. return this.fontSize$2(a0);
  2025. },
  2026. /** @expose */
  2027. padding : function(a0) {
  2028. var args = arguments;
  2029. if (args.length == 0) {
  2030. return this.padding$0();
  2031. }
  2032. if (args.length == 1 && typeof a0 === "function") {
  2033. return this.padding$2(a0);
  2034. }
  2035. return this.padding$1(a0);
  2036. },
  2037. /** @expose */
  2038. fontWeight : function(a0) {
  2039. var args = arguments;
  2040. if (args.length == 0) {
  2041. return this.fontWeight$1();
  2042. }
  2043. if (args.length == 1 && typeof a0 === "function") {
  2044. return this.fontWeight$0(a0);
  2045. }
  2046. return this.fontWeight$2(a0);
  2047. }
  2048. });
  2049. com_ibm_rave_ext_layout_cloud_CloudLayout._archimedeanSpiral = function() {
  2050. return function(size) {
  2051. var e = size[0] / (size[1] != 0 ? size[1] : 1);
  2052. return function(t) {
  2053. var _t = t * .1;
  2054. var a = e * _t * Math.cos(_t);
  2055. var b = _t * Math.sin(_t);
  2056. var result = [a, b];
  2057. return result;
  2058. };
  2059. };
  2060. };
  2061. com_ibm_rave_ext_layout_cloud_CloudLayout._rectangularSpiral = function() {
  2062. return function(size) {
  2063. var x = 0, y = 0;
  2064. var dy = 4, dx = dy * size[0] / size[1];
  2065. return function(t) {
  2066. var sign = t < 0 ? -1 : 1;
  2067. switch ((~~(Math.sqrt(1 + 4 * sign * t) - sign)) & 3) {
  2068. case 0:
  2069. x += dx;
  2070. break;
  2071. case 1:
  2072. y += dy;
  2073. break;
  2074. case 2:
  2075. x -= dx;
  2076. break;
  2077. default:
  2078. y -= dy;
  2079. break;
  2080. }
  2081. var result = [x, y];
  2082. return result;
  2083. };
  2084. };
  2085. };
  2086. com_ibm_rave_ext_layout_cloud_CloudLayout.zeroArray = function(n) {
  2087. var a = [];
  2088. for (var i = 0; i < n; ++i) {
  2089. a[i] = 0;
  2090. }
  2091. return a;
  2092. };
  2093. com_ibm_rave_ext_layout_cloud_CloudLayout.cloudBounds = function(bounds, d) {
  2094. var b0 = bounds[0], b1 = bounds[1];
  2095. if (d["x"] + d["x0"] < b0[0]) {
  2096. b0[0] = d["x"] + d["x0"];
  2097. }
  2098. if (d["y"] + d["y0"] < b0[1]) {
  2099. b0[1] = d["y"] + d["y0"];
  2100. }
  2101. if (d["x"] + d["x1"] > b1[0]) {
  2102. b1[0] = d["x"] + d["x1"];
  2103. }
  2104. if (d["y"] + d["y1"] > b1[1]) {
  2105. b1[1] = d["y"] + d["y1"];
  2106. }
  2107. };
  2108. com_ibm_rave_ext_layout_cloud_CloudLayout.getRandom = function() {
  2109. return rave.random.randomizer()();
  2110. };
  2111. com_ibm_rave_ext_layout_cloud_CloudLayout.BUFFER_INCREASE_PERCENT = 1.4;
  2112. com_ibm_rave_ext_layout_cloud_CloudLayout.WORD_LETTER_MAX_LENGTH = 50;
  2113. com_ibm_rave_ext_layout_cloud_CloudLayout.ARCHIMEDEAN = "archimedean";
  2114. com_ibm_rave_ext_layout_cloud_CloudLayout.cloudText = function(data, index, groupIndex) {
  2115. return (data)["text"];
  2116. };
  2117. com_ibm_rave_ext_layout_cloud_CloudLayout.cloudFont = function(data, index, groupIndex) {
  2118. return "serif";
  2119. };
  2120. com_ibm_rave_ext_layout_cloud_CloudLayout.cloudFontNormal = function(data, index, groupIndex) {
  2121. return "normal";
  2122. };
  2123. com_ibm_rave_ext_layout_cloud_CloudLayout.cloudFontSize = function(data, index, groupIndex) {
  2124. return Math.sqrt((data)["value"]);
  2125. };
  2126. com_ibm_rave_ext_layout_cloud_CloudLayout.cloudRotate = function(data, index, groupIndex) {
  2127. return ((~~(com_ibm_rave_ext_layout_cloud_CloudLayout.getRandom() * 6)) - 3) * 30;
  2128. };
  2129. com_ibm_rave_ext_layout_cloud_CloudLayout.cloudPadding = function(data, index, groupIndex) {
  2130. return 1;
  2131. };
  2132. com_ibm_rave_ext_layout_cloud_CloudLayout.cloudRadians = Math.PI / 180;
  2133. com_ibm_rave_ext_layout_cloud_CloudLayout.context_width = (1 << 11) >> 5;
  2134. com_ibm_rave_ext_layout_cloud_CloudLayout.context_height = 1 << 11;
  2135. // $source: com/ibm/rave/ext/layout/cloud/nativeImpl/GraphicContextUtil
  2136. /************************************************************************
  2137. ** IBM Confidential
  2138. **
  2139. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  2140. **
  2141. ** (C) Copyright IBM Corp. 2015
  2142. **
  2143. ** The source code for this program is not published or otherwise divested of its trade secrets,
  2144. ** irrespective of what has been deposited with the U.S. Copyright Office.
  2145. ************************************************************************/
  2146. /** @expose */
  2147. var com_ibm_rave_ext_layout_cloud_nativeImpl_GraphicContextUtil = {
  2148. isDocumentDefined : function(){
  2149. return typeof document !== "undefined";
  2150. }
  2151. };
  2152. // $source: com/ibm/rave/ext/internal/layout/bubble/CirclePackMethod
  2153. /************************************************************************
  2154. ** IBM Confidential
  2155. **
  2156. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  2157. **
  2158. ** (C) Copyright IBM Corp. 2017
  2159. **
  2160. ** The source code for this program is not published or otherwise divested of its trade secrets,
  2161. ** irrespective of what has been deposited with the U.S. Copyright Office.
  2162. ************************************************************************/
  2163. // GENERATED
  2164. //@import com/ibm/rave/ext/internal/layout/bubble/BubblePackLayoutMethod (loadtime) // distance, superclass
  2165. //@import com/ibm/rave/ext/internal/layout/utils/Qtree (runtime) // newQTreeNode, new
  2166. //@import com/ibm/rave/ext/internal/layout/utils/DoubleUtils (runtime) // compare
  2167. /**
  2168. * Algorithm, which will pack all bubbles into a circle
  2169. */
  2170. var com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod = rave['internal']['Declare'](com_ibm_rave_ext_internal_layout_bubble_BubblePackLayoutMethod, {
  2171. /**
  2172. * interm values used by algorithm
  2173. */
  2174. //radii : null,
  2175. //extent : null,
  2176. //edges : null,
  2177. //locations : null,
  2178. //tree : null,
  2179. //collision_test : null,
  2180. /**
  2181. * Constructor
  2182. * @param (Array) extent - available area extent
  2183. */
  2184. constructor : function(extent) {
  2185. this.extent = extent;
  2186. },
  2187. getLocationForCanonicalCircles : function(r, r0, r1, p) {
  2188. var A = r0 + r1;
  2189. var B = r0 + r;
  2190. var C = r1 + r;
  2191. var x = (A * A + B * B - C * C) / 2 / A;
  2192. var y = Math.sqrt(B * B - x * x);
  2193. if (!p) {
  2194. return [x, y];
  2195. }
  2196. p[0] = x;
  2197. p[1] = y;
  2198. return p;
  2199. },
  2200. _createRootNode : function(node) {
  2201. var root = {};
  2202. root["item"] = null;
  2203. this._updateRectangle(root, [node["x"], node["y"]], node["r"]);
  2204. return root;
  2205. },
  2206. _createQTNode : function(index) {
  2207. var node = {};
  2208. node["item"] = index;
  2209. this._updateRectangle(node, this.locations[index], this.radii[index]);
  2210. return node;
  2211. },
  2212. _updateRectangle : function(node, point, r) {
  2213. var size = 2 * r;
  2214. node["x"] = point[0] - r;
  2215. node["y"] = point[1] - r;
  2216. node["width"] = size;
  2217. node["height"] = size;
  2218. },
  2219. pack : function(root) {
  2220. var nodes = root["children"];
  2221. if (!nodes || nodes.length == 0) {
  2222. return;
  2223. }
  2224. var n = nodes.length;
  2225. this.radii = [];
  2226. var reverseOrder = [];
  2227. this.edges = [];
  2228. var o = com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod.makeSortOrder(nodes);
  2229. for (var i = 0; i < n; ++i) {
  2230. var idx = o[n - i - 1];
  2231. reverseOrder[idx] = i;
  2232. var child = nodes[idx];
  2233. this.radii[i] = child["r"];
  2234. }
  2235. this.locations = [];
  2236. this.tree = new com_ibm_rave_ext_internal_layout_utils_Qtree(0, this._createRootNode(root));
  2237. this.collision_test = com_ibm_rave_ext_internal_layout_utils_Qtree.newQTreeNode(0, 0, 0, 0, null);
  2238. this.locations[0] = [0, 0];
  2239. if (n > 1) {
  2240. var d = this.radii[0] + this.radii[1];
  2241. this.locations[1] = [d, 0];
  2242. }
  2243. if (n > 2) {
  2244. var r0 = this.radii[0];
  2245. var r1 = this.radii[1];
  2246. var r2 = this.radii[2];
  2247. var q = this.getLocationForCanonicalCircles(r2, r0, r1, null);
  2248. this.locations[2] = q;
  2249. var w = r0 * r0 + r1 * r1 + r2 * r2;
  2250. var sx = r1 * r1 * (r1 + r0) + r2 * r2 * q[0];
  2251. var sy = r2 * r2 * q[1];
  2252. for (var i = 0; i < 3; ++i) {
  2253. this.locations[i][0] = this.locations[i][0] - sx / w;
  2254. this.locations[i][1] = this.locations[i][1] - sy / w;
  2255. }
  2256. this.addEdge(new com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod.BubbleEdgeData(0, 1));
  2257. this.addEdge(new com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod.BubbleEdgeData(1, 0));
  2258. this.addEdge(new com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod.BubbleEdgeData(0, 2));
  2259. this.addEdge(new com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod.BubbleEdgeData(2, 0));
  2260. this.addEdge(new com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod.BubbleEdgeData(1, 2));
  2261. this.addEdge(new com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod.BubbleEdgeData(2, 1));
  2262. }
  2263. for (var i = 0, p = ~~Math.min(3, n); i < p; ++i) {
  2264. this.tree.insert(this._createQTNode(i));
  2265. }
  2266. if (n > 3) {
  2267. for (var k = 3; k < n; ++k) {
  2268. this.placeOnEdge(k);
  2269. }
  2270. }
  2271. var minMax = new rave['internal']['XYMin_Max']();
  2272. for (var i = 0; i < n; ++i) {
  2273. var location = this.locations[reverseOrder[i]];
  2274. var node = nodes[i];
  2275. node["x"] = location[0];
  2276. node["y"] = location[1];
  2277. minMax.bound(node);
  2278. }
  2279. var cx = (minMax.xMin + minMax.xMax) / 2, cy = (minMax.yMin + minMax.yMax) / 2, cr = 0;
  2280. for (var i = 0; i < n; ++i) {
  2281. var node = nodes[i];
  2282. node["x"] -= cx;
  2283. node["y"] -= cy;
  2284. cr = Math.max(cr, node["r"] + Math.sqrt(node["x"] * node["x"] + node["y"] * node["y"]));
  2285. }
  2286. root["r"] = cr;
  2287. },
  2288. placeOnEdge : function(k) {
  2289. var r = this.radii[k];
  2290. var q = [0, 0];
  2291. for (var i = 0; i < this.edges.length; ++i) {
  2292. var edge = this.edges[i];
  2293. var cr = edge.cr;
  2294. var isCrSet = cr != -1;
  2295. if (!isCrSet || r <= cr) {
  2296. var e1 = edge.e1;
  2297. var e2 = edge.e2;
  2298. this.placeTouching(this.locations[e1], this.radii[e1], this.locations[e2], this.radii[e2], r, q);
  2299. var intersects;
  2300. if (isCrSet) {
  2301. intersects = false;
  2302. } else if (edge.nearShapes) {
  2303. intersects = this.intersectsNearShapes(q, r, edge);
  2304. } else {
  2305. intersects = this.intersectsExisting(q, r, k);
  2306. }
  2307. if (!intersects) {
  2308. this.locations[k] = q;
  2309. this.tree.insert(this._createQTNode(k));
  2310. edge.cr = com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod.getLargestInsideCircleRadius(r, this.radii[e1], this.radii[e2]);
  2311. var bed1 = new com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod.BubbleEdgeData(k, e2);
  2312. var bed2 = new com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod.BubbleEdgeData(e1, k);
  2313. this.addEdge(bed1);
  2314. this.addEdge(bed2);
  2315. if (edge.nearShapes) {
  2316. bed1.nearShapes = edge.nearShapes;
  2317. bed2.nearShapes = edge.nearShapes;
  2318. edge.nearShapes.push(k);
  2319. } else if (!edge.nearShapes && isCrSet) {
  2320. bed1.nearShapes = [];
  2321. bed1.nearShapes.push(k);
  2322. bed1.nearShapes.push(e1);
  2323. bed1.nearShapes.push(e2);
  2324. bed1.nearShapes.push(edge.e3);
  2325. bed2.nearShapes = bed1.nearShapes;
  2326. }
  2327. edge.e3 = k;
  2328. return;
  2329. }
  2330. }
  2331. }
  2332. },
  2333. /**
  2334. * Check if the circle with radius 'r' at location 'p' intersects with any other circle.
  2335. * @param (Array) p - the location of the circle
  2336. * @param (double) r - the radius of the circle
  2337. * @param (int) n - the number of circles already in the graph
  2338. * @return (boolean) <code>true</code> if the circle would intersect another, <code>false</code> otherwise
  2339. */
  2340. intersectsExisting : function(p, r, n) {
  2341. this._updateRectangle(this.collision_test, p, r);
  2342. var method = this;
  2343. var tester = function(node) {
  2344. var rt = r + method.radii[node["item"]] - 1e-2;
  2345. var p2 = method.locations[node["item"]];
  2346. return com_ibm_rave_ext_internal_layout_bubble_BubblePackLayoutMethod.distance(p, p2) < rt;
  2347. };
  2348. return this.tree.collide(tester, this.collision_test);
  2349. },
  2350. placeTouching : function(c0, r0, c1, r1, r, point) {
  2351. var x1 = c1[0] - c0[0];
  2352. var y1 = c1[1] - c0[1];
  2353. var R = r0 + r1;
  2354. var cosA = x1 / R;
  2355. var sinA = y1 / R;
  2356. var p = this.getLocationForCanonicalCircles(r, r0, r1, point);
  2357. var x = p[0] * cosA - p[1] * sinA + c0[0];
  2358. var y = p[0] * sinA + p[1] * cosA + c0[1];
  2359. p[0] = x;
  2360. p[1] = y;
  2361. return p;
  2362. },
  2363. /**
  2364. * Check if the circle with radius 'r' at location 'p' intersects with any other circle. Only considers the near shapes in the edge data.
  2365. * @param (Array) p the location of the circle
  2366. * @param (double) r the radius of the circle
  2367. * @param (com.ibm.rave.ext.internal.layout.bubble.CirclePackMethod.BubbleEdgeData) edgeData the edge data containing near shapes to consider for intersection
  2368. * @return (boolean) <code>true</code> if the circle would intersect another, <code>false</code> otherwise
  2369. */
  2370. intersectsNearShapes : function(p, r, edgeData) {
  2371. var nearShapes = edgeData.nearShapes;
  2372. var adjacent1 = edgeData.e1;
  2373. var adjacent2 = edgeData.e2;
  2374. for (var j = 0, len = nearShapes.length; j < len; ++j) {
  2375. var i = nearShapes[j];
  2376. if (i != adjacent1 && i != adjacent2) {
  2377. var rt = r + this.radii[i] - 1e-2;
  2378. var p2 = this.locations[i];
  2379. if (com_ibm_rave_ext_internal_layout_bubble_BubblePackLayoutMethod.distance(p, p2) < rt) {
  2380. return true;
  2381. }
  2382. }
  2383. }
  2384. return false;
  2385. },
  2386. addEdge : function(e) {
  2387. var dp = this.getTouchPointDistance(e);
  2388. e.touchPointDistance = dp;
  2389. var size = this.edges.length;
  2390. if (size == 0) {
  2391. this.edges.push(e);
  2392. return;
  2393. }
  2394. var a = 0;
  2395. if (dp < this.edges[a].touchPointDistance) {
  2396. this.edges.splice(0, 0, e);
  2397. return;
  2398. }
  2399. var b = size - 1;
  2400. if (dp >= this.edges[b].touchPointDistance) {
  2401. this.edges.push(e);
  2402. return;
  2403. }
  2404. while (b > a + 1) {
  2405. var c = Math.floor((a + b) / 2);
  2406. var dc = this.edges[c].touchPointDistance;
  2407. if (dp < dc) {
  2408. b = c;
  2409. } else {
  2410. a = c;
  2411. }
  2412. }
  2413. this.edges.splice(b, 0, e);
  2414. },
  2415. getTouchPointDistance : function(e) {
  2416. var a = this.locations[e.e1];
  2417. var b = this.locations[e.e2];
  2418. var ra = this.radii[e.e1];
  2419. var rb = this.radii[e.e2];
  2420. var x = (a[0] * rb + b[0] * ra) / (ra + rb);
  2421. var y = (a[1] * rb + b[1] * ra) / (ra + rb);
  2422. return x * x + y * y;
  2423. }
  2424. });
  2425. com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod.makeSortOrder = function(nodes) {
  2426. var size = nodes.length;
  2427. var result = new Array(size);
  2428. for (var i = 0; i < size; ++i) {
  2429. result[i] = i;
  2430. }
  2431. result.sort(function(a, b) {
  2432. var indexA = ~~ (a);
  2433. var indexB = ~~ (b);
  2434. var d1 = nodes[indexA]["r"], d2 = nodes[indexB]["r"];
  2435. return com_ibm_rave_ext_internal_layout_utils_DoubleUtils.compare(d1, d2);
  2436. });
  2437. return result;
  2438. };
  2439. /**
  2440. * Find the largest circle radius that can fit between three other circles using Descartes' theorem.
  2441. * @param (double) r1 - first circle radius
  2442. * @param (double) r2 - second circle radius
  2443. * @param (double) r3 - third circle radius
  2444. * @return (double) the inside circle radius
  2445. */
  2446. com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod.getLargestInsideCircleRadius = function(r1, r2, r3) {
  2447. var a = 1 / r1;
  2448. var b = 1 / r2;
  2449. var c = 1 / r3;
  2450. return 1 / (a + b + c + 2 * Math.sqrt(a * b + b * c + c * a));
  2451. };
  2452. com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod.BubbleEdgeData = rave['internal']['Declare']({
  2453. //nearShapes : null,
  2454. e1 : 0,
  2455. e2 : 0,
  2456. e3 : -1,
  2457. cr : -1,
  2458. touchPointDistance : 0,
  2459. constructor : function(e1, e2) {
  2460. this.e1 = e1;
  2461. this.e2 = e2;
  2462. }
  2463. });
  2464. // $source: com/ibm/rave/ext/internal/layout/bubble/SquarePackMethod
  2465. /************************************************************************
  2466. ** IBM Confidential
  2467. **
  2468. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  2469. **
  2470. ** (C) Copyright IBM Corp. 2017
  2471. **
  2472. ** The source code for this program is not published or otherwise divested of its trade secrets,
  2473. ** irrespective of what has been deposited with the U.S. Copyright Office.
  2474. ************************************************************************/
  2475. // GENERATED
  2476. //@import com/ibm/rave/ext/internal/layout/bubble/CirclePackMethod (loadtime) // superclass
  2477. /**
  2478. * Algorithm, which will pack all bubbles into a square
  2479. */
  2480. var com_ibm_rave_ext_internal_layout_bubble_SquarePackMethod = rave['internal']['Declare'](com_ibm_rave_ext_internal_layout_bubble_CirclePackMethod, {
  2481. getTouchPointDistance : function(e) {
  2482. var a = this.locations[e.e1];
  2483. var b = this.locations[e.e2];
  2484. var ra = this.radii[e.e1];
  2485. var rb = this.radii[e.e2];
  2486. var x = (a[0] * rb + b[0] * ra) / (ra + rb);
  2487. var y = (a[1] * rb + b[1] * ra) / (ra + rb);
  2488. var dx = Math.abs(x) / this.extent[0];
  2489. var dy = Math.abs(y) / this.extent[1];
  2490. return Math.max(dx, dy);
  2491. }
  2492. /**
  2493. * Constructor
  2494. * @param (Array) extent - available area extent
  2495. */
  2496. //constructor : function(extent) {}
  2497. });
  2498. // $source: com/ibm/rave/ext/layout/RaveLayout
  2499. /************************************************************************
  2500. ** IBM Confidential
  2501. **
  2502. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  2503. **
  2504. ** (C) Copyright IBM Corp. 2017
  2505. **
  2506. ** The source code for this program is not published or otherwise divested of its trade secrets,
  2507. ** irrespective of what has been deposited with the U.S. Copyright Office.
  2508. ************************************************************************/
  2509. // GENERATED
  2510. //@import com/ibm/rave/ext/layout/bubble/BubbleLayout (static) // new
  2511. //@import com/ibm/rave/ext/layout/fill/FillLayout (static) // new
  2512. //@import com/ibm/rave/ext/layout/hexbin/Hexbin (static) // new
  2513. //@import com/ibm/rave/ext/layout/cloud/CloudLayout (static) // new
  2514. /**
  2515. * A factory of extended layouts for rave capability.
  2516. * @see BubbleLayout
  2517. */
  2518. var com_ibm_rave_ext_layout_RaveLayout = {
  2519. };
  2520. /**
  2521. * @return (com.ibm.rave.ext.layout.bubble.BubbleLayout) a new instance of {@link BubbleLayout}
  2522. * @see BubbleLayout
  2523. */
  2524. /** @expose */
  2525. com_ibm_rave_ext_layout_RaveLayout.bubble = function() {
  2526. return new com_ibm_rave_ext_layout_bubble_BubbleLayout();
  2527. };
  2528. /**
  2529. * @return (com.ibm.rave.ext.layout.fill.FillLayout) a new instance of {@link FillLayout}
  2530. * @see BubbleLayout
  2531. */
  2532. /** @expose */
  2533. com_ibm_rave_ext_layout_RaveLayout.fill = function() {
  2534. return new com_ibm_rave_ext_layout_fill_FillLayout();
  2535. };
  2536. /**
  2537. * @return (com.ibm.rave.ext.layout.hexbin.Hexbin) a new instance of {@link Hexbin}
  2538. * @see Hexbin
  2539. */
  2540. /** @expose */
  2541. com_ibm_rave_ext_layout_RaveLayout.hexbin = function() {
  2542. return new com_ibm_rave_ext_layout_hexbin_Hexbin();
  2543. };
  2544. /**
  2545. */
  2546. /** @expose */
  2547. com_ibm_rave_ext_layout_RaveLayout.cloud = function() {
  2548. return new com_ibm_rave_ext_layout_cloud_CloudLayout();
  2549. };
  2550. com_ibm_rave_ext_layout_RaveLayout.getRegistrationStatus = function() {
  2551. var registrationStatus = rave['internal']['RaveContextManager'].INSTANCE.getRaveContext().getData("RAVELAYOUT_EXTENSION_REGISTRATION_STATUS_KEY");
  2552. if (!registrationStatus) {
  2553. registrationStatus = new com_ibm_rave_ext_layout_RaveLayout.RegistrationStatus();
  2554. rave['internal']['RaveContextManager'].INSTANCE.getRaveContext().putData("RAVELAYOUT_EXTENSION_REGISTRATION_STATUS_KEY", registrationStatus);
  2555. }
  2556. return registrationStatus;
  2557. };
  2558. /**
  2559. * Register all extended layouts
  2560. * @return (boolean) true if registration was successful, false otherwise
  2561. * @see AbstractRegistryService
  2562. */
  2563. /** @expose */
  2564. com_ibm_rave_ext_layout_RaveLayout.init = function() {
  2565. var registrationStatus = com_ibm_rave_ext_layout_RaveLayout.getRegistrationStatus();
  2566. if (!registrationStatus.registered) {
  2567. registrationStatus.registered = rave.layout.extension("bubble", function() {
  2568. return com_ibm_rave_ext_layout_RaveLayout.bubble();
  2569. });
  2570. registrationStatus.registered &= rave.layout.extension("fill", function() {
  2571. return com_ibm_rave_ext_layout_RaveLayout.fill();
  2572. });
  2573. registrationStatus.registered &= rave.layout.extension("hexbin", function() {
  2574. return com_ibm_rave_ext_layout_RaveLayout.hexbin();
  2575. });
  2576. registrationStatus.registered &= rave.layout.extension("cloud", function() {
  2577. return com_ibm_rave_ext_layout_RaveLayout.cloud();
  2578. });
  2579. }
  2580. return registrationStatus.registered;
  2581. };
  2582. com_ibm_rave_ext_layout_RaveLayout.RegistrationStatus = rave['internal']['Declare']({
  2583. registered : false
  2584. });
  2585. /**
  2586. * bubble layout id
  2587. */
  2588. /** @expose */
  2589. com_ibm_rave_ext_layout_RaveLayout.BUBBLE = "bubble";
  2590. /**
  2591. * pack layout id
  2592. */
  2593. /** @expose */
  2594. com_ibm_rave_ext_layout_RaveLayout.FILL = "fill";
  2595. /**
  2596. * pack layout id
  2597. */
  2598. /** @expose */
  2599. com_ibm_rave_ext_layout_RaveLayout.CLOUD = "cloud";
  2600. /**
  2601. * hexbin layout id
  2602. */
  2603. /** @expose */
  2604. com_ibm_rave_ext_layout_RaveLayout.HEXBIN = "hexbin";
  2605. //com_ibm_rave_ext_layout_RaveLayout.EXTENSION_REGISTRATION_STATUS_KEY = "RAVELAYOUT_EXTENSION_REGISTRATION_STATUS_KEY";
  2606. // Auto initialization
  2607. com_ibm_rave_ext_layout_RaveLayout.init();
  2608. if (!rave.layout["bubble"]) {
  2609. rave.layout["bubble"] = function() {
  2610. return com_ibm_rave_ext_layout_RaveLayout.bubble();
  2611. };
  2612. } else {
  2613. console.log("Could not register extension: RaveLayout");
  2614. }
  2615. if (!rave.layout["fill"]) {
  2616. rave.layout["fill"] = function() {
  2617. return com_ibm_rave_ext_layout_RaveLayout.fill();
  2618. };
  2619. } else {
  2620. console.log("Could not register extension: RaveLayout");
  2621. }
  2622. if (!rave.layout["hexbin"]) {
  2623. rave.layout["hexbin"] = function() {
  2624. return com_ibm_rave_ext_layout_RaveLayout.hexbin();
  2625. };
  2626. } else {
  2627. console.log("Could not register extension: RaveLayout");
  2628. }
  2629. if (!rave.layout["cloud"]) {
  2630. rave.layout["cloud"] = function() {
  2631. return com_ibm_rave_ext_layout_RaveLayout.cloud();
  2632. };
  2633. } else {
  2634. console.log("Could not register extension: RaveLayout");
  2635. }
  2636. // $source: com/ibm/rave/ext/internal/layout/nativeImpl/Module
  2637. /************************************************************************
  2638. ** IBM Confidential
  2639. **
  2640. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  2641. **
  2642. ** (C) Copyright IBM Corp. 2015
  2643. **
  2644. ** The source code for this program is not published or otherwise divested of its trade secrets,
  2645. ** irrespective of what has been deposited with the U.S. Copyright Office.
  2646. ************************************************************************/
  2647. // @OnDemandLoad("rave-layouts")
  2648. // Must be the first import
  2649. // @import ./ModuleHeader
  2650. // @import com/ibm/rave/ext/layout/RaveLayout
  2651. })();
  2652. // This is the end of the factory method defined in the header. Added only during a full compiled JS build.
  2653. return rave;
  2654. }));