mxInfographic.js 94 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667
  1. /**
  2. * Copyright (c) 2006-2018, JGraph Holdings Ltd
  3. */
  4. //**********************************************************************************************************************************************************
  5. //Numbered entry (vertical)
  6. //**********************************************************************************************************************************************************
  7. /**
  8. * Extends mxShape.
  9. */
  10. function mxShapeInfographicNumEntryVert(bounds, fill, stroke, strokewidth)
  11. {
  12. mxShape.call(this);
  13. this.bounds = bounds;
  14. this.fill = fill;
  15. this.stroke = stroke;
  16. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  17. this.dy = 0.5;
  18. };
  19. /**
  20. * Extends mxShape.
  21. */
  22. mxUtils.extend(mxShapeInfographicNumEntryVert, mxActor);
  23. mxShapeInfographicNumEntryVert.prototype.cst = {NUM_ENTRY_VERT : 'mxgraph.infographic.numberedEntryVert'};
  24. mxShapeInfographicNumEntryVert.prototype.customProperties = [
  25. {name:'dy', dispName:'Circle Size', min:0, defVal: 25}
  26. ];
  27. /**
  28. * Function: paintVertexShape
  29. *
  30. * Paints the vertex shape.
  31. */
  32. mxShapeInfographicNumEntryVert.prototype.paintVertexShape = function(c, x, y, w, h)
  33. {
  34. c.translate(x, y);
  35. var dy = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  36. var inset = 5;
  37. var d = Math.min(dy, w - 2 * inset, h - inset);
  38. c.ellipse(w * 0.5 - d * 0.5, 0, d, d);
  39. c.fillAndStroke();
  40. c.begin();
  41. c.moveTo(0, d * 0.5);
  42. c.lineTo(w * 0.5 - d * 0.5 - inset, d * 0.5);
  43. c.arcTo(d * 0.5 + inset, d * 0.5 + inset, 0, 0, 0, w * 0.5 + d * 0.5 + inset, d * 0.5);
  44. c.lineTo(w, d * 0.5);
  45. c.lineTo(w, h);
  46. c.lineTo(0, h);
  47. c.close();
  48. c.fillAndStroke();
  49. };
  50. mxCellRenderer.registerShape(mxShapeInfographicNumEntryVert.prototype.cst.NUM_ENTRY_VERT, mxShapeInfographicNumEntryVert);
  51. Graph.handleFactory[mxShapeInfographicNumEntryVert.prototype.cst.NUM_ENTRY_VERT] = function(state)
  52. {
  53. var handles = [Graph.createHandle(state, ['dy'], function(bounds)
  54. {
  55. var dy = Math.max(0, Math.min(bounds.width, bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  56. return new mxPoint(bounds.x + bounds.width / 2, bounds.y + dy);
  57. }, function(bounds, pt)
  58. {
  59. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height, bounds.width, pt.y - bounds.y))) / 100;
  60. })];
  61. return handles;
  62. };
  63. mxShapeInfographicNumEntryVert.prototype.getConstraints = function(style, w, h)
  64. {
  65. var constr = [];
  66. var dy = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  67. var inset = 5;
  68. var d = Math.min(dy, w - 2 * inset, h - inset);
  69. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  70. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  71. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, d * 0.5));
  72. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, 0, d * 0.5));
  73. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false, null, 0, d * 0.25));
  74. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false, null, 0, d * 0.25));
  75. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  76. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  77. return (constr);
  78. };
  79. //**********************************************************************************************************************************************************
  80. //Bending Arch
  81. //**********************************************************************************************************************************************************
  82. /**
  83. * Extends mxShape.
  84. */
  85. function mxShapeInfographicBendingArch(bounds, fill, stroke, strokewidth)
  86. {
  87. mxShape.call(this);
  88. this.bounds = bounds;
  89. this.fill = fill;
  90. this.stroke = stroke;
  91. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  92. this.startAngle = 0.25;
  93. this.endAngle = 0.75;
  94. this.arcWidth = 0.5;
  95. };
  96. /**
  97. * Extends mxShape.
  98. */
  99. mxUtils.extend(mxShapeInfographicBendingArch, mxActor);
  100. mxShapeInfographicBendingArch.prototype.cst = {BENDING_ARCH : 'mxgraph.infographic.bendingArch'};
  101. mxShapeInfographicBendingArch.prototype.customProperties = [
  102. {name:'startAngle', dispName:'Start Angle', min:0, max:1, defVal: 0.75},
  103. {name:'endAngle', dispName:'End Angle', min:0, max:1, defVal: 0.25},
  104. {name:'arcWidth', dispName:'Arc Width', min:0, max:1, defVal: 0.25}
  105. ];
  106. /**
  107. * Function: paintVertexShape
  108. *
  109. * Paints the vertex shape.
  110. */
  111. mxShapeInfographicBendingArch.prototype.paintVertexShape = function(c, x, y, w, h)
  112. {
  113. c.translate(x, y);
  114. var startAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'startAngle', this.startAngle))));
  115. var endAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'endAngle', this.endAngle))));
  116. var arcWidth = 1 - Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arcWidth', this.arcWidth))));
  117. var rx = w * 0.5;
  118. var ry = h * 0.5;
  119. var rx2 = rx * arcWidth;
  120. var ry2 = ry * arcWidth;
  121. var startX = rx + Math.sin(startAngle) * rx;
  122. var startY = ry - Math.cos(startAngle) * ry;
  123. var innerStartX = rx + Math.sin(startAngle) * rx2;
  124. var innerStartY = ry - Math.cos(startAngle) * ry2;
  125. var endX = rx + Math.sin(endAngle) * rx;
  126. var endY = ry - Math.cos(endAngle) * ry;
  127. var innerEndX = rx + Math.sin(endAngle) * rx2;
  128. var innerEndY = ry - Math.cos(endAngle) * ry2;
  129. var angDiff = endAngle - startAngle;
  130. if (angDiff < 0)
  131. {
  132. angDiff = angDiff + Math.PI * 2;
  133. }
  134. var bigArc = 0;
  135. if (angDiff > Math.PI)
  136. {
  137. bigArc = 1;
  138. }
  139. var rx3 = rx2 - 5;
  140. var ry3 = ry2 - 5;
  141. c.ellipse(w * 0.5 - rx3, h * 0.5 - ry3, 2 * rx3, 2 * ry3);
  142. c.fillAndStroke();
  143. c.begin();
  144. c.moveTo(startX, startY);
  145. c.arcTo(rx, ry, 0, bigArc, 1, endX, endY);
  146. c.lineTo(innerEndX, innerEndY);
  147. c.arcTo(rx2, ry2, 0, bigArc, 0, innerStartX, innerStartY);
  148. c.close();
  149. c.fillAndStroke();
  150. };
  151. mxCellRenderer.registerShape(mxShapeInfographicBendingArch.prototype.cst.BENDING_ARCH, mxShapeInfographicBendingArch);
  152. mxShapeInfographicBendingArch.prototype.constraints = null;
  153. Graph.handleFactory[mxShapeInfographicBendingArch.prototype.cst.BENDING_ARCH] = function(state)
  154. {
  155. var handles = [Graph.createHandle(state, ['startAngle'], function(bounds)
  156. {
  157. var startAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'startAngle', this.startAngle))));
  158. return new mxPoint(bounds.x + bounds.width * 0.5 + Math.sin(startAngle) * bounds.width * 0.5, bounds.y + bounds.height * 0.5 - Math.cos(startAngle) * bounds.height * 0.5);
  159. }, function(bounds, pt)
  160. {
  161. var handleX = Math.round(100 * Math.max(-1, Math.min(1, (pt.x - bounds.x - bounds.width * 0.5) / (bounds.width * 0.5)))) / 100;
  162. var handleY = -Math.round(100 * Math.max(-1, Math.min(1, (pt.y - bounds.y - bounds.height * 0.5) / (bounds.height * 0.5)))) / 100;
  163. var res = 0.5 * Math.atan2(handleX, handleY) / Math.PI;
  164. if (res < 0)
  165. {
  166. res = 1 + res;
  167. }
  168. this.state.style['startAngle'] = res;
  169. })];
  170. var handle2 = Graph.createHandle(state, ['endAngle'], function(bounds)
  171. {
  172. var endAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'endAngle', this.endAngle))));
  173. return new mxPoint(bounds.x + bounds.width * 0.5 + Math.sin(endAngle) * bounds.width * 0.5, bounds.y + bounds.height * 0.5 - Math.cos(endAngle) * bounds.height * 0.5);
  174. }, function(bounds, pt)
  175. {
  176. var handleX = Math.round(100 * Math.max(-1, Math.min(1, (pt.x - bounds.x - bounds.width * 0.5) / (bounds.width * 0.5)))) / 100;
  177. var handleY = -Math.round(100 * Math.max(-1, Math.min(1, (pt.y - bounds.y - bounds.height * 0.5) / (bounds.height * 0.5)))) / 100;
  178. var res = 0.5 * Math.atan2(handleX, handleY) / Math.PI;
  179. if (res < 0)
  180. {
  181. res = 1 + res;
  182. }
  183. this.state.style['endAngle'] = res;
  184. });
  185. handles.push(handle2);
  186. var handle3 = Graph.createHandle(state, ['arcWidth'], function(bounds)
  187. {
  188. var arcWidth = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'arcWidth', this.arcWidth))));
  189. return new mxPoint(bounds.x + bounds.width / 2, bounds.y + arcWidth * bounds.height * 0.5);
  190. }, function(bounds, pt)
  191. {
  192. this.state.style['arcWidth'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, (pt.y - bounds.y) / (bounds.height * 0.5)))) / 100;
  193. });
  194. handles.push(handle3);
  195. return handles;
  196. };
  197. //**********************************************************************************************************************************************************
  198. //Parallelogram
  199. //**********************************************************************************************************************************************************
  200. /**
  201. * Extends mxShape.
  202. */
  203. function mxShapeInfographicParallelogram(bounds, fill, stroke, strokewidth)
  204. {
  205. mxShape.call(this);
  206. this.bounds = bounds;
  207. this.fill = fill;
  208. this.stroke = stroke;
  209. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  210. this.dx = 10;
  211. };
  212. /**
  213. * Extends mxShape.
  214. */
  215. mxUtils.extend(mxShapeInfographicParallelogram, mxActor);
  216. mxShapeInfographicParallelogram.prototype.cst = {PARALLELOGRAM : 'mxgraph.infographic.parallelogram'};
  217. mxShapeInfographicParallelogram.prototype.customProperties = [
  218. {name:'dx', dispName:'Angle', min:0, defVal: 15}
  219. ];
  220. /**
  221. * Function: paintVertexShape
  222. *
  223. * Paints the vertex shape.
  224. */
  225. mxShapeInfographicParallelogram.prototype.paintVertexShape = function(c, x, y, w, h)
  226. {
  227. c.translate(x, y);
  228. var dx = Math.max(0, Math.min(w * 0.5, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  229. c.begin();
  230. c.moveTo(0, h);
  231. c.lineTo(2 * dx, 0);
  232. c.lineTo(w, 0);
  233. c.lineTo(w - 2 * dx, h);
  234. c.close();
  235. c.fillAndStroke();
  236. };
  237. mxCellRenderer.registerShape(mxShapeInfographicParallelogram.prototype.cst.PARALLELOGRAM, mxShapeInfographicParallelogram);
  238. Graph.handleFactory[mxShapeInfographicParallelogram.prototype.cst.PARALLELOGRAM] = function(state)
  239. {
  240. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  241. {
  242. var dx = Math.max(0, Math.min(bounds.width / 2, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  243. return new mxPoint(bounds.x + dx, bounds.y + bounds.height / 2);
  244. }, function(bounds, pt)
  245. {
  246. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.width / 2, pt.x - bounds.x))) / 100;
  247. })];
  248. return handles;
  249. };
  250. mxShapeInfographicParallelogram.prototype.getConstraints = function(style, w, h)
  251. {
  252. var constr = [];
  253. var dx = Math.max(0, Math.min(w * 0.5, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  254. var w2 = w - 2 * dx;
  255. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  256. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 2 * dx, 0));
  257. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 2 * dx + w2 * 0.5, 0));
  258. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false, null, dx, 0));
  259. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  260. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - 2 * dx, h));
  261. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false, null, w - dx, 0));
  262. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w2 * 0.5, h));
  263. return (constr);
  264. };
  265. //**********************************************************************************************************************************************************
  266. //Ribbon Rolled
  267. //**********************************************************************************************************************************************************
  268. /**
  269. * Extends mxShape.
  270. */
  271. function mxShapeInfographicRibbonRolled(bounds, fill, stroke, strokewidth)
  272. {
  273. mxShape.call(this);
  274. this.bounds = bounds;
  275. this.fill = fill;
  276. this.stroke = stroke;
  277. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  278. this.dx = 185;
  279. this.dy = 15;
  280. };
  281. /**
  282. * Extends mxShape.
  283. */
  284. mxUtils.extend(mxShapeInfographicRibbonRolled, mxActor);
  285. mxShapeInfographicRibbonRolled.prototype.cst = {RIBBON_ROLLED : 'mxgraph.infographic.ribbonRolled'};
  286. mxShapeInfographicRibbonRolled.prototype.customProperties = [
  287. {name:'dx', dispName:'Roll Length', min:0, defVal: 185},
  288. {name:'dy', dispName:'Ribbon Width', min:0, defVal: 15}
  289. ];
  290. /**
  291. * Function: paintVertexShape
  292. *
  293. * Paints the vertex shape.
  294. */
  295. mxShapeInfographicRibbonRolled.prototype.paintVertexShape = function(c, x, y, w, h)
  296. {
  297. c.translate(x, y);
  298. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  299. var dy = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  300. c.begin();
  301. c.moveTo(0, dy);
  302. c.lineTo(dx, 0);
  303. c.lineTo(dx, dy);
  304. c.lineTo(w, dy);
  305. c.lineTo(w, h - dy);
  306. c.lineTo(w - dx, h);
  307. c.lineTo(w - dx, h - dy);
  308. c.lineTo(0, h - dy);
  309. c.close();
  310. c.fillAndStroke();
  311. c.setShadow(false);
  312. c.setFillAlpha('0.2');
  313. c.setFillColor('#000000');
  314. c.begin();
  315. c.moveTo(0, dy);
  316. c.lineTo(dx, 0);
  317. c.lineTo(dx, dy);
  318. c.close();
  319. c.moveTo(w, h - dy);
  320. c.lineTo(w - dx, h);
  321. c.lineTo(w - dx, h - dy);
  322. c.close();
  323. c.fill();
  324. c.begin();
  325. c.moveTo(0, dy);
  326. c.lineTo(dx, 0);
  327. c.lineTo(dx, dy);
  328. c.lineTo(w, dy);
  329. c.lineTo(w, h - dy);
  330. c.lineTo(w - dx, h);
  331. c.lineTo(w - dx, h - dy);
  332. c.lineTo(0, h - dy);
  333. c.close();
  334. c.stroke();
  335. };
  336. mxCellRenderer.registerShape(mxShapeInfographicRibbonRolled.prototype.cst.RIBBON_ROLLED, mxShapeInfographicRibbonRolled);
  337. Graph.handleFactory[mxShapeInfographicRibbonRolled.prototype.cst.RIBBON_ROLLED] = function(state)
  338. {
  339. var handles = [Graph.createHandle(state, ['dx', 'dy'], function(bounds)
  340. {
  341. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  342. var dy = Math.max(0, Math.min(bounds.height / 2, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  343. return new mxPoint(bounds.x + dx, bounds.y + dy);
  344. }, function(bounds, pt)
  345. {
  346. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.width, pt.x - bounds.x))) / 100;
  347. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, pt.y - bounds.y))) / 100;
  348. })];
  349. return handles;
  350. };
  351. mxShapeInfographicRibbonRolled.prototype.getConstraints = function(style, w, h)
  352. {
  353. var constr = [];
  354. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  355. var dy = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  356. var h2 = h - dy;
  357. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy));
  358. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false, null, 0, dy));
  359. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false, null, 0, dy));
  360. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false, null, 0, dy));
  361. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, 0, dy));
  362. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  363. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h2));
  364. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false, null, 0, h2));
  365. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false, null, 0, h2));
  366. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false, null, 0, h2));
  367. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false, null, 0, -dy));
  368. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  369. return (constr);
  370. };
  371. //**********************************************************************************************************************************************************
  372. //Ribbon Double Folded
  373. //**********************************************************************************************************************************************************
  374. /**
  375. * Extends mxShape.
  376. */
  377. function mxShapeInfographicRibbonDoubleFolded(bounds, fill, stroke, strokewidth)
  378. {
  379. mxShape.call(this);
  380. this.bounds = bounds;
  381. this.fill = fill;
  382. this.stroke = stroke;
  383. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  384. this.dx = 25;
  385. this.dy = 15;
  386. };
  387. /**
  388. * Extends mxShape.
  389. */
  390. mxUtils.extend(mxShapeInfographicRibbonDoubleFolded, mxActor);
  391. mxShapeInfographicRibbonDoubleFolded.prototype.cst = {RIBBON_DOUBLE_FOLDED : 'mxgraph.infographic.ribbonDoubleFolded'};
  392. mxShapeInfographicRibbonDoubleFolded.prototype.customProperties = [
  393. {name:'dx', dispName:'Fold Length', min:0, defVal: 25},
  394. {name:'dy', dispName:'Ribbon Width', min:0, defVal: 15}
  395. ];
  396. /**
  397. * Function: paintVertexShape
  398. *
  399. * Paints the vertex shape.
  400. */
  401. mxShapeInfographicRibbonDoubleFolded.prototype.paintVertexShape = function(c, x, y, w, h)
  402. {
  403. c.translate(x, y);
  404. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  405. var dy = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  406. c.begin();
  407. c.moveTo(0, dy);
  408. c.lineTo(dx, 0);
  409. c.lineTo(dx, dy);
  410. c.lineTo(w, dy);
  411. c.lineTo(w, h - dy);
  412. c.lineTo(w - dx, h);
  413. c.lineTo(w - dx, h - dy);
  414. c.lineTo(0, h - dy);
  415. c.close();
  416. c.fillAndStroke();
  417. c.setShadow(false);
  418. c.setFillAlpha('0.2');
  419. c.setFillColor('#000000');
  420. c.begin();
  421. c.moveTo(0, dy);
  422. c.lineTo(dx, 0);
  423. c.lineTo(dx, h - 2 * dy);
  424. c.lineTo(0, h - dy);
  425. c.close();
  426. c.moveTo(w, h - dy);
  427. c.lineTo(w - dx, h);
  428. c.lineTo(w - dx, h - dy);
  429. c.close();
  430. c.fill();
  431. c.begin();
  432. c.moveTo(0, dy);
  433. c.lineTo(dx, 0);
  434. c.lineTo(dx, dy);
  435. c.lineTo(w, dy);
  436. c.lineTo(w, h - dy);
  437. c.lineTo(w - dx, h);
  438. c.lineTo(w - dx, h - dy);
  439. c.lineTo(0, h - dy);
  440. c.close();
  441. c.stroke();
  442. };
  443. mxCellRenderer.registerShape(mxShapeInfographicRibbonDoubleFolded.prototype.cst.RIBBON_DOUBLE_FOLDED, mxShapeInfographicRibbonDoubleFolded);
  444. Graph.handleFactory[mxShapeInfographicRibbonDoubleFolded.prototype.cst.RIBBON_DOUBLE_FOLDED] = function(state)
  445. {
  446. var handles = [Graph.createHandle(state, ['dx', 'dy'], function(bounds)
  447. {
  448. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  449. var dy = Math.max(0, Math.min(bounds.height / 2, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  450. return new mxPoint(bounds.x + dx, bounds.y + dy);
  451. }, function(bounds, pt)
  452. {
  453. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.width, pt.x - bounds.x))) / 100;
  454. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, pt.y - bounds.y))) / 100;
  455. })];
  456. return handles;
  457. };
  458. mxShapeInfographicRibbonDoubleFolded.prototype.getConstraints = function(style, w, h)
  459. {
  460. var constr = [];
  461. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  462. var dy = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  463. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy));
  464. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false, null, 0, dy));
  465. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false, null, 0, dy));
  466. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false, null, 0, dy));
  467. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, 0, dy));
  468. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  469. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, 0, h - dy));
  470. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false, null, 0, h - dy));
  471. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false, null, 0, h - dy));
  472. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false, null, 0, h - dy));
  473. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - dy));
  474. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  475. return (constr);
  476. };
  477. //**********************************************************************************************************************************************************
  478. //Ribbon Front Folded
  479. //**********************************************************************************************************************************************************
  480. /**
  481. * Extends mxShape.
  482. */
  483. function mxShapeInfographicRibbonFrontFolded(bounds, fill, stroke, strokewidth)
  484. {
  485. mxShape.call(this);
  486. this.bounds = bounds;
  487. this.fill = fill;
  488. this.stroke = stroke;
  489. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  490. this.dx = 0.5;
  491. this.dy = 0.5;
  492. this.notch = 0.5;
  493. };
  494. /**
  495. * Extends mxShape.
  496. */
  497. mxUtils.extend(mxShapeInfographicRibbonFrontFolded, mxActor);
  498. mxShapeInfographicRibbonFrontFolded.prototype.cst = {RIBBON_FRONT_FOLDED : 'mxgraph.infographic.ribbonFrontFolded'};
  499. mxShapeInfographicRibbonFrontFolded.prototype.customProperties = [
  500. {name:'dx', dispName:'Fold Length', min:0, defVal: 25},
  501. {name:'dy', dispName:'Ribbon Width', min:0, defVal: 15},
  502. {name:'notch', dispName:'Notch', min:0, defVal: 15}
  503. ];
  504. /**
  505. * Function: paintVertexShape
  506. *
  507. * Paints the vertex shape.
  508. */
  509. mxShapeInfographicRibbonFrontFolded.prototype.paintVertexShape = function(c, x, y, w, h)
  510. {
  511. c.translate(x, y);
  512. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  513. var dy = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  514. var notch = Math.max(0, Math.min(w - dx, parseFloat(mxUtils.getValue(this.style, 'notch', this.notch))));
  515. c.begin();
  516. c.moveTo(0, dy);
  517. c.lineTo(dx, 0);
  518. c.lineTo(dx, dy);
  519. c.lineTo(w, dy);
  520. c.lineTo(w - notch, (h - dy) / 2 + dy);
  521. c.lineTo(w, h);
  522. c.lineTo(0, h);
  523. c.close();
  524. c.fillAndStroke();
  525. c.setShadow(false);
  526. c.setFillAlpha('0.2');
  527. c.setFillColor('#000000');
  528. c.begin();
  529. c.moveTo(0, dy);
  530. c.lineTo(dx, 0);
  531. c.lineTo(dx, h - dy);
  532. c.lineTo(0, h);
  533. c.close();
  534. c.fill();
  535. c.begin();
  536. c.moveTo(0, dy);
  537. c.lineTo(dx, 0);
  538. c.lineTo(dx, dy);
  539. c.lineTo(w, dy);
  540. c.lineTo(w - notch, (h - dy) / 2 + dy);
  541. c.lineTo(w, h);
  542. c.lineTo(0, h);
  543. c.close();
  544. c.stroke();
  545. };
  546. mxCellRenderer.registerShape(mxShapeInfographicRibbonFrontFolded.prototype.cst.RIBBON_FRONT_FOLDED, mxShapeInfographicRibbonFrontFolded);
  547. Graph.handleFactory[mxShapeInfographicRibbonFrontFolded.prototype.cst.RIBBON_FRONT_FOLDED] = function(state)
  548. {
  549. var handles = [Graph.createHandle(state, ['dx', 'dy'], function(bounds)
  550. {
  551. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  552. var dy = Math.max(0, Math.min(bounds.height / 2, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  553. return new mxPoint(bounds.x + dx, bounds.y + dy);
  554. }, function(bounds, pt)
  555. {
  556. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.width, pt.x - bounds.x))) / 100;
  557. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, pt.y - bounds.y))) / 100;
  558. })];
  559. var handle2 = Graph.createHandle(state, ['notch'], function(bounds)
  560. {
  561. var dy = Math.max(0, Math.min(bounds.height / 2, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  562. var notch = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'notch', this.notch))));
  563. return new mxPoint(bounds.x + bounds.width - notch, bounds.y + dy + (bounds.height - dy) * 0.5);
  564. }, function(bounds, pt)
  565. {
  566. this.state.style['notch'] = Math.round(100 * Math.max(0, Math.min(bounds.width, (bounds.width + bounds.x - pt.x)))) / 100;
  567. });
  568. handles.push(handle2);
  569. return handles;
  570. };
  571. mxShapeInfographicRibbonFrontFolded.prototype.getConstraints = function(style, w, h)
  572. {
  573. var constr = [];
  574. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  575. var dy = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  576. var notch = Math.max(0, Math.min(w - dx, parseFloat(mxUtils.getValue(this.style, 'notch', this.notch))));
  577. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy));
  578. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false, null, 0, dy));
  579. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false, null, 0, dy));
  580. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false, null, 0, dy));
  581. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, 0, dy));
  582. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - notch, (h + dy) * 0.5));
  583. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  584. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));
  585. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  586. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));
  587. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  588. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h + dy) * 0.5));
  589. return (constr);
  590. };
  591. //**********************************************************************************************************************************************************
  592. //Ribbon Back Folded
  593. //**********************************************************************************************************************************************************
  594. /**
  595. * Extends mxShape.
  596. */
  597. function mxShapeInfographicRibbonBackFolded(bounds, fill, stroke, strokewidth)
  598. {
  599. mxShape.call(this);
  600. this.bounds = bounds;
  601. this.fill = fill;
  602. this.stroke = stroke;
  603. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  604. this.dx = 0.5;
  605. this.dy = 0.5;
  606. this.notch = 0.5;
  607. };
  608. /**
  609. * Extends mxShape.
  610. */
  611. mxUtils.extend(mxShapeInfographicRibbonBackFolded, mxActor);
  612. mxShapeInfographicRibbonBackFolded.prototype.cst = {RIBBON_BACK_FOLDED : 'mxgraph.infographic.ribbonBackFolded'};
  613. mxShapeInfographicRibbonBackFolded.prototype.customProperties = [
  614. {name:'dx', dispName:'Fold Length', min:0, defVal: 25},
  615. {name:'dy', dispName:'Ribbon Width', min:0, defVal: 15},
  616. {name:'notch', dispName:'Notch', min:0, defVal: 15}
  617. ];
  618. /**
  619. * Function: paintVertexShape
  620. *
  621. * Paints the vertex shape.
  622. */
  623. mxShapeInfographicRibbonBackFolded.prototype.paintVertexShape = function(c, x, y, w, h)
  624. {
  625. c.translate(x, y);
  626. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  627. var dy = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  628. var notch = Math.max(0, Math.min(w - dx, parseFloat(mxUtils.getValue(this.style, 'notch', this.notch))));
  629. c.begin();
  630. c.moveTo(0, dy);
  631. c.lineTo(dx, 0);
  632. c.lineTo(dx, dy);
  633. c.lineTo(w, dy);
  634. c.lineTo(w - notch, (h - dy) / 2 + dy);
  635. c.lineTo(w, h);
  636. c.lineTo(0, h);
  637. c.close();
  638. c.fillAndStroke();
  639. c.setShadow(false);
  640. c.setFillAlpha('0.2');
  641. c.setFillColor('#000000');
  642. c.begin();
  643. c.moveTo(0, dy);
  644. c.lineTo(dx, 0);
  645. c.lineTo(dx, dy);
  646. c.close();
  647. c.fill();
  648. c.begin();
  649. c.moveTo(0, dy);
  650. c.lineTo(dx, 0);
  651. c.lineTo(dx, dy);
  652. c.lineTo(w, dy);
  653. c.lineTo(w - notch, (h - dy) / 2 + dy);
  654. c.lineTo(w, h);
  655. c.lineTo(0, h);
  656. c.close();
  657. c.stroke();
  658. };
  659. mxCellRenderer.registerShape(mxShapeInfographicRibbonBackFolded.prototype.cst.RIBBON_BACK_FOLDED, mxShapeInfographicRibbonBackFolded);
  660. Graph.handleFactory[mxShapeInfographicRibbonBackFolded.prototype.cst.RIBBON_BACK_FOLDED] = function(state)
  661. {
  662. var handles = [Graph.createHandle(state, ['dx', 'dy'], function(bounds)
  663. {
  664. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  665. var dy = Math.max(0, Math.min(bounds.height / 2, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  666. return new mxPoint(bounds.x + dx, bounds.y + dy);
  667. }, function(bounds, pt)
  668. {
  669. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.width, pt.x - bounds.x))) / 100;
  670. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, pt.y - bounds.y))) / 100;
  671. })];
  672. var handle2 = Graph.createHandle(state, ['notch'], function(bounds)
  673. {
  674. var dy = Math.max(0, Math.min(bounds.height / 2, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  675. var notch = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'notch', this.notch))));
  676. return new mxPoint(bounds.x + bounds.width - notch, bounds.y + dy + (bounds.height - dy) * 0.5);
  677. }, function(bounds, pt)
  678. {
  679. this.state.style['notch'] = Math.round(100 * Math.max(0, Math.min(bounds.width, (bounds.width + bounds.x - pt.x)))) / 100;
  680. });
  681. handles.push(handle2);
  682. return handles;
  683. };
  684. mxShapeInfographicRibbonBackFolded.prototype.getConstraints = function(style, w, h)
  685. {
  686. var constr = [];
  687. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  688. var dy = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  689. var notch = Math.max(0, Math.min(w - dx, parseFloat(mxUtils.getValue(this.style, 'notch', this.notch))));
  690. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy));
  691. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false, null, 0, dy));
  692. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false, null, 0, dy));
  693. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false, null, 0, dy));
  694. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, 0, dy));
  695. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - notch, (h + dy) * 0.5));
  696. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  697. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));
  698. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  699. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));
  700. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  701. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h + dy) * 0.5));
  702. return (constr);
  703. };
  704. //**********************************************************************************************************************************************************
  705. //Banner
  706. //**********************************************************************************************************************************************************
  707. /**
  708. * Extends mxShape.
  709. */
  710. function mxShapeInfographicBanner(bounds, fill, stroke, strokewidth)
  711. {
  712. mxShape.call(this);
  713. this.bounds = bounds;
  714. this.fill = fill;
  715. this.stroke = stroke;
  716. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  717. this.dx = 0.5;
  718. this.dy = 0.5;
  719. this.notch = 0.5;
  720. };
  721. /**
  722. * Extends mxShape.
  723. */
  724. mxUtils.extend(mxShapeInfographicBanner, mxActor);
  725. mxShapeInfographicBanner.prototype.cst = {BANNER : 'mxgraph.infographic.banner'};
  726. mxShapeInfographicBanner.prototype.customProperties = [
  727. {name:'dx', dispName:'Fold Length', min:0, defVal: 25},
  728. {name:'dy', dispName:'Ribbon Width', min:0, defVal: 15},
  729. {name:'notch', dispName:'Notch', min:0, defVal: 15}
  730. ];
  731. /**
  732. * Function: paintVertexShape
  733. *
  734. * Paints the vertex shape.
  735. */
  736. mxShapeInfographicBanner.prototype.paintVertexShape = function(c, x, y, w, h)
  737. {
  738. c.translate(x, y);
  739. var dx = Math.max(0, Math.min(w / 2, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  740. var dy = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  741. var notch = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'notch', this.notch))));
  742. dx = Math.min(w / 2 - 2 * dy, dx);
  743. notch = Math.min(dx, notch);
  744. c.begin();
  745. c.moveTo(0, dy);
  746. c.lineTo(dx, dy);
  747. c.lineTo(dx, 0);
  748. c.lineTo(w - dx, 0);
  749. c.lineTo(w - dx, dy);
  750. c.lineTo(w, dy);
  751. c.lineTo(w - notch, (h - dy) * 0.5 + dy);
  752. c.lineTo(w, h);
  753. c.lineTo(w - dx - 2 * dy, h);
  754. c.lineTo(w - dx - 2 * dy, h - dy);
  755. c.lineTo(dx + 2 * dy, h - dy);
  756. c.lineTo(dx + 2 * dy, h);
  757. c.lineTo(0, h);
  758. c.lineTo(notch, (h - dy) * 0.5 + dy);
  759. c.close();
  760. c.fillAndStroke();
  761. c.setShadow(false);
  762. c.setFillAlpha('0.2');
  763. c.setFillColor('#000000');
  764. c.begin();
  765. c.moveTo(0,dy);
  766. c.lineTo(dx, dy);
  767. c.lineTo(dx, h - dy);
  768. c.lineTo(dx + 2 * dy, h);
  769. c.lineTo(0, h);
  770. c.lineTo(notch, (h - dy) * 0.5 + dy);
  771. c.close();
  772. c.moveTo(w,dy);
  773. c.lineTo(w - dx, dy);
  774. c.lineTo(w - dx, h - dy);
  775. c.lineTo(w - dx - 2 * dy, h);
  776. c.lineTo(w, h);
  777. c.lineTo(w - notch, (h - dy) * 0.5 + dy);
  778. c.close();
  779. c.fill();
  780. c.setFillAlpha('0.4');
  781. c.begin();
  782. c.moveTo(dx, h - dy);
  783. c.lineTo(dx + 2 * dy, h - dy);
  784. c.lineTo(dx + 2 * dy, h);
  785. c.close();
  786. c.moveTo(w - dx, h - dy);
  787. c.lineTo(w - dx - 2 * dy, h - dy);
  788. c.lineTo(w - dx - 2 * dy, h);
  789. c.close();
  790. c.fill();
  791. };
  792. mxCellRenderer.registerShape(mxShapeInfographicBanner.prototype.cst.BANNER, mxShapeInfographicBanner);
  793. Graph.handleFactory[mxShapeInfographicBanner.prototype.cst.BANNER] = function(state)
  794. {
  795. var handles = [Graph.createHandle(state, ['dx', 'dy'], function(bounds)
  796. {
  797. var dx = Math.max(0, Math.min(bounds.width / 2, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  798. var dy = Math.max(0, Math.min(bounds.height / 2, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  799. return new mxPoint(bounds.x + bounds.width - dx, bounds.y + dy);
  800. }, function(bounds, pt)
  801. {
  802. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.width / 2, bounds.x + bounds.width - pt.x))) / 100;
  803. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, pt.y - bounds.y))) / 100;
  804. })];
  805. var handle2 = Graph.createHandle(state, ['notch'], function(bounds)
  806. {
  807. var dy = Math.max(0, Math.min(bounds.height / 2, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  808. var dx = Math.max(0, Math.min(bounds.width / 2, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  809. var notch = Math.max(0, Math.min(dx, parseFloat(mxUtils.getValue(this.state.style, 'notch', this.notch))));
  810. return new mxPoint(bounds.x + bounds.width - notch, bounds.y + dy + (bounds.height - dy) * 0.5);
  811. }, function(bounds, pt)
  812. {
  813. this.state.style['notch'] = Math.round(100 * Math.max(0, Math.min(bounds.width, (bounds.width + bounds.x - pt.x)))) / 100;
  814. });
  815. handles.push(handle2);
  816. return handles;
  817. };
  818. mxShapeInfographicBanner.prototype.getConstraints = function(style, w, h)
  819. {
  820. var constr = [];
  821. var dx = Math.max(0, Math.min(w / 2, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  822. var dy = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  823. var notch = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'notch', this.notch))));
  824. dx = Math.min(w / 2 - 2 * dy, dx);
  825. notch = Math.min(dx, notch);
  826. var w2 = w - 2 * dx;
  827. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, 0));
  828. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + w2 * 0.25, 0));
  829. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + w2 * 0.5, 0));
  830. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + w2 * 0.75, 0));
  831. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + w2, 0));
  832. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + w2, (h - dy) * 0.5));
  833. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + w2, h - dy));
  834. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + w2 * 0.75, h - dy));
  835. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + w2 * 0.5, h - dy));
  836. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + w2 * 0.25, h - dy));
  837. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, h - dy));
  838. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, (h - dy) * 0.5));
  839. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, notch, (h + dy) * 0.5));
  840. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - notch, (h + dy) * 0.5));
  841. return (constr);
  842. };
  843. //**********************************************************************************************************************************************************
  844. //Circular Callout
  845. //**********************************************************************************************************************************************************
  846. /**
  847. * Extends mxShape.
  848. */
  849. function mxShapeInfographicCircularCallout(bounds, fill, stroke, strokewidth)
  850. {
  851. mxShape.call(this);
  852. this.bounds = bounds;
  853. this.fill = fill;
  854. this.stroke = stroke;
  855. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  856. this.dy = 0.5;
  857. };
  858. /**
  859. * Extends mxShape.
  860. */
  861. mxUtils.extend(mxShapeInfographicCircularCallout, mxActor);
  862. mxShapeInfographicCircularCallout.prototype.cst = {CIRCULAR_CALLOUT : 'mxgraph.infographic.circularCallout'};
  863. mxShapeInfographicCircularCallout.prototype.customProperties = [
  864. {name:'dy', dispName:'Ribbon Width', min:0, defVal: 15}
  865. ];
  866. /**
  867. * Function: paintVertexShape
  868. *
  869. * Paints the vertex shape.
  870. */
  871. mxShapeInfographicCircularCallout.prototype.paintVertexShape = function(c, x, y, w, h)
  872. {
  873. c.translate(x, y);
  874. var dy = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  875. var rx = Math.max(0, Math.min(w * 0.5, w * 0.5 - dy));
  876. var ry = Math.max(0, Math.min(h * 0.5, h * 0.5 - dy));
  877. c.begin();
  878. c.moveTo(w, h * 0.5);
  879. c.arcTo(w * 0.5, h * 0.5, 0, 0, 1, w * 0.5, h);
  880. c.arcTo(w * 0.5, h * 0.5, 0, 0, 1, 0, h * 0.5);
  881. c.arcTo(w * 0.5, h * 0.5, 0, 0, 1, w * 0.5, 0);
  882. c.lineTo(w, 0);
  883. c.close();
  884. c.moveTo(w * 0.5, dy);
  885. c.arcTo(rx, ry, 0, 0, 0, w * 0.5 - rx, h * 0.5);
  886. c.arcTo(rx, ry, 0, 0, 0, w * 0.5, h * 0.5 + ry);
  887. c.arcTo(rx, ry, 0, 0, 0, w * 0.5 + rx, h * 0.5);
  888. c.arcTo(rx, ry, 0, 0, 0, w * 0.5, h * 0.5 - ry);
  889. c.close();
  890. c.fillAndStroke();
  891. };
  892. mxCellRenderer.registerShape(mxShapeInfographicCircularCallout.prototype.cst.CIRCULAR_CALLOUT, mxShapeInfographicCircularCallout);
  893. Graph.handleFactory[mxShapeInfographicCircularCallout.prototype.cst.CIRCULAR_CALLOUT] = function(state)
  894. {
  895. var handles = [Graph.createHandle(state, ['dy'], function(bounds)
  896. {
  897. var dy = Math.max(0, Math.min(bounds.height / 2, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  898. return new mxPoint(bounds.x + bounds.width * 0.5, bounds.y + dy);
  899. }, function(bounds, pt)
  900. {
  901. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, pt.y - bounds.y))) / 100;
  902. })];
  903. return handles;
  904. };
  905. mxShapeInfographicCircularCallout.prototype.getConstraints = function(style, w, h)
  906. {
  907. var constr = [];
  908. var dy = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  909. var rx = Math.max(0, Math.min(w * 0.5, w * 0.5 - dy));
  910. var ry = Math.max(0, Math.min(h * 0.5, h * 0.5 - dy));
  911. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  912. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  913. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  914. constr.push(new mxConnectionConstraint(new mxPoint(0.855, 0.855), false));
  915. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  916. constr.push(new mxConnectionConstraint(new mxPoint(0.145, 0.855), false));
  917. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  918. constr.push(new mxConnectionConstraint(new mxPoint(0.145, 0.145), false));
  919. return (constr);
  920. };
  921. //**********************************************************************************************************************************************************
  922. //Shaded triangle
  923. //**********************************************************************************************************************************************************
  924. /**
  925. * Extends mxShape.
  926. */
  927. function mxShapeInfographicShadedTriangle(bounds, fill, stroke, strokewidth)
  928. {
  929. mxShape.call(this);
  930. this.bounds = bounds;
  931. this.fill = fill;
  932. this.stroke = stroke;
  933. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  934. };
  935. /**
  936. * Extends mxShape.
  937. */
  938. mxUtils.extend(mxShapeInfographicShadedTriangle, mxActor);
  939. mxShapeInfographicShadedTriangle.prototype.cst = {SHADED_TRIANGLE : 'mxgraph.infographic.shadedTriangle'};
  940. /**
  941. * Function: paintVertexShape
  942. *
  943. * Paints the vertex shape.
  944. */
  945. mxShapeInfographicShadedTriangle.prototype.paintVertexShape = function(c, x, y, w, h)
  946. {
  947. c.translate(x, y);
  948. c.begin();
  949. c.moveTo(0, h);
  950. c.lineTo(w * 0.5, 0);
  951. c.lineTo(w, h);
  952. c.close();
  953. c.fillAndStroke();
  954. c.setShadow(false);
  955. c.setFillColor('#ffffff');
  956. c.setFillAlpha('0.2');
  957. c.begin();
  958. c.moveTo(0, h);
  959. c.lineTo(w * 0.5, 0);
  960. c.lineTo(w * 0.5, h * 0.67);
  961. c.close();
  962. c.fill();
  963. c.setFillColor('#000000');
  964. c.begin();
  965. c.moveTo(w, h);
  966. c.lineTo(w * 0.5, h * 0.67);
  967. c.lineTo(w * 0.5, 0);
  968. c.close();
  969. c.fill();
  970. c.begin();
  971. c.moveTo(0, h);
  972. c.lineTo(w * 0.5, 0);
  973. c.lineTo(w, h);
  974. c.close();
  975. c.stroke();
  976. };
  977. mxCellRenderer.registerShape(mxShapeInfographicShadedTriangle.prototype.cst.SHADED_TRIANGLE, mxShapeInfographicShadedTriangle);
  978. mxShapeInfographicShadedTriangle.prototype.getConstraints = function(style, w, h)
  979. {
  980. var constr = [];
  981. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  982. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0.5), false));
  983. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  984. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  985. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  986. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0.5), false));
  987. return (constr);
  988. };
  989. //**********************************************************************************************************************************************************
  990. //Shaded pyramid
  991. //**********************************************************************************************************************************************************
  992. /**
  993. * Extends mxShape.
  994. */
  995. function mxShapeInfographicShadedPyramid(bounds, fill, stroke, strokewidth)
  996. {
  997. mxShape.call(this);
  998. this.bounds = bounds;
  999. this.fill = fill;
  1000. this.stroke = stroke;
  1001. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1002. };
  1003. /**
  1004. * Extends mxShape.
  1005. */
  1006. mxUtils.extend(mxShapeInfographicShadedPyramid, mxActor);
  1007. mxShapeInfographicShadedPyramid.prototype.cst = {SHADED_PYRAMID : 'mxgraph.infographic.shadedPyramid'};
  1008. /**
  1009. * Function: paintVertexShape
  1010. *
  1011. * Paints the vertex shape.
  1012. */
  1013. mxShapeInfographicShadedPyramid.prototype.paintVertexShape = function(c, x, y, w, h)
  1014. {
  1015. c.translate(x, y);
  1016. var h1 = Math.max(h - w * 0.3, 0);
  1017. c.begin();
  1018. c.moveTo(0, h1);
  1019. c.lineTo(w * 0.5, 0);
  1020. c.lineTo(w, h1);
  1021. c.lineTo(w * 0.5, h);
  1022. c.close();
  1023. c.fillAndStroke();
  1024. c.setShadow(false);
  1025. c.setFillColor('#ffffff');
  1026. c.setFillAlpha('0.2');
  1027. c.begin();
  1028. c.moveTo(0, h1);
  1029. c.lineTo(w * 0.5, 0);
  1030. c.lineTo(w * 0.5, h);
  1031. c.close();
  1032. c.fill();
  1033. c.setFillColor('#000000');
  1034. c.begin();
  1035. c.moveTo(w, h1);
  1036. c.lineTo(w * 0.5, h);
  1037. c.lineTo(w * 0.5, 0);
  1038. c.close();
  1039. c.fill();
  1040. c.begin();
  1041. c.moveTo(0, h1);
  1042. c.lineTo(w * 0.5, 0);
  1043. c.lineTo(w, h1);
  1044. c.lineTo(w * 0.5, h);
  1045. c.close();
  1046. c.stroke();
  1047. };
  1048. mxCellRenderer.registerShape(mxShapeInfographicShadedPyramid.prototype.cst.SHADED_PYRAMID, mxShapeInfographicShadedPyramid);
  1049. mxShapeInfographicShadedPyramid.prototype.getConstraints = function(style, w, h)
  1050. {
  1051. var constr = [];
  1052. var h1 = Math.max(h - w * 0.3, 0);
  1053. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1054. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.75, h1 * 0.5));
  1055. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h1));
  1056. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.75, (h + h1) * 0.5));
  1057. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5, h));
  1058. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.25, (h + h1) * 0.5));
  1059. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h1));
  1060. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.25, h1 * 0.5));
  1061. return (constr);
  1062. };
  1063. //**********************************************************************************************************************************************************
  1064. //Pyramid step
  1065. //**********************************************************************************************************************************************************
  1066. /**
  1067. * Extends mxShape.
  1068. */
  1069. function mxShapeInfographicPyramidStep(bounds, fill, stroke, strokewidth)
  1070. {
  1071. mxShape.call(this);
  1072. this.bounds = bounds;
  1073. this.fill = fill;
  1074. this.stroke = stroke;
  1075. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1076. };
  1077. /**
  1078. * Extends mxShape.
  1079. */
  1080. mxUtils.extend(mxShapeInfographicPyramidStep, mxActor);
  1081. mxShapeInfographicPyramidStep.prototype.cst = {PYRAMID_STEP : 'mxgraph.infographic.pyramidStep'};
  1082. /**
  1083. * Function: paintVertexShape
  1084. *
  1085. * Paints the vertex shape.
  1086. */
  1087. mxShapeInfographicPyramidStep.prototype.paintVertexShape = function(c, x, y, w, h)
  1088. {
  1089. c.translate(x, y);
  1090. var h1 = Math.max(w * 0.1, 0);
  1091. c.begin();
  1092. c.moveTo(0, h1);
  1093. c.lineTo(w * 0.5, 0);
  1094. c.lineTo(w, h1);
  1095. c.lineTo(w, h);
  1096. c.lineTo(0, h);
  1097. c.close();
  1098. c.fillAndStroke();
  1099. c.setShadow(false);
  1100. c.setFillColor('#ffffff');
  1101. c.setFillAlpha('0.2');
  1102. c.begin();
  1103. c.moveTo(0, h1);
  1104. c.lineTo(w * 0.5, 0);
  1105. c.lineTo(w * 0.5, h);
  1106. c.lineTo(0, h);
  1107. c.close();
  1108. c.fill();
  1109. c.setFillColor('#000000');
  1110. c.begin();
  1111. c.moveTo(w, h1);
  1112. c.lineTo(w, h);
  1113. c.lineTo(w * 0.5, h);
  1114. c.lineTo(w * 0.5, 0);
  1115. c.close();
  1116. c.fill();
  1117. c.begin();
  1118. c.moveTo(0, h1);
  1119. c.lineTo(w * 0.5, 0);
  1120. c.lineTo(w, h1);
  1121. c.lineTo(w, h);
  1122. c.lineTo(0, h);
  1123. c.close();
  1124. c.stroke();
  1125. };
  1126. mxCellRenderer.registerShape(mxShapeInfographicPyramidStep.prototype.cst.PYRAMID_STEP, mxShapeInfographicPyramidStep);
  1127. mxShapeInfographicPyramidStep.prototype.getConstraints = function(style, w, h)
  1128. {
  1129. var constr = [];
  1130. var h1 = Math.max(w * 0.1, 0);
  1131. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1132. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.75, h1 * 0.5));
  1133. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h1));
  1134. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h1 + (h - h1) * 0.25));
  1135. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h1 + (h - h1) * 0.5));
  1136. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h1 + (h - h1) * 0.75));
  1137. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h));
  1138. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.75, h));
  1139. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5, h));
  1140. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.25, h));
  1141. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h));
  1142. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h1 + (h - h1) * 0.75));
  1143. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h1 + (h - h1) * 0.5));
  1144. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h1 + (h - h1) * 0.25));
  1145. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.25, h1 * 0.5));
  1146. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h1));
  1147. return (constr);
  1148. };
  1149. //**********************************************************************************************************************************************************
  1150. //Cylinder
  1151. //**********************************************************************************************************************************************************
  1152. /**
  1153. * Extends mxShape.
  1154. */
  1155. function mxShapeInfographicCylinder(bounds, fill, stroke, strokewidth)
  1156. {
  1157. mxShape.call(this);
  1158. this.bounds = bounds;
  1159. this.fill = fill;
  1160. this.stroke = stroke;
  1161. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1162. };
  1163. /**
  1164. * Extends mxShape.
  1165. */
  1166. mxUtils.extend(mxShapeInfographicCylinder, mxActor);
  1167. mxShapeInfographicCylinder.prototype.cst = {CYLINDER : 'mxgraph.infographic.cylinder'};
  1168. /**
  1169. * Function: paintVertexShape
  1170. *
  1171. * Paints the vertex shape.
  1172. */
  1173. mxShapeInfographicCylinder.prototype.paintVertexShape = function(c, x, y, w, h)
  1174. {
  1175. c.translate(x, y);
  1176. var dy = 20;
  1177. var rx = w * 0.5;
  1178. var ry = dy * 0.5;
  1179. c.begin();
  1180. c.moveTo(0, dy * 0.5);
  1181. c.arcTo(rx, ry, 0, 0, 1, w, ry);
  1182. c.lineTo(w, h - ry);
  1183. c.arcTo(rx, ry, 0, 0, 1, 0, h - ry);
  1184. c.close();
  1185. c.fillAndStroke();
  1186. c.setShadow(false);
  1187. c.setGradient('#000000', '#ffffff', 0, 0, w, h, mxConstants.DIRECTION_EAST, 0.4, 0.4);
  1188. c.begin();
  1189. c.moveTo(0, dy * 0.5);
  1190. c.arcTo(rx, ry, 0, 0, 0, w, ry);
  1191. c.lineTo(w, h - ry);
  1192. c.arcTo(rx, ry, 0, 0, 1, 0, h - ry);
  1193. c.close();
  1194. c.fill();
  1195. c.begin();
  1196. c.moveTo(0, dy * 0.5);
  1197. c.arcTo(rx, ry, 0, 0, 1, w, ry);
  1198. c.lineTo(w, h - ry);
  1199. c.arcTo(rx, ry, 0, 0, 1, 0, h - ry);
  1200. c.close();
  1201. c.stroke();
  1202. };
  1203. mxCellRenderer.registerShape(mxShapeInfographicCylinder.prototype.cst.CYLINDER, mxShapeInfographicCylinder);
  1204. mxShapeInfographicCylinder.prototype.getConstraints = function(style, w, h)
  1205. {
  1206. var constr = [];
  1207. var dy = 20;
  1208. var rx = w * 0.5;
  1209. var ry = dy * 0.5;
  1210. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy * 0.5));
  1211. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1212. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy * 0.5));
  1213. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy * 0.5 + (h - dy) * 0.25));
  1214. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy * 0.5 + (h - dy) * 0.5));
  1215. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy * 0.5 + (h - dy) * 0.75));
  1216. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h - dy * 0.5));
  1217. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  1218. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - dy * 0.5));
  1219. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy * 0.5 + (h - dy) * 0.75));
  1220. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy * 0.5 + (h - dy) * 0.5));
  1221. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy * 0.5 + (h - dy) * 0.25));
  1222. return (constr);
  1223. };
  1224. //**********************************************************************************************************************************************************
  1225. //Circular Callout 2
  1226. //**********************************************************************************************************************************************************
  1227. /**
  1228. * Extends mxShape.
  1229. */
  1230. function mxShapeInfographicCircularCallout2(bounds, fill, stroke, strokewidth)
  1231. {
  1232. mxShape.call(this);
  1233. this.bounds = bounds;
  1234. this.fill = fill;
  1235. this.stroke = stroke;
  1236. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1237. this.dy = 0.5;
  1238. };
  1239. /**
  1240. * Extends mxShape.
  1241. */
  1242. mxUtils.extend(mxShapeInfographicCircularCallout2, mxActor);
  1243. mxShapeInfographicCircularCallout2.prototype.cst = {CIRCULAR_CALLOUT_2 : 'mxgraph.infographic.circularCallout2'};
  1244. /**
  1245. * Function: paintVertexShape
  1246. *
  1247. * Paints the vertex shape.
  1248. */
  1249. mxShapeInfographicCircularCallout2.prototype.paintVertexShape = function(c, x, y, w, h)
  1250. {
  1251. c.translate(x, y);
  1252. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, 'none');
  1253. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, 'none');
  1254. c.setFillColor(strokeColor);
  1255. var rx = Math.max(0, Math.min(w * 0.5, h * 0.4, h * 0.5 - 7));
  1256. c.begin();
  1257. c.moveTo(w * 0.5 - 2, 2.15 * rx);
  1258. c.arcTo(rx * 0.23, rx * 0.23, 0, 0, 0, w * 0.5 - rx * 0.2, rx * 1.97);
  1259. c.arcTo(rx, rx, 0, 0, 1, w * 0.5 - rx, rx);
  1260. c.arcTo(rx, rx, 0, 0, 1, w * 0.5, 0);
  1261. c.arcTo(rx, rx, 0, 0, 1, w * 0.5 + rx, rx);
  1262. c.arcTo(rx, rx, 0, 0, 1, w * 0.5 + rx * 0.2, rx * 1.97);
  1263. c.arcTo(rx * 0.23, rx * 0.23, 0, 0, 0, w * 0.5 + 2, 2.15 * rx);
  1264. var rxMin = Math.max(rx * 0.1, 6);
  1265. if (rx * 0.04 > 4)
  1266. {
  1267. c.lineTo(w * 0.5 + 2, h - rx * 0.22);
  1268. c.arcTo(rx * 0.05, rx * 0.05, 0, 0, 0, w * 0.5 + rx * 0.04, h - rx * 0.19);
  1269. }
  1270. else
  1271. {
  1272. c.lineTo(w * 0.5 + 2, h - 2 * rxMin);
  1273. }
  1274. c.arcTo(rxMin, rxMin, 0, 0, 1, w * 0.5 + rxMin, h - rxMin);
  1275. c.arcTo(rxMin, rxMin, 0, 0, 1, w * 0.5, h);
  1276. c.arcTo(rxMin, rxMin, 0, 0, 1, w * 0.5 - rxMin, h - rxMin);
  1277. if (rx * 0.04 > 4)
  1278. {
  1279. c.arcTo(rxMin, rxMin, 0, 0, 1, w * 0.5 - rx * 0.04, h - rx * 0.19);
  1280. c.arcTo(rxMin * 0.5, rxMin * 0.5, 0, 0, 0, w * 0.5 - 2, h - rx * 0.22);
  1281. }
  1282. else
  1283. {
  1284. c.arcTo(rxMin, rxMin, 0, 0, 1, w * 0.5 - 2, h - 2 * rxMin);
  1285. }
  1286. c.close();
  1287. c.moveTo(w * 0.5, rx * 0.2);
  1288. c.arcTo(rx * 0.8, rx * 0.8, 0, 0, 0, w * 0.5 - rx * 0.8, rx * 0.8);
  1289. c.arcTo(rx * 0.8, rx * 0.8, 0, 0, 0, w * 0.5, rx * 1.8);
  1290. c.arcTo(rx * 0.8, rx * 0.8, 0, 0, 0, w * 0.5 + rx * 0.8, rx * 0.8);
  1291. c.arcTo(rx * 0.8, rx * 0.8, 0, 0, 0, w * 0.5, rx * 0.2);
  1292. c.close();
  1293. c.moveTo(w * 0.5, h - rxMin * 1.75);
  1294. c.arcTo(rxMin * 0.75, rxMin * 0.75, 0, 0, 0, w * 0.5 - rxMin * 0.75, h - rxMin );
  1295. c.arcTo(rxMin * 0.75, rxMin * 0.75, 0, 0, 0, w * 0.5, h - rxMin * 0.25);
  1296. c.arcTo(rxMin * 0.75, rxMin * 0.75, 0, 0, 0, w * 0.5 + rxMin * 0.75, h - rxMin);
  1297. c.arcTo(rxMin * 0.75, rxMin * 0.75, 0, 0, 0, w * 0.5, h - rxMin * 1.75);
  1298. c.close();
  1299. c.fill();
  1300. c.setFillColor(fillColor);
  1301. c.setShadow(false);
  1302. c.begin();
  1303. c.moveTo(w * 0.5, rx * 0.2);
  1304. c.arcTo(rx * 0.8, rx * 0.8, 0, 0, 0, w * 0.5 - rx * 0.8, rx * 0.8);
  1305. c.arcTo(rx * 0.8, rx * 0.8, 0, 0, 0, w * 0.5, rx * 1.8);
  1306. c.arcTo(rx * 0.8, rx * 0.8, 0, 0, 0, w * 0.5 + rx * 0.8, rx * 0.8);
  1307. c.arcTo(rx * 0.8, rx * 0.8, 0, 0, 0, w * 0.5, rx * 0.2);
  1308. c.close();
  1309. c.moveTo(w * 0.5, h - rxMin * 1.75);
  1310. c.arcTo(rxMin * 0.75, rxMin * 0.75, 0, 0, 0, w * 0.5 - rxMin * 0.75, h - rxMin );
  1311. c.arcTo(rxMin * 0.75, rxMin * 0.75, 0, 0, 0, w * 0.5, h - rxMin * 0.25);
  1312. c.arcTo(rxMin * 0.75, rxMin * 0.75, 0, 0, 0, w * 0.5 + rxMin * 0.75, h - rxMin);
  1313. c.arcTo(rxMin * 0.75, rxMin * 0.75, 0, 0, 0, w * 0.5, h - rxMin * 1.75);
  1314. c.close();
  1315. c.fill();
  1316. };
  1317. mxCellRenderer.registerShape(mxShapeInfographicCircularCallout2.prototype.cst.CIRCULAR_CALLOUT_2, mxShapeInfographicCircularCallout2);
  1318. mxShapeInfographicCircularCallout2.prototype.getConstraints = function(style, w, h)
  1319. {
  1320. var constr = [];
  1321. var rx = Math.max(0, Math.min(w * 0.5, h * 0.4, h * 0.5 - 7));
  1322. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5 - rx, rx));
  1323. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1324. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5 + rx, rx));
  1325. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  1326. return (constr);
  1327. };
  1328. //**********************************************************************************************************************************************************
  1329. //Banner Single Fold
  1330. //**********************************************************************************************************************************************************
  1331. /**
  1332. * Extends mxShape.
  1333. */
  1334. function mxShapeInfographicBannerSingleFold(bounds, fill, stroke, strokewidth)
  1335. {
  1336. mxShape.call(this);
  1337. this.bounds = bounds;
  1338. this.fill = fill;
  1339. this.stroke = stroke;
  1340. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1341. this.dx = 0.5;
  1342. this.dy = 0.5;
  1343. this.dx2 = 0.5;
  1344. this.notch = 0.5;
  1345. };
  1346. /**
  1347. * Extends mxShape.
  1348. */
  1349. mxUtils.extend(mxShapeInfographicBannerSingleFold, mxActor);
  1350. mxShapeInfographicBannerSingleFold.prototype.cst = {BANNER_SINGLE_FOLD : 'mxgraph.infographic.bannerSingleFold'};
  1351. mxShapeInfographicBannerSingleFold.prototype.customProperties = [
  1352. {name:'dx', dispName: 'Fold Length', type:'float', defVal:32, min:0},
  1353. {name:'dy', dispName: 'Banner Width', type:'float', defVal:17, min:0},
  1354. {name:'notch', dispName: 'Notch', type:'float', defVal:15, min:0}
  1355. ];
  1356. /**
  1357. * Function: paintVertexShape
  1358. *
  1359. * Paints the vertex shape.
  1360. */
  1361. mxShapeInfographicBannerSingleFold.prototype.paintVertexShape = function(c, x, y, w, h)
  1362. {
  1363. c.translate(x, y);
  1364. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1365. var dy = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  1366. var notch = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'notch', this.notch))));
  1367. dx = Math.min(w - 2 * dy, dx);
  1368. var dx2 = Math.max(0, Math.min(w - dx - 2 * dy, parseFloat(mxUtils.getValue(this.style, 'dx2', this.dx2))));
  1369. notch = Math.min(dx, notch);
  1370. c.begin();
  1371. c.moveTo(dx2, 0);
  1372. c.lineTo(w - dx, 0);
  1373. c.lineTo(w - dx, dy);
  1374. c.lineTo(w, dy);
  1375. c.lineTo(w - notch, (h - dy) * 0.5 + dy);
  1376. c.lineTo(w, h);
  1377. c.lineTo(w - dx - 2 * dy, h);
  1378. c.lineTo(w - dx - 2 * dy, h - dy);
  1379. c.lineTo(dx2, h - dy);
  1380. c.lineTo(0, (h - dy) * 0.5);
  1381. c.close();
  1382. c.fillAndStroke();
  1383. c.setShadow(false);
  1384. c.setFillAlpha('0.05');
  1385. c.setFillColor('#000000');
  1386. c.begin();
  1387. c.moveTo(w,dy);
  1388. c.lineTo(w - dx, dy);
  1389. c.lineTo(w - dx, h - dy);
  1390. c.lineTo(w - dx - 2 * dy, h);
  1391. c.lineTo(w, h);
  1392. c.lineTo(w - notch, (h - dy) * 0.5 + dy);
  1393. c.close();
  1394. c.fill();
  1395. c.setFillAlpha('0.4');
  1396. c.begin();
  1397. c.moveTo(w - dx, h - dy);
  1398. c.lineTo(w - dx - 2 * dy, h - dy);
  1399. c.lineTo(w - dx - 2 * dy, h);
  1400. c.close();
  1401. c.fill();
  1402. c.begin();
  1403. c.moveTo(dx2, 0);
  1404. c.lineTo(w - dx, 0);
  1405. c.lineTo(w - dx, dy);
  1406. c.lineTo(w, dy);
  1407. c.lineTo(w - notch, (h - dy) * 0.5 + dy);
  1408. c.lineTo(w, h);
  1409. c.lineTo(w - dx - 2 * dy, h);
  1410. c.lineTo(w - dx - 2 * dy, h - dy);
  1411. c.lineTo(dx2, h - dy);
  1412. c.lineTo(0, (h - dy) * 0.5);
  1413. c.close();
  1414. c.stroke();
  1415. };
  1416. mxCellRenderer.registerShape(mxShapeInfographicBannerSingleFold.prototype.cst.BANNER_SINGLE_FOLD, mxShapeInfographicBannerSingleFold);
  1417. Graph.handleFactory[mxShapeInfographicBannerSingleFold.prototype.cst.BANNER_SINGLE_FOLD] = function(state)
  1418. {
  1419. var handles = [Graph.createHandle(state, ['dx', 'dy'], function(bounds)
  1420. {
  1421. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1422. var dy = Math.max(0, Math.min(bounds.height / 2, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  1423. return new mxPoint(bounds.x + bounds.width - dx, bounds.y + dy);
  1424. }, function(bounds, pt)
  1425. {
  1426. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.width, bounds.x + bounds.width - pt.x))) / 100;
  1427. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, pt.y - bounds.y))) / 100;
  1428. })];
  1429. var handle2 = Graph.createHandle(state, ['notch'], function(bounds)
  1430. {
  1431. var dy = Math.max(0, Math.min(bounds.height / 2, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  1432. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1433. var notch = Math.max(0, Math.min(dx, parseFloat(mxUtils.getValue(this.state.style, 'notch', this.notch))));
  1434. return new mxPoint(bounds.x + bounds.width - notch, bounds.y + dy + (bounds.height - dy) * 0.5);
  1435. }, function(bounds, pt)
  1436. {
  1437. this.state.style['notch'] = Math.round(100 * Math.max(0, Math.min(bounds.width, (bounds.width + bounds.x - pt.x)))) / 100;
  1438. });
  1439. handles.push(handle2);
  1440. var handle3 = Graph.createHandle(state, ['dx2'], function(bounds)
  1441. {
  1442. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1443. var dy = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  1444. var dx2 = Math.max(0, Math.min(bounds.width - dx, parseFloat(mxUtils.getValue(this.state.style, 'dx2', this.dx2))));
  1445. return new mxPoint(bounds.x + dx2, bounds.y + (bounds.height - dy) * 0.5);
  1446. }, function(bounds, pt)
  1447. {
  1448. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1449. var dy = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  1450. this.state.style['dx2'] = Math.round(100 * Math.max(0, Math.min(bounds.width - dx - 2 * dy, pt.x - bounds.x))) / 100;
  1451. });
  1452. handles.push(handle3);
  1453. return handles;
  1454. };
  1455. mxShapeInfographicBannerSingleFold.prototype.getConstraints = function(style, w, h)
  1456. {
  1457. var constr = [];
  1458. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1459. var dy = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  1460. var notch = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'notch', this.notch))));
  1461. dx = Math.min(w - 2 * dy, dx);
  1462. var dx2 = Math.max(0, Math.min(w - dx - 2 * dy, parseFloat(mxUtils.getValue(this.style, 'dx2', this.dx2))));
  1463. notch = Math.min(dx, notch);
  1464. var w2 = w - dx - dx2;
  1465. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dy) * 0.5));
  1466. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2, 0));
  1467. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 + w2 * 0.25, 0));
  1468. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 + w2 * 0.5, 0));
  1469. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 + w2 * 0.75, 0));
  1470. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 + w2, 0));
  1471. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx * 0.25, dy));
  1472. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx * 0.5, dy));
  1473. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx * 0.75, dy));
  1474. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy));
  1475. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - notch, (h + dy) * 0.5));
  1476. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h));
  1477. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx - 2 * dy, h));
  1478. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - (dx + 2 * dy) * 0.75, h));
  1479. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - (dx + 2 * dy) * 0.5, h));
  1480. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - (dx + 2 * dy) * 0.25, h));
  1481. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2, h - dy));
  1482. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 + w2 * 0.25, h - dy));
  1483. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 + w2 * 0.5, h - dy));
  1484. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 + w2 * 0.75, h - dy));
  1485. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 + w2, h - dy));
  1486. return (constr);
  1487. };
  1488. //**********************************************************************************************************************************************************
  1489. //Shaded Cube
  1490. //**********************************************************************************************************************************************************
  1491. /**
  1492. * Extends mxShape.
  1493. */
  1494. function mxShapeInfographicShadedCube(bounds, fill, stroke, strokewidth)
  1495. {
  1496. mxShape.call(this);
  1497. this.bounds = bounds;
  1498. this.fill = fill;
  1499. this.stroke = stroke;
  1500. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1501. this.isoAngle = 15;
  1502. };
  1503. /**
  1504. * Extends mxShape.
  1505. */
  1506. mxUtils.extend(mxShapeInfographicShadedCube, mxActor);
  1507. mxShapeInfographicShadedCube.prototype.cst = {SHADED_CUBE : 'mxgraph.infographic.shadedCube'};
  1508. mxShapeInfographicShadedCube.prototype.customProperties = [
  1509. {name:'isoAngle', dispName: 'Perspective', type:'float', defVal:15, min:0}
  1510. ];
  1511. /**
  1512. * Function: paintVertexShape
  1513. *
  1514. * Paints the vertex shape.
  1515. */
  1516. mxShapeInfographicShadedCube.prototype.paintVertexShape = function(c, x, y, w, h)
  1517. {
  1518. c.translate(x, y);
  1519. var isoAngle = Math.max(0.01, Math.min(94, parseFloat(mxUtils.getValue(this.style, 'isoAngle', this.isoAngle)))) * Math.PI / 200 ;
  1520. var isoH = Math.min(w * Math.tan(isoAngle), h * 0.5);
  1521. c.begin();
  1522. c.moveTo(w * 0.5, 0);
  1523. c.lineTo(w, isoH);
  1524. c.lineTo(w, h - isoH);
  1525. c.lineTo(w * 0.5, h);
  1526. c.lineTo(0, h - isoH);
  1527. c.lineTo(0, isoH);
  1528. c.close();
  1529. c.fillAndStroke();
  1530. c.setShadow(false);
  1531. c.setFillAlpha('0.2');
  1532. c.setFillColor('#000000');
  1533. c.begin();
  1534. c.moveTo(w * 0.5, 2 * isoH);
  1535. c.lineTo(w, isoH);
  1536. c.lineTo(w, h - isoH);
  1537. c.lineTo(w * 0.5, h);
  1538. c.close();
  1539. c.fill();
  1540. c.setFillColor('#ffffff');
  1541. c.begin();
  1542. c.moveTo(w * 0.5, 2 * isoH);
  1543. c.lineTo(0, isoH);
  1544. c.lineTo(0, h - isoH);
  1545. c.lineTo(w * 0.5, h);
  1546. c.close();
  1547. c.fill();
  1548. };
  1549. mxCellRenderer.registerShape(mxShapeInfographicShadedCube.prototype.cst.SHADED_CUBE, mxShapeInfographicShadedCube);
  1550. Graph.handleFactory[mxShapeInfographicShadedCube.prototype.cst.SHADED_CUBE] = function(state)
  1551. {
  1552. var handles = [Graph.createHandle(state, ['isoAngle'], function(bounds)
  1553. {
  1554. var isoAngle = Math.max(0.01, Math.min(94, parseFloat(mxUtils.getValue(this.state.style, 'isoAngle', this.isoAngle)))) * Math.PI / 200 ;
  1555. var isoH = Math.min(bounds.width * Math.tan(isoAngle), bounds.height * 0.5);
  1556. return new mxPoint(bounds.x, bounds.y + isoH);
  1557. }, function(bounds, pt)
  1558. {
  1559. this.state.style['isoAngle'] = Math.round(100 * Math.max(0, Math.min(100, pt.y - bounds.y))) / 100;
  1560. })];
  1561. return handles;
  1562. };
  1563. mxShapeInfographicShadedCube.prototype.getConstraints = function(style, w, h)
  1564. {
  1565. var constr = [];
  1566. var isoAngle = Math.max(0.01, Math.min(94, parseFloat(mxUtils.getValue(this.style, 'isoAngle', this.isoAngle)))) * Math.PI / 200 ;
  1567. var isoH = Math.min(w * Math.tan(isoAngle), h * 0.5);
  1568. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1569. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.75, isoH * 0.5));
  1570. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, isoH));
  1571. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, isoH + (h - 2 * isoH) * 0.25));
  1572. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, isoH + (h - 2 * isoH) * 0.5));
  1573. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, isoH + (h - 2 * isoH) * 0.75));
  1574. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h - isoH));
  1575. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.75, h - isoH * 0.5));
  1576. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  1577. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.25, h - isoH * 0.5));
  1578. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - isoH));
  1579. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - isoH));
  1580. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, isoH + (h - 2 * isoH) * 0.75));
  1581. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, isoH + (h - 2 * isoH) * 0.5));
  1582. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, isoH + (h - 2 * isoH) * 0.25));
  1583. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, isoH));
  1584. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.25, isoH * 0.5));
  1585. return (constr);
  1586. };
  1587. //**********************************************************************************************************************************************************
  1588. //Partial Concentric Ellipse
  1589. //**********************************************************************************************************************************************************
  1590. /**
  1591. * Extends mxShape.
  1592. */
  1593. function mxShapeInfographicPartConcEllipse(bounds, fill, stroke, strokewidth)
  1594. {
  1595. mxShape.call(this);
  1596. this.bounds = bounds;
  1597. this.fill = fill;
  1598. this.stroke = stroke;
  1599. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1600. this.startAngle = 0.25;
  1601. this.endAngle = 0.75;
  1602. this.arcWidth = 0.5;
  1603. };
  1604. /**
  1605. * Extends mxShape.
  1606. */
  1607. mxUtils.extend(mxShapeInfographicPartConcEllipse, mxActor);
  1608. mxShapeInfographicPartConcEllipse.prototype.cst = {PART_CONC_ELLIPSE : 'mxgraph.infographic.partConcEllipse'};
  1609. mxShapeInfographicPartConcEllipse.prototype.customProperties = [
  1610. {name:'startAngle', dispName:'Start Angle', min:0, max:1, defVal: 0.25},
  1611. {name:'endAngle', dispName:'End Angle', min:0, max:1, defVal: 0.1},
  1612. {name:'arcWidth', dispName:'Arc Width', min:0, max:1, defVal: 0.5}
  1613. ];
  1614. /**
  1615. * Function: paintVertexShape
  1616. *
  1617. * Paints the vertex shape.
  1618. */
  1619. mxShapeInfographicPartConcEllipse.prototype.paintVertexShape = function(c, x, y, w, h)
  1620. {
  1621. c.translate(x, y);
  1622. var startAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'startAngle', this.startAngle))));
  1623. var endAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'endAngle', this.endAngle))));
  1624. var arcWidth = 1 - Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arcWidth', this.arcWidth))));
  1625. var rx = w * 0.5;
  1626. var ry = h * 0.5;
  1627. var rx2 = rx * arcWidth;
  1628. var ry2 = ry * arcWidth;
  1629. var angDiff = endAngle - startAngle;
  1630. if (angDiff < 0)
  1631. {
  1632. angDiff = angDiff + Math.PI * 2;
  1633. }
  1634. else if (angDiff == Math.PI)
  1635. {
  1636. endAngle = endAngle + 0.00001;
  1637. }
  1638. var startX = rx + Math.sin(startAngle) * rx;
  1639. var startY = ry - Math.cos(startAngle) * ry;
  1640. var innerStartX = rx + Math.sin(startAngle) * rx2;
  1641. var innerStartY = ry - Math.cos(startAngle) * ry2;
  1642. var endX = rx + Math.sin(endAngle) * rx;
  1643. var endY = ry - Math.cos(endAngle) * ry;
  1644. var innerEndX = rx + Math.sin(endAngle) * rx2;
  1645. var innerEndY = ry - Math.cos(endAngle) * ry2;
  1646. var bigArc = 0;
  1647. if (angDiff <= Math.PI)
  1648. {
  1649. bigArc = 1;
  1650. }
  1651. c.begin();
  1652. c.moveTo(rx, 0);
  1653. c.arcTo(rx, ry, 0, 0, 1, w, ry);
  1654. c.arcTo(rx, ry, 0, 0, 1, rx, h);
  1655. c.arcTo(rx, ry, 0, 0, 1, 0, ry);
  1656. c.arcTo(rx, ry, 0, 0, 1, rx, 0);
  1657. c.close();
  1658. c.moveTo(rx, h * 0.5 - ry2);
  1659. c.arcTo(rx2, ry2, 0, 0, 0, w * 0.5 - rx2, ry);
  1660. c.arcTo(rx2, ry2, 0, 0, 0, rx, h * 0.5 + ry2);
  1661. c.arcTo(rx2, ry2, 0, 0, 0, w * 0.5 + rx2, ry);
  1662. c.arcTo(rx2, ry2, 0, 0, 0, rx, h * 0.5 - ry2);
  1663. c.close();
  1664. c.fillAndStroke();
  1665. c.setShadow(false);
  1666. c.setFillAlpha('0.2');
  1667. c.setFillColor('#ffffff');
  1668. c.begin();
  1669. c.moveTo(startX, startY);
  1670. c.arcTo(rx, ry, 0, bigArc, 0, endX, endY);
  1671. c.lineTo(innerEndX, innerEndY);
  1672. c.arcTo(rx2, ry2, 0, bigArc, 1, innerStartX, innerStartY);
  1673. c.close();
  1674. c.fill();
  1675. var rx = w * 0.5;
  1676. var ry = h * 0.5;
  1677. var rx2 = rx * arcWidth;
  1678. var ry2 = ry * arcWidth;
  1679. var rx3 = rx2 + (rx - rx2) * 0.25;
  1680. var ry3 = ry2 + (ry - ry2) * 0.25;
  1681. c.setFillColor('#000000');
  1682. c.begin();
  1683. c.moveTo(rx, h * 0.5 - ry2);
  1684. c.arcTo(rx2, ry2, 0, 0, 1, w * 0.5 + rx2, ry);
  1685. c.arcTo(rx2, ry2, 0, 0, 1, rx, h * 0.5 + ry2);
  1686. c.arcTo(rx2, ry2, 0, 0, 1, w * 0.5 - rx2, ry);
  1687. c.arcTo(rx2, ry2, 0, 0, 1, rx, h * 0.5 - ry2);
  1688. c.close();
  1689. c.moveTo(rx, h * 0.5 - ry3);
  1690. c.arcTo(rx3, ry3, 0, 0, 0, w * 0.5 - rx3, ry);
  1691. c.arcTo(rx3, ry3, 0, 0, 0, rx, h * 0.5 + ry3);
  1692. c.arcTo(rx3, ry3, 0, 0, 0, w * 0.5 + rx3, ry);
  1693. c.arcTo(rx3, ry3, 0, 0, 0, rx, h * 0.5 - ry3);
  1694. c.close();
  1695. c.fill();
  1696. };
  1697. mxCellRenderer.registerShape(mxShapeInfographicPartConcEllipse.prototype.cst.PART_CONC_ELLIPSE, mxShapeInfographicPartConcEllipse);
  1698. Graph.handleFactory[mxShapeInfographicPartConcEllipse.prototype.cst.PART_CONC_ELLIPSE] = function(state)
  1699. {
  1700. var handles = [Graph.createHandle(state, ['startAngle'], function(bounds)
  1701. {
  1702. var startAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'startAngle', this.startAngle))));
  1703. return new mxPoint(bounds.x + bounds.width * 0.5 + Math.sin(startAngle) * bounds.width * 0.5, bounds.y + bounds.height * 0.5 - Math.cos(startAngle) * bounds.height * 0.5);
  1704. }, function(bounds, pt)
  1705. {
  1706. var handleX = Math.round(100 * Math.max(-1, Math.min(1, (pt.x - bounds.x - bounds.width * 0.5) / (bounds.width * 0.5)))) / 100;
  1707. var handleY = -Math.round(100 * Math.max(-1, Math.min(1, (pt.y - bounds.y - bounds.height * 0.5) / (bounds.height * 0.5)))) / 100;
  1708. var res = 0.5 * Math.atan2(handleX, handleY) / Math.PI;
  1709. if (res < 0)
  1710. {
  1711. res = 1 + res;
  1712. }
  1713. this.state.style['startAngle'] = res;
  1714. })];
  1715. var handle2 = Graph.createHandle(state, ['endAngle'], function(bounds)
  1716. {
  1717. var endAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'endAngle', this.endAngle))));
  1718. return new mxPoint(bounds.x + bounds.width * 0.5 + Math.sin(endAngle) * bounds.width * 0.5, bounds.y + bounds.height * 0.5 - Math.cos(endAngle) * bounds.height * 0.5);
  1719. }, function(bounds, pt)
  1720. {
  1721. var handleX = Math.round(100 * Math.max(-1, Math.min(1, (pt.x - bounds.x - bounds.width * 0.5) / (bounds.width * 0.5)))) / 100;
  1722. var handleY = -Math.round(100 * Math.max(-1, Math.min(1, (pt.y - bounds.y - bounds.height * 0.5) / (bounds.height * 0.5)))) / 100;
  1723. var res = 0.5 * Math.atan2(handleX, handleY) / Math.PI;
  1724. if (res < 0)
  1725. {
  1726. res = 1 + res;
  1727. }
  1728. this.state.style['endAngle'] = res;
  1729. });
  1730. handles.push(handle2);
  1731. var handle3 = Graph.createHandle(state, ['arcWidth'], function(bounds)
  1732. {
  1733. var arcWidth = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'arcWidth', this.arcWidth))));
  1734. return new mxPoint(bounds.x + bounds.width / 2, bounds.y + arcWidth * bounds.height * 0.5);
  1735. }, function(bounds, pt)
  1736. {
  1737. this.state.style['arcWidth'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, (pt.y - bounds.y) / (bounds.height * 0.5)))) / 100;
  1738. });
  1739. handles.push(handle3);
  1740. return handles;
  1741. };
  1742. mxShapeInfographicPartConcEllipse.prototype.getConstraints = function(style, w, h)
  1743. {
  1744. var constr = [];
  1745. constr.push(new mxConnectionConstraint(new mxPoint(0.145, 0.145), false));
  1746. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1747. constr.push(new mxConnectionConstraint(new mxPoint(0.855, 0.145), false));
  1748. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  1749. constr.push(new mxConnectionConstraint(new mxPoint(0.855, 0.855), false));
  1750. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  1751. constr.push(new mxConnectionConstraint(new mxPoint(0.145, 0.855), false));
  1752. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  1753. return (constr);
  1754. };
  1755. //**********************************************************************************************************************************************************
  1756. //Banner Half Fold
  1757. //**********************************************************************************************************************************************************
  1758. /**
  1759. * Extends mxShape.
  1760. */
  1761. function mxShapeInfographicBannerHalfFold(bounds, fill, stroke, strokewidth)
  1762. {
  1763. mxShape.call(this);
  1764. this.bounds = bounds;
  1765. this.fill = fill;
  1766. this.stroke = stroke;
  1767. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1768. this.dx = 0.5;
  1769. this.dx2 = 0.5;
  1770. this.notch = 0.5;
  1771. };
  1772. /**
  1773. * Extends mxShape.
  1774. */
  1775. mxUtils.extend(mxShapeInfographicBannerHalfFold, mxActor);
  1776. mxShapeInfographicBannerHalfFold.prototype.cst = {BANNER_HALF_FOLD : 'mxgraph.infographic.bannerHalfFold'};
  1777. mxShapeInfographicBannerHalfFold.prototype.customProperties = [
  1778. {name:'dx', dispName:'Banner Width', min:0, defVal: 40},
  1779. {name:'dx2', dispName:'Spike Size', min:0, defVal: 20},
  1780. {name:'notch', dispName:'Notch Size', min:0, defVal: 15}
  1781. ];
  1782. /**
  1783. * Function: paintVertexShape
  1784. *
  1785. * Paints the vertex shape.
  1786. */
  1787. mxShapeInfographicBannerHalfFold.prototype.paintVertexShape = function(c, x, y, w, h)
  1788. {
  1789. c.translate(x, y);
  1790. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1791. var dx2 = Math.max(0, Math.min(w - dx, parseFloat(mxUtils.getValue(this.style, 'dx2', this.dx2))));
  1792. var notch = Math.max(0, Math.min(h - dx, parseFloat(mxUtils.getValue(this.style, 'notch', this.notch))));
  1793. c.begin();
  1794. c.moveTo(dx2, 0);
  1795. c.lineTo(w - dx, 0);
  1796. c.lineTo(w, dx);
  1797. c.lineTo(w, h);
  1798. c.lineTo(w - dx * 0.5, h - notch);
  1799. c.lineTo(w - dx, h);
  1800. c.lineTo(w - dx, dx);
  1801. c.lineTo(dx2, dx);
  1802. c.lineTo(0, dx * 0.5);
  1803. c.close();
  1804. c.fillAndStroke();
  1805. c.setShadow(false);
  1806. c.setFillAlpha('0.2');
  1807. c.setFillColor('#000000');
  1808. c.begin();
  1809. c.moveTo(w - dx, dx);
  1810. c.lineTo(w, dx);
  1811. c.lineTo(w, h);
  1812. c.lineTo(w - dx * 0.5, h - notch);
  1813. c.lineTo(w - dx, h);
  1814. c.lineTo(w - dx, dx);
  1815. c.lineTo(0, dx);
  1816. c.close();
  1817. c.fill();
  1818. c.begin();
  1819. c.moveTo(dx2, 0);
  1820. c.lineTo(w - dx, 0);
  1821. c.lineTo(w, dx);
  1822. c.lineTo(w, h);
  1823. c.lineTo(w - dx * 0.5, h - notch);
  1824. c.lineTo(w - dx, h);
  1825. c.lineTo(w - dx, dx);
  1826. c.lineTo(dx2, dx);
  1827. c.lineTo(0, dx * 0.5);
  1828. c.close();
  1829. c.stroke();
  1830. };
  1831. mxCellRenderer.registerShape(mxShapeInfographicBannerHalfFold.prototype.cst.BANNER_HALF_FOLD, mxShapeInfographicBannerHalfFold);
  1832. Graph.handleFactory[mxShapeInfographicBannerHalfFold.prototype.cst.BANNER_HALF_FOLD] = function(state)
  1833. {
  1834. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1835. {
  1836. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1837. return new mxPoint(bounds.x + bounds.width - dx, bounds.y + dx);
  1838. }, function(bounds, pt)
  1839. {
  1840. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.width, bounds.x + bounds.width - pt.x))) / 100;
  1841. })];
  1842. var handle2 = Graph.createHandle(state, ['notch'], function(bounds)
  1843. {
  1844. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1845. var notch = Math.max(0, Math.min(bounds.height - dx, parseFloat(mxUtils.getValue(this.state.style, 'notch', this.notch))));
  1846. return new mxPoint(bounds.x + bounds.width - dx * 0.5, bounds.y + bounds.height - notch);
  1847. }, function(bounds, pt)
  1848. {
  1849. this.state.style['notch'] = Math.round(100 * Math.max(0, Math.min(bounds.height, (bounds.height + bounds.y - pt.y)))) / 100;
  1850. });
  1851. handles.push(handle2);
  1852. var handle3 = Graph.createHandle(state, ['dx2'], function(bounds)
  1853. {
  1854. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1855. var dx2 = Math.max(0, Math.min(bounds.width - dx, parseFloat(mxUtils.getValue(this.state.style, 'dx2', this.dx2))));
  1856. return new mxPoint(bounds.x + dx2, bounds.y + dx);
  1857. }, function(bounds, pt)
  1858. {
  1859. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1860. this.state.style['dx2'] = Math.round(100 * Math.max(0, Math.min(bounds.width - dx, pt.x - bounds.x))) / 100;
  1861. });
  1862. handles.push(handle3);
  1863. return handles;
  1864. };
  1865. mxShapeInfographicBannerHalfFold.prototype.getConstraints = function(style, w, h)
  1866. {
  1867. var constr = [];
  1868. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1869. var dx2 = Math.max(0, Math.min(w - dx, parseFloat(mxUtils.getValue(this.style, 'dx2', this.dx2))));
  1870. var notch = Math.max(0, Math.min(h - dx, parseFloat(mxUtils.getValue(this.style, 'notch', this.notch))));
  1871. var w2 = w - dx - dx2;
  1872. var h2 = h - dx;
  1873. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dx * 0.5));
  1874. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2, 0));
  1875. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 + w2 * 0.25, 0));
  1876. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 + w2 * 0.5, 0));
  1877. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 + w2 * 0.75, 0));
  1878. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, 0));
  1879. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx * 0.5, dx * 0.5));
  1880. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dx));
  1881. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dx + h2 * 0.25));
  1882. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dx + h2 * 0.5));
  1883. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dx + h2 * 0.75));
  1884. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  1885. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx * 0.5, h - notch));
  1886. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, h));
  1887. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  1888. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, dx + h2 * 0.75));
  1889. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, dx + h2 * 0.5));
  1890. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, dx + h2 * 0.25));
  1891. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, dx));
  1892. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 + w2 * 0.25, dx));
  1893. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 + w2 * 0.5, dx));
  1894. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 + w2 * 0.75, dx));
  1895. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2, dx));
  1896. return (constr);
  1897. };
  1898. //**********************************************************************************************************************************************************
  1899. //Circular Dial
  1900. //**********************************************************************************************************************************************************
  1901. /**
  1902. * Extends mxShape.
  1903. */
  1904. function mxShapeInfographicCircularDial(bounds, fill, stroke, strokewidth)
  1905. {
  1906. mxShape.call(this);
  1907. this.bounds = bounds;
  1908. this.fill = fill;
  1909. this.stroke = stroke;
  1910. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1911. this.dy = 0.5;
  1912. };
  1913. /**
  1914. * Extends mxShape.
  1915. */
  1916. mxUtils.extend(mxShapeInfographicCircularDial, mxActor);
  1917. mxShapeInfographicCircularDial.prototype.cst = {CIRCULAR_DIAL : 'mxgraph.infographic.circularDial'};
  1918. mxShapeInfographicCircularDial.prototype.customProperties = [
  1919. {name:'dy', dispName:'Hole Size', min:0, defVal: 15}
  1920. ];
  1921. /**
  1922. * Function: paintVertexShape
  1923. *
  1924. * Paints the vertex shape.
  1925. */
  1926. mxShapeInfographicCircularDial.prototype.paintVertexShape = function(c, x, y, w, h)
  1927. {
  1928. c.translate(x, y);
  1929. var dy = Math.max(0, Math.min(h * 0.5 - 10, w * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  1930. var rx = Math.max(0, Math.min(w * 0.5, h * 0.5 - 10));
  1931. var rx2 = rx - dy;
  1932. c.begin();
  1933. c.moveTo(w * 0.5 - rx, h);
  1934. c.lineTo(w * 0.5 - rx, rx);
  1935. c.arcTo(rx, rx, 0, 0, 1, w * 0.5, 0);
  1936. c.arcTo(rx, rx, 0, 0, 1, w * 0.5 + rx, rx);
  1937. c.lineTo(w * 0.5 + rx, h);
  1938. c.close();
  1939. c.moveTo(w * 0.5, dy);
  1940. c.arcTo(rx2, rx2, 0, 0, 0, w * 0.5 - rx2, rx);
  1941. c.arcTo(rx2, rx2, 0, 0, 0, w * 0.5, rx + rx2);
  1942. c.arcTo(rx2, rx2, 0, 0, 0, w * 0.5 + rx2, rx);
  1943. c.arcTo(rx2, rx2, 0, 0, 0, w * 0.5, dy);
  1944. c.close();
  1945. c.fillAndStroke();
  1946. c.setShadow(false);
  1947. c.setFillAlpha('0.2');
  1948. c.setFillColor('#000000');
  1949. c.begin();
  1950. c.moveTo(w * 0.5 - rx, 2 * rx);
  1951. c.lineTo(w * 0.5 + rx, 2 * rx);
  1952. c.lineTo(w * 0.5 + rx, h);
  1953. c.lineTo(w * 0.5 - rx, h);
  1954. c.close();
  1955. c.fill();
  1956. };
  1957. mxCellRenderer.registerShape(mxShapeInfographicCircularDial.prototype.cst.CIRCULAR_DIAL, mxShapeInfographicCircularDial);
  1958. Graph.handleFactory[mxShapeInfographicCircularDial.prototype.cst.CIRCULAR_DIAL] = function(state)
  1959. {
  1960. var handles = [Graph.createHandle(state, ['dy'], function(bounds)
  1961. {
  1962. var dy = Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  1963. return new mxPoint(bounds.x + bounds.width * 0.5, bounds.y + dy);
  1964. }, function(bounds, pt)
  1965. {
  1966. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, pt.y - bounds.y))) / 100;
  1967. })];
  1968. return handles;
  1969. };
  1970. mxShapeInfographicCircularDial.prototype.getConstraints = function(style, w, h)
  1971. {
  1972. var constr = [];
  1973. var dy = Math.max(0, Math.min(h * 0.5 - 10, w * 0.5, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  1974. var rx = Math.max(0, Math.min(w * 0.5, h * 0.5 - 10));
  1975. var rx2 = rx - dy;
  1976. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5 - rx, h));
  1977. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5 - rx, (rx + h) * 0.5));
  1978. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5 - rx, rx));
  1979. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5 - rx * 0.71, rx * 0.29));
  1980. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5, 0));
  1981. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5 + rx * 0.71, rx * 0.29));
  1982. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5 + rx, rx));
  1983. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5 + rx, (rx + h) * 0.5));
  1984. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5 + rx, h));
  1985. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5 + rx * 0.5, h));
  1986. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5 - rx * 0.5, h));
  1987. return (constr);
  1988. };
  1989. //**********************************************************************************************************************************************************
  1990. //Simple ribbon
  1991. //**********************************************************************************************************************************************************
  1992. /**
  1993. * Extends mxShape.
  1994. */
  1995. function mxShapeInfographicRibbonSimple(bounds, fill, stroke, strokewidth)
  1996. {
  1997. mxShape.call(this);
  1998. this.bounds = bounds;
  1999. this.fill = fill;
  2000. this.stroke = stroke;
  2001. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2002. this.notch1 = 0.5;
  2003. this.notch2 = 0.5;
  2004. };
  2005. /**
  2006. * Extends mxShape.
  2007. */
  2008. mxUtils.extend(mxShapeInfographicRibbonSimple, mxActor);
  2009. mxShapeInfographicRibbonSimple.prototype.cst = {RIBBON_SIMPLE : 'mxgraph.infographic.ribbonSimple'};
  2010. mxShapeInfographicRibbonSimple.prototype.customProperties = [
  2011. {name:'notch1', dispName:'Notch Size', min:0, defVal: 20},
  2012. {name:'notch2', dispName:'Spike Size', min:0, defVal: 20}
  2013. ];
  2014. /**
  2015. * Function: paintVertexShape
  2016. *
  2017. * Paints the vertex shape.
  2018. */
  2019. mxShapeInfographicRibbonSimple.prototype.paintVertexShape = function(c, x, y, w, h)
  2020. {
  2021. c.translate(x, y);
  2022. var notch1 = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'notch1', this.notch2))));
  2023. var notch2 = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'notch2', this.notch2))));
  2024. c.begin();
  2025. c.moveTo(0, h);
  2026. c.lineTo(notch1, h * 0.5);
  2027. c.lineTo(0, 0);
  2028. c.lineTo(w - notch2, 0);
  2029. c.lineTo(w, h * 0.5);
  2030. c.lineTo(w - notch2, h);
  2031. c.close();
  2032. c.fillAndStroke();
  2033. };
  2034. mxCellRenderer.registerShape(mxShapeInfographicRibbonSimple.prototype.cst.RIBBON_SIMPLE, mxShapeInfographicRibbonSimple);
  2035. Graph.handleFactory[mxShapeInfographicRibbonSimple.prototype.cst.RIBBON_SIMPLE] = function(state)
  2036. {
  2037. var handles = [Graph.createHandle(state, ['notch1'], function(bounds)
  2038. {
  2039. var notch1 = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'notch1', this.notch1))));
  2040. return new mxPoint(bounds.x + notch1, bounds.y + bounds.height * 0.5);
  2041. }, function(bounds, pt)
  2042. {
  2043. this.state.style['notch1'] = Math.round(100 * Math.max(0, Math.min(bounds.width, pt.x - bounds.x))) / 100;
  2044. })];
  2045. var handle2 = Graph.createHandle(state, ['notch2'], function(bounds)
  2046. {
  2047. var notch2 = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'notch2', this.notch2))));
  2048. return new mxPoint(bounds.x + bounds.width - notch2, bounds.y);
  2049. }, function(bounds, pt)
  2050. {
  2051. this.state.style['notch2'] = Math.round(100 * Math.max(0, Math.min(bounds.width, (bounds.width + bounds.x - pt.x)))) / 100;
  2052. });
  2053. handles.push(handle2);
  2054. return handles;
  2055. };
  2056. mxShapeInfographicRibbonSimple.prototype.getConstraints = function(style, w, h)
  2057. {
  2058. var constr = [];
  2059. var notch1 = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'notch1', this.notch2))));
  2060. var notch2 = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'notch2', this.notch2))));
  2061. var w2 = w - notch2;
  2062. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  2063. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w2 * 0.25, 0));
  2064. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w2 * 0.5, 0));
  2065. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w2 * 0.75, 0));
  2066. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w2, 0));
  2067. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  2068. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w2, h));
  2069. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w2 * 0.75, h));
  2070. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w2 * 0.5, h));
  2071. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w2 * 0.25, h));
  2072. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  2073. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, notch1, h * 0.5));
  2074. return (constr);
  2075. };
  2076. //**********************************************************************************************************************************************************
  2077. //Bar with callout
  2078. //**********************************************************************************************************************************************************
  2079. /**
  2080. * Extends mxShape.
  2081. */
  2082. function mxShapeInfographicBarCallout(bounds, fill, stroke, strokewidth)
  2083. {
  2084. mxShape.call(this);
  2085. this.bounds = bounds;
  2086. this.fill = fill;
  2087. this.stroke = stroke;
  2088. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2089. this.dx = 0.5;
  2090. this.dy = 0.5;
  2091. };
  2092. /**
  2093. * Extends mxShape.
  2094. */
  2095. mxUtils.extend(mxShapeInfographicBarCallout, mxActor);
  2096. mxShapeInfographicBarCallout.prototype.cst = {BAR_CALLOUT : 'mxgraph.infographic.barCallout'};
  2097. mxShapeInfographicBarCallout.prototype.customProperties = [
  2098. {name:'dx', dispName:'Callout Position', min:0, defVal: 100},
  2099. {name:'dy', dispName:'Callout Size', min:0, defVal: 30}
  2100. ];
  2101. /**
  2102. * Function: paintVertexShape
  2103. *
  2104. * Paints the vertex shape.
  2105. */
  2106. mxShapeInfographicBarCallout.prototype.paintVertexShape = function(c, x, y, w, h)
  2107. {
  2108. c.translate(x, y);
  2109. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  2110. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  2111. var x1 = Math.max(dx - dy * 0.35, 0);
  2112. var x2 = Math.min(dx + dy * 0.35, w);
  2113. c.begin();
  2114. c.moveTo(0, 0);
  2115. c.lineTo(w, 0);
  2116. c.lineTo(w, h - dy);
  2117. c.lineTo(x2, h - dy);
  2118. c.lineTo(dx, h);
  2119. c.lineTo(x1, h - dy);
  2120. c.lineTo(0, h - dy);
  2121. c.close();
  2122. c.fillAndStroke();
  2123. };
  2124. mxCellRenderer.registerShape(mxShapeInfographicBarCallout.prototype.cst.BAR_CALLOUT, mxShapeInfographicBarCallout);
  2125. mxShapeInfographicBarCallout.prototype.constraints = null;
  2126. Graph.handleFactory[mxShapeInfographicBarCallout.prototype.cst.BAR_CALLOUT] = function(state)
  2127. {
  2128. var handles = [Graph.createHandle(state, ['dx', 'dy'], function(bounds)
  2129. {
  2130. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  2131. var dy = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  2132. return new mxPoint(bounds.x + dx, bounds.y + bounds.height - dy);
  2133. }, function(bounds, pt)
  2134. {
  2135. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.width, pt.x - bounds.x))) / 100;
  2136. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height, bounds.y + bounds.height - pt.y))) / 100;
  2137. })];
  2138. return handles;
  2139. };
  2140. mxShapeInfographicBarCallout.prototype.getConstraints = function(style, w, h)
  2141. {
  2142. var constr = [];
  2143. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  2144. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  2145. var x1 = Math.max(dx - dy * 0.35, 0);
  2146. var x2 = Math.min(dx + dy * 0.35, w);
  2147. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  2148. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
  2149. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  2150. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
  2151. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  2152. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dy) * 0.5));
  2153. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h - dy));
  2154. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false, null, 0, h - dy));
  2155. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false, null, 0, h - dy));
  2156. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, h));
  2157. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - dy));
  2158. return (constr);
  2159. };
  2160. //**********************************************************************************************************************************************************
  2161. //Flag
  2162. //**********************************************************************************************************************************************************
  2163. /**
  2164. * Extends mxShape.
  2165. */
  2166. function mxShapeInfographicFlag(bounds, fill, stroke, strokewidth)
  2167. {
  2168. mxShape.call(this);
  2169. this.bounds = bounds;
  2170. this.fill = fill;
  2171. this.stroke = stroke;
  2172. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2173. this.dx = 0.5;
  2174. this.dy = 0.5;
  2175. };
  2176. /**
  2177. * Extends mxShape.
  2178. */
  2179. mxUtils.extend(mxShapeInfographicFlag, mxActor);
  2180. mxShapeInfographicFlag.prototype.cst = {FLAG : 'mxgraph.infographic.flag'};
  2181. mxShapeInfographicFlag.prototype.customProperties = [
  2182. {name:'dx', dispName:'Pole Width', min:0, defVal: 30},
  2183. {name:'dy', dispName:'Spike Size', min:0, defVal: 20}
  2184. ];
  2185. /**
  2186. * Function: paintVertexShape
  2187. *
  2188. * Paints the vertex shape.
  2189. */
  2190. mxShapeInfographicFlag.prototype.paintVertexShape = function(c, x, y, w, h)
  2191. {
  2192. c.translate(x, y);
  2193. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  2194. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  2195. c.begin();
  2196. c.moveTo(0, 0);
  2197. c.lineTo(w, 0);
  2198. c.lineTo(w, h - dy);
  2199. c.lineTo(dx, h - dy);
  2200. c.lineTo(dx * 0.5, h);
  2201. c.lineTo(0, h - dy);
  2202. c.close();
  2203. c.fillAndStroke();
  2204. c.setShadow(false);
  2205. c.setFillAlpha('0.2');
  2206. c.setFillColor('#ffffff');
  2207. c.begin();
  2208. c.moveTo(0, 0);
  2209. c.lineTo(dx, 0);
  2210. c.lineTo(dx, h - dy);
  2211. c.lineTo(dx * 0.5, h);
  2212. c.lineTo(0, h - dy);
  2213. c.close();
  2214. c.fill();
  2215. };
  2216. mxCellRenderer.registerShape(mxShapeInfographicFlag.prototype.cst.FLAG, mxShapeInfographicFlag);
  2217. Graph.handleFactory[mxShapeInfographicFlag.prototype.cst.FLAG] = function(state)
  2218. {
  2219. var handles = [Graph.createHandle(state, ['dx', 'dy'], function(bounds)
  2220. {
  2221. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  2222. var dy = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  2223. return new mxPoint(bounds.x + dx, bounds.y + bounds.height - dy);
  2224. }, function(bounds, pt)
  2225. {
  2226. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.width, pt.x - bounds.x))) / 100;
  2227. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height, bounds.y + bounds.height - pt.y))) / 100;
  2228. })];
  2229. return handles;
  2230. };
  2231. mxShapeInfographicFlag.prototype.getConstraints = function(style, w, h)
  2232. {
  2233. var constr = [];
  2234. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  2235. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  2236. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  2237. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
  2238. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  2239. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
  2240. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  2241. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dy) * 0.5));
  2242. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h - dy));
  2243. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - dy));
  2244. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dy) * 0.5));
  2245. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.75, h - dy));
  2246. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5, h - dy));
  2247. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.25, h - dy));
  2248. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx * 0.5, h));
  2249. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx * 0.5, 0));
  2250. return (constr);
  2251. };