Shapes.js 102 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277
  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. // Internal storage
  1380. function TeeShape()
  1381. {
  1382. mxActor.call(this);
  1383. };
  1384. mxUtils.extend(TeeShape, mxActor);
  1385. TeeShape.prototype.dx = 20;
  1386. TeeShape.prototype.dy = 20;
  1387. // Corner
  1388. TeeShape.prototype.redrawPath = function(c, x, y, w, h)
  1389. {
  1390. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1391. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  1392. var w2 = Math.abs(w - dx) / 2;
  1393. var s = Math.min(w / 2, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1394. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1395. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w, 0), new mxPoint(w, dy), new mxPoint((w + dx) / 2, dy),
  1396. new mxPoint((w + dx) / 2, h), new mxPoint((w - dx) / 2, h), new mxPoint((w - dx) / 2, dy),
  1397. new mxPoint(0, dy)], this.isRounded, arcSize, true);
  1398. c.end();
  1399. };
  1400. mxCellRenderer.prototype.defaultShapes['tee'] = TeeShape;
  1401. // Arrow
  1402. function SingleArrowShape()
  1403. {
  1404. mxActor.call(this);
  1405. };
  1406. mxUtils.extend(SingleArrowShape, mxActor);
  1407. SingleArrowShape.prototype.arrowWidth = 0.3;
  1408. SingleArrowShape.prototype.arrowSize = 0.2;
  1409. SingleArrowShape.prototype.redrawPath = function(c, x, y, w, h)
  1410. {
  1411. var aw = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowWidth', this.arrowWidth))));
  1412. var as = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowSize', this.arrowSize))));
  1413. var at = (h - aw) / 2;
  1414. var ab = at + aw;
  1415. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1416. this.addPoints(c, [new mxPoint(0, at), new mxPoint(w - as, at), new mxPoint(w - as, 0), new mxPoint(w, h / 2),
  1417. new mxPoint(w - as, h), new mxPoint(w - as, ab), new mxPoint(0, ab)],
  1418. this.isRounded, arcSize, true);
  1419. c.end();
  1420. };
  1421. mxCellRenderer.prototype.defaultShapes['singleArrow'] = SingleArrowShape;
  1422. // Arrow
  1423. function DoubleArrowShape()
  1424. {
  1425. mxActor.call(this);
  1426. };
  1427. mxUtils.extend(DoubleArrowShape, mxActor);
  1428. DoubleArrowShape.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', SingleArrowShape.prototype.arrowWidth))));
  1431. var as = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowSize', SingleArrowShape.prototype.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, h / 2), new mxPoint(as, 0), new mxPoint(as, at), new mxPoint(w - as, at),
  1436. new mxPoint(w - as, 0), new mxPoint(w, h / 2), new mxPoint(w - as, h),
  1437. new mxPoint(w - as, ab), new mxPoint(as, ab), new mxPoint(as, h)],
  1438. this.isRounded, arcSize, true);
  1439. c.end();
  1440. };
  1441. mxCellRenderer.prototype.defaultShapes['doubleArrow'] = DoubleArrowShape;
  1442. // Data storage
  1443. function DataStorageShape()
  1444. {
  1445. mxActor.call(this);
  1446. };
  1447. mxUtils.extend(DataStorageShape, mxActor);
  1448. DataStorageShape.prototype.size = 0.1;
  1449. DataStorageShape.prototype.redrawPath = function(c, x, y, w, h)
  1450. {
  1451. var s = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1452. c.moveTo(s, 0);
  1453. c.lineTo(w, 0);
  1454. c.quadTo(w - s * 2, h / 2, w, h);
  1455. c.lineTo(s, h);
  1456. c.quadTo(s - s * 2, h / 2, s, 0);
  1457. c.close();
  1458. c.end();
  1459. };
  1460. mxCellRenderer.prototype.defaultShapes['dataStorage'] = DataStorageShape;
  1461. // Or
  1462. function OrShape()
  1463. {
  1464. mxActor.call(this);
  1465. };
  1466. mxUtils.extend(OrShape, mxActor);
  1467. OrShape.prototype.redrawPath = function(c, x, y, w, h)
  1468. {
  1469. c.moveTo(0, 0);
  1470. c.quadTo(w, 0, w, h / 2);
  1471. c.quadTo(w, h, 0, h);
  1472. c.close();
  1473. c.end();
  1474. };
  1475. mxCellRenderer.prototype.defaultShapes['or'] = OrShape;
  1476. // Xor
  1477. function XorShape()
  1478. {
  1479. mxActor.call(this);
  1480. };
  1481. mxUtils.extend(XorShape, mxActor);
  1482. XorShape.prototype.redrawPath = function(c, x, y, w, h)
  1483. {
  1484. c.moveTo(0, 0);
  1485. c.quadTo(w, 0, w, h / 2);
  1486. c.quadTo(w, h, 0, h);
  1487. c.quadTo(w / 2, h / 2, 0, 0);
  1488. c.close();
  1489. c.end();
  1490. };
  1491. mxCellRenderer.prototype.defaultShapes['xor'] = XorShape;
  1492. // Loop limit
  1493. function LoopLimitShape()
  1494. {
  1495. mxActor.call(this);
  1496. };
  1497. mxUtils.extend(LoopLimitShape, mxActor);
  1498. LoopLimitShape.prototype.size = 20;
  1499. LoopLimitShape.prototype.redrawPath = function(c, x, y, w, h)
  1500. {
  1501. var s = Math.min(w / 2, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1502. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1503. this.addPoints(c, [new mxPoint(s, 0), new mxPoint(w - s, 0), new mxPoint(w, s * 0.8), new mxPoint(w, h),
  1504. new mxPoint(0, h), new mxPoint(0, s * 0.8)], this.isRounded, arcSize, true);
  1505. c.end();
  1506. };
  1507. mxCellRenderer.prototype.defaultShapes['loopLimit'] = LoopLimitShape;
  1508. // Off page connector
  1509. function OffPageConnectorShape()
  1510. {
  1511. mxActor.call(this);
  1512. };
  1513. mxUtils.extend(OffPageConnectorShape, mxActor);
  1514. OffPageConnectorShape.prototype.size = 3 / 8;
  1515. OffPageConnectorShape.prototype.redrawPath = function(c, x, y, w, h)
  1516. {
  1517. var s = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1518. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1519. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w, 0), new mxPoint(w, h - s), new mxPoint(w / 2, h),
  1520. new mxPoint(0, h - s)], this.isRounded, arcSize, true);
  1521. c.end();
  1522. };
  1523. mxCellRenderer.prototype.defaultShapes['offPageConnector'] = OffPageConnectorShape;
  1524. // Internal storage
  1525. function TapeDataShape()
  1526. {
  1527. mxEllipse.call(this);
  1528. };
  1529. mxUtils.extend(TapeDataShape, mxEllipse);
  1530. TapeDataShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1531. {
  1532. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  1533. c.begin();
  1534. c.moveTo(x + w / 2, y + h);
  1535. c.lineTo(x + w, y + h);
  1536. c.end();
  1537. c.stroke();
  1538. };
  1539. mxCellRenderer.prototype.defaultShapes['tapeData'] = TapeDataShape;
  1540. // OrEllipseShape
  1541. function OrEllipseShape()
  1542. {
  1543. mxEllipse.call(this);
  1544. };
  1545. mxUtils.extend(OrEllipseShape, mxEllipse);
  1546. OrEllipseShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1547. {
  1548. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  1549. c.setShadow(false);
  1550. c.begin();
  1551. c.moveTo(x, y + h / 2);
  1552. c.lineTo(x + w, y + h / 2);
  1553. c.end();
  1554. c.stroke();
  1555. c.begin();
  1556. c.moveTo(x + w / 2, y);
  1557. c.lineTo(x + w / 2, y + h);
  1558. c.end();
  1559. c.stroke();
  1560. };
  1561. mxCellRenderer.prototype.defaultShapes['orEllipse'] = OrEllipseShape;
  1562. // SumEllipseShape
  1563. function SumEllipseShape()
  1564. {
  1565. mxEllipse.call(this);
  1566. };
  1567. mxUtils.extend(SumEllipseShape, mxEllipse);
  1568. SumEllipseShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1569. {
  1570. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  1571. var s2 = 0.145;
  1572. c.setShadow(false);
  1573. c.begin();
  1574. c.moveTo(x + w * s2, y + h * s2);
  1575. c.lineTo(x + w * (1 - s2), y + h * (1 - s2));
  1576. c.end();
  1577. c.stroke();
  1578. c.begin();
  1579. c.moveTo(x + w * (1 - s2), y + h * s2);
  1580. c.lineTo(x + w * s2, y + h * (1 - s2));
  1581. c.end();
  1582. c.stroke();
  1583. };
  1584. mxCellRenderer.prototype.defaultShapes['sumEllipse'] = SumEllipseShape;
  1585. // SortShape
  1586. function SortShape()
  1587. {
  1588. mxRhombus.call(this);
  1589. };
  1590. mxUtils.extend(SortShape, mxRhombus);
  1591. SortShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1592. {
  1593. mxRhombus.prototype.paintVertexShape.apply(this, arguments);
  1594. c.setShadow(false);
  1595. c.begin();
  1596. c.moveTo(x, y + h / 2);
  1597. c.lineTo(x + w, y + h / 2);
  1598. c.end();
  1599. c.stroke();
  1600. };
  1601. mxCellRenderer.prototype.defaultShapes['sortShape'] = SortShape;
  1602. // CollateShape
  1603. function CollateShape()
  1604. {
  1605. mxEllipse.call(this);
  1606. };
  1607. mxUtils.extend(CollateShape, mxEllipse);
  1608. CollateShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1609. {
  1610. c.begin();
  1611. c.moveTo(x, y);
  1612. c.lineTo(x + w, y);
  1613. c.lineTo(x + w / 2, y + h / 2);
  1614. c.close();
  1615. c.fillAndStroke();
  1616. c.begin();
  1617. c.moveTo(x, y + h);
  1618. c.lineTo(x + w, y + h);
  1619. c.lineTo(x + w / 2, y + h / 2);
  1620. c.close();
  1621. c.fillAndStroke();
  1622. };
  1623. mxCellRenderer.prototype.defaultShapes['collate'] = CollateShape;
  1624. // DimensionShape
  1625. function DimensionShape()
  1626. {
  1627. mxEllipse.call(this);
  1628. };
  1629. mxUtils.extend(DimensionShape, mxEllipse);
  1630. DimensionShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1631. {
  1632. // Arrow size
  1633. var al = 10;
  1634. var cy = y + h - al / 2;
  1635. c.begin();
  1636. c.moveTo(x, y);
  1637. c.lineTo(x, y + h);
  1638. c.moveTo(x, cy);
  1639. c.lineTo(x + al, cy - al / 2);
  1640. c.moveTo(x, cy);
  1641. c.lineTo(x + al, cy + al / 2);
  1642. c.moveTo(x, cy);
  1643. c.lineTo(x + w, cy);
  1644. // Opposite side
  1645. c.moveTo(x + w, y);
  1646. c.lineTo(x + w, y + h);
  1647. c.moveTo(x + w, cy);
  1648. c.lineTo(x + w - al, cy - al / 2);
  1649. c.moveTo(x + w, cy);
  1650. c.lineTo(x + w - al, cy + al / 2);
  1651. c.end();
  1652. c.stroke();
  1653. };
  1654. mxCellRenderer.prototype.defaultShapes['dimension'] = DimensionShape;
  1655. // PartialRectangleShape
  1656. function PartialRectangleShape()
  1657. {
  1658. mxEllipse.call(this);
  1659. };
  1660. mxUtils.extend(PartialRectangleShape, mxEllipse);
  1661. PartialRectangleShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1662. {
  1663. if (!this.outline)
  1664. {
  1665. c.setStrokeColor(null);
  1666. }
  1667. mxRectangleShape.prototype.paintBackground.apply(this, arguments);
  1668. if (this.style != null)
  1669. {
  1670. c.setStrokeColor(this.stroke);
  1671. c.rect(x, y, w, h);
  1672. c.fill();
  1673. if (mxUtils.getValue(this.style, 'top', '1') == '1')
  1674. {
  1675. c.begin();
  1676. c.moveTo(x, y);
  1677. c.lineTo(x + w, y);
  1678. c.end();
  1679. c.stroke();
  1680. }
  1681. if (mxUtils.getValue(this.style, 'right', '1') == '1')
  1682. {
  1683. c.begin();
  1684. c.moveTo(x + w, y);
  1685. c.lineTo(x + w, y + h);
  1686. c.end();
  1687. c.stroke();
  1688. }
  1689. if (mxUtils.getValue(this.style, 'bottom', '1') == '1')
  1690. {
  1691. c.begin();
  1692. c.moveTo(x + w, y + h);
  1693. c.lineTo(x, y + h);
  1694. c.end();
  1695. c.stroke();
  1696. }
  1697. if (mxUtils.getValue(this.style, 'left', '1') == '1')
  1698. {
  1699. c.begin();
  1700. c.moveTo(x, y + h);
  1701. c.lineTo(x, y);
  1702. c.end();
  1703. c.stroke();
  1704. }
  1705. }
  1706. };
  1707. mxCellRenderer.prototype.defaultShapes['partialRectangle'] = PartialRectangleShape;
  1708. // LineEllipseShape
  1709. function LineEllipseShape()
  1710. {
  1711. mxEllipse.call(this);
  1712. };
  1713. mxUtils.extend(LineEllipseShape, mxEllipse);
  1714. LineEllipseShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1715. {
  1716. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  1717. c.setShadow(false);
  1718. c.begin();
  1719. if (mxUtils.getValue(this.style, 'line') == 'vertical')
  1720. {
  1721. c.moveTo(x + w / 2, y);
  1722. c.lineTo(x + w / 2, y + h);
  1723. }
  1724. else
  1725. {
  1726. c.moveTo(x, y + h / 2);
  1727. c.lineTo(x + w, y + h / 2);
  1728. }
  1729. c.end();
  1730. c.stroke();
  1731. };
  1732. mxCellRenderer.prototype.defaultShapes['lineEllipse'] = LineEllipseShape;
  1733. // Delay
  1734. function DelayShape()
  1735. {
  1736. mxActor.call(this);
  1737. };
  1738. mxUtils.extend(DelayShape, mxActor);
  1739. DelayShape.prototype.redrawPath = function(c, x, y, w, h)
  1740. {
  1741. var dx = Math.min(w, h / 2);
  1742. c.moveTo(0, 0);
  1743. c.lineTo(w - dx, 0);
  1744. c.quadTo(w, 0, w, h / 2);
  1745. c.quadTo(w, h, w - dx, h);
  1746. c.lineTo(0, h);
  1747. c.close();
  1748. c.end();
  1749. };
  1750. mxCellRenderer.prototype.defaultShapes['delay'] = DelayShape;
  1751. // Cross Shape
  1752. function CrossShape()
  1753. {
  1754. mxActor.call(this);
  1755. };
  1756. mxUtils.extend(CrossShape, mxActor);
  1757. CrossShape.prototype.size = 0.2;
  1758. CrossShape.prototype.redrawPath = function(c, x, y, w, h)
  1759. {
  1760. var m = Math.min(h, w);
  1761. var size = Math.max(0, Math.min(m, m * parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1762. var t = (h - size) / 2;
  1763. var b = t + size;
  1764. var l = (w - size) / 2;
  1765. var r = l + size;
  1766. c.moveTo(0, t);
  1767. c.lineTo(l, t);
  1768. c.lineTo(l, 0);
  1769. c.lineTo(r, 0);
  1770. c.lineTo(r, t);
  1771. c.lineTo(w, t);
  1772. c.lineTo(w, b);
  1773. c.lineTo(r, b);
  1774. c.lineTo(r, h);
  1775. c.lineTo(l, h);
  1776. c.lineTo(l, b);
  1777. c.lineTo(0, b);
  1778. c.close();
  1779. c.end();
  1780. };
  1781. mxCellRenderer.prototype.defaultShapes['cross'] = CrossShape;
  1782. // Display
  1783. function DisplayShape()
  1784. {
  1785. mxActor.call(this);
  1786. };
  1787. mxUtils.extend(DisplayShape, mxActor);
  1788. DisplayShape.prototype.size = 0.25;
  1789. DisplayShape.prototype.redrawPath = function(c, x, y, w, h)
  1790. {
  1791. var dx = Math.min(w, h / 2);
  1792. var s = Math.min(w - dx, Math.max(0, parseFloat(mxUtils.getValue(this.style, 'size', this.size))) * w);
  1793. c.moveTo(0, h / 2);
  1794. c.lineTo(s, 0);
  1795. c.lineTo(w - dx, 0);
  1796. c.quadTo(w, 0, w, h / 2);
  1797. c.quadTo(w, h, w - dx, h);
  1798. c.lineTo(s, h);
  1799. c.close();
  1800. c.end();
  1801. };
  1802. mxCellRenderer.prototype.defaultShapes['display'] = DisplayShape;
  1803. // Registers and defines the custom marker
  1804. mxMarker.addMarker('dash', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  1805. {
  1806. var nx = unitX * (size + sw + 1);
  1807. var ny = unitY * (size + sw + 1);
  1808. return function()
  1809. {
  1810. c.begin();
  1811. c.moveTo(pe.x - nx / 2 - ny / 2, pe.y - ny / 2 + nx / 2);
  1812. c.lineTo(pe.x + ny / 2 - 3 * nx / 2, pe.y - 3 * ny / 2 - nx / 2);
  1813. c.stroke();
  1814. };
  1815. });
  1816. // Registers and defines the custom marker
  1817. mxMarker.addMarker('cross', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  1818. {
  1819. var nx = unitX * (size + sw + 1);
  1820. var ny = unitY * (size + sw + 1);
  1821. return function()
  1822. {
  1823. c.begin();
  1824. c.moveTo(pe.x - nx / 2 - ny / 2, pe.y - ny / 2 + nx / 2);
  1825. c.lineTo(pe.x + ny / 2 - 3 * nx / 2, pe.y - 3 * ny / 2 - nx / 2);
  1826. c.moveTo(pe.x - nx / 2 + ny / 2, pe.y - ny / 2 - nx / 2);
  1827. c.lineTo(pe.x - ny / 2 - 3 * nx / 2, pe.y - 3 * ny / 2 + nx / 2);
  1828. c.stroke();
  1829. };
  1830. });
  1831. function circleMarker(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  1832. {
  1833. var a = size / 2;
  1834. var size = size + sw;
  1835. var pt = pe.clone();
  1836. pe.x -= unitX * (2 * size + sw);
  1837. pe.y -= unitY * (2 * size + sw);
  1838. unitX = unitX * (size + sw);
  1839. unitY = unitY * (size + sw);
  1840. return function()
  1841. {
  1842. c.ellipse(pt.x - unitX - size, pt.y - unitY - size, 2 * size, 2 * size);
  1843. if (filled)
  1844. {
  1845. c.fillAndStroke();
  1846. }
  1847. else
  1848. {
  1849. c.stroke();
  1850. }
  1851. };
  1852. };
  1853. mxMarker.addMarker('circle', circleMarker);
  1854. mxMarker.addMarker('circlePlus', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  1855. {
  1856. var pt = pe.clone();
  1857. var fn = circleMarker.apply(this, arguments);
  1858. var nx = unitX * (size + 2 * sw); // (size + sw + 1);
  1859. var ny = unitY * (size + 2 * sw); //(size + sw + 1);
  1860. return function()
  1861. {
  1862. fn.apply(this, arguments);
  1863. c.begin();
  1864. c.moveTo(pt.x - unitX * (sw), pt.y - unitY * (sw));
  1865. c.lineTo(pt.x - 2 * nx + unitX * (sw), pt.y - 2 * ny + unitY * (sw));
  1866. c.moveTo(pt.x - nx - ny + unitY * sw, pt.y - ny + nx - unitX * sw);
  1867. c.lineTo(pt.x + ny - nx - unitY * sw, pt.y - ny - nx + unitX * sw);
  1868. c.stroke();
  1869. };
  1870. });
  1871. mxMarker.addMarker('async', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  1872. {
  1873. // The angle of the forward facing arrow sides against the x axis is
  1874. // 26.565 degrees, 1/sin(26.565) = 2.236 / 2 = 1.118 ( / 2 allows for
  1875. // only half the strokewidth is processed ).
  1876. var endOffsetX = unitX * sw * 1.118;
  1877. var endOffsetY = unitY * sw * 1.118;
  1878. unitX = unitX * (size + sw);
  1879. unitY = unitY * (size + sw);
  1880. var pt = pe.clone();
  1881. pt.x -= endOffsetX;
  1882. pt.y -= endOffsetY;
  1883. var f = 1;
  1884. pe.x += -unitX * f - endOffsetX;
  1885. pe.y += -unitY * f - endOffsetY;
  1886. return function()
  1887. {
  1888. c.begin();
  1889. c.moveTo(pt.x, pt.y);
  1890. if (source)
  1891. {
  1892. c.lineTo(pt.x - unitX - unitY / 2, pt.y - unitY + unitX / 2);
  1893. }
  1894. else
  1895. {
  1896. c.lineTo(pt.x + unitY / 2 - unitX, pt.y - unitY - unitX / 2);
  1897. }
  1898. c.lineTo(pt.x - unitX, pt.y - unitY);
  1899. c.close();
  1900. if (filled)
  1901. {
  1902. c.fillAndStroke();
  1903. }
  1904. else
  1905. {
  1906. c.stroke();
  1907. }
  1908. };
  1909. });
  1910. function createOpenAsyncArrow(widthFactor)
  1911. {
  1912. widthFactor = (widthFactor != null) ? widthFactor : 2;
  1913. return function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  1914. {
  1915. unitX = unitX * (size + sw);
  1916. unitY = unitY * (size + sw);
  1917. var pt = pe.clone();
  1918. return function()
  1919. {
  1920. c.begin();
  1921. c.moveTo(pt.x, pt.y);
  1922. if (source)
  1923. {
  1924. c.lineTo(pt.x - unitX - unitY / widthFactor, pt.y - unitY + unitX / widthFactor);
  1925. }
  1926. else
  1927. {
  1928. c.lineTo(pt.x + unitY / widthFactor - unitX, pt.y - unitY - unitX / widthFactor);
  1929. }
  1930. c.stroke();
  1931. };
  1932. }
  1933. };
  1934. mxMarker.addMarker('openAsync', createOpenAsyncArrow(2));
  1935. function arrow(canvas, shape, type, pe, unitX, unitY, size, source, sw, filled)
  1936. {
  1937. // The angle of the forward facing arrow sides against the x axis is
  1938. // 26.565 degrees, 1/sin(26.565) = 2.236 / 2 = 1.118 ( / 2 allows for
  1939. // only half the strokewidth is processed ).
  1940. var endOffsetX = unitX * sw * 1.118;
  1941. var endOffsetY = unitY * sw * 1.118;
  1942. unitX = unitX * (size + sw);
  1943. unitY = unitY * (size + sw);
  1944. var pt = pe.clone();
  1945. pt.x -= endOffsetX;
  1946. pt.y -= endOffsetY;
  1947. var f = (type != mxConstants.ARROW_CLASSIC && type != mxConstants.ARROW_CLASSIC_THIN) ? 1 : 3 / 4;
  1948. pe.x += -unitX * f - endOffsetX;
  1949. pe.y += -unitY * f - endOffsetY;
  1950. return function()
  1951. {
  1952. canvas.begin();
  1953. canvas.moveTo(pt.x, pt.y);
  1954. canvas.lineTo(pt.x - unitX - unitY / widthFactor, pt.y - unitY + unitX / widthFactor);
  1955. if (type == mxConstants.ARROW_CLASSIC || type == mxConstants.ARROW_CLASSIC_THIN)
  1956. {
  1957. canvas.lineTo(pt.x - unitX * 3 / 4, pt.y - unitY * 3 / 4);
  1958. }
  1959. canvas.lineTo(pt.x + unitY / widthFactor - unitX, pt.y - unitY - unitX / widthFactor);
  1960. canvas.close();
  1961. if (filled)
  1962. {
  1963. canvas.fillAndStroke();
  1964. }
  1965. else
  1966. {
  1967. canvas.stroke();
  1968. }
  1969. };
  1970. }
  1971. // Handlers are only added if mxVertexHandler is defined (ie. not in embedded graph)
  1972. if (typeof mxVertexHandler !== 'undefined')
  1973. {
  1974. function createHandle(state, keys, getPositionFn, setPositionFn, ignoreGrid)
  1975. {
  1976. var handle = new mxHandle(state, null, mxVertexHandler.prototype.secondaryHandleImage);
  1977. handle.execute = function()
  1978. {
  1979. for (var i = 0; i < keys.length; i++)
  1980. {
  1981. this.copyStyle(keys[i]);
  1982. }
  1983. };
  1984. handle.getPosition = getPositionFn;
  1985. handle.setPosition = setPositionFn;
  1986. handle.ignoreGrid = (ignoreGrid != null) ? ignoreGrid : true;
  1987. return handle;
  1988. };
  1989. function createArcHandle(state, yOffset)
  1990. {
  1991. return createHandle(state, [mxConstants.STYLE_ARCSIZE], function(bounds)
  1992. {
  1993. var arcSize = Math.max(0, parseFloat(mxUtils.getValue(state.style,
  1994. mxConstants.STYLE_ARCSIZE, mxConstants.RECTANGLE_ROUNDING_FACTOR * 100))) / 100;
  1995. var tmp = (yOffset != null) ? yOffset : bounds.height / 8;
  1996. return new mxPoint(bounds.x + bounds.width - Math.min(Math.max(bounds.width / 2, bounds.height / 2),
  1997. Math.min(bounds.width, bounds.height) * arcSize), bounds.y + tmp);
  1998. }, function(bounds, pt, me)
  1999. {
  2000. var f = Math.min(50, Math.max(0, (bounds.width - pt.x + bounds.x) * 100 /
  2001. Math.min(bounds.width, bounds.height)));
  2002. this.state.style[mxConstants.STYLE_ARCSIZE] = Math.round(f);
  2003. });
  2004. }
  2005. function createArcHandleFunction()
  2006. {
  2007. return function(state)
  2008. {
  2009. var handles = [];
  2010. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2011. {
  2012. handles.push(createArcHandle(state));
  2013. }
  2014. return handles;
  2015. };
  2016. };
  2017. function createTrapezoidHandleFunction(max)
  2018. {
  2019. return function(state)
  2020. {
  2021. var handles = [createHandle(state, ['size'], function(bounds)
  2022. {
  2023. var size = Math.max(0, Math.min(max, parseFloat(mxUtils.getValue(this.state.style, 'size', TrapezoidShape.prototype.size))));
  2024. return new mxPoint(bounds.x + size * bounds.width * 0.75, bounds.y + bounds.height / 4);
  2025. }, function(bounds, pt)
  2026. {
  2027. this.state.style['size'] = Math.max(0, Math.min(max, (pt.x - bounds.x) / (bounds.width * 0.75)));
  2028. })];
  2029. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2030. {
  2031. handles.push(createArcHandle(state));
  2032. }
  2033. return handles;
  2034. };
  2035. };
  2036. function createDisplayHandleFunction(defaultValue, allowArcHandle, max)
  2037. {
  2038. max = (max != null) ? max : 1;
  2039. return function(state)
  2040. {
  2041. var handles = [createHandle(state, ['size'], function(bounds)
  2042. {
  2043. var size = parseFloat(mxUtils.getValue(this.state.style, 'size', defaultValue));
  2044. return new mxPoint(bounds.x + size * bounds.width, bounds.getCenterY());
  2045. }, function(bounds, pt)
  2046. {
  2047. this.state.style['size'] = Math.max(0, Math.min(max, (pt.x - bounds.x) / bounds.width));
  2048. })];
  2049. if (allowArcHandle && mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2050. {
  2051. handles.push(createArcHandle(state));
  2052. }
  2053. return handles;
  2054. };
  2055. };
  2056. function createCubeHandleFunction(factor, defaultValue, allowArcHandle)
  2057. {
  2058. return function(state)
  2059. {
  2060. var handles = [createHandle(state, ['size'], function(bounds)
  2061. {
  2062. var size = Math.max(0, Math.min(bounds.width, Math.min(bounds.height, parseFloat(
  2063. mxUtils.getValue(this.state.style, 'size', defaultValue))))) * factor;
  2064. return new mxPoint(bounds.x + size, bounds.y + size);
  2065. }, function(bounds, pt)
  2066. {
  2067. this.state.style['size'] = Math.round(Math.max(0, Math.min(Math.min(bounds.width, pt.x - bounds.x),
  2068. Math.min(bounds.height, pt.y - bounds.y))) / factor);
  2069. })];
  2070. if (allowArcHandle && mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2071. {
  2072. handles.push(createArcHandle(state));
  2073. }
  2074. return handles;
  2075. };
  2076. };
  2077. function createArrowHandleFunction(maxSize)
  2078. {
  2079. return function(state)
  2080. {
  2081. return [createHandle(state, ['arrowWidth', 'arrowSize'], function(bounds)
  2082. {
  2083. var aw = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'arrowWidth', SingleArrowShape.prototype.arrowWidth)));
  2084. var as = Math.max(0, Math.min(maxSize, mxUtils.getValue(this.state.style, 'arrowSize', SingleArrowShape.prototype.arrowSize)));
  2085. return new mxPoint(bounds.x + (1 - as) * bounds.width, bounds.y + (1 - aw) * bounds.height / 2);
  2086. }, function(bounds, pt)
  2087. {
  2088. this.state.style['arrowWidth'] = Math.max(0, Math.min(1, Math.abs(bounds.y + bounds.height / 2 - pt.y) / bounds.height * 2));
  2089. this.state.style['arrowSize'] = Math.max(0, Math.min(maxSize, (bounds.x + bounds.width - pt.x) / (bounds.width)));
  2090. })];
  2091. };
  2092. };
  2093. function createEdgeHandle(state, keys, start, getPosition, setPosition)
  2094. {
  2095. var pts = state.absolutePoints;
  2096. var n = pts.length - 1;
  2097. var tr = state.view.translate;
  2098. var s = state.view.scale;
  2099. var p0 = (start) ? pts[0] : pts[n];
  2100. var p1 = (start) ? pts[1] : pts[n - 1];
  2101. var dx = (start) ? p1.x - p0.x : p1.x - p0.x;
  2102. var dy = (start) ? p1.y - p0.y : p1.y - p0.y;
  2103. var dist = Math.sqrt(dx * dx + dy * dy);
  2104. return createHandle(state, keys, function(bounds)
  2105. {
  2106. var pt = getPosition.call(this, dist, dx / dist, dy / dist, p0, p1);
  2107. return new mxPoint(pt.x / s - tr.x, pt.y / s - tr.y);
  2108. }, function(bounds, pt, me)
  2109. {
  2110. var dist = Math.sqrt(dx * dx + dy * dy);
  2111. pt.x = (pt.x + tr.x) * s;
  2112. pt.y = (pt.y + tr.y) * s;
  2113. setPosition.call(this, dist, dx / dist, dy / dist, p0, p1, pt, me);
  2114. });
  2115. };
  2116. function createEdgeWidthHandle(state, start, spacing)
  2117. {
  2118. return createEdgeHandle(state, ['width'], start, function(dist, nx, ny, p0, p1)
  2119. {
  2120. var w = state.shape.getEdgeWidth() * state.view.scale + spacing;
  2121. return new mxPoint(p0.x + nx * dist / 4 + ny * w / 2, p0.y + ny * dist / 4 - nx * w / 2);
  2122. }, function(dist, nx, ny, p0, p1, pt)
  2123. {
  2124. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  2125. state.style['width'] = Math.round(w * 2) / state.view.scale - spacing;
  2126. });
  2127. };
  2128. function ptLineDistance(x1, y1, x2, y2, x0, y0)
  2129. {
  2130. return Math.abs((y2 - y1) * x0 - (x2 - x1) * y0 + x2 * y1 - y2 * x1) / Math.sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
  2131. }
  2132. var handleFactory = {
  2133. 'link': function(state)
  2134. {
  2135. var spacing = 10;
  2136. return [createEdgeWidthHandle(state, true, spacing), createEdgeWidthHandle(state, false, spacing)];
  2137. },
  2138. 'flexArrow': function(state)
  2139. {
  2140. // Do not use state.shape.startSize/endSize since it is cached
  2141. var tol = state.view.graph.gridSize / state.view.scale;
  2142. var handles = [];
  2143. if (mxUtils.getValue(state.style, mxConstants.STYLE_STARTARROW, mxConstants.NONE) != mxConstants.NONE)
  2144. {
  2145. handles.push(createEdgeHandle(state, ['width', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], true, function(dist, nx, ny, p0, p1)
  2146. {
  2147. var w = (state.shape.getEdgeWidth() - state.shape.strokewidth) * state.view.scale;
  2148. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  2149. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) + ny * w / 2,
  2150. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) - nx * w / 2);
  2151. }, function(dist, nx, ny, p0, p1, pt, me)
  2152. {
  2153. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  2154. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  2155. state.style[mxConstants.STYLE_STARTSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  2156. state.style['width'] = Math.round(w * 2) / state.view.scale;
  2157. // Applies to opposite side
  2158. if (mxEvent.isControlDown(me.getEvent()))
  2159. {
  2160. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  2161. }
  2162. // Snaps to end geometry
  2163. if (!mxEvent.isAltDown(me.getEvent()))
  2164. {
  2165. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_STARTSIZE]) - parseFloat(state.style[mxConstants.STYLE_ENDSIZE])) < tol / 6)
  2166. {
  2167. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  2168. }
  2169. }
  2170. }));
  2171. handles.push(createEdgeHandle(state, ['startWidth', 'endWidth', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], true, function(dist, nx, ny, p0, p1)
  2172. {
  2173. var w = (state.shape.getStartArrowWidth() - state.shape.strokewidth) * state.view.scale;
  2174. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  2175. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) + ny * w / 2,
  2176. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) - nx * w / 2);
  2177. }, function(dist, nx, ny, p0, p1, pt, me)
  2178. {
  2179. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  2180. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  2181. state.style[mxConstants.STYLE_STARTSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  2182. state.style['startWidth'] = Math.max(0, Math.round(w * 2) - state.shape.getEdgeWidth()) / state.view.scale;
  2183. // Applies to opposite side
  2184. if (mxEvent.isControlDown(me.getEvent()))
  2185. {
  2186. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  2187. state.style['endWidth'] = state.style['startWidth'];
  2188. }
  2189. // Snaps to endWidth
  2190. if (!mxEvent.isAltDown(me.getEvent()))
  2191. {
  2192. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_STARTSIZE]) - parseFloat(state.style[mxConstants.STYLE_ENDSIZE])) < tol / 6)
  2193. {
  2194. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  2195. }
  2196. if (Math.abs(parseFloat(state.style['startWidth']) - parseFloat(state.style['endWidth'])) < tol)
  2197. {
  2198. state.style['startWidth'] = state.style['endWidth'];
  2199. }
  2200. }
  2201. }));
  2202. }
  2203. if (mxUtils.getValue(state.style, mxConstants.STYLE_ENDARROW, mxConstants.NONE) != mxConstants.NONE)
  2204. {
  2205. handles.push(createEdgeHandle(state, ['width', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], false, function(dist, nx, ny, p0, p1)
  2206. {
  2207. var w = (state.shape.getEdgeWidth() - state.shape.strokewidth) * state.view.scale;
  2208. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_ENDSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  2209. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) - ny * w / 2,
  2210. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) + nx * w / 2);
  2211. }, function(dist, nx, ny, p0, p1, pt, me)
  2212. {
  2213. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  2214. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  2215. state.style[mxConstants.STYLE_ENDSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  2216. state.style['width'] = Math.round(w * 2) / state.view.scale;
  2217. // Applies to opposite side
  2218. if (mxEvent.isControlDown(me.getEvent()))
  2219. {
  2220. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  2221. }
  2222. // Snaps to start geometry
  2223. if (!mxEvent.isAltDown(me.getEvent()))
  2224. {
  2225. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_ENDSIZE]) - parseFloat(state.style[mxConstants.STYLE_STARTSIZE])) < tol / 6)
  2226. {
  2227. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  2228. }
  2229. }
  2230. }));
  2231. handles.push(createEdgeHandle(state, ['startWidth', 'endWidth', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], false, function(dist, nx, ny, p0, p1)
  2232. {
  2233. var w = (state.shape.getEndArrowWidth() - state.shape.strokewidth) * state.view.scale;
  2234. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_ENDSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  2235. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) - ny * w / 2,
  2236. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) + nx * w / 2);
  2237. }, function(dist, nx, ny, p0, p1, pt, me)
  2238. {
  2239. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  2240. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  2241. state.style[mxConstants.STYLE_ENDSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  2242. state.style['endWidth'] = Math.max(0, Math.round(w * 2) - state.shape.getEdgeWidth()) / state.view.scale;
  2243. // Applies to opposite side
  2244. if (mxEvent.isControlDown(me.getEvent()))
  2245. {
  2246. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  2247. state.style['startWidth'] = state.style['endWidth'];
  2248. }
  2249. // Snaps to start geometry
  2250. if (!mxEvent.isAltDown(me.getEvent()))
  2251. {
  2252. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_ENDSIZE]) - parseFloat(state.style[mxConstants.STYLE_STARTSIZE])) < tol / 6)
  2253. {
  2254. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  2255. }
  2256. if (Math.abs(parseFloat(state.style['endWidth']) - parseFloat(state.style['startWidth'])) < tol)
  2257. {
  2258. state.style['endWidth'] = state.style['startWidth'];
  2259. }
  2260. }
  2261. }));
  2262. }
  2263. return handles;
  2264. },
  2265. 'swimlane': function(state)
  2266. {
  2267. var handles = [createHandle(state, [mxConstants.STYLE_STARTSIZE], function(bounds)
  2268. {
  2269. var size = parseFloat(mxUtils.getValue(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_STARTSIZE));
  2270. if (mxUtils.getValue(state.style, mxConstants.STYLE_HORIZONTAL, 1) == 1)
  2271. {
  2272. return new mxPoint(bounds.getCenterX(), bounds.y + Math.max(0, Math.min(bounds.height, size)));
  2273. }
  2274. else
  2275. {
  2276. return new mxPoint(bounds.x + Math.max(0, Math.min(bounds.width, size)), bounds.getCenterY());
  2277. }
  2278. }, function(bounds, pt)
  2279. {
  2280. state.style[mxConstants.STYLE_STARTSIZE] =
  2281. (mxUtils.getValue(this.state.style, mxConstants.STYLE_HORIZONTAL, 1) == 1) ?
  2282. Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y))) :
  2283. Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x)));
  2284. })];
  2285. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED))
  2286. {
  2287. var size = parseFloat(mxUtils.getValue(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_STARTSIZE));
  2288. handles.push(createArcHandle(state, size / 2));
  2289. }
  2290. return handles;
  2291. },
  2292. 'label': createArcHandleFunction(),
  2293. 'ext': createArcHandleFunction(),
  2294. 'rectangle': createArcHandleFunction(),
  2295. 'triangle': createArcHandleFunction(),
  2296. 'rhombus': createArcHandleFunction(),
  2297. 'umlLifeline': function(state)
  2298. {
  2299. return [createHandle(state, ['size'], function(bounds)
  2300. {
  2301. var size = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'size', UmlLifeline.prototype.size))));
  2302. return new mxPoint(bounds.getCenterX(), bounds.y + size);
  2303. }, function(bounds, pt)
  2304. {
  2305. this.state.style['size'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  2306. }, false)];
  2307. },
  2308. 'umlFrame': function(state)
  2309. {
  2310. var handles = [createHandle(state, ['width', 'height'], function(bounds)
  2311. {
  2312. var w0 = Math.max(UmlFrame.prototype.corner, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'width', UmlFrame.prototype.width)));
  2313. var h0 = Math.max(UmlFrame.prototype.corner * 1.5, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'height', UmlFrame.prototype.height)));
  2314. return new mxPoint(bounds.x + w0, bounds.y + h0);
  2315. }, function(bounds, pt)
  2316. {
  2317. this.state.style['width'] = Math.round(Math.max(UmlFrame.prototype.corner, Math.min(bounds.width, pt.x - bounds.x)));
  2318. this.state.style['height'] = Math.round(Math.max(UmlFrame.prototype.corner * 1.5, Math.min(bounds.height, pt.y - bounds.y)));
  2319. }, false)];
  2320. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2321. {
  2322. handles.push(createArcHandle(state));
  2323. }
  2324. return handles;
  2325. },
  2326. 'process': function(state)
  2327. {
  2328. var handles = [createHandle(state, ['size'], function(bounds)
  2329. {
  2330. var size = Math.max(0, Math.min(0.5, parseFloat(mxUtils.getValue(this.state.style, 'size', ProcessShape.prototype.size))));
  2331. return new mxPoint(bounds.x + bounds.width * size, bounds.y + bounds.height / 4);
  2332. }, function(bounds, pt)
  2333. {
  2334. this.state.style['size'] = Math.max(0, Math.min(0.5, (pt.x - bounds.x) / bounds.width));
  2335. })];
  2336. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2337. {
  2338. handles.push(createArcHandle(state));
  2339. }
  2340. return handles;
  2341. },
  2342. 'cross': function(state)
  2343. {
  2344. return [createHandle(state, ['size'], function(bounds)
  2345. {
  2346. var m = Math.min(bounds.width, bounds.height);
  2347. var size = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'size', CrossShape.prototype.size))) * m / 2;
  2348. return new mxPoint(bounds.getCenterX() - size, bounds.getCenterY() - size);
  2349. }, function(bounds, pt)
  2350. {
  2351. var m = Math.min(bounds.width, bounds.height);
  2352. this.state.style['size'] = Math.max(0, Math.min(1, Math.min((Math.max(0, bounds.getCenterY() - pt.y) / m) * 2,
  2353. (Math.max(0, bounds.getCenterX() - pt.x) / m) * 2)));
  2354. })];
  2355. },
  2356. 'note': function(state)
  2357. {
  2358. return [createHandle(state, ['size'], function(bounds)
  2359. {
  2360. var size = Math.max(0, Math.min(bounds.width, Math.min(bounds.height, parseFloat(
  2361. mxUtils.getValue(this.state.style, 'size', NoteShape.prototype.size)))));
  2362. return new mxPoint(bounds.x + bounds.width - size, bounds.y + size);
  2363. }, function(bounds, pt)
  2364. {
  2365. this.state.style['size'] = Math.round(Math.max(0, Math.min(Math.min(bounds.width, bounds.x + bounds.width - pt.x),
  2366. Math.min(bounds.height, pt.y - bounds.y))));
  2367. })];
  2368. },
  2369. 'manualInput': function(state)
  2370. {
  2371. var handles = [createHandle(state, ['size'], function(bounds)
  2372. {
  2373. var size = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'size', ManualInputShape.prototype.size)));
  2374. return new mxPoint(bounds.x + bounds.width / 4, bounds.y + size * 3 / 4);
  2375. }, function(bounds, pt)
  2376. {
  2377. this.state.style['size'] = Math.round(Math.max(0, Math.min(bounds.height, (pt.y - bounds.y) * 4 / 3)));
  2378. })];
  2379. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2380. {
  2381. handles.push(createArcHandle(state));
  2382. }
  2383. return handles;
  2384. },
  2385. 'dataStorage': function(state)
  2386. {
  2387. return [createHandle(state, ['size'], function(bounds)
  2388. {
  2389. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', DataStorageShape.prototype.size))));
  2390. return new mxPoint(bounds.x + (1 - size) * bounds.width, bounds.getCenterY());
  2391. }, function(bounds, pt)
  2392. {
  2393. this.state.style['size'] = Math.max(0, Math.min(1, (bounds.x + bounds.width - pt.x) / bounds.width));
  2394. })];
  2395. },
  2396. 'internalStorage': function(state)
  2397. {
  2398. var handles = [createHandle(state, ['dx', 'dy'], function(bounds)
  2399. {
  2400. var dx = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'dx', InternalStorageShape.prototype.dx)));
  2401. var dy = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'dy', InternalStorageShape.prototype.dy)));
  2402. return new mxPoint(bounds.x + dx, bounds.y + dy);
  2403. }, function(bounds, pt)
  2404. {
  2405. this.state.style['dx'] = Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x)));
  2406. this.state.style['dy'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  2407. })];
  2408. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  2409. {
  2410. handles.push(createArcHandle(state));
  2411. }
  2412. return handles;
  2413. },
  2414. 'corner': function(state)
  2415. {
  2416. return [createHandle(state, ['dx', 'dy'], function(bounds)
  2417. {
  2418. var dx = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'dx', CornerShape.prototype.dx)));
  2419. var dy = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'dy', CornerShape.prototype.dy)));
  2420. return new mxPoint(bounds.x + dx, bounds.y + dy);
  2421. }, function(bounds, pt)
  2422. {
  2423. this.state.style['dx'] = Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x)));
  2424. this.state.style['dy'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  2425. })];
  2426. },
  2427. 'tee': function(state)
  2428. {
  2429. return [createHandle(state, ['dx', 'dy'], function(bounds)
  2430. {
  2431. var dx = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'dx', TeeShape.prototype.dx)));
  2432. var dy = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'dy', TeeShape.prototype.dy)));
  2433. return new mxPoint(bounds.x + (bounds.width + dx) / 2, bounds.y + dy);
  2434. }, function(bounds, pt)
  2435. {
  2436. this.state.style['dx'] = Math.round(Math.max(0, Math.min(bounds.width / 2, (pt.x - bounds.x - bounds.width / 2)) * 2));
  2437. this.state.style['dy'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  2438. })];
  2439. },
  2440. 'singleArrow': createArrowHandleFunction(1),
  2441. 'doubleArrow': createArrowHandleFunction(0.5),
  2442. 'folder': function(state)
  2443. {
  2444. return [createHandle(state, ['tabWidth', 'tabHeight'], function(bounds)
  2445. {
  2446. var tw = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'tabWidth', FolderShape.prototype.tabWidth)));
  2447. var th = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'tabHeight', FolderShape.prototype.tabHeight)));
  2448. if (mxUtils.getValue(this.state.style, 'tabPosition', FolderShape.prototype.tabPosition) == mxConstants.ALIGN_RIGHT)
  2449. {
  2450. tw = bounds.width - tw;
  2451. }
  2452. return new mxPoint(bounds.x + tw, bounds.y + th);
  2453. }, function(bounds, pt)
  2454. {
  2455. var tw = Math.max(0, Math.min(bounds.width, pt.x - bounds.x));
  2456. if (mxUtils.getValue(this.state.style, 'tabPosition', FolderShape.prototype.tabPosition) == mxConstants.ALIGN_RIGHT)
  2457. {
  2458. tw = bounds.width - tw;
  2459. }
  2460. this.state.style['tabWidth'] = Math.round(tw);
  2461. this.state.style['tabHeight'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  2462. })];
  2463. },
  2464. 'document': function(state)
  2465. {
  2466. return [createHandle(state, ['size'], function(bounds)
  2467. {
  2468. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', DocumentShape.prototype.size))));
  2469. return new mxPoint(bounds.x + 3 * bounds.width / 4, bounds.y + (1 - size) * bounds.height);
  2470. }, function(bounds, pt)
  2471. {
  2472. this.state.style['size'] = Math.max(0, Math.min(1, (bounds.y + bounds.height - pt.y) / bounds.height));
  2473. })];
  2474. },
  2475. 'tape': function(state)
  2476. {
  2477. return [createHandle(state, ['size'], function(bounds)
  2478. {
  2479. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', TapeShape.prototype.size))));
  2480. return new mxPoint(bounds.getCenterX(), bounds.y + size * bounds.height / 2);
  2481. }, function(bounds, pt)
  2482. {
  2483. this.state.style['size'] = Math.max(0, Math.min(1, ((pt.y - bounds.y) / bounds.height) * 2));
  2484. })];
  2485. },
  2486. 'offPageConnector': function(state)
  2487. {
  2488. return [createHandle(state, ['size'], function(bounds)
  2489. {
  2490. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', OffPageConnectorShape.prototype.size))));
  2491. return new mxPoint(bounds.getCenterX(), bounds.y + (1 - size) * bounds.height);
  2492. }, function(bounds, pt)
  2493. {
  2494. this.state.style['size'] = Math.max(0, Math.min(1, (bounds.y + bounds.height - pt.y) / bounds.height));
  2495. })];
  2496. },
  2497. 'step': createDisplayHandleFunction(StepShape.prototype.size, true),
  2498. 'hexagon': createDisplayHandleFunction(HexagonShape.prototype.size, true, 0.5),
  2499. 'curlyBracket': createDisplayHandleFunction(CurlyBracketShape.prototype.size, false),
  2500. 'display': createDisplayHandleFunction(DisplayShape.prototype.size, false),
  2501. 'cube': createCubeHandleFunction(1, CubeShape.prototype.size, false),
  2502. 'card': createCubeHandleFunction(0.5, CardShape.prototype.size, true),
  2503. 'loopLimit': createCubeHandleFunction(0.5, LoopLimitShape.prototype.size, true),
  2504. 'trapezoid': createTrapezoidHandleFunction(0.5),
  2505. 'parallelogram': createTrapezoidHandleFunction(1)
  2506. };
  2507. // Exposes custom handles
  2508. Graph.createHandle = createHandle;
  2509. Graph.handleFactory = handleFactory;
  2510. mxVertexHandler.prototype.createCustomHandles = function()
  2511. {
  2512. // Not rotatable means locked
  2513. if (this.state.view.graph.getSelectionCount() == 1)
  2514. {
  2515. if (this.graph.isCellRotatable(this.state.cell))
  2516. // LATER: Make locked state independent of rotatable flag, fix toggle if default is false
  2517. //if (this.graph.isCellResizable(this.state.cell) || this.graph.isCellMovable(this.state.cell))
  2518. {
  2519. var name = this.state.style['shape'];
  2520. if (this.state.view.graph.cellRenderer.defaultShapes[name] == null)
  2521. {
  2522. name = mxConstants.SHAPE_RECTANGLE;
  2523. }
  2524. var fn = handleFactory[name];
  2525. if (fn != null)
  2526. {
  2527. return fn(this.state);
  2528. }
  2529. }
  2530. }
  2531. return null;
  2532. };
  2533. mxEdgeHandler.prototype.createCustomHandles = function()
  2534. {
  2535. if (this.state.view.graph.getSelectionCount() == 1)
  2536. {
  2537. var name = this.state.style['shape'];
  2538. if (this.state.view.graph.cellRenderer.defaultShapes[name] == null)
  2539. {
  2540. name = mxConstants.SHAPE_CONNECTOR;
  2541. }
  2542. var fn = handleFactory[name];
  2543. if (fn != null)
  2544. {
  2545. return fn(this.state);
  2546. }
  2547. }
  2548. return null;
  2549. }
  2550. }
  2551. else
  2552. {
  2553. // Dummy entries to avoid NPE in embed mode
  2554. Graph.createHandle = function() {};
  2555. Graph.handleFactory = {};
  2556. }
  2557. var isoHVector = new mxPoint(1, 0);
  2558. var isoVVector = new mxPoint(1, 0);
  2559. var alpha1 = mxUtils.toRadians(-30);
  2560. var cos1 = Math.cos(alpha1);
  2561. var sin1 = Math.sin(alpha1);
  2562. isoHVector = mxUtils.getRotatedPoint(isoHVector, cos1, sin1);
  2563. var alpha2 = mxUtils.toRadians(-150);
  2564. var cos2 = Math.cos(alpha2);
  2565. var sin2 = Math.sin(alpha2);
  2566. isoVVector = mxUtils.getRotatedPoint(isoVVector, cos2, sin2);
  2567. mxEdgeStyle.IsometricConnector = function (state, source, target, points, result)
  2568. {
  2569. var view = state.view;
  2570. var pt = (points != null && points.length > 0) ? points[0] : null;
  2571. var pts = state.absolutePoints;
  2572. var p0 = pts[0];
  2573. var pe = pts[pts.length-1];
  2574. if (pt != null)
  2575. {
  2576. pt = view.transformControlPoint(state, pt);
  2577. }
  2578. if (p0 == null)
  2579. {
  2580. if (source != null)
  2581. {
  2582. p0 = new mxPoint(source.getCenterX(), source.getCenterY());
  2583. }
  2584. }
  2585. if (pe == null)
  2586. {
  2587. if (target != null)
  2588. {
  2589. pe = new mxPoint(target.getCenterX(), target.getCenterY());
  2590. }
  2591. }
  2592. var a1 = isoHVector.x;
  2593. var a2 = isoHVector.y;
  2594. var b1 = isoVVector.x;
  2595. var b2 = isoVVector.y;
  2596. var elbow = mxUtils.getValue(state.style, 'elbow', 'horizontal') == 'horizontal';
  2597. if (pe != null && p0 != null)
  2598. {
  2599. var last = p0;
  2600. function isoLineTo(x, y, ignoreFirst)
  2601. {
  2602. var c1 = x - last.x;
  2603. var c2 = y - last.y;
  2604. // Solves for isometric base vectors
  2605. var h = (b2 * c1 - b1 * c2) / (a1 * b2 - a2 * b1);
  2606. var v = (a2 * c1 - a1 * c2) / (a2 * b1 - a1 * b2);
  2607. if (elbow)
  2608. {
  2609. if (ignoreFirst)
  2610. {
  2611. last = new mxPoint(last.x + a1 * h, last.y + a2 * h);
  2612. result.push(last);
  2613. }
  2614. last = new mxPoint(last.x + b1 * v, last.y + b2 * v);
  2615. result.push(last);
  2616. }
  2617. else
  2618. {
  2619. if (ignoreFirst)
  2620. {
  2621. last = new mxPoint(last.x + b1 * v, last.y + b2 * v);
  2622. result.push(last);
  2623. }
  2624. last = new mxPoint(last.x + a1 * h, last.y + a2 * h);
  2625. result.push(last);
  2626. }
  2627. };
  2628. if (pt == null)
  2629. {
  2630. pt = new mxPoint(p0.x + (pe.x - p0.x) / 2, p0.y + (pe.y - p0.y) / 2);
  2631. }
  2632. isoLineTo(pt.x, pt.y, true);
  2633. isoLineTo(pe.x, pe.y, false);
  2634. }
  2635. };
  2636. mxStyleRegistry.putValue('isometricEdgeStyle', mxEdgeStyle.IsometricConnector);
  2637. var graphCreateEdgeHandler = Graph.prototype.createEdgeHandler;
  2638. Graph.prototype.createEdgeHandler = function(state, edgeStyle)
  2639. {
  2640. if (edgeStyle == mxEdgeStyle.IsometricConnector)
  2641. {
  2642. var handler = new mxElbowEdgeHandler(state);
  2643. handler.snapToTerminals = false;
  2644. return handler;
  2645. }
  2646. return graphCreateEdgeHandler.apply(this, arguments);
  2647. };
  2648. // Defines connection points for all shapes
  2649. IsoRectangleShape.prototype.constraints = [];
  2650. IsoCubeShape.prototype.constraints = [];
  2651. mxRectangleShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  2652. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2653. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  2654. new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  2655. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  2656. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  2657. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  2658. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  2659. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  2660. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  2661. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2662. new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
  2663. mxEllipse.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0), true), new mxConnectionConstraint(new mxPoint(1, 0), true),
  2664. new mxConnectionConstraint(new mxPoint(0, 1), true), new mxConnectionConstraint(new mxPoint(1, 1), true),
  2665. new mxConnectionConstraint(new mxPoint(0.5, 0), true), new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2666. new mxConnectionConstraint(new mxPoint(0, 0.5), true), new mxConnectionConstraint(new mxPoint(1, 0.5))];
  2667. mxLabel.prototype.constraints = mxRectangleShape.prototype.constraints;
  2668. mxImageShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2669. mxSwimlane.prototype.constraints = mxRectangleShape.prototype.constraints;
  2670. PlusShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2671. NoteShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2672. CardShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2673. CubeShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2674. FolderShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2675. InternalStorageShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2676. DataStorageShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2677. TapeDataShape.prototype.constraints = mxEllipse.prototype.constraints;
  2678. OrEllipseShape.prototype.constraints = mxEllipse.prototype.constraints;
  2679. SumEllipseShape.prototype.constraints = mxEllipse.prototype.constraints;
  2680. LineEllipseShape.prototype.constraints = mxEllipse.prototype.constraints;
  2681. ManualInputShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2682. DelayShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2683. DisplayShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2684. LoopLimitShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2685. OffPageConnectorShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2686. mxCylinder.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.15, 0.05), false),
  2687. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2688. new mxConnectionConstraint(new mxPoint(0.85, 0.05), false),
  2689. new mxConnectionConstraint(new mxPoint(0, 0.3), true),
  2690. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  2691. new mxConnectionConstraint(new mxPoint(0, 0.7), true),
  2692. new mxConnectionConstraint(new mxPoint(1, 0.3), true),
  2693. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  2694. new mxConnectionConstraint(new mxPoint(1, 0.7), true),
  2695. new mxConnectionConstraint(new mxPoint(0.15, 0.95), false),
  2696. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2697. new mxConnectionConstraint(new mxPoint(0.85, 0.95), false)];
  2698. UmlActorShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0.1), false),
  2699. new mxConnectionConstraint(new mxPoint(0.5, 0), false),
  2700. new mxConnectionConstraint(new mxPoint(0.75, 0.1), false),
  2701. new mxConnectionConstraint(new mxPoint(0, 1/3), false),
  2702. new mxConnectionConstraint(new mxPoint(0, 1), false),
  2703. new mxConnectionConstraint(new mxPoint(1, 1/3), false),
  2704. new mxConnectionConstraint(new mxPoint(1, 1), false),
  2705. new mxConnectionConstraint(new mxPoint(0.5, 0.5), false)];
  2706. ComponentShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  2707. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2708. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  2709. new mxConnectionConstraint(new mxPoint(0, 0.3), true),
  2710. new mxConnectionConstraint(new mxPoint(0, 0.7), true),
  2711. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  2712. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  2713. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  2714. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  2715. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2716. new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
  2717. mxActor.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2718. new mxConnectionConstraint(new mxPoint(0.25, 0.2), false),
  2719. new mxConnectionConstraint(new mxPoint(0.1, 0.5), false),
  2720. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  2721. new mxConnectionConstraint(new mxPoint(0.75, 0.25), false),
  2722. new mxConnectionConstraint(new mxPoint(0.9, 0.5), false),
  2723. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  2724. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  2725. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2726. new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
  2727. SwitchShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0), false),
  2728. new mxConnectionConstraint(new mxPoint(0.5, 0.25), false),
  2729. new mxConnectionConstraint(new mxPoint(1, 0), false),
  2730. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  2731. new mxConnectionConstraint(new mxPoint(0.75, 0.5), false),
  2732. new mxConnectionConstraint(new mxPoint(0, 1), false),
  2733. new mxConnectionConstraint(new mxPoint(0.5, 0.75), false),
  2734. new mxConnectionConstraint(new mxPoint(1, 1), false)];
  2735. TapeShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.35), false),
  2736. new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  2737. new mxConnectionConstraint(new mxPoint(0, 0.65), false),
  2738. new mxConnectionConstraint(new mxPoint(1, 0.35), false),
  2739. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  2740. new mxConnectionConstraint(new mxPoint(1, 0.65), false),
  2741. new mxConnectionConstraint(new mxPoint(0.25, 1), false),
  2742. new mxConnectionConstraint(new mxPoint(0.75, 0), false)];
  2743. // TODO: Relative ports
  2744. StepShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  2745. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2746. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  2747. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  2748. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2749. new mxConnectionConstraint(new mxPoint(0.75, 1), true),
  2750. new mxConnectionConstraint(new mxPoint(0.1, 0.25), false),
  2751. new mxConnectionConstraint(new mxPoint(0.2, 0.5), false),
  2752. new mxConnectionConstraint(new mxPoint(0.1, 0.75), false),
  2753. new mxConnectionConstraint(new mxPoint(0.9, 0.25), false),
  2754. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  2755. new mxConnectionConstraint(new mxPoint(0.9, 0.75), false)];
  2756. mxLine.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  2757. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  2758. new mxConnectionConstraint(new mxPoint(0.75, 0.5), false),
  2759. new mxConnectionConstraint(new mxPoint(1, 0.5), false)];
  2760. LollipopShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.5, 0), false),
  2761. new mxConnectionConstraint(new mxPoint(0.5, 1), false)];
  2762. mxDoubleEllipse.prototype.constraints = mxEllipse.prototype.constraints;
  2763. mxRhombus.prototype.constraints = mxEllipse.prototype.constraints;
  2764. mxTriangle.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  2765. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  2766. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  2767. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2768. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2769. new mxConnectionConstraint(new mxPoint(1, 0.5), true)];
  2770. mxHexagon.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.375, 0), true),
  2771. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2772. new mxConnectionConstraint(new mxPoint(0.625, 0), true),
  2773. new mxConnectionConstraint(new mxPoint(0.125, 0.25), false),
  2774. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  2775. new mxConnectionConstraint(new mxPoint(0.125, 0.75), false),
  2776. new mxConnectionConstraint(new mxPoint(0.875, 0.25), false),
  2777. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  2778. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  2779. new mxConnectionConstraint(new mxPoint(0.875, 0.75), false),
  2780. new mxConnectionConstraint(new mxPoint(0.375, 1), true),
  2781. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  2782. new mxConnectionConstraint(new mxPoint(0.625, 1), true)];
  2783. mxCloud.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0.25), false),
  2784. new mxConnectionConstraint(new mxPoint(0.4, 0.1), false),
  2785. new mxConnectionConstraint(new mxPoint(0.16, 0.55), false),
  2786. new mxConnectionConstraint(new mxPoint(0.07, 0.4), false),
  2787. new mxConnectionConstraint(new mxPoint(0.31, 0.8), false),
  2788. new mxConnectionConstraint(new mxPoint(0.13, 0.77), false),
  2789. new mxConnectionConstraint(new mxPoint(0.8, 0.8), false),
  2790. new mxConnectionConstraint(new mxPoint(0.55, 0.95), false),
  2791. new mxConnectionConstraint(new mxPoint(0.875, 0.5), false),
  2792. new mxConnectionConstraint(new mxPoint(0.96, 0.7), false),
  2793. new mxConnectionConstraint(new mxPoint(0.625, 0.2), false),
  2794. new mxConnectionConstraint(new mxPoint(0.88, 0.25), false)];
  2795. ParallelogramShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2796. TrapezoidShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  2797. DocumentShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  2798. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  2799. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  2800. new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  2801. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  2802. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  2803. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  2804. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  2805. new mxConnectionConstraint(new mxPoint(1, 0.75), true)];
  2806. mxArrow.prototype.constraints = null;
  2807. TeeShape.prototype.constraints = null;
  2808. CornerShape.prototype.constraints = null;
  2809. SingleArrowShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  2810. new mxConnectionConstraint(new mxPoint(1, 0.5), false)];
  2811. DoubleArrowShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  2812. new mxConnectionConstraint(new mxPoint(1, 0.5), false)];
  2813. CrossShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  2814. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  2815. new mxConnectionConstraint(new mxPoint(0.5, 0), false),
  2816. new mxConnectionConstraint(new mxPoint(0.5, 1), false)];
  2817. UmlLifeline.prototype.constraints = null;
  2818. OrShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.25), false),
  2819. new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  2820. new mxConnectionConstraint(new mxPoint(0, 0.75), false),
  2821. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  2822. new mxConnectionConstraint(new mxPoint(0.7, 0.1), false),
  2823. new mxConnectionConstraint(new mxPoint(0.7, 0.9), false)];
  2824. XorShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.175, 0.25), false),
  2825. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  2826. new mxConnectionConstraint(new mxPoint(0.175, 0.75), false),
  2827. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  2828. new mxConnectionConstraint(new mxPoint(0.7, 0.1), false),
  2829. new mxConnectionConstraint(new mxPoint(0.7, 0.9), false)];
  2830. })();