Shapes.js 103 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313
  1. /**
  2. * Copyright (c) 2006-2015, JGraph Ltd
  3. */
  4. /**
  5. * Registers shapes.
  6. */
  7. (function()
  8. {
  9. // Cube Shape, supports size style
  10. function CubeShape()
  11. {
  12. mxCylinder.call(this);
  13. };
  14. mxUtils.extend(CubeShape, mxCylinder);
  15. CubeShape.prototype.size = 20;
  16. CubeShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  17. {
  18. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  19. if (isForeground)
  20. {
  21. path.moveTo(s, h);
  22. path.lineTo(s, s);
  23. path.lineTo(0, 0);
  24. path.moveTo(s, s);
  25. path.lineTo(w, s);
  26. path.end();
  27. }
  28. else
  29. {
  30. path.moveTo(0, 0);
  31. path.lineTo(w - s, 0);
  32. path.lineTo(w, s);
  33. path.lineTo(w, h);
  34. path.lineTo(s, h);
  35. path.lineTo(0, h - s);
  36. path.lineTo(0, 0);
  37. path.close();
  38. path.end();
  39. }
  40. };
  41. mxCellRenderer.prototype.defaultShapes['cube'] = CubeShape;
  42. var tan30 = Math.tan(mxUtils.toRadians(30));
  43. var tan30Dx = (0.5 - tan30) / 2;
  44. // Cube Shape, supports size style
  45. function IsoRectangleShape()
  46. {
  47. mxActor.call(this);
  48. };
  49. mxUtils.extend(IsoRectangleShape, mxActor);
  50. IsoRectangleShape.prototype.size = 20;
  51. IsoRectangleShape.prototype.redrawPath = function(path, x, y, w, h)
  52. {
  53. var m = Math.min(w, h / tan30);
  54. path.translate((w - m) / 2, (h - m) / 2 + m / 4);
  55. path.moveTo(0, 0.25 * m);
  56. path.lineTo(0.5 * m, m * tan30Dx);
  57. path.lineTo(m, 0.25 * m);
  58. path.lineTo(0.5 * m, (0.5 - tan30Dx) * m);
  59. path.lineTo(0, 0.25 * m);
  60. path.close();
  61. path.end();
  62. };
  63. mxCellRenderer.prototype.defaultShapes['isoRectangle'] = IsoRectangleShape;
  64. // Cube Shape, supports size style
  65. function IsoCubeShape()
  66. {
  67. mxCylinder.call(this);
  68. };
  69. mxUtils.extend(IsoCubeShape, mxCylinder);
  70. IsoCubeShape.prototype.size = 20;
  71. IsoCubeShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  72. {
  73. var m = Math.min(w, h / (0.5 + tan30));
  74. if (isForeground)
  75. {
  76. path.moveTo(0, 0.25 * m);
  77. path.lineTo(0.5 * m, (0.5 - tan30Dx) * m);
  78. path.lineTo(m, 0.25 * m);
  79. path.moveTo(0.5 * m, (0.5 - tan30Dx) * m);
  80. path.lineTo(0.5 * m, (1 - tan30Dx) * m);
  81. path.end();
  82. }
  83. else
  84. {
  85. path.translate((w - m) / 2, (h - m) / 2);
  86. path.moveTo(0, 0.25 * m);
  87. path.lineTo(0.5 * m, m * tan30Dx);
  88. path.lineTo(m, 0.25 * m);
  89. path.lineTo(m, 0.75 * m);
  90. path.lineTo(0.5 * m, (1 - tan30Dx) * m);
  91. path.lineTo(0, 0.75 * m);
  92. path.close();
  93. path.end();
  94. }
  95. };
  96. mxCellRenderer.prototype.defaultShapes['isoCube'] = IsoCubeShape;
  97. // DataStore Shape, supports size style
  98. function DataStoreShape()
  99. {
  100. mxCylinder.call(this);
  101. };
  102. mxUtils.extend(DataStoreShape, mxCylinder);
  103. DataStoreShape.prototype.redrawPath = function(c, x, y, w, h, isForeground)
  104. {
  105. var dy = Math.min(h / 2, Math.round(h / 8) + this.strokewidth - 1);
  106. if ((isForeground && this.fill != null) || (!isForeground && this.fill == null))
  107. {
  108. c.moveTo(0, dy);
  109. c.curveTo(0, 2 * dy, w, 2 * dy, w, dy);
  110. // Needs separate shapes for correct hit-detection
  111. if (!isForeground)
  112. {
  113. c.stroke();
  114. c.begin();
  115. }
  116. c.translate(0, dy / 2);
  117. c.moveTo(0, dy);
  118. c.curveTo(0, 2 * dy, w, 2 * dy, w, dy);
  119. // Needs separate shapes for correct hit-detection
  120. if (!isForeground)
  121. {
  122. c.stroke();
  123. c.begin();
  124. }
  125. c.translate(0, dy / 2);
  126. c.moveTo(0, dy);
  127. c.curveTo(0, 2 * dy, w, 2 * dy, w, dy);
  128. // Needs separate shapes for correct hit-detection
  129. if (!isForeground)
  130. {
  131. c.stroke();
  132. c.begin();
  133. }
  134. c.translate(0, -dy);
  135. }
  136. if (!isForeground)
  137. {
  138. c.moveTo(0, dy);
  139. c.curveTo(0, -dy / 3, w, -dy / 3, w, dy);
  140. c.lineTo(w, h - dy);
  141. c.curveTo(w, h + dy / 3, 0, h + dy / 3, 0, h - dy);
  142. c.close();
  143. }
  144. };
  145. DataStoreShape.prototype.getLabelBounds = function(rect)
  146. {
  147. var dy = 2.5 * Math.min(rect.height / 2, Math.round(rect.height / 8) + this.strokewidth - 1);
  148. if ((!this.flipV && (this.direction == null || this.direction == mxConstants.DIRECTION_EAST) ||
  149. (this.flipV && this.direction == mxConstants.DIRECTION_WEST)))
  150. {
  151. rect.y += dy;
  152. rect.height -= dy;
  153. }
  154. else if ((!this.flipV && this.direction == mxConstants.DIRECTION_SOUTH) ||
  155. ((this.flipV && this.direction == mxConstants.DIRECTION_NORTH)))
  156. {
  157. rect.width -= dy;
  158. }
  159. else if ((!this.flipV && this.direction == mxConstants.DIRECTION_WEST) ||
  160. (this.flipV && (this.direction == null || this.direction == mxConstants.DIRECTION_EAST)))
  161. {
  162. rect.height -= dy;
  163. }
  164. else if ((!this.flipV && this.direction == mxConstants.DIRECTION_NORTH) ||
  165. (this.flipV && this.direction == mxConstants.DIRECTION_SOUTH))
  166. {
  167. rect.x += dy;
  168. rect.width -= dy;
  169. }
  170. return rect;
  171. };
  172. mxCellRenderer.prototype.defaultShapes['datastore'] = DataStoreShape;
  173. // Note Shape, supports size style
  174. function NoteShape()
  175. {
  176. mxCylinder.call(this);
  177. };
  178. mxUtils.extend(NoteShape, mxCylinder);
  179. NoteShape.prototype.size = 30;
  180. NoteShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  181. {
  182. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  183. if (isForeground)
  184. {
  185. path.moveTo(w - s, 0);
  186. path.lineTo(w - s, s);
  187. path.lineTo(w, s);
  188. path.end();
  189. }
  190. else
  191. {
  192. path.moveTo(0, 0);
  193. path.lineTo(w - s, 0);
  194. path.lineTo(w, s);
  195. path.lineTo(w, h);
  196. path.lineTo(0, h);
  197. path.lineTo(0, 0);
  198. path.close();
  199. path.end();
  200. }
  201. };
  202. mxCellRenderer.prototype.defaultShapes['note'] = NoteShape;
  203. // Note Shape, supports size style
  204. function SwitchShape()
  205. {
  206. mxActor.call(this);
  207. };
  208. mxUtils.extend(SwitchShape, mxActor);
  209. SwitchShape.prototype.redrawPath = function(c, x, y, w, h)
  210. {
  211. var curve = 0.5;
  212. c.moveTo(0, 0);
  213. c.quadTo(w / 2, h * curve, w, 0);
  214. c.quadTo(w * (1 - curve), h / 2, w, h);
  215. c.quadTo(w / 2, h * (1 - curve), 0, h);
  216. c.quadTo(w * curve, h / 2, 0, 0);
  217. c.end();
  218. };
  219. mxCellRenderer.prototype.defaultShapes['switch'] = SwitchShape;
  220. // Folder Shape, supports tabWidth, tabHeight styles
  221. function FolderShape()
  222. {
  223. mxCylinder.call(this);
  224. };
  225. mxUtils.extend(FolderShape, mxCylinder);
  226. FolderShape.prototype.tabWidth = 60;
  227. FolderShape.prototype.tabHeight = 20;
  228. FolderShape.prototype.tabPosition = 'right';
  229. FolderShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  230. {
  231. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'tabWidth', this.tabWidth))));
  232. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'tabHeight', this.tabHeight))));
  233. var tp = mxUtils.getValue(this.style, 'tabPosition', this.tabPosition);
  234. if (isForeground)
  235. {
  236. if (tp == 'left')
  237. {
  238. path.moveTo(0, dy);
  239. path.lineTo(dx, dy);
  240. }
  241. // Right is default
  242. else
  243. {
  244. path.moveTo(w - dx, dy);
  245. path.lineTo(w, dy);
  246. }
  247. path.end();
  248. }
  249. else
  250. {
  251. if (tp == 'left')
  252. {
  253. path.moveTo(0, 0);
  254. path.lineTo(dx, 0);
  255. path.lineTo(dx, dy);
  256. path.lineTo(w, dy);
  257. }
  258. // Right is default
  259. else
  260. {
  261. path.moveTo(0, dy);
  262. path.lineTo(w - dx, dy);
  263. path.lineTo(w - dx, 0);
  264. path.lineTo(w, 0);
  265. }
  266. path.lineTo(w, h);
  267. path.lineTo(0, h);
  268. path.lineTo(0, dy);
  269. path.close();
  270. path.end();
  271. }
  272. };
  273. mxCellRenderer.prototype.defaultShapes['folder'] = FolderShape;
  274. // Card shape
  275. function CardShape()
  276. {
  277. mxActor.call(this);
  278. };
  279. mxUtils.extend(CardShape, mxActor);
  280. CardShape.prototype.size = 30;
  281. CardShape.prototype.redrawPath = function(c, x, y, w, h)
  282. {
  283. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  284. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  285. this.addPoints(c, [new mxPoint(s, 0), new mxPoint(w, 0), new mxPoint(w, h), new mxPoint(0, h), new mxPoint(0, s)],
  286. this.isRounded, arcSize, true);
  287. c.end();
  288. };
  289. mxCellRenderer.prototype.defaultShapes['card'] = CardShape;
  290. // Tape shape
  291. function TapeShape()
  292. {
  293. mxActor.call(this);
  294. };
  295. mxUtils.extend(TapeShape, mxActor);
  296. TapeShape.prototype.size = 0.4;
  297. TapeShape.prototype.redrawPath = function(c, x, y, w, h)
  298. {
  299. var dy = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  300. var fy = 1.4;
  301. c.moveTo(0, dy / 2);
  302. c.quadTo(w / 4, dy * fy, w / 2, dy / 2);
  303. c.quadTo(w * 3 / 4, dy * (1 - fy), w, dy / 2);
  304. c.lineTo(w, h - dy / 2);
  305. c.quadTo(w * 3 / 4, h - dy * fy, w / 2, h - dy / 2);
  306. c.quadTo(w / 4, h - dy * (1 - fy), 0, h - dy / 2);
  307. c.lineTo(0, dy / 2);
  308. c.close();
  309. c.end();
  310. };
  311. mxCellRenderer.prototype.defaultShapes['tape'] = TapeShape;
  312. // Document shape
  313. function DocumentShape()
  314. {
  315. mxActor.call(this);
  316. };
  317. mxUtils.extend(DocumentShape, mxActor);
  318. DocumentShape.prototype.size = 0.3;
  319. DocumentShape.prototype.redrawPath = function(c, x, y, w, h)
  320. {
  321. var dy = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  322. var fy = 1.4;
  323. c.moveTo(0, 0);
  324. c.lineTo(w, 0);
  325. c.lineTo(w, h - dy / 2);
  326. c.quadTo(w * 3 / 4, h - dy * fy, w / 2, h - dy / 2);
  327. c.quadTo(w / 4, h - dy * (1 - fy), 0, h - dy / 2);
  328. c.lineTo(0, dy / 2);
  329. c.close();
  330. c.end();
  331. };
  332. mxCellRenderer.prototype.defaultShapes['document'] = DocumentShape;
  333. // Parallelogram shape
  334. function ParallelogramShape()
  335. {
  336. mxActor.call(this);
  337. };
  338. mxUtils.extend(ParallelogramShape, mxActor);
  339. ParallelogramShape.prototype.size = 0.2;
  340. ParallelogramShape.prototype.redrawPath = function(c, x, y, w, h)
  341. {
  342. var dx = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  343. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  344. this.addPoints(c, [new mxPoint(0, h), new mxPoint(dx, 0), new mxPoint(w, 0), new mxPoint(w - dx, h)],
  345. this.isRounded, arcSize, true);
  346. c.end();
  347. };
  348. mxCellRenderer.prototype.defaultShapes['parallelogram'] = ParallelogramShape;
  349. // Trapezoid shape
  350. function TrapezoidShape()
  351. {
  352. mxActor.call(this);
  353. };
  354. mxUtils.extend(TrapezoidShape, mxActor);
  355. TrapezoidShape.prototype.size = 0.2;
  356. TrapezoidShape.prototype.redrawPath = function(c, x, y, w, h)
  357. {
  358. var dx = w * Math.max(0, Math.min(0.5, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  359. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  360. this.addPoints(c, [new mxPoint(0, h), new mxPoint(dx, 0), new mxPoint(w - dx, 0), new mxPoint(w, h)],
  361. this.isRounded, arcSize, true);
  362. };
  363. mxCellRenderer.prototype.defaultShapes['trapezoid'] = TrapezoidShape;
  364. // Curly Bracket shape
  365. function CurlyBracketShape()
  366. {
  367. mxActor.call(this);
  368. };
  369. mxUtils.extend(CurlyBracketShape, mxActor);
  370. CurlyBracketShape.prototype.size = 0.5;
  371. CurlyBracketShape.prototype.redrawPath = function(c, x, y, w, h)
  372. {
  373. c.setFillColor(null);
  374. var s = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  375. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  376. this.addPoints(c, [new mxPoint(w, 0), new mxPoint(s, 0), new mxPoint(s, h / 2),
  377. new mxPoint(0, h / 2), new mxPoint(s, h / 2), new mxPoint(s, h),
  378. new mxPoint(w, h)], this.isRounded, arcSize, false);
  379. c.end();
  380. };
  381. mxCellRenderer.prototype.defaultShapes['curlyBracket'] = CurlyBracketShape;
  382. // Parallel marker shape
  383. function ParallelMarkerShape()
  384. {
  385. mxActor.call(this);
  386. };
  387. mxUtils.extend(ParallelMarkerShape, mxActor);
  388. ParallelMarkerShape.prototype.redrawPath = function(c, x, y, w, h)
  389. {
  390. c.setStrokeWidth(1);
  391. c.setFillColor(this.stroke);
  392. var w2 = w / 5;
  393. c.rect(0, 0, w2, h);
  394. c.fillAndStroke();
  395. c.rect(2 * w2, 0, w2, h);
  396. c.fillAndStroke();
  397. c.rect(4 * w2, 0, w2, h);
  398. c.fillAndStroke();
  399. };
  400. mxCellRenderer.prototype.defaultShapes['parallelMarker'] = ParallelMarkerShape;
  401. /**
  402. * Adds handJiggle style (jiggle=n sets jiggle)
  403. */
  404. function HandJiggle(canvas, defaultVariation)
  405. {
  406. this.canvas = canvas;
  407. // Avoids "spikes" in the output
  408. this.canvas.setLineJoin('round');
  409. this.canvas.setLineCap('round');
  410. this.defaultVariation = defaultVariation;
  411. this.originalLineTo = this.canvas.lineTo;
  412. this.canvas.lineTo = mxUtils.bind(this, HandJiggle.prototype.lineTo);
  413. this.originalMoveTo = this.canvas.moveTo;
  414. this.canvas.moveTo = mxUtils.bind(this, HandJiggle.prototype.moveTo);
  415. this.originalClose = this.canvas.close;
  416. this.canvas.close = mxUtils.bind(this, HandJiggle.prototype.close);
  417. this.originalQuadTo = this.canvas.quadTo;
  418. this.canvas.quadTo = mxUtils.bind(this, HandJiggle.prototype.quadTo);
  419. this.originalCurveTo = this.canvas.curveTo;
  420. this.canvas.curveTo = mxUtils.bind(this, HandJiggle.prototype.curveTo);
  421. this.originalArcTo = this.canvas.arcTo;
  422. this.canvas.arcTo = mxUtils.bind(this, HandJiggle.prototype.arcTo);
  423. };
  424. HandJiggle.prototype.moveTo = function(endX, endY)
  425. {
  426. this.originalMoveTo.apply(this.canvas, arguments);
  427. this.lastX = endX;
  428. this.lastY = endY;
  429. this.firstX = endX;
  430. this.firstY = endY;
  431. };
  432. HandJiggle.prototype.close = function()
  433. {
  434. if (this.firstX != null && this.firstY != null)
  435. {
  436. this.lineTo(this.firstX, this.firstY);
  437. this.originalClose.apply(this.canvas, arguments);
  438. }
  439. this.originalClose.apply(this.canvas, arguments);
  440. };
  441. HandJiggle.prototype.quadTo = function(x1, y1, x2, y2)
  442. {
  443. this.originalQuadTo.apply(this.canvas, arguments);
  444. this.lastX = x2;
  445. this.lastY = y2;
  446. };
  447. HandJiggle.prototype.curveTo = function(x1, y1, x2, y2, x3, y3)
  448. {
  449. this.originalCurveTo.apply(this.canvas, arguments);
  450. this.lastX = x3;
  451. this.lastY = y3;
  452. };
  453. HandJiggle.prototype.arcTo = function(rx, ry, angle, largeArcFlag, sweepFlag, x, y)
  454. {
  455. this.originalArcTo.apply(this.canvas, arguments);
  456. this.lastX = x;
  457. this.lastY = y;
  458. };
  459. HandJiggle.prototype.lineTo = function(endX, endY)
  460. {
  461. // LATER: Check why this.canvas.lastX cannot be used
  462. if (this.lastX != null && this.lastY != null)
  463. {
  464. var dx = Math.abs(endX - this.lastX);
  465. var dy = Math.abs(endY - this.lastY);
  466. var dist = Math.sqrt(dx * dx + dy * dy);
  467. if (dist < 2)
  468. {
  469. this.originalLineTo.apply(this.canvas, arguments);
  470. this.lastX = endX;
  471. this.lastY = endY;
  472. return;
  473. }
  474. var segs = Math.round(dist / 10);
  475. var variation = this.defaultVariation;
  476. if (segs < 5)
  477. {
  478. segs = 5;
  479. variation /= 3;
  480. }
  481. function sign(x)
  482. {
  483. return typeof x === 'number' ? x ? x < 0 ? -1 : 1 : x === x ? 0 : NaN : NaN;
  484. }
  485. var stepX = sign(endX - this.lastX) * dx / segs;
  486. var stepY = sign(endY - this.lastY) * dy / segs;
  487. var fx = dx / dist;
  488. var fy = dy / dist;
  489. for (var s = 0; s < segs; s++)
  490. {
  491. var x = stepX * s + this.lastX;
  492. var y = stepY * s + this.lastY;
  493. var offset = (Math.random() - 0.5) * variation;
  494. this.originalLineTo.call(this.canvas, x - offset * fy, y - offset * fx);
  495. }
  496. this.originalLineTo.call(this.canvas, endX, endY);
  497. this.lastX = endX;
  498. this.lastY = endY;
  499. }
  500. else
  501. {
  502. this.originalLineTo.apply(this.canvas, arguments);
  503. this.lastX = endX;
  504. this.lastY = endY;
  505. }
  506. };
  507. HandJiggle.prototype.destroy = function()
  508. {
  509. this.canvas.lineTo = this.originalLineTo;
  510. this.canvas.moveTo = this.originalMoveTo;
  511. this.canvas.close = this.originalClose;
  512. this.canvas.quadTo = this.originalQuadTo;
  513. this.canvas.curveTo = this.originalCurveTo;
  514. this.canvas.arcTo = this.originalArcTo;
  515. };
  516. // Installs hand jiggle in all shapes
  517. var mxShapePaint0 = mxShape.prototype.paint;
  518. mxShape.prototype.defaultJiggle = 1.5;
  519. mxShape.prototype.paint = function(c)
  520. {
  521. // NOTE: getValue does not return a boolean value so !('0') would return true here and below
  522. if (this.style != null && mxUtils.getValue(this.style, 'comic', '0') != '0' && c.handHiggle == null)
  523. {
  524. c.handJiggle = new HandJiggle(c, mxUtils.getValue(this.style, 'jiggle', this.defaultJiggle));
  525. }
  526. mxShapePaint0.apply(this, arguments);
  527. if (c.handJiggle != null)
  528. {
  529. c.handJiggle.destroy();
  530. delete c.handJiggle;
  531. }
  532. };
  533. // Sets default jiggle for diamond
  534. mxRhombus.prototype.defaultJiggle = 2;
  535. /**
  536. * Overrides to avoid call to rect
  537. */
  538. var mxRectangleShapeIsHtmlAllowed0 = mxRectangleShape.prototype.isHtmlAllowed;
  539. mxRectangleShape.prototype.isHtmlAllowed = function()
  540. {
  541. return (this.style == null || mxUtils.getValue(this.style, 'comic', '0') == '0') &&
  542. mxRectangleShapeIsHtmlAllowed0.apply(this, arguments);
  543. };
  544. var mxRectangleShapePaintBackground0 = mxRectangleShape.prototype.paintBackground;
  545. mxRectangleShape.prototype.paintBackground = function(c, x, y, w, h)
  546. {
  547. if (c.handJiggle == null)
  548. {
  549. mxRectangleShapePaintBackground0.apply(this, arguments);
  550. }
  551. else
  552. {
  553. var events = true;
  554. if (this.style != null)
  555. {
  556. events = mxUtils.getValue(this.style, mxConstants.STYLE_POINTER_EVENTS, '1') == '1';
  557. }
  558. if (events || (this.fill != null && this.fill != mxConstants.NONE) ||
  559. (this.stroke != null && this.stroke != mxConstants.NONE))
  560. {
  561. if (!events && (this.fill == null || this.fill == mxConstants.NONE))
  562. {
  563. c.pointerEvents = false;
  564. }
  565. c.begin();
  566. if (this.isRounded)
  567. {
  568. var f = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE,
  569. mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100;
  570. var r = Math.min(w * f, h * f);
  571. c.moveTo(x + r, y);
  572. c.lineTo(x + w - r, y);
  573. c.quadTo(x + w, y, x + w, y + r);
  574. c.lineTo(x + w, y + h - r);
  575. c.quadTo(x + w, y + h, x + w - r, y + h);
  576. c.lineTo(x + r, y + h);
  577. c.quadTo(x, y + h, x, y + h - r);
  578. c.lineTo(x, y + r);
  579. c.quadTo(x, y, x + r, y);
  580. }
  581. else
  582. {
  583. c.moveTo(x, y);
  584. c.lineTo(x + w, y);
  585. c.lineTo(x + w, y + h);
  586. c.lineTo(x, y + h);
  587. c.lineTo(x, y);
  588. }
  589. // LATER: Check if close is needed here
  590. c.close();
  591. c.end();
  592. c.fillAndStroke();
  593. }
  594. }
  595. };
  596. /**
  597. * Disables glass effect with hand jiggle.
  598. */
  599. var mxRectangleShapePaintForeground0 = mxRectangleShape.prototype.paintForeground;
  600. mxRectangleShape.prototype.paintForeground = function(c, x, y, w, h)
  601. {
  602. if (c.handJiggle == null)
  603. {
  604. mxRectangleShapePaintForeground0.apply(this, arguments);
  605. }
  606. };
  607. // End of hand jiggle integration
  608. // Process Shape
  609. function ProcessShape()
  610. {
  611. mxRectangleShape.call(this);
  612. };
  613. mxUtils.extend(ProcessShape, mxRectangleShape);
  614. ProcessShape.prototype.size = 0.1;
  615. ProcessShape.prototype.isHtmlAllowed = function()
  616. {
  617. return false;
  618. };
  619. ProcessShape.prototype.getLabelBounds = function(rect)
  620. {
  621. if (mxUtils.getValue(this.state.style, mxConstants.STYLE_HORIZONTAL, true) ==
  622. (this.direction == null ||
  623. this.direction == mxConstants.DIRECTION_EAST ||
  624. this.direction == mxConstants.DIRECTION_WEST))
  625. {
  626. var w = rect.width;
  627. var h = rect.height;
  628. var r = new mxRectangle(rect.x, rect.y, w, h);
  629. var inset = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  630. if (this.isRounded)
  631. {
  632. var f = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE,
  633. mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100;
  634. inset = Math.max(inset, Math.min(w * f, h * f));
  635. }
  636. r.x += inset;
  637. r.width -= 2 * inset;
  638. return r;
  639. }
  640. return rect;
  641. };
  642. ProcessShape.prototype.paintForeground = function(c, x, y, w, h)
  643. {
  644. var inset = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  645. if (this.isRounded)
  646. {
  647. var f = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE,
  648. mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100;
  649. inset = Math.max(inset, Math.min(w * f, h * f));
  650. }
  651. c.begin();
  652. c.moveTo(x + inset, y);
  653. c.lineTo(x + inset, y + h);
  654. c.moveTo(x + w - inset, y);
  655. c.lineTo(x + w - inset, y + h);
  656. c.end();
  657. c.stroke();
  658. mxRectangleShape.prototype.paintForeground.apply(this, arguments);
  659. };
  660. mxCellRenderer.prototype.defaultShapes['process'] = ProcessShape;
  661. // Step shape
  662. function StepShape()
  663. {
  664. mxActor.call(this);
  665. };
  666. mxUtils.extend(StepShape, mxActor);
  667. StepShape.prototype.size = 0.2;
  668. StepShape.prototype.redrawPath = function(c, x, y, w, h)
  669. {
  670. var s = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  671. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  672. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w - s, 0), new mxPoint(w, h / 2), new mxPoint(w - s, h),
  673. new mxPoint(0, h), new mxPoint(s, h / 2)], this.isRounded, arcSize, true);
  674. c.end();
  675. };
  676. mxCellRenderer.prototype.defaultShapes['step'] = StepShape;
  677. // Hexagon shape
  678. function HexagonShape()
  679. {
  680. mxActor.call(this);
  681. };
  682. mxUtils.extend(HexagonShape, mxHexagon);
  683. HexagonShape.prototype.size = 0.25;
  684. HexagonShape.prototype.redrawPath = function(c, x, y, w, h)
  685. {
  686. var s = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  687. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  688. this.addPoints(c, [new mxPoint(s, 0), new mxPoint(w - s, 0), new mxPoint(w, 0.5 * h), new mxPoint(w - s, h),
  689. new mxPoint(s, h), new mxPoint(0, 0.5 * h)], this.isRounded, arcSize, true);
  690. };
  691. mxCellRenderer.prototype.defaultShapes['hexagon'] = HexagonShape;
  692. // Plus Shape
  693. function PlusShape()
  694. {
  695. mxRectangleShape.call(this);
  696. };
  697. mxUtils.extend(PlusShape, mxRectangleShape);
  698. PlusShape.prototype.isHtmlAllowed = function()
  699. {
  700. return false;
  701. };
  702. PlusShape.prototype.paintForeground = function(c, x, y, w, h)
  703. {
  704. var border = Math.min(w / 5, h / 5) + 1;
  705. c.begin();
  706. c.moveTo(x + w / 2, y + border);
  707. c.lineTo(x + w / 2, y + h - border);
  708. c.moveTo(x + border, y + h / 2);
  709. c.lineTo(x + w - border, y + h / 2);
  710. c.end();
  711. c.stroke();
  712. mxRectangleShape.prototype.paintForeground.apply(this, arguments);
  713. };
  714. mxCellRenderer.prototype.defaultShapes['plus'] = PlusShape;
  715. // Overrides painting of rhombus shape to allow for double style
  716. var mxRhombusPaintVertexShape = mxRhombus.prototype.paintVertexShape;
  717. mxRhombus.prototype.getLabelBounds = function(rect)
  718. {
  719. if (this.style['double'] == 1)
  720. {
  721. var margin = (Math.max(2, this.strokewidth + 1) * 2 + parseFloat(this.style[mxConstants.STYLE_MARGIN] || 0)) * this.scale;
  722. return new mxRectangle(rect.x + margin, rect.y + margin, rect.width - 2 * margin, rect.height - 2 * margin);
  723. }
  724. return rect;
  725. };
  726. mxRhombus.prototype.paintVertexShape = function(c, x, y, w, h)
  727. {
  728. mxRhombusPaintVertexShape.apply(this, arguments);
  729. if (!this.outline && this.style['double'] == 1)
  730. {
  731. var margin = Math.max(2, this.strokewidth + 1) * 2 + parseFloat(this.style[mxConstants.STYLE_MARGIN] || 0);
  732. x += margin;
  733. y += margin;
  734. w -= 2 * margin;
  735. h -= 2 * margin;
  736. if (w > 0 && h > 0)
  737. {
  738. c.setShadow(false);
  739. // Workaround for closure compiler bug where the lines with x and y above
  740. // are removed if arguments is used as second argument in call below.
  741. mxRhombusPaintVertexShape.apply(this, [c, x, y, w, h]);
  742. }
  743. }
  744. };
  745. // CompositeShape
  746. function ExtendedShape()
  747. {
  748. mxRectangleShape.call(this);
  749. };
  750. mxUtils.extend(ExtendedShape, mxRectangleShape);
  751. ExtendedShape.prototype.isHtmlAllowed = function()
  752. {
  753. return false;
  754. };
  755. ExtendedShape.prototype.getLabelBounds = function(rect)
  756. {
  757. if (this.style['double'] == 1)
  758. {
  759. var margin = (Math.max(2, this.strokewidth + 1) + parseFloat(this.style[mxConstants.STYLE_MARGIN] || 0)) * this.scale;
  760. return new mxRectangle(rect.x + margin, rect.y + margin, rect.width - 2 * margin, rect.height - 2 * margin);
  761. }
  762. return rect;
  763. };
  764. ExtendedShape.prototype.paintForeground = function(c, x, y, w, h)
  765. {
  766. if (this.style != null)
  767. {
  768. if (!this.outline && this.style['double'] == 1)
  769. {
  770. var margin = Math.max(2, this.strokewidth + 1) + parseFloat(this.style[mxConstants.STYLE_MARGIN] || 0);
  771. x += margin;
  772. y += margin;
  773. w -= 2 * margin;
  774. h -= 2 * margin;
  775. if (w > 0 && h > 0)
  776. {
  777. mxRectangleShape.prototype.paintBackground.apply(this, arguments);
  778. }
  779. }
  780. c.setDashed(false);
  781. // Draws the symbols defined in the style. The symbols are
  782. // numbered from 1...n. Possible postfixes are align,
  783. // verticalAlign, spacing, arcSpacing, width, height
  784. var counter = 0;
  785. var shape = null;
  786. do
  787. {
  788. shape = mxCellRenderer.prototype.defaultShapes[this.style['symbol' + counter]];
  789. if (shape != null)
  790. {
  791. var align = this.style['symbol' + counter + 'Align'];
  792. var valign = this.style['symbol' + counter + 'VerticalAlign'];
  793. var width = this.style['symbol' + counter + 'Width'];
  794. var height = this.style['symbol' + counter + 'Height'];
  795. var spacing = this.style['symbol' + counter + 'Spacing'] || 0;
  796. var arcspacing = this.style['symbol' + counter + 'ArcSpacing'];
  797. if (arcspacing != null)
  798. {
  799. spacing += this.getArcSize(w + this.strokewidth, h + this.strokewidth) * arcspacing;
  800. }
  801. var x2 = x;
  802. var y2 = y;
  803. if (align == mxConstants.ALIGN_CENTER)
  804. {
  805. x2 += (w - width) / 2;
  806. }
  807. else if (align == mxConstants.ALIGN_RIGHT)
  808. {
  809. x2 += w - width - spacing;
  810. }
  811. else
  812. {
  813. x2 += spacing;
  814. }
  815. if (valign == mxConstants.ALIGN_MIDDLE)
  816. {
  817. y2 += (h - height) / 2;
  818. }
  819. else if (valign == mxConstants.ALIGN_BOTTOM)
  820. {
  821. y2 += h - height - spacing;
  822. }
  823. else
  824. {
  825. y2 += spacing;
  826. }
  827. c.save();
  828. // Small hack to pass style along into subshape
  829. var tmp = new shape();
  830. // TODO: Clone style and override settings (eg. strokewidth)
  831. tmp.style = this.style;
  832. shape.prototype.paintVertexShape.call(tmp, c, x2, y2, width, height);
  833. c.restore();
  834. }
  835. counter++;
  836. }
  837. while (shape != null);
  838. }
  839. // Paints glass effect
  840. mxRectangleShape.prototype.paintForeground.apply(this, arguments);
  841. };
  842. mxCellRenderer.prototype.defaultShapes['ext'] = ExtendedShape;
  843. // Tape Shape, supports size style
  844. function MessageShape()
  845. {
  846. mxCylinder.call(this);
  847. };
  848. mxUtils.extend(MessageShape, mxCylinder);
  849. MessageShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  850. {
  851. if (isForeground)
  852. {
  853. path.moveTo(0, 0);
  854. path.lineTo(w / 2, h / 2);
  855. path.lineTo(w, 0);
  856. path.end();
  857. }
  858. else
  859. {
  860. path.moveTo(0, 0);
  861. path.lineTo(w, 0);
  862. path.lineTo(w, h);
  863. path.lineTo(0, h);
  864. path.close();
  865. }
  866. };
  867. mxCellRenderer.prototype.defaultShapes['message'] = MessageShape;
  868. // UML Actor Shape
  869. function UmlActorShape()
  870. {
  871. mxShape.call(this);
  872. };
  873. mxUtils.extend(UmlActorShape, mxShape);
  874. UmlActorShape.prototype.paintBackground = function(c, x, y, w, h)
  875. {
  876. c.translate(x, y);
  877. // Head
  878. c.ellipse(w / 4, 0, w / 2, h / 4);
  879. c.fillAndStroke();
  880. c.begin();
  881. c.moveTo(w / 2, h / 4);
  882. c.lineTo(w / 2, 2 * h / 3);
  883. // Arms
  884. c.moveTo(w / 2, h / 3);
  885. c.lineTo(0, h / 3);
  886. c.moveTo(w / 2, h / 3);
  887. c.lineTo(w, h / 3);
  888. // Legs
  889. c.moveTo(w / 2, 2 * h / 3);
  890. c.lineTo(0, h);
  891. c.moveTo(w / 2, 2 * h / 3);
  892. c.lineTo(w, h);
  893. c.end();
  894. c.stroke();
  895. };
  896. // Replaces existing actor shape
  897. mxCellRenderer.prototype.defaultShapes['umlActor'] = UmlActorShape;
  898. // UML Boundary Shape
  899. function UmlBoundaryShape()
  900. {
  901. mxShape.call(this);
  902. };
  903. mxUtils.extend(UmlBoundaryShape, mxShape);
  904. UmlBoundaryShape.prototype.getLabelBounds = function(rect)
  905. {
  906. return new mxRectangle(rect.x + rect.width / 6, rect.y, rect.width * 5 / 6, rect.height);
  907. };
  908. UmlBoundaryShape.prototype.paintBackground = function(c, x, y, w, h)
  909. {
  910. c.translate(x, y);
  911. // Base line
  912. c.begin();
  913. c.moveTo(0, h / 4);
  914. c.lineTo(0, h * 3 / 4);
  915. c.end();
  916. c.stroke();
  917. // Horizontal line
  918. c.begin();
  919. c.moveTo(0, h / 2);
  920. c.lineTo(w / 6, h / 2);
  921. c.end();
  922. c.stroke();
  923. // Circle
  924. c.ellipse(w / 6, 0, w * 5 / 6, h);
  925. c.fillAndStroke();
  926. };
  927. // Replaces existing actor shape
  928. mxCellRenderer.prototype.defaultShapes['umlBoundary'] = UmlBoundaryShape;
  929. // UML Entity Shape
  930. function UmlEntityShape()
  931. {
  932. mxEllipse.call(this);
  933. };
  934. mxUtils.extend(UmlEntityShape, mxEllipse);
  935. UmlEntityShape.prototype.paintVertexShape = function(c, x, y, w, h)
  936. {
  937. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  938. c.begin();
  939. c.moveTo(x + w / 8, y + h);
  940. c.lineTo(x + w * 7 / 8, y + h);
  941. c.end();
  942. c.stroke();
  943. };
  944. mxCellRenderer.prototype.defaultShapes['umlEntity'] = UmlEntityShape;
  945. // UML Destroy Shape
  946. function UmlDestroyShape()
  947. {
  948. mxShape.call(this);
  949. };
  950. mxUtils.extend(UmlDestroyShape, mxShape);
  951. UmlDestroyShape.prototype.paintVertexShape = function(c, x, y, w, h)
  952. {
  953. c.translate(x, y);
  954. c.begin();
  955. c.moveTo(w, 0);
  956. c.lineTo(0, h);
  957. c.moveTo(0, 0);
  958. c.lineTo(w, h);
  959. c.end();
  960. c.stroke();
  961. };
  962. mxCellRenderer.prototype.defaultShapes['umlDestroy'] = UmlDestroyShape;
  963. // UML Control Shape
  964. function UmlControlShape()
  965. {
  966. mxShape.call(this);
  967. };
  968. mxUtils.extend(UmlControlShape, mxShape);
  969. UmlControlShape.prototype.getLabelBounds = function(rect)
  970. {
  971. return new mxRectangle(rect.x, rect.y + rect.height / 8, rect.width, rect.height * 7 / 8);
  972. };
  973. UmlControlShape.prototype.paintBackground = function(c, x, y, w, h)
  974. {
  975. c.translate(x, y);
  976. // Upper line
  977. c.begin();
  978. c.moveTo(w * 3 / 8, h / 8 * 1.1);
  979. c.lineTo(w * 5 / 8, 0);
  980. c.end();
  981. c.stroke();
  982. // Circle
  983. c.ellipse(0, h / 8, w, h * 7 / 8);
  984. c.fillAndStroke();
  985. };
  986. UmlControlShape.prototype.paintForeground = function(c, x, y, w, h)
  987. {
  988. // Lower line
  989. c.begin();
  990. c.moveTo(w * 3 / 8, h / 8 * 1.1);
  991. c.lineTo(w * 5 / 8, h / 4);
  992. c.end();
  993. c.stroke();
  994. };
  995. // Replaces existing actor shape
  996. mxCellRenderer.prototype.defaultShapes['umlControl'] = UmlControlShape;
  997. // UML Lifeline Shape
  998. function UmlLifeline()
  999. {
  1000. mxRectangleShape.call(this);
  1001. };
  1002. mxUtils.extend(UmlLifeline, mxRectangleShape);
  1003. UmlLifeline.prototype.size = 40;
  1004. UmlLifeline.prototype.isHtmlAllowed = function()
  1005. {
  1006. return false;
  1007. };
  1008. UmlLifeline.prototype.getLabelBounds = function(rect)
  1009. {
  1010. var size = Math.max(0, Math.min(rect.height, parseFloat(mxUtils.getValue(this.style, 'size', this.size)) * this.scale));
  1011. return new mxRectangle(rect.x, rect.y, rect.width, size);
  1012. };
  1013. UmlLifeline.prototype.paintBackground = function(c, x, y, w, h)
  1014. {
  1015. var size = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1016. var participant = mxUtils.getValue(this.style, 'participant');
  1017. if (participant == null || this.state == null)
  1018. {
  1019. mxRectangleShape.prototype.paintBackground.call(this, c, x, y, w, size);
  1020. }
  1021. else
  1022. {
  1023. var ctor = this.state.view.graph.cellRenderer.getShape(participant);
  1024. if (ctor != null && ctor != UmlLifeline)
  1025. {
  1026. var shape = new ctor();
  1027. shape.apply(this.state);
  1028. c.save();
  1029. shape.paintVertexShape(c, x, y, w, size);
  1030. c.restore();
  1031. }
  1032. }
  1033. if (size < h)
  1034. {
  1035. c.setDashed(true);
  1036. c.begin();
  1037. c.moveTo(x + w / 2, y + size);
  1038. c.lineTo(x + w / 2, y + h);
  1039. c.end();
  1040. c.stroke();
  1041. }
  1042. };
  1043. UmlLifeline.prototype.paintForeground = function(c, x, y, w, h)
  1044. {
  1045. var size = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1046. mxRectangleShape.prototype.paintForeground.call(this, c, x, y, w, Math.min(h, size));
  1047. };
  1048. mxCellRenderer.prototype.defaultShapes['umlLifeline'] = UmlLifeline;
  1049. // UML Frame Shape
  1050. function UmlFrame()
  1051. {
  1052. mxShape.call(this);
  1053. };
  1054. mxUtils.extend(UmlFrame, mxShape);
  1055. UmlFrame.prototype.width = 60;
  1056. UmlFrame.prototype.height = 30;
  1057. UmlFrame.prototype.corner = 10;
  1058. UmlFrame.prototype.getLabelBounds = function(rect)
  1059. {
  1060. var w = Math.max(0, Math.min(rect.width, parseFloat(mxUtils.getValue(this.style, 'width', this.width)) * this.scale));
  1061. var h = Math.max(0, Math.min(rect.height, parseFloat(mxUtils.getValue(this.style, 'height', this.height)) * this.scale));
  1062. return new mxRectangle(rect.x, rect.y, w, h);
  1063. };
  1064. UmlFrame.prototype.paintBackground = function(c, x, y, w, h)
  1065. {
  1066. var co = this.corner;
  1067. var w0 = Math.min(w, Math.max(co, parseFloat(mxUtils.getValue(this.style, 'width', this.width))));
  1068. var h0 = Math.min(h, Math.max(co * 1.5, parseFloat(mxUtils.getValue(this.style, 'height', this.height))));
  1069. c.begin();
  1070. c.moveTo(x, y);
  1071. c.lineTo(x + w0, y);
  1072. c.lineTo(x + w0, y + Math.max(0, h0 - co * 1.5));
  1073. c.lineTo(x + Math.max(0, w0 - co), y + h0);
  1074. c.lineTo(x, y + h0);
  1075. c.close();
  1076. c.fillAndStroke();
  1077. c.begin();
  1078. c.moveTo(x + w0, y);
  1079. c.lineTo(x + w, y);
  1080. c.lineTo(x + w, y + h);
  1081. c.lineTo(x, y + h);
  1082. c.lineTo(x, y + h0);
  1083. c.stroke();
  1084. };
  1085. mxCellRenderer.prototype.defaultShapes['umlFrame'] = UmlFrame;
  1086. mxPerimeter.LifelinePerimeter = function (bounds, vertex, next, orthogonal)
  1087. {
  1088. var size = UmlLifeline.prototype.size;
  1089. if (vertex != null)
  1090. {
  1091. size = mxUtils.getValue(vertex.style, 'size', size) * vertex.view.scale;
  1092. }
  1093. var sw = (parseFloat(vertex.style[mxConstants.STYLE_STROKEWIDTH] || 1) * vertex.view.scale / 2) - 1;
  1094. if (next.x < bounds.getCenterX())
  1095. {
  1096. sw += 1;
  1097. sw *= -1;
  1098. }
  1099. return new mxPoint(bounds.getCenterX() + sw, Math.min(bounds.y + bounds.height,
  1100. Math.max(bounds.y + size, next.y)));
  1101. };
  1102. mxStyleRegistry.putValue('lifelinePerimeter', mxPerimeter.LifelinePerimeter);
  1103. mxPerimeter.OrthogonalPerimeter = function (bounds, vertex, next, orthogonal)
  1104. {
  1105. orthogonal = true;
  1106. return mxPerimeter.RectanglePerimeter.apply(this, arguments);
  1107. };
  1108. mxStyleRegistry.putValue('orthogonalPerimeter', mxPerimeter.OrthogonalPerimeter);
  1109. mxPerimeter.BackbonePerimeter = function (bounds, vertex, next, orthogonal)
  1110. {
  1111. var sw = (parseFloat(vertex.style[mxConstants.STYLE_STROKEWIDTH] || 1) * vertex.view.scale / 2) - 1;
  1112. if (vertex.style['backboneSize'] != null)
  1113. {
  1114. sw += (parseFloat(vertex.style['backboneSize']) * vertex.view.scale / 2) - 1;
  1115. }
  1116. if (vertex.style[mxConstants.STYLE_DIRECTION] == 'south' ||
  1117. vertex.style[mxConstants.STYLE_DIRECTION] == 'north')
  1118. {
  1119. if (next.x < bounds.getCenterX())
  1120. {
  1121. sw += 1;
  1122. sw *= -1;
  1123. }
  1124. return new mxPoint(bounds.getCenterX() + sw, Math.min(bounds.y + bounds.height,
  1125. Math.max(bounds.y, next.y)));
  1126. }
  1127. else
  1128. {
  1129. if (next.y < bounds.getCenterY())
  1130. {
  1131. sw += 1;
  1132. sw *= -1;
  1133. }
  1134. return new mxPoint(Math.min(bounds.x + bounds.width, Math.max(bounds.x, next.x)),
  1135. bounds.getCenterY() + sw);
  1136. }
  1137. };
  1138. mxStyleRegistry.putValue('backbonePerimeter', mxPerimeter.BackbonePerimeter);
  1139. // Lollipop Shape
  1140. function LollipopShape()
  1141. {
  1142. mxShape.call(this);
  1143. };
  1144. mxUtils.extend(LollipopShape, mxShape);
  1145. LollipopShape.prototype.size = 10;
  1146. LollipopShape.prototype.paintBackground = function(c, x, y, w, h)
  1147. {
  1148. var sz = parseFloat(mxUtils.getValue(this.style, 'size', this.size));
  1149. c.translate(x, y);
  1150. c.ellipse((w - sz) / 2, 0, sz, sz);
  1151. c.fillAndStroke();
  1152. c.begin();
  1153. c.moveTo(w / 2, sz);
  1154. c.lineTo(w / 2, h);
  1155. c.end();
  1156. c.stroke();
  1157. };
  1158. mxCellRenderer.prototype.defaultShapes['lollipop'] = LollipopShape;
  1159. // Lollipop Shape
  1160. function RequiresShape()
  1161. {
  1162. mxShape.call(this);
  1163. };
  1164. mxUtils.extend(RequiresShape, mxShape);
  1165. RequiresShape.prototype.size = 10;
  1166. RequiresShape.prototype.inset = 2;
  1167. RequiresShape.prototype.paintBackground = function(c, x, y, w, h)
  1168. {
  1169. var sz = parseFloat(mxUtils.getValue(this.style, 'size', this.size));
  1170. var inset = parseFloat(mxUtils.getValue(this.style, 'inset', this.inset)) + this.strokewidth;
  1171. c.translate(x, y);
  1172. c.begin();
  1173. c.moveTo(w / 2, sz + inset);
  1174. c.lineTo(w / 2, h);
  1175. c.end();
  1176. c.stroke();
  1177. c.begin();
  1178. c.moveTo((w - sz) / 2 - inset, sz / 2);
  1179. c.quadTo((w - sz) / 2 - inset, sz + inset, w / 2, sz + inset);
  1180. c.quadTo((w + sz) / 2 + inset, sz + inset, (w + sz) / 2 + inset, sz / 2);
  1181. c.end();
  1182. c.stroke();
  1183. };
  1184. mxCellRenderer.prototype.defaultShapes['requires'] = RequiresShape;
  1185. // Component shape
  1186. function ComponentShape()
  1187. {
  1188. mxCylinder.call(this);
  1189. };
  1190. mxUtils.extend(ComponentShape, mxCylinder);
  1191. ComponentShape.prototype.jettyWidth = 32;
  1192. ComponentShape.prototype.jettyHeight = 12;
  1193. ComponentShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  1194. {
  1195. var dx = parseFloat(mxUtils.getValue(this.style, 'jettyWidth', this.jettyWidth));
  1196. var dy = parseFloat(mxUtils.getValue(this.style, 'jettyHeight', this.jettyHeight));
  1197. var x0 = dx / 2;
  1198. var x1 = x0 + dx / 2;
  1199. var y0 = 0.3 * h - dy / 2;
  1200. var y1 = 0.7 * h - dy / 2;
  1201. if (isForeground)
  1202. {
  1203. path.moveTo(x0, y0);
  1204. path.lineTo(x1, y0);
  1205. path.lineTo(x1, y0 + dy);
  1206. path.lineTo(x0, y0 + dy);
  1207. path.moveTo(x0, y1);
  1208. path.lineTo(x1, y1);
  1209. path.lineTo(x1, y1 + dy);
  1210. path.lineTo(x0, y1 + dy);
  1211. path.end();
  1212. }
  1213. else
  1214. {
  1215. path.moveTo(x0, 0);
  1216. path.lineTo(w, 0);
  1217. path.lineTo(w, h);
  1218. path.lineTo(x0, h);
  1219. path.lineTo(x0, y1 + dy);
  1220. path.lineTo(0, y1 + dy);
  1221. path.lineTo(0, y1);
  1222. path.lineTo(x0, y1);
  1223. path.lineTo(x0, y0 + dy);
  1224. path.lineTo(0, y0 + dy);
  1225. path.lineTo(0, y0);
  1226. path.lineTo(x0, y0);
  1227. path.close();
  1228. path.end();
  1229. }
  1230. };
  1231. mxCellRenderer.prototype.defaultShapes['component'] = ComponentShape;
  1232. // State Shapes derives from double ellipse
  1233. function StateShape()
  1234. {
  1235. mxDoubleEllipse.call(this);
  1236. };
  1237. mxUtils.extend(StateShape, mxDoubleEllipse);
  1238. StateShape.prototype.outerStroke = true;
  1239. StateShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1240. {
  1241. var inset = Math.min(4, Math.min(w / 5, h / 5));
  1242. if (w > 0 && h > 0)
  1243. {
  1244. c.ellipse(x + inset, y + inset, w - 2 * inset, h - 2 * inset);
  1245. c.fillAndStroke();
  1246. }
  1247. c.setShadow(false);
  1248. if (this.outerStroke)
  1249. {
  1250. c.ellipse(x, y, w, h);
  1251. c.stroke();
  1252. }
  1253. };
  1254. mxCellRenderer.prototype.defaultShapes['endState'] = StateShape;
  1255. function StartStateShape()
  1256. {
  1257. StateShape.call(this);
  1258. };
  1259. mxUtils.extend(StartStateShape, StateShape);
  1260. StartStateShape.prototype.outerStroke = false;
  1261. mxCellRenderer.prototype.defaultShapes['startState'] = StartStateShape;
  1262. // Link shape
  1263. function LinkShape()
  1264. {
  1265. mxArrowConnector.call(this);
  1266. this.spacing = 0;
  1267. };
  1268. mxUtils.extend(LinkShape, mxArrowConnector);
  1269. LinkShape.prototype.defaultWidth = 4;
  1270. LinkShape.prototype.isOpenEnded = function()
  1271. {
  1272. return true;
  1273. };
  1274. LinkShape.prototype.getEdgeWidth = function()
  1275. {
  1276. return mxUtils.getNumber(this.style, 'width', this.defaultWidth) + Math.max(0, this.strokewidth - 1);
  1277. };
  1278. LinkShape.prototype.isArrowRounded = function()
  1279. {
  1280. return this.isRounded;
  1281. };
  1282. // Registers the link shape
  1283. mxCellRenderer.prototype.defaultShapes['link'] = LinkShape;
  1284. // Generic arrow
  1285. function FlexArrowShape()
  1286. {
  1287. mxArrowConnector.call(this);
  1288. this.spacing = 0;
  1289. };
  1290. mxUtils.extend(FlexArrowShape, mxArrowConnector);
  1291. FlexArrowShape.prototype.defaultWidth = 10;
  1292. FlexArrowShape.prototype.defaultArrowWidth = 20;
  1293. FlexArrowShape.prototype.getStartArrowWidth = function()
  1294. {
  1295. return this.getEdgeWidth() + mxUtils.getNumber(this.style, 'startWidth', this.defaultArrowWidth);
  1296. };
  1297. FlexArrowShape.prototype.getEndArrowWidth = function()
  1298. {
  1299. return this.getEdgeWidth() + mxUtils.getNumber(this.style, 'endWidth', this.defaultArrowWidth);;
  1300. };
  1301. FlexArrowShape.prototype.getEdgeWidth = function()
  1302. {
  1303. return mxUtils.getNumber(this.style, 'width', this.defaultWidth) + Math.max(0, this.strokewidth - 1);
  1304. };
  1305. // Registers the link shape
  1306. mxCellRenderer.prototype.defaultShapes['flexArrow'] = FlexArrowShape;
  1307. // Manual Input shape
  1308. function ManualInputShape()
  1309. {
  1310. mxActor.call(this);
  1311. };
  1312. mxUtils.extend(ManualInputShape, mxActor);
  1313. ManualInputShape.prototype.size = 30;
  1314. ManualInputShape.prototype.redrawPath = function(c, x, y, w, h)
  1315. {
  1316. var s = Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)));
  1317. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1318. this.addPoints(c, [new mxPoint(0, h), new mxPoint(0, s), new mxPoint(w, 0), new mxPoint(w, h)],
  1319. this.isRounded, arcSize, true);
  1320. c.end();
  1321. };
  1322. mxCellRenderer.prototype.defaultShapes['manualInput'] = ManualInputShape;
  1323. // Internal storage
  1324. function InternalStorageShape()
  1325. {
  1326. mxRectangleShape.call(this);
  1327. };
  1328. mxUtils.extend(InternalStorageShape, mxRectangleShape);
  1329. InternalStorageShape.prototype.dx = 20;
  1330. InternalStorageShape.prototype.dy = 20;
  1331. InternalStorageShape.prototype.isHtmlAllowed = function()
  1332. {
  1333. return false;
  1334. };
  1335. InternalStorageShape.prototype.paintForeground = function(c, x, y, w, h)
  1336. {
  1337. mxRectangleShape.prototype.paintForeground.apply(this, arguments);
  1338. var inset = 0;
  1339. if (this.isRounded)
  1340. {
  1341. var f = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE,
  1342. mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100;
  1343. inset = Math.max(inset, Math.min(w * f, h * f));
  1344. }
  1345. var dx = Math.max(inset, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1346. var dy = Math.max(inset, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  1347. c.begin();
  1348. c.moveTo(x, y + dy);
  1349. c.lineTo(x + w, y + dy);
  1350. c.end();
  1351. c.stroke();
  1352. c.begin();
  1353. c.moveTo(x + dx, y);
  1354. c.lineTo(x + dx, y + h);
  1355. c.end();
  1356. c.stroke();
  1357. };
  1358. mxCellRenderer.prototype.defaultShapes['internalStorage'] = InternalStorageShape;
  1359. // Internal storage
  1360. function CornerShape()
  1361. {
  1362. mxActor.call(this);
  1363. };
  1364. mxUtils.extend(CornerShape, mxActor);
  1365. CornerShape.prototype.dx = 20;
  1366. CornerShape.prototype.dy = 20;
  1367. // Corner
  1368. CornerShape.prototype.redrawPath = function(c, x, y, w, h)
  1369. {
  1370. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1371. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  1372. var s = Math.min(w / 2, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1373. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1374. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w, 0), new mxPoint(w, dy), new mxPoint(dx, dy),
  1375. new mxPoint(dx, h), new mxPoint(0, h)], this.isRounded, arcSize, true);
  1376. c.end();
  1377. };
  1378. mxCellRenderer.prototype.defaultShapes['corner'] = CornerShape;
  1379. // Crossbar shape
  1380. function CrossbarShape()
  1381. {
  1382. mxActor.call(this);
  1383. };
  1384. mxUtils.extend(CrossbarShape, mxActor);
  1385. CrossbarShape.prototype.redrawPath = function(c, x, y, w, h)
  1386. {
  1387. c.moveTo(0, 0);
  1388. c.lineTo(0, h);
  1389. c.end();
  1390. c.moveTo(w, 0);
  1391. c.lineTo(w, h);
  1392. c.end();
  1393. c.moveTo(0, h / 2);
  1394. c.lineTo(w, h / 2);
  1395. c.end();
  1396. };
  1397. mxCellRenderer.prototype.defaultShapes['crossbar'] = CrossbarShape;
  1398. // Internal storage
  1399. function TeeShape()
  1400. {
  1401. mxActor.call(this);
  1402. };
  1403. mxUtils.extend(TeeShape, mxActor);
  1404. TeeShape.prototype.dx = 20;
  1405. TeeShape.prototype.dy = 20;
  1406. // Corner
  1407. TeeShape.prototype.redrawPath = function(c, x, y, w, h)
  1408. {
  1409. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1410. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  1411. var w2 = Math.abs(w - dx) / 2;
  1412. var s = Math.min(w / 2, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1413. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1414. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w, 0), new mxPoint(w, dy), new mxPoint((w + dx) / 2, dy),
  1415. new mxPoint((w + dx) / 2, h), new mxPoint((w - dx) / 2, h), new mxPoint((w - dx) / 2, dy),
  1416. new mxPoint(0, dy)], this.isRounded, arcSize, true);
  1417. c.end();
  1418. };
  1419. mxCellRenderer.prototype.defaultShapes['tee'] = TeeShape;
  1420. // Arrow
  1421. function SingleArrowShape()
  1422. {
  1423. mxActor.call(this);
  1424. };
  1425. mxUtils.extend(SingleArrowShape, mxActor);
  1426. SingleArrowShape.prototype.arrowWidth = 0.3;
  1427. SingleArrowShape.prototype.arrowSize = 0.2;
  1428. SingleArrowShape.prototype.redrawPath = function(c, x, y, w, h)
  1429. {
  1430. var aw = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowWidth', this.arrowWidth))));
  1431. var as = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowSize', this.arrowSize))));
  1432. var at = (h - aw) / 2;
  1433. var ab = at + aw;
  1434. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1435. this.addPoints(c, [new mxPoint(0, at), new mxPoint(w - as, at), new mxPoint(w - as, 0), new mxPoint(w, h / 2),
  1436. new mxPoint(w - as, h), new mxPoint(w - as, ab), new mxPoint(0, ab)],
  1437. this.isRounded, arcSize, true);
  1438. c.end();
  1439. };
  1440. mxCellRenderer.prototype.defaultShapes['singleArrow'] = SingleArrowShape;
  1441. // Arrow
  1442. function DoubleArrowShape()
  1443. {
  1444. mxActor.call(this);
  1445. };
  1446. mxUtils.extend(DoubleArrowShape, mxActor);
  1447. DoubleArrowShape.prototype.redrawPath = function(c, x, y, w, h)
  1448. {
  1449. var aw = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowWidth', SingleArrowShape.prototype.arrowWidth))));
  1450. var as = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowSize', SingleArrowShape.prototype.arrowSize))));
  1451. var at = (h - aw) / 2;
  1452. var ab = at + aw;
  1453. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1454. this.addPoints(c, [new mxPoint(0, h / 2), new mxPoint(as, 0), new mxPoint(as, at), new mxPoint(w - as, at),
  1455. new mxPoint(w - as, 0), new mxPoint(w, h / 2), new mxPoint(w - as, h),
  1456. new mxPoint(w - as, ab), new mxPoint(as, ab), new mxPoint(as, h)],
  1457. this.isRounded, arcSize, true);
  1458. c.end();
  1459. };
  1460. mxCellRenderer.prototype.defaultShapes['doubleArrow'] = DoubleArrowShape;
  1461. // Data storage
  1462. function DataStorageShape()
  1463. {
  1464. mxActor.call(this);
  1465. };
  1466. mxUtils.extend(DataStorageShape, mxActor);
  1467. DataStorageShape.prototype.size = 0.1;
  1468. DataStorageShape.prototype.redrawPath = function(c, x, y, w, h)
  1469. {
  1470. var s = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1471. c.moveTo(s, 0);
  1472. c.lineTo(w, 0);
  1473. c.quadTo(w - s * 2, h / 2, w, h);
  1474. c.lineTo(s, h);
  1475. c.quadTo(s - s * 2, h / 2, s, 0);
  1476. c.close();
  1477. c.end();
  1478. };
  1479. mxCellRenderer.prototype.defaultShapes['dataStorage'] = DataStorageShape;
  1480. // Or
  1481. function OrShape()
  1482. {
  1483. mxActor.call(this);
  1484. };
  1485. mxUtils.extend(OrShape, mxActor);
  1486. OrShape.prototype.redrawPath = function(c, x, y, w, h)
  1487. {
  1488. c.moveTo(0, 0);
  1489. c.quadTo(w, 0, w, h / 2);
  1490. c.quadTo(w, h, 0, h);
  1491. c.close();
  1492. c.end();
  1493. };
  1494. mxCellRenderer.prototype.defaultShapes['or'] = OrShape;
  1495. // Xor
  1496. function XorShape()
  1497. {
  1498. mxActor.call(this);
  1499. };
  1500. mxUtils.extend(XorShape, mxActor);
  1501. XorShape.prototype.redrawPath = function(c, x, y, w, h)
  1502. {
  1503. c.moveTo(0, 0);
  1504. c.quadTo(w, 0, w, h / 2);
  1505. c.quadTo(w, h, 0, h);
  1506. c.quadTo(w / 2, h / 2, 0, 0);
  1507. c.close();
  1508. c.end();
  1509. };
  1510. mxCellRenderer.prototype.defaultShapes['xor'] = XorShape;
  1511. // Loop limit
  1512. function LoopLimitShape()
  1513. {
  1514. mxActor.call(this);
  1515. };
  1516. mxUtils.extend(LoopLimitShape, mxActor);
  1517. LoopLimitShape.prototype.size = 20;
  1518. LoopLimitShape.prototype.redrawPath = function(c, x, y, w, h)
  1519. {
  1520. var s = Math.min(w / 2, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1521. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1522. this.addPoints(c, [new mxPoint(s, 0), new mxPoint(w - s, 0), new mxPoint(w, s * 0.8), new mxPoint(w, h),
  1523. new mxPoint(0, h), new mxPoint(0, s * 0.8)], this.isRounded, arcSize, true);
  1524. c.end();
  1525. };
  1526. mxCellRenderer.prototype.defaultShapes['loopLimit'] = LoopLimitShape;
  1527. // Off page connector
  1528. function OffPageConnectorShape()
  1529. {
  1530. mxActor.call(this);
  1531. };
  1532. mxUtils.extend(OffPageConnectorShape, mxActor);
  1533. OffPageConnectorShape.prototype.size = 3 / 8;
  1534. OffPageConnectorShape.prototype.redrawPath = function(c, x, y, w, h)
  1535. {
  1536. var s = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1537. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1538. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w, 0), new mxPoint(w, h - s), new mxPoint(w / 2, h),
  1539. new mxPoint(0, h - s)], this.isRounded, arcSize, true);
  1540. c.end();
  1541. };
  1542. mxCellRenderer.prototype.defaultShapes['offPageConnector'] = OffPageConnectorShape;
  1543. // Internal storage
  1544. function TapeDataShape()
  1545. {
  1546. mxEllipse.call(this);
  1547. };
  1548. mxUtils.extend(TapeDataShape, mxEllipse);
  1549. TapeDataShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1550. {
  1551. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  1552. c.begin();
  1553. c.moveTo(x + w / 2, y + h);
  1554. c.lineTo(x + w, y + h);
  1555. c.end();
  1556. c.stroke();
  1557. };
  1558. mxCellRenderer.prototype.defaultShapes['tapeData'] = TapeDataShape;
  1559. // OrEllipseShape
  1560. function OrEllipseShape()
  1561. {
  1562. mxEllipse.call(this);
  1563. };
  1564. mxUtils.extend(OrEllipseShape, mxEllipse);
  1565. OrEllipseShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1566. {
  1567. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  1568. c.setShadow(false);
  1569. c.begin();
  1570. c.moveTo(x, y + h / 2);
  1571. c.lineTo(x + w, y + h / 2);
  1572. c.end();
  1573. c.stroke();
  1574. c.begin();
  1575. c.moveTo(x + w / 2, y);
  1576. c.lineTo(x + w / 2, y + h);
  1577. c.end();
  1578. c.stroke();
  1579. };
  1580. mxCellRenderer.prototype.defaultShapes['orEllipse'] = OrEllipseShape;
  1581. // SumEllipseShape
  1582. function SumEllipseShape()
  1583. {
  1584. mxEllipse.call(this);
  1585. };
  1586. mxUtils.extend(SumEllipseShape, mxEllipse);
  1587. SumEllipseShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1588. {
  1589. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  1590. var s2 = 0.145;
  1591. c.setShadow(false);
  1592. c.begin();
  1593. c.moveTo(x + w * s2, y + h * s2);
  1594. c.lineTo(x + w * (1 - s2), y + h * (1 - s2));
  1595. c.end();
  1596. c.stroke();
  1597. c.begin();
  1598. c.moveTo(x + w * (1 - s2), y + h * s2);
  1599. c.lineTo(x + w * s2, y + h * (1 - s2));
  1600. c.end();
  1601. c.stroke();
  1602. };
  1603. mxCellRenderer.prototype.defaultShapes['sumEllipse'] = SumEllipseShape;
  1604. // SortShape
  1605. function SortShape()
  1606. {
  1607. mxRhombus.call(this);
  1608. };
  1609. mxUtils.extend(SortShape, mxRhombus);
  1610. SortShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1611. {
  1612. mxRhombus.prototype.paintVertexShape.apply(this, arguments);
  1613. c.setShadow(false);
  1614. c.begin();
  1615. c.moveTo(x, y + h / 2);
  1616. c.lineTo(x + w, y + h / 2);
  1617. c.end();
  1618. c.stroke();
  1619. };
  1620. mxCellRenderer.prototype.defaultShapes['sortShape'] = SortShape;
  1621. // CollateShape
  1622. function CollateShape()
  1623. {
  1624. mxEllipse.call(this);
  1625. };
  1626. mxUtils.extend(CollateShape, mxEllipse);
  1627. CollateShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1628. {
  1629. c.begin();
  1630. c.moveTo(x, y);
  1631. c.lineTo(x + w, y);
  1632. c.lineTo(x + w / 2, y + h / 2);
  1633. c.close();
  1634. c.fillAndStroke();
  1635. c.begin();
  1636. c.moveTo(x, y + h);
  1637. c.lineTo(x + w, y + h);
  1638. c.lineTo(x + w / 2, y + h / 2);
  1639. c.close();
  1640. c.fillAndStroke();
  1641. };
  1642. mxCellRenderer.prototype.defaultShapes['collate'] = CollateShape;
  1643. // DimensionShape
  1644. function DimensionShape()
  1645. {
  1646. mxEllipse.call(this);
  1647. };
  1648. mxUtils.extend(DimensionShape, mxEllipse);
  1649. DimensionShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1650. {
  1651. // Arrow size
  1652. var al = 10;
  1653. var cy = y + h - al / 2;
  1654. c.begin();
  1655. c.moveTo(x, y);
  1656. c.lineTo(x, y + h);
  1657. c.moveTo(x, cy);
  1658. c.lineTo(x + al, cy - al / 2);
  1659. c.moveTo(x, cy);
  1660. c.lineTo(x + al, cy + al / 2);
  1661. c.moveTo(x, cy);
  1662. c.lineTo(x + w, cy);
  1663. // Opposite side
  1664. c.moveTo(x + w, y);
  1665. c.lineTo(x + w, y + h);
  1666. c.moveTo(x + w, cy);
  1667. c.lineTo(x + w - al, cy - al / 2);
  1668. c.moveTo(x + w, cy);
  1669. c.lineTo(x + w - al, cy + al / 2);
  1670. c.end();
  1671. c.stroke();
  1672. };
  1673. mxCellRenderer.prototype.defaultShapes['dimension'] = DimensionShape;
  1674. // PartialRectangleShape
  1675. function PartialRectangleShape()
  1676. {
  1677. mxEllipse.call(this);
  1678. };
  1679. mxUtils.extend(PartialRectangleShape, mxEllipse);
  1680. PartialRectangleShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1681. {
  1682. if (!this.outline)
  1683. {
  1684. c.setStrokeColor(null);
  1685. }
  1686. mxRectangleShape.prototype.paintBackground.apply(this, arguments);
  1687. if (this.style != null)
  1688. {
  1689. c.setStrokeColor(this.stroke);
  1690. c.rect(x, y, w, h);
  1691. c.fill();
  1692. if (mxUtils.getValue(this.style, 'top', '1') == '1')
  1693. {
  1694. c.begin();
  1695. c.moveTo(x, y);
  1696. c.lineTo(x + w, y);
  1697. c.end();
  1698. c.stroke();
  1699. }
  1700. if (mxUtils.getValue(this.style, 'right', '1') == '1')
  1701. {
  1702. c.begin();
  1703. c.moveTo(x + w, y);
  1704. c.lineTo(x + w, y + h);
  1705. c.end();
  1706. c.stroke();
  1707. }
  1708. if (mxUtils.getValue(this.style, 'bottom', '1') == '1')
  1709. {
  1710. c.begin();
  1711. c.moveTo(x + w, y + h);
  1712. c.lineTo(x, y + h);
  1713. c.end();
  1714. c.stroke();
  1715. }
  1716. if (mxUtils.getValue(this.style, 'left', '1') == '1')
  1717. {
  1718. c.begin();
  1719. c.moveTo(x, y + h);
  1720. c.lineTo(x, y);
  1721. c.end();
  1722. c.stroke();
  1723. }
  1724. }
  1725. };
  1726. mxCellRenderer.prototype.defaultShapes['partialRectangle'] = PartialRectangleShape;
  1727. // LineEllipseShape
  1728. function LineEllipseShape()
  1729. {
  1730. mxEllipse.call(this);
  1731. };
  1732. mxUtils.extend(LineEllipseShape, mxEllipse);
  1733. LineEllipseShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1734. {
  1735. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  1736. c.setShadow(false);
  1737. c.begin();
  1738. if (mxUtils.getValue(this.style, 'line') == 'vertical')
  1739. {
  1740. c.moveTo(x + w / 2, y);
  1741. c.lineTo(x + w / 2, y + h);
  1742. }
  1743. else
  1744. {
  1745. c.moveTo(x, y + h / 2);
  1746. c.lineTo(x + w, y + h / 2);
  1747. }
  1748. c.end();
  1749. c.stroke();
  1750. };
  1751. mxCellRenderer.prototype.defaultShapes['lineEllipse'] = LineEllipseShape;
  1752. // Delay
  1753. function DelayShape()
  1754. {
  1755. mxActor.call(this);
  1756. };
  1757. mxUtils.extend(DelayShape, mxActor);
  1758. DelayShape.prototype.redrawPath = function(c, x, y, w, h)
  1759. {
  1760. var dx = Math.min(w, h / 2);
  1761. c.moveTo(0, 0);
  1762. c.lineTo(w - dx, 0);
  1763. c.quadTo(w, 0, w, h / 2);
  1764. c.quadTo(w, h, w - dx, h);
  1765. c.lineTo(0, h);
  1766. c.close();
  1767. c.end();
  1768. };
  1769. mxCellRenderer.prototype.defaultShapes['delay'] = DelayShape;
  1770. // Cross Shape
  1771. function CrossShape()
  1772. {
  1773. mxActor.call(this);
  1774. };
  1775. mxUtils.extend(CrossShape, mxActor);
  1776. CrossShape.prototype.size = 0.2;
  1777. CrossShape.prototype.redrawPath = function(c, x, y, w, h)
  1778. {
  1779. var m = Math.min(h, w);
  1780. var size = Math.max(0, Math.min(m, m * parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1781. var t = (h - size) / 2;
  1782. var b = t + size;
  1783. var l = (w - size) / 2;
  1784. var r = l + size;
  1785. c.moveTo(0, t);
  1786. c.lineTo(l, t);
  1787. c.lineTo(l, 0);
  1788. c.lineTo(r, 0);
  1789. c.lineTo(r, t);
  1790. c.lineTo(w, t);
  1791. c.lineTo(w, b);
  1792. c.lineTo(r, b);
  1793. c.lineTo(r, h);
  1794. c.lineTo(l, h);
  1795. c.lineTo(l, b);
  1796. c.lineTo(0, b);
  1797. c.close();
  1798. c.end();
  1799. };
  1800. mxCellRenderer.prototype.defaultShapes['cross'] = CrossShape;
  1801. // Display
  1802. function DisplayShape()
  1803. {
  1804. mxActor.call(this);
  1805. };
  1806. mxUtils.extend(DisplayShape, mxActor);
  1807. DisplayShape.prototype.size = 0.25;
  1808. DisplayShape.prototype.redrawPath = function(c, x, y, w, h)
  1809. {
  1810. var dx = Math.min(w, h / 2);
  1811. var s = Math.min(w - dx, Math.max(0, parseFloat(mxUtils.getValue(this.style, 'size', this.size))) * w);
  1812. c.moveTo(0, h / 2);
  1813. c.lineTo(s, 0);
  1814. c.lineTo(w - dx, 0);
  1815. c.quadTo(w, 0, w, h / 2);
  1816. c.quadTo(w, h, w - dx, h);
  1817. c.lineTo(s, h);
  1818. c.close();
  1819. c.end();
  1820. };
  1821. mxCellRenderer.prototype.defaultShapes['display'] = DisplayShape;
  1822. // Registers and defines the custom marker
  1823. mxMarker.addMarker('dash', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  1824. {
  1825. var nx = unitX * (size + sw + 1);
  1826. var ny = unitY * (size + sw + 1);
  1827. return function()
  1828. {
  1829. c.begin();
  1830. c.moveTo(pe.x - nx / 2 - ny / 2, pe.y - ny / 2 + nx / 2);
  1831. c.lineTo(pe.x + ny / 2 - 3 * nx / 2, pe.y - 3 * ny / 2 - nx / 2);
  1832. c.stroke();
  1833. };
  1834. });
  1835. // Registers and defines the custom marker
  1836. mxMarker.addMarker('cross', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  1837. {
  1838. var nx = unitX * (size + sw + 1);
  1839. var ny = unitY * (size + sw + 1);
  1840. return function()
  1841. {
  1842. c.begin();
  1843. c.moveTo(pe.x - nx / 2 - ny / 2, pe.y - ny / 2 + nx / 2);
  1844. c.lineTo(pe.x + ny / 2 - 3 * nx / 2, pe.y - 3 * ny / 2 - nx / 2);
  1845. c.moveTo(pe.x - nx / 2 + ny / 2, pe.y - ny / 2 - nx / 2);
  1846. c.lineTo(pe.x - ny / 2 - 3 * nx / 2, pe.y - 3 * ny / 2 + nx / 2);
  1847. c.stroke();
  1848. };
  1849. });
  1850. function circleMarker(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  1851. {
  1852. var a = size / 2;
  1853. var size = size + sw;
  1854. var pt = pe.clone();
  1855. pe.x -= unitX * (2 * size + sw);
  1856. pe.y -= unitY * (2 * size + sw);
  1857. unitX = unitX * (size + sw);
  1858. unitY = unitY * (size + sw);
  1859. return function()
  1860. {
  1861. c.ellipse(pt.x - unitX - size, pt.y - unitY - size, 2 * size, 2 * size);
  1862. if (filled)
  1863. {
  1864. c.fillAndStroke();
  1865. }
  1866. else
  1867. {
  1868. c.stroke();
  1869. }
  1870. };
  1871. };
  1872. mxMarker.addMarker('circle', circleMarker);
  1873. mxMarker.addMarker('circlePlus', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  1874. {
  1875. var pt = pe.clone();
  1876. var fn = circleMarker.apply(this, arguments);
  1877. var nx = unitX * (size + 2 * sw); // (size + sw + 1);
  1878. var ny = unitY * (size + 2 * sw); //(size + sw + 1);
  1879. return function()
  1880. {
  1881. fn.apply(this, arguments);
  1882. c.begin();
  1883. c.moveTo(pt.x - unitX * (sw), pt.y - unitY * (sw));
  1884. c.lineTo(pt.x - 2 * nx + unitX * (sw), pt.y - 2 * ny + unitY * (sw));
  1885. c.moveTo(pt.x - nx - ny + unitY * sw, pt.y - ny + nx - unitX * sw);
  1886. c.lineTo(pt.x + ny - nx - unitY * sw, pt.y - ny - nx + unitX * sw);
  1887. c.stroke();
  1888. };
  1889. });
  1890. mxMarker.addMarker('async', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  1891. {
  1892. // The angle of the forward facing arrow sides against the x axis is
  1893. // 26.565 degrees, 1/sin(26.565) = 2.236 / 2 = 1.118 ( / 2 allows for
  1894. // only half the strokewidth is processed ).
  1895. var endOffsetX = unitX * sw * 1.118;
  1896. var endOffsetY = unitY * sw * 1.118;
  1897. unitX = unitX * (size + sw);
  1898. unitY = unitY * (size + sw);
  1899. var pt = pe.clone();
  1900. pt.x -= endOffsetX;
  1901. pt.y -= endOffsetY;
  1902. var f = 1;
  1903. pe.x += -unitX * f - endOffsetX;
  1904. pe.y += -unitY * f - endOffsetY;
  1905. return function()
  1906. {
  1907. c.begin();
  1908. c.moveTo(pt.x, pt.y);
  1909. if (source)
  1910. {
  1911. c.lineTo(pt.x - unitX - unitY / 2, pt.y - unitY + unitX / 2);
  1912. }
  1913. else
  1914. {
  1915. c.lineTo(pt.x + unitY / 2 - unitX, pt.y - unitY - unitX / 2);
  1916. }
  1917. c.lineTo(pt.x - unitX, pt.y - unitY);
  1918. c.close();
  1919. if (filled)
  1920. {
  1921. c.fillAndStroke();
  1922. }
  1923. else
  1924. {
  1925. c.stroke();
  1926. }
  1927. };
  1928. });
  1929. function createOpenAsyncArrow(widthFactor)
  1930. {
  1931. widthFactor = (widthFactor != null) ? widthFactor : 2;
  1932. return function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  1933. {
  1934. unitX = unitX * (size + sw);
  1935. unitY = unitY * (size + sw);
  1936. var pt = pe.clone();
  1937. return function()
  1938. {
  1939. c.begin();
  1940. c.moveTo(pt.x, pt.y);
  1941. if (source)
  1942. {
  1943. c.lineTo(pt.x - unitX - unitY / widthFactor, pt.y - unitY + unitX / widthFactor);
  1944. }
  1945. else
  1946. {
  1947. c.lineTo(pt.x + unitY / widthFactor - unitX, pt.y - unitY - unitX / widthFactor);
  1948. }
  1949. c.stroke();
  1950. };
  1951. }
  1952. };
  1953. mxMarker.addMarker('openAsync', createOpenAsyncArrow(2));
  1954. function arrow(canvas, shape, type, pe, unitX, unitY, size, source, sw, filled)
  1955. {
  1956. // The angle of the forward facing arrow sides against the x axis is
  1957. // 26.565 degrees, 1/sin(26.565) = 2.236 / 2 = 1.118 ( / 2 allows for
  1958. // only half the strokewidth is processed ).
  1959. var endOffsetX = unitX * sw * 1.118;
  1960. var endOffsetY = unitY * sw * 1.118;
  1961. unitX = unitX * (size + sw);
  1962. unitY = unitY * (size + sw);
  1963. var pt = pe.clone();
  1964. pt.x -= endOffsetX;
  1965. pt.y -= endOffsetY;
  1966. var f = (type != mxConstants.ARROW_CLASSIC && type != mxConstants.ARROW_CLASSIC_THIN) ? 1 : 3 / 4;
  1967. pe.x += -unitX * f - endOffsetX;
  1968. pe.y += -unitY * f - endOffsetY;
  1969. return function()
  1970. {
  1971. canvas.begin();
  1972. canvas.moveTo(pt.x, pt.y);
  1973. canvas.lineTo(pt.x - unitX - unitY / widthFactor, pt.y - unitY + unitX / widthFactor);
  1974. if (type == mxConstants.ARROW_CLASSIC || type == mxConstants.ARROW_CLASSIC_THIN)
  1975. {
  1976. canvas.lineTo(pt.x - unitX * 3 / 4, pt.y - unitY * 3 / 4);
  1977. }
  1978. canvas.lineTo(pt.x + unitY / widthFactor - unitX, pt.y - unitY - unitX / widthFactor);
  1979. canvas.close();
  1980. if (filled)
  1981. {
  1982. canvas.fillAndStroke();
  1983. }
  1984. else
  1985. {
  1986. canvas.stroke();
  1987. }
  1988. };
  1989. }
  1990. // Handlers are only added if mxVertexHandler is defined (ie. not in embedded graph)
  1991. if (typeof mxVertexHandler !== 'undefined')
  1992. {
  1993. function createHandle(state, keys, getPositionFn, setPositionFn, ignoreGrid)
  1994. {
  1995. var handle = new mxHandle(state, null, mxVertexHandler.prototype.secondaryHandleImage);
  1996. handle.execute = function()
  1997. {
  1998. for (var i = 0; i < keys.length; i++)
  1999. {
  2000. this.copyStyle(keys[i]);
  2001. }
  2002. };
  2003. handle.getPosition = getPositionFn;
  2004. handle.setPosition = setPositionFn;
  2005. handle.ignoreGrid = (ignoreGrid != null) ? ignoreGrid : true;
  2006. return handle;
  2007. };
  2008. function createArcHandle(state, yOffset)
  2009. {
  2010. return createHandle(state, [mxConstants.STYLE_ARCSIZE], function(bounds)
  2011. {
  2012. var arcSize = Math.max(0, parseFloat(mxUtils.getValue(state.style,
  2013. mxConstants.STYLE_ARCSIZE, mxConstants.RECTANGLE_ROUNDING_FACTOR * 100))) / 100;
  2014. var tmp = (yOffset != null) ? yOffset : bounds.height / 8;
  2015. return new mxPoint(bounds.x + bounds.width - Math.min(Math.max(bounds.width / 2, bounds.height / 2),
  2016. Math.min(bounds.width, bounds.height) * arcSize), bounds.y + tmp);
  2017. }, function(bounds, pt, me)
  2018. {
  2019. var f = Math.min(50, Math.max(0, (bounds.width - pt.x + bounds.x) * 100 /
  2020. Math.min(bounds.width, bounds.height)));
  2021. this.state.style[mxConstants.STYLE_ARCSIZE] = Math.round(f);
  2022. });
  2023. }
  2024. function createArcHandleFunction()
  2025. {
  2026. return function(state)
  2027. {
  2028. var handles = [];
  2029. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2030. {
  2031. handles.push(createArcHandle(state));
  2032. }
  2033. return handles;
  2034. };
  2035. };
  2036. function createTrapezoidHandleFunction(max)
  2037. {
  2038. return function(state)
  2039. {
  2040. var handles = [createHandle(state, ['size'], function(bounds)
  2041. {
  2042. var size = Math.max(0, Math.min(max, parseFloat(mxUtils.getValue(this.state.style, 'size', TrapezoidShape.prototype.size))));
  2043. return new mxPoint(bounds.x + size * bounds.width * 0.75, bounds.y + bounds.height / 4);
  2044. }, function(bounds, pt)
  2045. {
  2046. this.state.style['size'] = Math.max(0, Math.min(max, (pt.x - bounds.x) / (bounds.width * 0.75)));
  2047. })];
  2048. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2049. {
  2050. handles.push(createArcHandle(state));
  2051. }
  2052. return handles;
  2053. };
  2054. };
  2055. function createDisplayHandleFunction(defaultValue, allowArcHandle, max)
  2056. {
  2057. max = (max != null) ? max : 1;
  2058. return function(state)
  2059. {
  2060. var handles = [createHandle(state, ['size'], function(bounds)
  2061. {
  2062. var size = parseFloat(mxUtils.getValue(this.state.style, 'size', defaultValue));
  2063. return new mxPoint(bounds.x + size * bounds.width, bounds.getCenterY());
  2064. }, function(bounds, pt)
  2065. {
  2066. this.state.style['size'] = Math.max(0, Math.min(max, (pt.x - bounds.x) / bounds.width));
  2067. })];
  2068. if (allowArcHandle && mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2069. {
  2070. handles.push(createArcHandle(state));
  2071. }
  2072. return handles;
  2073. };
  2074. };
  2075. function createCubeHandleFunction(factor, defaultValue, allowArcHandle)
  2076. {
  2077. return function(state)
  2078. {
  2079. var handles = [createHandle(state, ['size'], function(bounds)
  2080. {
  2081. var size = Math.max(0, Math.min(bounds.width, Math.min(bounds.height, parseFloat(
  2082. mxUtils.getValue(this.state.style, 'size', defaultValue))))) * factor;
  2083. return new mxPoint(bounds.x + size, bounds.y + size);
  2084. }, function(bounds, pt)
  2085. {
  2086. this.state.style['size'] = Math.round(Math.max(0, Math.min(Math.min(bounds.width, pt.x - bounds.x),
  2087. Math.min(bounds.height, pt.y - bounds.y))) / factor);
  2088. })];
  2089. if (allowArcHandle && mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2090. {
  2091. handles.push(createArcHandle(state));
  2092. }
  2093. return handles;
  2094. };
  2095. };
  2096. function createArrowHandleFunction(maxSize)
  2097. {
  2098. return function(state)
  2099. {
  2100. return [createHandle(state, ['arrowWidth', 'arrowSize'], function(bounds)
  2101. {
  2102. var aw = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'arrowWidth', SingleArrowShape.prototype.arrowWidth)));
  2103. var as = Math.max(0, Math.min(maxSize, mxUtils.getValue(this.state.style, 'arrowSize', SingleArrowShape.prototype.arrowSize)));
  2104. return new mxPoint(bounds.x + (1 - as) * bounds.width, bounds.y + (1 - aw) * bounds.height / 2);
  2105. }, function(bounds, pt)
  2106. {
  2107. this.state.style['arrowWidth'] = Math.max(0, Math.min(1, Math.abs(bounds.y + bounds.height / 2 - pt.y) / bounds.height * 2));
  2108. this.state.style['arrowSize'] = Math.max(0, Math.min(maxSize, (bounds.x + bounds.width - pt.x) / (bounds.width)));
  2109. })];
  2110. };
  2111. };
  2112. function createEdgeHandle(state, keys, start, getPosition, setPosition)
  2113. {
  2114. var pts = state.absolutePoints;
  2115. var n = pts.length - 1;
  2116. var tr = state.view.translate;
  2117. var s = state.view.scale;
  2118. var p0 = (start) ? pts[0] : pts[n];
  2119. var p1 = (start) ? pts[1] : pts[n - 1];
  2120. var dx = (start) ? p1.x - p0.x : p1.x - p0.x;
  2121. var dy = (start) ? p1.y - p0.y : p1.y - p0.y;
  2122. var dist = Math.sqrt(dx * dx + dy * dy);
  2123. return createHandle(state, keys, function(bounds)
  2124. {
  2125. var pt = getPosition.call(this, dist, dx / dist, dy / dist, p0, p1);
  2126. return new mxPoint(pt.x / s - tr.x, pt.y / s - tr.y);
  2127. }, function(bounds, pt, me)
  2128. {
  2129. var dist = Math.sqrt(dx * dx + dy * dy);
  2130. pt.x = (pt.x + tr.x) * s;
  2131. pt.y = (pt.y + tr.y) * s;
  2132. setPosition.call(this, dist, dx / dist, dy / dist, p0, p1, pt, me);
  2133. });
  2134. };
  2135. function createEdgeWidthHandle(state, start, spacing)
  2136. {
  2137. return createEdgeHandle(state, ['width'], start, function(dist, nx, ny, p0, p1)
  2138. {
  2139. var w = state.shape.getEdgeWidth() * state.view.scale + spacing;
  2140. return new mxPoint(p0.x + nx * dist / 4 + ny * w / 2, p0.y + ny * dist / 4 - nx * w / 2);
  2141. }, function(dist, nx, ny, p0, p1, pt)
  2142. {
  2143. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  2144. state.style['width'] = Math.round(w * 2) / state.view.scale - spacing;
  2145. });
  2146. };
  2147. function ptLineDistance(x1, y1, x2, y2, x0, y0)
  2148. {
  2149. return Math.abs((y2 - y1) * x0 - (x2 - x1) * y0 + x2 * y1 - y2 * x1) / Math.sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
  2150. }
  2151. var handleFactory = {
  2152. 'link': function(state)
  2153. {
  2154. var spacing = 10;
  2155. return [createEdgeWidthHandle(state, true, spacing), createEdgeWidthHandle(state, false, spacing)];
  2156. },
  2157. 'flexArrow': function(state)
  2158. {
  2159. // Do not use state.shape.startSize/endSize since it is cached
  2160. var tol = state.view.graph.gridSize / state.view.scale;
  2161. var handles = [];
  2162. if (mxUtils.getValue(state.style, mxConstants.STYLE_STARTARROW, mxConstants.NONE) != mxConstants.NONE)
  2163. {
  2164. handles.push(createEdgeHandle(state, ['width', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], true, function(dist, nx, ny, p0, p1)
  2165. {
  2166. var w = (state.shape.getEdgeWidth() - state.shape.strokewidth) * state.view.scale;
  2167. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  2168. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) + ny * w / 2,
  2169. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) - nx * w / 2);
  2170. }, function(dist, nx, ny, p0, p1, pt, me)
  2171. {
  2172. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  2173. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  2174. state.style[mxConstants.STYLE_STARTSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  2175. state.style['width'] = Math.round(w * 2) / state.view.scale;
  2176. // Applies to opposite side
  2177. if (mxEvent.isControlDown(me.getEvent()))
  2178. {
  2179. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  2180. }
  2181. // Snaps to end geometry
  2182. if (!mxEvent.isAltDown(me.getEvent()))
  2183. {
  2184. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_STARTSIZE]) - parseFloat(state.style[mxConstants.STYLE_ENDSIZE])) < tol / 6)
  2185. {
  2186. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  2187. }
  2188. }
  2189. }));
  2190. handles.push(createEdgeHandle(state, ['startWidth', 'endWidth', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], true, function(dist, nx, ny, p0, p1)
  2191. {
  2192. var w = (state.shape.getStartArrowWidth() - state.shape.strokewidth) * state.view.scale;
  2193. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  2194. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) + ny * w / 2,
  2195. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) - nx * w / 2);
  2196. }, function(dist, nx, ny, p0, p1, pt, me)
  2197. {
  2198. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  2199. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  2200. state.style[mxConstants.STYLE_STARTSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  2201. state.style['startWidth'] = Math.max(0, Math.round(w * 2) - state.shape.getEdgeWidth()) / state.view.scale;
  2202. // Applies to opposite side
  2203. if (mxEvent.isControlDown(me.getEvent()))
  2204. {
  2205. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  2206. state.style['endWidth'] = state.style['startWidth'];
  2207. }
  2208. // Snaps to endWidth
  2209. if (!mxEvent.isAltDown(me.getEvent()))
  2210. {
  2211. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_STARTSIZE]) - parseFloat(state.style[mxConstants.STYLE_ENDSIZE])) < tol / 6)
  2212. {
  2213. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  2214. }
  2215. if (Math.abs(parseFloat(state.style['startWidth']) - parseFloat(state.style['endWidth'])) < tol)
  2216. {
  2217. state.style['startWidth'] = state.style['endWidth'];
  2218. }
  2219. }
  2220. }));
  2221. }
  2222. if (mxUtils.getValue(state.style, mxConstants.STYLE_ENDARROW, mxConstants.NONE) != mxConstants.NONE)
  2223. {
  2224. handles.push(createEdgeHandle(state, ['width', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], false, function(dist, nx, ny, p0, p1)
  2225. {
  2226. var w = (state.shape.getEdgeWidth() - state.shape.strokewidth) * state.view.scale;
  2227. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_ENDSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  2228. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) - ny * w / 2,
  2229. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) + nx * w / 2);
  2230. }, function(dist, nx, ny, p0, p1, pt, me)
  2231. {
  2232. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  2233. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  2234. state.style[mxConstants.STYLE_ENDSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  2235. state.style['width'] = Math.round(w * 2) / state.view.scale;
  2236. // Applies to opposite side
  2237. if (mxEvent.isControlDown(me.getEvent()))
  2238. {
  2239. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  2240. }
  2241. // Snaps to start geometry
  2242. if (!mxEvent.isAltDown(me.getEvent()))
  2243. {
  2244. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_ENDSIZE]) - parseFloat(state.style[mxConstants.STYLE_STARTSIZE])) < tol / 6)
  2245. {
  2246. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  2247. }
  2248. }
  2249. }));
  2250. handles.push(createEdgeHandle(state, ['startWidth', 'endWidth', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], false, function(dist, nx, ny, p0, p1)
  2251. {
  2252. var w = (state.shape.getEndArrowWidth() - state.shape.strokewidth) * state.view.scale;
  2253. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_ENDSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  2254. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) - ny * w / 2,
  2255. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) + nx * w / 2);
  2256. }, function(dist, nx, ny, p0, p1, pt, me)
  2257. {
  2258. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  2259. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  2260. state.style[mxConstants.STYLE_ENDSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  2261. state.style['endWidth'] = Math.max(0, Math.round(w * 2) - state.shape.getEdgeWidth()) / state.view.scale;
  2262. // Applies to opposite side
  2263. if (mxEvent.isControlDown(me.getEvent()))
  2264. {
  2265. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  2266. state.style['startWidth'] = state.style['endWidth'];
  2267. }
  2268. // Snaps to start geometry
  2269. if (!mxEvent.isAltDown(me.getEvent()))
  2270. {
  2271. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_ENDSIZE]) - parseFloat(state.style[mxConstants.STYLE_STARTSIZE])) < tol / 6)
  2272. {
  2273. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  2274. }
  2275. if (Math.abs(parseFloat(state.style['endWidth']) - parseFloat(state.style['startWidth'])) < tol)
  2276. {
  2277. state.style['endWidth'] = state.style['startWidth'];
  2278. }
  2279. }
  2280. }));
  2281. }
  2282. return handles;
  2283. },
  2284. 'swimlane': function(state)
  2285. {
  2286. var handles = [createHandle(state, [mxConstants.STYLE_STARTSIZE], function(bounds)
  2287. {
  2288. var size = parseFloat(mxUtils.getValue(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_STARTSIZE));
  2289. if (mxUtils.getValue(state.style, mxConstants.STYLE_HORIZONTAL, 1) == 1)
  2290. {
  2291. return new mxPoint(bounds.getCenterX(), bounds.y + Math.max(0, Math.min(bounds.height, size)));
  2292. }
  2293. else
  2294. {
  2295. return new mxPoint(bounds.x + Math.max(0, Math.min(bounds.width, size)), bounds.getCenterY());
  2296. }
  2297. }, function(bounds, pt)
  2298. {
  2299. state.style[mxConstants.STYLE_STARTSIZE] =
  2300. (mxUtils.getValue(this.state.style, mxConstants.STYLE_HORIZONTAL, 1) == 1) ?
  2301. Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y))) :
  2302. Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x)));
  2303. })];
  2304. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED))
  2305. {
  2306. var size = parseFloat(mxUtils.getValue(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_STARTSIZE));
  2307. handles.push(createArcHandle(state, size / 2));
  2308. }
  2309. return handles;
  2310. },
  2311. 'label': createArcHandleFunction(),
  2312. 'ext': createArcHandleFunction(),
  2313. 'rectangle': createArcHandleFunction(),
  2314. 'triangle': createArcHandleFunction(),
  2315. 'rhombus': createArcHandleFunction(),
  2316. 'umlLifeline': function(state)
  2317. {
  2318. return [createHandle(state, ['size'], function(bounds)
  2319. {
  2320. var size = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'size', UmlLifeline.prototype.size))));
  2321. return new mxPoint(bounds.getCenterX(), bounds.y + size);
  2322. }, function(bounds, pt)
  2323. {
  2324. this.state.style['size'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  2325. }, false)];
  2326. },
  2327. 'umlFrame': function(state)
  2328. {
  2329. var handles = [createHandle(state, ['width', 'height'], function(bounds)
  2330. {
  2331. var w0 = Math.max(UmlFrame.prototype.corner, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'width', UmlFrame.prototype.width)));
  2332. var h0 = Math.max(UmlFrame.prototype.corner * 1.5, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'height', UmlFrame.prototype.height)));
  2333. return new mxPoint(bounds.x + w0, bounds.y + h0);
  2334. }, function(bounds, pt)
  2335. {
  2336. this.state.style['width'] = Math.round(Math.max(UmlFrame.prototype.corner, Math.min(bounds.width, pt.x - bounds.x)));
  2337. this.state.style['height'] = Math.round(Math.max(UmlFrame.prototype.corner * 1.5, Math.min(bounds.height, pt.y - bounds.y)));
  2338. }, false)];
  2339. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2340. {
  2341. handles.push(createArcHandle(state));
  2342. }
  2343. return handles;
  2344. },
  2345. 'process': function(state)
  2346. {
  2347. var handles = [createHandle(state, ['size'], function(bounds)
  2348. {
  2349. var size = Math.max(0, Math.min(0.5, parseFloat(mxUtils.getValue(this.state.style, 'size', ProcessShape.prototype.size))));
  2350. return new mxPoint(bounds.x + bounds.width * size, bounds.y + bounds.height / 4);
  2351. }, function(bounds, pt)
  2352. {
  2353. this.state.style['size'] = Math.max(0, Math.min(0.5, (pt.x - bounds.x) / bounds.width));
  2354. })];
  2355. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2356. {
  2357. handles.push(createArcHandle(state));
  2358. }
  2359. return handles;
  2360. },
  2361. 'cross': function(state)
  2362. {
  2363. return [createHandle(state, ['size'], function(bounds)
  2364. {
  2365. var m = Math.min(bounds.width, bounds.height);
  2366. var size = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'size', CrossShape.prototype.size))) * m / 2;
  2367. return new mxPoint(bounds.getCenterX() - size, bounds.getCenterY() - size);
  2368. }, function(bounds, pt)
  2369. {
  2370. var m = Math.min(bounds.width, bounds.height);
  2371. this.state.style['size'] = Math.max(0, Math.min(1, Math.min((Math.max(0, bounds.getCenterY() - pt.y) / m) * 2,
  2372. (Math.max(0, bounds.getCenterX() - pt.x) / m) * 2)));
  2373. })];
  2374. },
  2375. 'note': function(state)
  2376. {
  2377. return [createHandle(state, ['size'], function(bounds)
  2378. {
  2379. var size = Math.max(0, Math.min(bounds.width, Math.min(bounds.height, parseFloat(
  2380. mxUtils.getValue(this.state.style, 'size', NoteShape.prototype.size)))));
  2381. return new mxPoint(bounds.x + bounds.width - size, bounds.y + size);
  2382. }, function(bounds, pt)
  2383. {
  2384. this.state.style['size'] = Math.round(Math.max(0, Math.min(Math.min(bounds.width, bounds.x + bounds.width - pt.x),
  2385. Math.min(bounds.height, pt.y - bounds.y))));
  2386. })];
  2387. },
  2388. 'manualInput': function(state)
  2389. {
  2390. var handles = [createHandle(state, ['size'], function(bounds)
  2391. {
  2392. var size = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'size', ManualInputShape.prototype.size)));
  2393. return new mxPoint(bounds.x + bounds.width / 4, bounds.y + size * 3 / 4);
  2394. }, function(bounds, pt)
  2395. {
  2396. this.state.style['size'] = Math.round(Math.max(0, Math.min(bounds.height, (pt.y - bounds.y) * 4 / 3)));
  2397. })];
  2398. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2399. {
  2400. handles.push(createArcHandle(state));
  2401. }
  2402. return handles;
  2403. },
  2404. 'dataStorage': function(state)
  2405. {
  2406. return [createHandle(state, ['size'], function(bounds)
  2407. {
  2408. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', DataStorageShape.prototype.size))));
  2409. return new mxPoint(bounds.x + (1 - size) * bounds.width, bounds.getCenterY());
  2410. }, function(bounds, pt)
  2411. {
  2412. this.state.style['size'] = Math.max(0, Math.min(1, (bounds.x + bounds.width - pt.x) / bounds.width));
  2413. })];
  2414. },
  2415. 'internalStorage': function(state)
  2416. {
  2417. var handles = [createHandle(state, ['dx', 'dy'], function(bounds)
  2418. {
  2419. var dx = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'dx', InternalStorageShape.prototype.dx)));
  2420. var dy = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'dy', InternalStorageShape.prototype.dy)));
  2421. return new mxPoint(bounds.x + dx, bounds.y + dy);
  2422. }, function(bounds, pt)
  2423. {
  2424. this.state.style['dx'] = Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x)));
  2425. this.state.style['dy'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  2426. })];
  2427. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2428. {
  2429. handles.push(createArcHandle(state));
  2430. }
  2431. return handles;
  2432. },
  2433. 'corner': function(state)
  2434. {
  2435. return [createHandle(state, ['dx', 'dy'], function(bounds)
  2436. {
  2437. var dx = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'dx', CornerShape.prototype.dx)));
  2438. var dy = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'dy', CornerShape.prototype.dy)));
  2439. return new mxPoint(bounds.x + dx, bounds.y + dy);
  2440. }, function(bounds, pt)
  2441. {
  2442. this.state.style['dx'] = Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x)));
  2443. this.state.style['dy'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  2444. })];
  2445. },
  2446. 'tee': function(state)
  2447. {
  2448. return [createHandle(state, ['dx', 'dy'], function(bounds)
  2449. {
  2450. var dx = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'dx', TeeShape.prototype.dx)));
  2451. var dy = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'dy', TeeShape.prototype.dy)));
  2452. return new mxPoint(bounds.x + (bounds.width + dx) / 2, bounds.y + dy);
  2453. }, function(bounds, pt)
  2454. {
  2455. this.state.style['dx'] = Math.round(Math.max(0, Math.min(bounds.width / 2, (pt.x - bounds.x - bounds.width / 2)) * 2));
  2456. this.state.style['dy'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  2457. })];
  2458. },
  2459. 'singleArrow': createArrowHandleFunction(1),
  2460. 'doubleArrow': createArrowHandleFunction(0.5),
  2461. 'folder': function(state)
  2462. {
  2463. return [createHandle(state, ['tabWidth', 'tabHeight'], function(bounds)
  2464. {
  2465. var tw = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'tabWidth', FolderShape.prototype.tabWidth)));
  2466. var th = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'tabHeight', FolderShape.prototype.tabHeight)));
  2467. if (mxUtils.getValue(this.state.style, 'tabPosition', FolderShape.prototype.tabPosition) == mxConstants.ALIGN_RIGHT)
  2468. {
  2469. tw = bounds.width - tw;
  2470. }
  2471. return new mxPoint(bounds.x + tw, bounds.y + th);
  2472. }, function(bounds, pt)
  2473. {
  2474. var tw = Math.max(0, Math.min(bounds.width, pt.x - bounds.x));
  2475. if (mxUtils.getValue(this.state.style, 'tabPosition', FolderShape.prototype.tabPosition) == mxConstants.ALIGN_RIGHT)
  2476. {
  2477. tw = bounds.width - tw;
  2478. }
  2479. this.state.style['tabWidth'] = Math.round(tw);
  2480. this.state.style['tabHeight'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  2481. })];
  2482. },
  2483. 'document': function(state)
  2484. {
  2485. return [createHandle(state, ['size'], function(bounds)
  2486. {
  2487. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', DocumentShape.prototype.size))));
  2488. return new mxPoint(bounds.x + 3 * bounds.width / 4, bounds.y + (1 - size) * bounds.height);
  2489. }, function(bounds, pt)
  2490. {
  2491. this.state.style['size'] = Math.max(0, Math.min(1, (bounds.y + bounds.height - pt.y) / bounds.height));
  2492. })];
  2493. },
  2494. 'tape': function(state)
  2495. {
  2496. return [createHandle(state, ['size'], function(bounds)
  2497. {
  2498. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', TapeShape.prototype.size))));
  2499. return new mxPoint(bounds.getCenterX(), bounds.y + size * bounds.height / 2);
  2500. }, function(bounds, pt)
  2501. {
  2502. this.state.style['size'] = Math.max(0, Math.min(1, ((pt.y - bounds.y) / bounds.height) * 2));
  2503. })];
  2504. },
  2505. 'offPageConnector': function(state)
  2506. {
  2507. return [createHandle(state, ['size'], function(bounds)
  2508. {
  2509. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', OffPageConnectorShape.prototype.size))));
  2510. return new mxPoint(bounds.getCenterX(), bounds.y + (1 - size) * bounds.height);
  2511. }, function(bounds, pt)
  2512. {
  2513. this.state.style['size'] = Math.max(0, Math.min(1, (bounds.y + bounds.height - pt.y) / bounds.height));
  2514. })];
  2515. },
  2516. 'step': createDisplayHandleFunction(StepShape.prototype.size, true),
  2517. 'hexagon': createDisplayHandleFunction(HexagonShape.prototype.size, true, 0.5),
  2518. 'curlyBracket': createDisplayHandleFunction(CurlyBracketShape.prototype.size, false),
  2519. 'display': createDisplayHandleFunction(DisplayShape.prototype.size, false),
  2520. 'cube': createCubeHandleFunction(1, CubeShape.prototype.size, false),
  2521. 'card': createCubeHandleFunction(0.5, CardShape.prototype.size, true),
  2522. 'loopLimit': createCubeHandleFunction(0.5, LoopLimitShape.prototype.size, true),
  2523. 'trapezoid': createTrapezoidHandleFunction(0.5),
  2524. 'parallelogram': createTrapezoidHandleFunction(1)
  2525. };
  2526. // Exposes custom handles
  2527. Graph.createHandle = createHandle;
  2528. Graph.handleFactory = handleFactory;
  2529. mxVertexHandler.prototype.createCustomHandles = function()
  2530. {
  2531. // Not rotatable means locked
  2532. if (this.state.view.graph.getSelectionCount() == 1)
  2533. {
  2534. if (this.graph.isCellRotatable(this.state.cell))
  2535. // LATER: Make locked state independent of rotatable flag, fix toggle if default is false
  2536. //if (this.graph.isCellResizable(this.state.cell) || this.graph.isCellMovable(this.state.cell))
  2537. {
  2538. var name = this.state.style['shape'];
  2539. if (this.state.view.graph.cellRenderer.defaultShapes[name] == null &&
  2540. mxStencilRegistry.getStencil(name) == null)
  2541. {
  2542. name = mxConstants.SHAPE_RECTANGLE;
  2543. }
  2544. var fn = handleFactory[name];
  2545. if (fn != null)
  2546. {
  2547. return fn(this.state);
  2548. }
  2549. }
  2550. }
  2551. return null;
  2552. };
  2553. mxEdgeHandler.prototype.createCustomHandles = function()
  2554. {
  2555. if (this.state.view.graph.getSelectionCount() == 1)
  2556. {
  2557. var name = this.state.style['shape'];
  2558. if (this.state.view.graph.cellRenderer.defaultShapes[name] == null &&
  2559. mxStencilRegistry.getStencil(name) == null)
  2560. {
  2561. name = mxConstants.SHAPE_CONNECTOR;
  2562. }
  2563. var fn = handleFactory[name];
  2564. if (fn != null)
  2565. {
  2566. return fn(this.state);
  2567. }
  2568. }
  2569. return null;
  2570. }
  2571. }
  2572. else
  2573. {
  2574. // Dummy entries to avoid NPE in embed mode
  2575. Graph.createHandle = function() {};
  2576. Graph.handleFactory = {};
  2577. }
  2578. var isoHVector = new mxPoint(1, 0);
  2579. var isoVVector = new mxPoint(1, 0);
  2580. var alpha1 = mxUtils.toRadians(-30);
  2581. var cos1 = Math.cos(alpha1);
  2582. var sin1 = Math.sin(alpha1);
  2583. isoHVector = mxUtils.getRotatedPoint(isoHVector, cos1, sin1);
  2584. var alpha2 = mxUtils.toRadians(-150);
  2585. var cos2 = Math.cos(alpha2);
  2586. var sin2 = Math.sin(alpha2);
  2587. isoVVector = mxUtils.getRotatedPoint(isoVVector, cos2, sin2);
  2588. mxEdgeStyle.IsometricConnector = function (state, source, target, points, result)
  2589. {
  2590. var view = state.view;
  2591. var pt = (points != null && points.length > 0) ? points[0] : null;
  2592. var pts = state.absolutePoints;
  2593. var p0 = pts[0];
  2594. var pe = pts[pts.length-1];
  2595. if (pt != null)
  2596. {
  2597. pt = view.transformControlPoint(state, pt);
  2598. }
  2599. if (p0 == null)
  2600. {
  2601. if (source != null)
  2602. {
  2603. p0 = new mxPoint(source.getCenterX(), source.getCenterY());
  2604. }
  2605. }
  2606. if (pe == null)
  2607. {
  2608. if (target != null)
  2609. {
  2610. pe = new mxPoint(target.getCenterX(), target.getCenterY());
  2611. }
  2612. }
  2613. var a1 = isoHVector.x;
  2614. var a2 = isoHVector.y;
  2615. var b1 = isoVVector.x;
  2616. var b2 = isoVVector.y;
  2617. var elbow = mxUtils.getValue(state.style, 'elbow', 'horizontal') == 'horizontal';
  2618. if (pe != null && p0 != null)
  2619. {
  2620. var last = p0;
  2621. function isoLineTo(x, y, ignoreFirst)
  2622. {
  2623. var c1 = x - last.x;
  2624. var c2 = y - last.y;
  2625. // Solves for isometric base vectors
  2626. var h = (b2 * c1 - b1 * c2) / (a1 * b2 - a2 * b1);
  2627. var v = (a2 * c1 - a1 * c2) / (a2 * b1 - a1 * b2);
  2628. if (elbow)
  2629. {
  2630. if (ignoreFirst)
  2631. {
  2632. last = new mxPoint(last.x + a1 * h, last.y + a2 * h);
  2633. result.push(last);
  2634. }
  2635. last = new mxPoint(last.x + b1 * v, last.y + b2 * v);
  2636. result.push(last);
  2637. }
  2638. else
  2639. {
  2640. if (ignoreFirst)
  2641. {
  2642. last = new mxPoint(last.x + b1 * v, last.y + b2 * v);
  2643. result.push(last);
  2644. }
  2645. last = new mxPoint(last.x + a1 * h, last.y + a2 * h);
  2646. result.push(last);
  2647. }
  2648. };
  2649. if (pt == null)
  2650. {
  2651. pt = new mxPoint(p0.x + (pe.x - p0.x) / 2, p0.y + (pe.y - p0.y) / 2);
  2652. }
  2653. isoLineTo(pt.x, pt.y, true);
  2654. isoLineTo(pe.x, pe.y, false);
  2655. }
  2656. };
  2657. mxStyleRegistry.putValue('isometricEdgeStyle', mxEdgeStyle.IsometricConnector);
  2658. var graphCreateEdgeHandler = Graph.prototype.createEdgeHandler;
  2659. Graph.prototype.createEdgeHandler = function(state, edgeStyle)
  2660. {
  2661. if (edgeStyle == mxEdgeStyle.IsometricConnector)
  2662. {
  2663. var handler = new mxElbowEdgeHandler(state);
  2664. handler.snapToTerminals = false;
  2665. return handler;
  2666. }
  2667. return graphCreateEdgeHandler.apply(this, arguments);
  2668. };
  2669. // Defines connection points for all shapes
  2670. IsoRectangleShape.prototype.constraints = [];
  2671. IsoCubeShape.prototype.constraints = [];
  2672. mxRectangleShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  2673. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2674. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  2675. new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  2676. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  2677. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  2678. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  2679. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  2680. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  2681. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  2682. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2683. new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
  2684. mxEllipse.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0), true), new mxConnectionConstraint(new mxPoint(1, 0), true),
  2685. new mxConnectionConstraint(new mxPoint(0, 1), true), new mxConnectionConstraint(new mxPoint(1, 1), true),
  2686. new mxConnectionConstraint(new mxPoint(0.5, 0), true), new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2687. new mxConnectionConstraint(new mxPoint(0, 0.5), true), new mxConnectionConstraint(new mxPoint(1, 0.5))];
  2688. mxLabel.prototype.constraints = mxRectangleShape.prototype.constraints;
  2689. mxImageShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2690. mxSwimlane.prototype.constraints = mxRectangleShape.prototype.constraints;
  2691. PlusShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2692. NoteShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2693. CardShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2694. CubeShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2695. FolderShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2696. InternalStorageShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2697. DataStorageShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2698. TapeDataShape.prototype.constraints = mxEllipse.prototype.constraints;
  2699. OrEllipseShape.prototype.constraints = mxEllipse.prototype.constraints;
  2700. SumEllipseShape.prototype.constraints = mxEllipse.prototype.constraints;
  2701. LineEllipseShape.prototype.constraints = mxEllipse.prototype.constraints;
  2702. ManualInputShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2703. DelayShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2704. DisplayShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2705. LoopLimitShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2706. OffPageConnectorShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2707. mxCylinder.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.15, 0.05), false),
  2708. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2709. new mxConnectionConstraint(new mxPoint(0.85, 0.05), false),
  2710. new mxConnectionConstraint(new mxPoint(0, 0.3), true),
  2711. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  2712. new mxConnectionConstraint(new mxPoint(0, 0.7), true),
  2713. new mxConnectionConstraint(new mxPoint(1, 0.3), true),
  2714. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  2715. new mxConnectionConstraint(new mxPoint(1, 0.7), true),
  2716. new mxConnectionConstraint(new mxPoint(0.15, 0.95), false),
  2717. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2718. new mxConnectionConstraint(new mxPoint(0.85, 0.95), false)];
  2719. UmlActorShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0.1), false),
  2720. new mxConnectionConstraint(new mxPoint(0.5, 0), false),
  2721. new mxConnectionConstraint(new mxPoint(0.75, 0.1), false),
  2722. new mxConnectionConstraint(new mxPoint(0, 1/3), false),
  2723. new mxConnectionConstraint(new mxPoint(0, 1), false),
  2724. new mxConnectionConstraint(new mxPoint(1, 1/3), false),
  2725. new mxConnectionConstraint(new mxPoint(1, 1), false),
  2726. new mxConnectionConstraint(new mxPoint(0.5, 0.5), false)];
  2727. ComponentShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  2728. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2729. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  2730. new mxConnectionConstraint(new mxPoint(0, 0.3), true),
  2731. new mxConnectionConstraint(new mxPoint(0, 0.7), true),
  2732. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  2733. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  2734. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  2735. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  2736. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2737. new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
  2738. mxActor.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2739. new mxConnectionConstraint(new mxPoint(0.25, 0.2), false),
  2740. new mxConnectionConstraint(new mxPoint(0.1, 0.5), false),
  2741. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  2742. new mxConnectionConstraint(new mxPoint(0.75, 0.25), false),
  2743. new mxConnectionConstraint(new mxPoint(0.9, 0.5), false),
  2744. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  2745. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  2746. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2747. new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
  2748. SwitchShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0), false),
  2749. new mxConnectionConstraint(new mxPoint(0.5, 0.25), false),
  2750. new mxConnectionConstraint(new mxPoint(1, 0), false),
  2751. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  2752. new mxConnectionConstraint(new mxPoint(0.75, 0.5), false),
  2753. new mxConnectionConstraint(new mxPoint(0, 1), false),
  2754. new mxConnectionConstraint(new mxPoint(0.5, 0.75), false),
  2755. new mxConnectionConstraint(new mxPoint(1, 1), false)];
  2756. TapeShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.35), false),
  2757. new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  2758. new mxConnectionConstraint(new mxPoint(0, 0.65), false),
  2759. new mxConnectionConstraint(new mxPoint(1, 0.35), false),
  2760. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  2761. new mxConnectionConstraint(new mxPoint(1, 0.65), false),
  2762. new mxConnectionConstraint(new mxPoint(0.25, 1), false),
  2763. new mxConnectionConstraint(new mxPoint(0.75, 0), false)];
  2764. // TODO: Relative ports
  2765. StepShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  2766. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2767. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  2768. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  2769. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2770. new mxConnectionConstraint(new mxPoint(0.75, 1), true),
  2771. new mxConnectionConstraint(new mxPoint(0.1, 0.25), false),
  2772. new mxConnectionConstraint(new mxPoint(0.2, 0.5), false),
  2773. new mxConnectionConstraint(new mxPoint(0.1, 0.75), false),
  2774. new mxConnectionConstraint(new mxPoint(0.9, 0.25), false),
  2775. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  2776. new mxConnectionConstraint(new mxPoint(0.9, 0.75), false)];
  2777. mxLine.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  2778. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  2779. new mxConnectionConstraint(new mxPoint(0.75, 0.5), false),
  2780. new mxConnectionConstraint(new mxPoint(1, 0.5), false)];
  2781. LollipopShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.5, 0), false),
  2782. new mxConnectionConstraint(new mxPoint(0.5, 1), false)];
  2783. mxDoubleEllipse.prototype.constraints = mxEllipse.prototype.constraints;
  2784. mxRhombus.prototype.constraints = mxEllipse.prototype.constraints;
  2785. mxTriangle.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  2786. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  2787. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  2788. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2789. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2790. new mxConnectionConstraint(new mxPoint(1, 0.5), true)];
  2791. mxHexagon.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.375, 0), true),
  2792. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2793. new mxConnectionConstraint(new mxPoint(0.625, 0), true),
  2794. new mxConnectionConstraint(new mxPoint(0.125, 0.25), false),
  2795. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  2796. new mxConnectionConstraint(new mxPoint(0.125, 0.75), false),
  2797. new mxConnectionConstraint(new mxPoint(0.875, 0.25), false),
  2798. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  2799. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  2800. new mxConnectionConstraint(new mxPoint(0.875, 0.75), false),
  2801. new mxConnectionConstraint(new mxPoint(0.375, 1), true),
  2802. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2803. new mxConnectionConstraint(new mxPoint(0.625, 1), true)];
  2804. mxCloud.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0.25), false),
  2805. new mxConnectionConstraint(new mxPoint(0.4, 0.1), false),
  2806. new mxConnectionConstraint(new mxPoint(0.16, 0.55), false),
  2807. new mxConnectionConstraint(new mxPoint(0.07, 0.4), false),
  2808. new mxConnectionConstraint(new mxPoint(0.31, 0.8), false),
  2809. new mxConnectionConstraint(new mxPoint(0.13, 0.77), false),
  2810. new mxConnectionConstraint(new mxPoint(0.8, 0.8), false),
  2811. new mxConnectionConstraint(new mxPoint(0.55, 0.95), false),
  2812. new mxConnectionConstraint(new mxPoint(0.875, 0.5), false),
  2813. new mxConnectionConstraint(new mxPoint(0.96, 0.7), false),
  2814. new mxConnectionConstraint(new mxPoint(0.625, 0.2), false),
  2815. new mxConnectionConstraint(new mxPoint(0.88, 0.25), false)];
  2816. ParallelogramShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2817. TrapezoidShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2818. DocumentShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  2819. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2820. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  2821. new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  2822. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  2823. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  2824. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  2825. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  2826. new mxConnectionConstraint(new mxPoint(1, 0.75), true)];
  2827. mxArrow.prototype.constraints = null;
  2828. TeeShape.prototype.constraints = null;
  2829. CornerShape.prototype.constraints = null;
  2830. CrossbarShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0), false),
  2831. new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  2832. new mxConnectionConstraint(new mxPoint(0, 1), false),
  2833. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  2834. new mxConnectionConstraint(new mxPoint(0.5, 0.5), false),
  2835. new mxConnectionConstraint(new mxPoint(0.75, 0.5), false),
  2836. new mxConnectionConstraint(new mxPoint(1, 0), false),
  2837. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  2838. new mxConnectionConstraint(new mxPoint(1, 1), false)];
  2839. SingleArrowShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  2840. new mxConnectionConstraint(new mxPoint(1, 0.5), false)];
  2841. DoubleArrowShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  2842. new mxConnectionConstraint(new mxPoint(1, 0.5), false)];
  2843. CrossShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  2844. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  2845. new mxConnectionConstraint(new mxPoint(0.5, 0), false),
  2846. new mxConnectionConstraint(new mxPoint(0.5, 1), false)];
  2847. UmlLifeline.prototype.constraints = null;
  2848. OrShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.25), false),
  2849. new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  2850. new mxConnectionConstraint(new mxPoint(0, 0.75), false),
  2851. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  2852. new mxConnectionConstraint(new mxPoint(0.7, 0.1), false),
  2853. new mxConnectionConstraint(new mxPoint(0.7, 0.9), false)];
  2854. XorShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.175, 0.25), false),
  2855. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  2856. new mxConnectionConstraint(new mxPoint(0.175, 0.75), false),
  2857. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  2858. new mxConnectionConstraint(new mxPoint(0.7, 0.1), false),
  2859. new mxConnectionConstraint(new mxPoint(0.7, 0.9), false)];
  2860. })();