mxInfographic.js 94 KB

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