Shapes.js 167 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310
  1. /**
  2. * Copyright (c) 2006-2015, JGraph Ltd
  3. */
  4. /**
  5. * Registers shapes.
  6. */
  7. (function()
  8. {
  9. // LATER: Use this to implement striping
  10. function paintTableBackground(state, c, x, y, w, h, r)
  11. {
  12. if (state != null)
  13. {
  14. var graph = state.view.graph;
  15. var start = graph.getActualStartSize(state.cell);
  16. var rows = graph.model.getChildCells(state.cell, true);
  17. if (rows.length > 0)
  18. {
  19. var events = false;
  20. if (this.style != null)
  21. {
  22. events = mxUtils.getValue(this.style, mxConstants.STYLE_POINTER_EVENTS, '1') == '1';
  23. }
  24. if (!events)
  25. {
  26. c.pointerEvents = false;
  27. }
  28. var evenRowColor = mxUtils.getValue(state.style,
  29. 'evenRowColor', mxConstants.NONE);
  30. var oddRowColor = mxUtils.getValue(state.style,
  31. 'oddRowColor', mxConstants.NONE);
  32. var evenColColor = mxUtils.getValue(state.style,
  33. 'evenColumnColor', mxConstants.NONE);
  34. var oddColColor = mxUtils.getValue(state.style,
  35. 'oddColumnColor', mxConstants.NONE);
  36. var cols = graph.model.getChildCells(rows[0], true);
  37. // Paints column backgrounds
  38. for (var i = 0; i < cols.length; i++)
  39. {
  40. var clr = (mxUtils.mod(i, 2) == 1) ? evenColColor : oddColColor;
  41. var geo = graph.getCellGeometry(cols[i]);
  42. if (geo != null && clr != mxConstants.NONE)
  43. {
  44. c.setFillColor(clr);
  45. c.begin();
  46. c.moveTo(x + geo.x, y + start.y);
  47. if (r > 0 && i == cols.length - 1)
  48. {
  49. c.lineTo(x + geo.x + geo.width - r, y);
  50. c.quadTo(x + geo.x + geo.width, y, x + geo.x + geo.width, y + r);
  51. c.lineTo(x + geo.x + geo.width, y + h - r);
  52. c.quadTo(x + geo.x + geo.width, y + h, x + geo.x + geo.width - r, y + h);
  53. }
  54. else
  55. {
  56. c.lineTo(x + geo.x + geo.width, y + start.y);
  57. c.lineTo(x + geo.x + geo.width, y + h - start.height);
  58. }
  59. c.lineTo(x + geo.x, y + h);
  60. c.close();
  61. c.fill();
  62. }
  63. }
  64. // Paints row backgrounds
  65. for (var i = 0; i < rows.length; i++)
  66. {
  67. var clr = (mxUtils.mod(i, 2) == 1) ? evenRowColor : oddRowColor;
  68. var geo = graph.getCellGeometry(rows[i]);
  69. if (geo != null && clr != mxConstants.NONE)
  70. {
  71. var b = (i == rows.length - 1) ? y + h : y + geo.y + geo.height;
  72. c.setFillColor(clr);
  73. c.begin();
  74. c.moveTo(x + start.x, y + geo.y);
  75. c.lineTo(x + w - start.width, y + geo.y);
  76. if (r > 0 && i == rows.length - 1)
  77. {
  78. c.lineTo(x + w, b - r);
  79. c.quadTo(x + w, b, x + w - r, b);
  80. c.lineTo(x + r, b);
  81. c.quadTo(x, b, x, b - r);
  82. }
  83. else
  84. {
  85. c.lineTo(x + w - start.width, b);
  86. c.lineTo(x + start.x, b);
  87. }
  88. c.close();
  89. c.fill();
  90. }
  91. }
  92. }
  93. }
  94. };
  95. // Table Shape
  96. function TableShape()
  97. {
  98. mxSwimlane.call(this);
  99. };
  100. mxUtils.extend(TableShape, mxSwimlane);
  101. TableShape.prototype.getLabelBounds = function(rect)
  102. {
  103. var start = this.getTitleSize();
  104. if (start == 0)
  105. {
  106. return mxShape.prototype.getLabelBounds.apply(this, arguments);
  107. }
  108. else
  109. {
  110. return mxSwimlane.prototype.getLabelBounds.apply(this, arguments);
  111. }
  112. };
  113. TableShape.prototype.paintVertexShape = function(c, x, y, w, h)
  114. {
  115. // LATER: Split background to add striping
  116. //paintTableBackground(this.state, c, x, y, w, h);
  117. var start = this.getTitleSize();
  118. if (start == 0)
  119. {
  120. mxRectangleShape.prototype.paintBackground.apply(this, arguments);
  121. }
  122. else
  123. {
  124. mxSwimlane.prototype.paintVertexShape.apply(this, arguments);
  125. c.translate(-x, -y);
  126. }
  127. this.paintForeground(c, x, y, w, h);
  128. };
  129. TableShape.prototype.paintForeground = function(c, x, y, w, h)
  130. {
  131. if (this.state != null)
  132. {
  133. var flipH = this.flipH;
  134. var flipV = this.flipV;
  135. if (this.direction == mxConstants.DIRECTION_NORTH || this.direction == mxConstants.DIRECTION_SOUTH)
  136. {
  137. var tmp = flipH;
  138. flipH = flipV;
  139. flipV = tmp;
  140. }
  141. // Negative transform to avoid save/restore
  142. c.rotate(-this.getShapeRotation(), flipH, flipV, x + w / 2, y + h / 2);
  143. s = this.scale;
  144. x = this.bounds.x / s;
  145. y = this.bounds.y / s;
  146. w = this.bounds.width / s;
  147. h = this.bounds.height / s;
  148. this.paintTableForeground(c, x, y, w, h);
  149. }
  150. };
  151. TableShape.prototype.paintTableForeground = function(c, x, y, w, h)
  152. {
  153. var graph = this.state.view.graph;
  154. var start = graph.getActualStartSize(this.state.cell);
  155. var rows = graph.model.getChildCells(this.state.cell, true);
  156. if (rows.length > 0)
  157. {
  158. var rowLines = mxUtils.getValue(this.state.style,
  159. 'rowLines', '1') != '0';
  160. var columnLines = mxUtils.getValue(this.state.style,
  161. 'columnLines', '1') != '0';
  162. // Paints row lines
  163. if (rowLines)
  164. {
  165. for (var i = 1; i < rows.length; i++)
  166. {
  167. var geo = graph.getCellGeometry(rows[i]);
  168. if (geo != null)
  169. {
  170. c.begin();
  171. c.moveTo(x + start.x, y + geo.y);
  172. c.lineTo(x + w - start.width, y + geo.y);
  173. c.end();
  174. c.stroke();
  175. }
  176. }
  177. }
  178. if (columnLines)
  179. {
  180. var cols = graph.model.getChildCells(rows[0], true);
  181. // Paints column lines
  182. for (var i = 1; i < cols.length; i++)
  183. {
  184. var geo = graph.getCellGeometry(cols[i]);
  185. if (geo != null)
  186. {
  187. c.begin();
  188. c.moveTo(x + geo.x + start.x, y + start.y);
  189. c.lineTo(x + geo.x + start.x, y + h - start.height);
  190. c.end();
  191. c.stroke();
  192. }
  193. }
  194. }
  195. }
  196. };
  197. mxCellRenderer.registerShape('table', TableShape);
  198. // Cube Shape, supports size style
  199. function CubeShape()
  200. {
  201. mxCylinder.call(this);
  202. };
  203. mxUtils.extend(CubeShape, mxCylinder);
  204. CubeShape.prototype.size = 20;
  205. CubeShape.prototype.darkOpacity = 0;
  206. CubeShape.prototype.darkOpacity2 = 0;
  207. CubeShape.prototype.paintVertexShape = function(c, x, y, w, h)
  208. {
  209. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  210. var op = Math.max(-1, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'darkOpacity', this.darkOpacity))));
  211. var op2 = Math.max(-1, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'darkOpacity2', this.darkOpacity2))));
  212. c.translate(x, y);
  213. c.begin();
  214. c.moveTo(0, 0);
  215. c.lineTo(w - s, 0);
  216. c.lineTo(w, s);
  217. c.lineTo(w, h);
  218. c.lineTo(s, h);
  219. c.lineTo(0, h - s);
  220. c.lineTo(0, 0);
  221. c.close();
  222. c.end();
  223. c.fillAndStroke();
  224. if (!this.outline)
  225. {
  226. c.setShadow(false);
  227. if (op != 0)
  228. {
  229. c.setFillAlpha(Math.abs(op));
  230. c.setFillColor((op < 0) ? '#FFFFFF' : '#000000');
  231. c.begin();
  232. c.moveTo(0, 0);
  233. c.lineTo(w - s, 0);
  234. c.lineTo(w, s);
  235. c.lineTo(s, s);
  236. c.close();
  237. c.fill();
  238. }
  239. if (op2 != 0)
  240. {
  241. c.setFillAlpha(Math.abs(op2));
  242. c.setFillColor((op2 < 0) ? '#FFFFFF' : '#000000');
  243. c.begin();
  244. c.moveTo(0, 0);
  245. c.lineTo(s, s);
  246. c.lineTo(s, h);
  247. c.lineTo(0, h - s);
  248. c.close();
  249. c.fill();
  250. }
  251. c.begin();
  252. c.moveTo(s, h);
  253. c.lineTo(s, s);
  254. c.lineTo(0, 0);
  255. c.moveTo(s, s);
  256. c.lineTo(w, s);
  257. c.end();
  258. c.stroke();
  259. }
  260. };
  261. CubeShape.prototype.getLabelMargins = function(rect)
  262. {
  263. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  264. {
  265. var s = parseFloat(mxUtils.getValue(this.style, 'size', this.size)) * this.scale;
  266. return new mxRectangle(s, s, 0, 0);
  267. }
  268. return null;
  269. };
  270. mxCellRenderer.registerShape('cube', CubeShape);
  271. var tan30 = Math.tan(mxUtils.toRadians(30));
  272. var tan30Dx = (0.5 - tan30) / 2;
  273. // Cube Shape, supports size style
  274. function IsoRectangleShape()
  275. {
  276. mxActor.call(this);
  277. };
  278. mxUtils.extend(IsoRectangleShape, mxActor);
  279. IsoRectangleShape.prototype.size = 20;
  280. IsoRectangleShape.prototype.redrawPath = function(path, x, y, w, h)
  281. {
  282. var m = Math.min(w, h / tan30);
  283. path.translate((w - m) / 2, (h - m) / 2 + m / 4);
  284. path.moveTo(0, 0.25 * m);
  285. path.lineTo(0.5 * m, m * tan30Dx);
  286. path.lineTo(m, 0.25 * m);
  287. path.lineTo(0.5 * m, (0.5 - tan30Dx) * m);
  288. path.lineTo(0, 0.25 * m);
  289. path.close();
  290. path.end();
  291. };
  292. mxCellRenderer.registerShape('isoRectangle', IsoRectangleShape);
  293. // Cube Shape, supports size style
  294. function IsoCubeShape()
  295. {
  296. mxCylinder.call(this);
  297. };
  298. mxUtils.extend(IsoCubeShape, mxCylinder);
  299. IsoCubeShape.prototype.size = 20;
  300. IsoCubeShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  301. {
  302. var m = Math.min(w, h / (0.5 + tan30));
  303. if (isForeground)
  304. {
  305. path.moveTo(0, 0.25 * m);
  306. path.lineTo(0.5 * m, (0.5 - tan30Dx) * m);
  307. path.lineTo(m, 0.25 * m);
  308. path.moveTo(0.5 * m, (0.5 - tan30Dx) * m);
  309. path.lineTo(0.5 * m, (1 - tan30Dx) * m);
  310. path.end();
  311. }
  312. else
  313. {
  314. path.translate((w - m) / 2, (h - m) / 2);
  315. path.moveTo(0, 0.25 * m);
  316. path.lineTo(0.5 * m, m * tan30Dx);
  317. path.lineTo(m, 0.25 * m);
  318. path.lineTo(m, 0.75 * m);
  319. path.lineTo(0.5 * m, (1 - tan30Dx) * m);
  320. path.lineTo(0, 0.75 * m);
  321. path.close();
  322. path.end();
  323. }
  324. };
  325. mxCellRenderer.registerShape('isoCube', IsoCubeShape);
  326. // DataStore Shape, supports size style
  327. function DataStoreShape()
  328. {
  329. mxCylinder.call(this);
  330. };
  331. mxUtils.extend(DataStoreShape, mxCylinder);
  332. DataStoreShape.prototype.redrawPath = function(c, x, y, w, h, isForeground)
  333. {
  334. var dy = Math.min(h / 2, Math.round(h / 8) + this.strokewidth - 1);
  335. if ((isForeground && this.fill != null) || (!isForeground && this.fill == null))
  336. {
  337. c.moveTo(0, dy);
  338. c.curveTo(0, 2 * dy, w, 2 * dy, w, dy);
  339. // Needs separate shapes for correct hit-detection
  340. if (!isForeground)
  341. {
  342. c.stroke();
  343. c.begin();
  344. }
  345. c.translate(0, dy / 2);
  346. c.moveTo(0, dy);
  347. c.curveTo(0, 2 * dy, w, 2 * dy, w, dy);
  348. // Needs separate shapes for correct hit-detection
  349. if (!isForeground)
  350. {
  351. c.stroke();
  352. c.begin();
  353. }
  354. c.translate(0, dy / 2);
  355. c.moveTo(0, dy);
  356. c.curveTo(0, 2 * dy, w, 2 * dy, w, dy);
  357. // Needs separate shapes for correct hit-detection
  358. if (!isForeground)
  359. {
  360. c.stroke();
  361. c.begin();
  362. }
  363. c.translate(0, -dy);
  364. }
  365. if (!isForeground)
  366. {
  367. c.moveTo(0, dy);
  368. c.curveTo(0, -dy / 3, w, -dy / 3, w, dy);
  369. c.lineTo(w, h - dy);
  370. c.curveTo(w, h + dy / 3, 0, h + dy / 3, 0, h - dy);
  371. c.close();
  372. }
  373. };
  374. DataStoreShape.prototype.getLabelMargins = function(rect)
  375. {
  376. return new mxRectangle(0, 2.5 * Math.min(rect.height / 2,
  377. Math.round(rect.height / 8) + this.strokewidth - 1), 0, 0);
  378. }
  379. mxCellRenderer.registerShape('datastore', DataStoreShape);
  380. // Note Shape, supports size style
  381. function NoteShape()
  382. {
  383. mxCylinder.call(this);
  384. };
  385. mxUtils.extend(NoteShape, mxCylinder);
  386. NoteShape.prototype.size = 30;
  387. NoteShape.prototype.darkOpacity = 0;
  388. NoteShape.prototype.paintVertexShape = function(c, x, y, w, h)
  389. {
  390. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  391. var op = Math.max(-1, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'darkOpacity', this.darkOpacity))));
  392. c.translate(x, y);
  393. c.begin();
  394. c.moveTo(0, 0);
  395. c.lineTo(w - s, 0);
  396. c.lineTo(w, s);
  397. c.lineTo(w, h);
  398. c.lineTo(0, h);
  399. c.lineTo(0, 0);
  400. c.close();
  401. c.end();
  402. c.fillAndStroke();
  403. if (!this.outline)
  404. {
  405. c.setShadow(false);
  406. if (op != 0)
  407. {
  408. c.setFillAlpha(Math.abs(op));
  409. c.setFillColor((op < 0) ? '#FFFFFF' : '#000000');
  410. c.begin();
  411. c.moveTo(w - s, 0);
  412. c.lineTo(w - s, s);
  413. c.lineTo(w, s);
  414. c.close();
  415. c.fill();
  416. }
  417. c.begin();
  418. c.moveTo(w - s, 0);
  419. c.lineTo(w - s, s);
  420. c.lineTo(w, s);
  421. c.end();
  422. c.stroke();
  423. }
  424. };
  425. mxCellRenderer.registerShape('note', NoteShape);
  426. // Note Shape, supports size style
  427. function NoteShape2()
  428. {
  429. NoteShape.call(this);
  430. };
  431. mxUtils.extend(NoteShape2, NoteShape);
  432. mxCellRenderer.registerShape('note2', NoteShape2);
  433. // Flexible cube Shape
  434. function IsoCubeShape2()
  435. {
  436. mxShape.call(this);
  437. };
  438. mxUtils.extend(IsoCubeShape2, mxShape);
  439. IsoCubeShape2.prototype.isoAngle = 15;
  440. IsoCubeShape2.prototype.paintVertexShape = function(c, x, y, w, h)
  441. {
  442. var isoAngle = Math.max(0.01, Math.min(94, parseFloat(mxUtils.getValue(this.style, 'isoAngle', this.isoAngle)))) * Math.PI / 200 ;
  443. var isoH = Math.min(w * Math.tan(isoAngle), h * 0.5);
  444. c.translate(x,y);
  445. c.begin();
  446. c.moveTo(w * 0.5, 0);
  447. c.lineTo(w, isoH);
  448. c.lineTo(w, h - isoH);
  449. c.lineTo(w * 0.5, h);
  450. c.lineTo(0, h - isoH);
  451. c.lineTo(0, isoH);
  452. c.close();
  453. c.fillAndStroke();
  454. c.setShadow(false);
  455. c.begin();
  456. c.moveTo(0, isoH);
  457. c.lineTo(w * 0.5, 2 * isoH);
  458. c.lineTo(w, isoH);
  459. c.moveTo(w * 0.5, 2 * isoH);
  460. c.lineTo(w * 0.5, h);
  461. c.stroke();
  462. };
  463. mxCellRenderer.registerShape('isoCube2', IsoCubeShape2);
  464. // (LEGACY) Flexible cylinder Shape
  465. function CylinderShape()
  466. {
  467. mxShape.call(this);
  468. };
  469. mxUtils.extend(CylinderShape, mxShape);
  470. CylinderShape.prototype.size = 15;
  471. CylinderShape.prototype.paintVertexShape = function(c, x, y, w, h)
  472. {
  473. var size = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  474. c.translate(x,y);
  475. if (size == 0)
  476. {
  477. c.rect(0, 0, w, h);
  478. c.fillAndStroke();
  479. }
  480. else
  481. {
  482. c.begin();
  483. c.moveTo(0, size);
  484. c.arcTo(w * 0.5, size, 0, 0, 1, w * 0.5, 0);
  485. c.arcTo(w * 0.5, size, 0, 0, 1, w, size);
  486. c.lineTo(w, h - size);
  487. c.arcTo(w * 0.5, size, 0, 0, 1, w * 0.5, h);
  488. c.arcTo(w * 0.5, size, 0, 0, 1, 0, h - size);
  489. c.close();
  490. c.fillAndStroke();
  491. c.setShadow(false);
  492. c.begin();
  493. c.moveTo(w, size);
  494. c.arcTo(w * 0.5, size, 0, 0, 1, w * 0.5, 2 * size);
  495. c.arcTo(w * 0.5, size, 0, 0, 1, 0, size);
  496. c.stroke();
  497. }
  498. };
  499. mxCellRenderer.registerShape('cylinder2', CylinderShape);
  500. // Flexible cylinder3 Shape with offset label
  501. function CylinderShape3(bounds, fill, stroke, strokewidth)
  502. {
  503. mxShape.call(this);
  504. this.bounds = bounds;
  505. this.fill = fill;
  506. this.stroke = stroke;
  507. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  508. };
  509. mxUtils.extend(CylinderShape3, mxCylinder);
  510. CylinderShape3.prototype.size = 15;
  511. CylinderShape3.prototype.paintVertexShape = function(c, x, y, w, h)
  512. {
  513. var size = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  514. var lid = mxUtils.getValue(this.style, 'lid', true);
  515. c.translate(x,y);
  516. if (size == 0)
  517. {
  518. c.rect(0, 0, w, h);
  519. c.fillAndStroke();
  520. }
  521. else
  522. {
  523. c.begin();
  524. if (lid)
  525. {
  526. c.moveTo(0, size);
  527. c.arcTo(w * 0.5, size, 0, 0, 1, w * 0.5, 0);
  528. c.arcTo(w * 0.5, size, 0, 0, 1, w, size);
  529. }
  530. else
  531. {
  532. c.moveTo(0, 0);
  533. c.arcTo(w * 0.5, size, 0, 0, 0, w * 0.5, size);
  534. c.arcTo(w * 0.5, size, 0, 0, 0, w, 0);
  535. }
  536. c.lineTo(w, h - size);
  537. c.arcTo(w * 0.5, size, 0, 0, 1, w * 0.5, h);
  538. c.arcTo(w * 0.5, size, 0, 0, 1, 0, h - size);
  539. c.close();
  540. c.fillAndStroke();
  541. c.setShadow(false);
  542. if (lid)
  543. {
  544. c.begin();
  545. c.moveTo(w, size);
  546. c.arcTo(w * 0.5, size, 0, 0, 1, w * 0.5, 2 * size);
  547. c.arcTo(w * 0.5, size, 0, 0, 1, 0, size);
  548. c.stroke();
  549. }
  550. }
  551. };
  552. mxCellRenderer.registerShape('cylinder3', CylinderShape3);
  553. // Switch Shape, supports size style
  554. function SwitchShape()
  555. {
  556. mxActor.call(this);
  557. };
  558. mxUtils.extend(SwitchShape, mxActor);
  559. SwitchShape.prototype.redrawPath = function(c, x, y, w, h)
  560. {
  561. var curve = 0.5;
  562. c.moveTo(0, 0);
  563. c.quadTo(w / 2, h * curve, w, 0);
  564. c.quadTo(w * (1 - curve), h / 2, w, h);
  565. c.quadTo(w / 2, h * (1 - curve), 0, h);
  566. c.quadTo(w * curve, h / 2, 0, 0);
  567. c.end();
  568. };
  569. mxCellRenderer.registerShape('switch', SwitchShape);
  570. // Folder Shape, supports tabWidth, tabHeight styles
  571. function FolderShape()
  572. {
  573. mxCylinder.call(this);
  574. };
  575. mxUtils.extend(FolderShape, mxCylinder);
  576. FolderShape.prototype.tabWidth = 60;
  577. FolderShape.prototype.tabHeight = 20;
  578. FolderShape.prototype.tabPosition = 'right';
  579. FolderShape.prototype.arcSize = 0.1;
  580. FolderShape.prototype.paintVertexShape = function(c, x, y, w, h)
  581. {
  582. c.translate(x, y);
  583. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'tabWidth', this.tabWidth))));
  584. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'tabHeight', this.tabHeight))));
  585. var tp = mxUtils.getValue(this.style, 'tabPosition', this.tabPosition);
  586. var rounded = mxUtils.getValue(this.style, 'rounded', false);
  587. var absArcSize = mxUtils.getValue(this.style, 'absoluteArcSize', false);
  588. var arcSize = parseFloat(mxUtils.getValue(this.style, 'arcSize', this.arcSize));
  589. if (!absArcSize)
  590. {
  591. arcSize = Math.min(w, h) * arcSize;
  592. }
  593. arcSize = Math.min(arcSize, w * 0.5, (h - dy) * 0.5);
  594. dx = Math.max(dx, arcSize);
  595. dx = Math.min(w - arcSize, dx);
  596. if (!rounded)
  597. {
  598. arcSize = 0;
  599. }
  600. c.begin();
  601. if (tp == 'left')
  602. {
  603. c.moveTo(Math.max(arcSize, 0), dy);
  604. c.lineTo(Math.max(arcSize, 0), 0);
  605. c.lineTo(dx, 0);
  606. c.lineTo(dx, dy);
  607. }
  608. // Right is default
  609. else
  610. {
  611. c.moveTo(w - dx, dy);
  612. c.lineTo(w - dx, 0);
  613. c.lineTo(w - Math.max(arcSize, 0), 0);
  614. c.lineTo(w - Math.max(arcSize, 0), dy);
  615. }
  616. if (rounded)
  617. {
  618. c.moveTo(0, arcSize + dy);
  619. c.arcTo(arcSize, arcSize, 0, 0, 1, arcSize, dy);
  620. c.lineTo(w - arcSize, dy);
  621. c.arcTo(arcSize, arcSize, 0, 0, 1, w, arcSize + dy);
  622. c.lineTo(w, h - arcSize);
  623. c.arcTo(arcSize, arcSize, 0, 0, 1, w - arcSize, h);
  624. c.lineTo(arcSize, h);
  625. c.arcTo(arcSize, arcSize, 0, 0, 1, 0, h - arcSize);
  626. }
  627. else
  628. {
  629. c.moveTo(0, dy);
  630. c.lineTo(w, dy);
  631. c.lineTo(w, h);
  632. c.lineTo(0, h);
  633. }
  634. c.close();
  635. c.fillAndStroke();
  636. c.setShadow(false);
  637. var sym = mxUtils.getValue(this.style, 'folderSymbol', null);
  638. if (sym == 'triangle')
  639. {
  640. c.begin();
  641. c.moveTo(w - 30, dy + 20);
  642. c.lineTo(w - 20, dy + 10);
  643. c.lineTo(w - 10, dy + 20);
  644. c.close();
  645. c.stroke();
  646. }
  647. };
  648. mxCellRenderer.registerShape('folder', FolderShape);
  649. // Folder Shape, supports tabWidth, tabHeight styles
  650. function UMLStateShape()
  651. {
  652. mxCylinder.call(this);
  653. };
  654. mxUtils.extend(UMLStateShape, mxCylinder);
  655. UMLStateShape.prototype.arcSize = 0.1;
  656. UMLStateShape.prototype.paintVertexShape = function(c, x, y, w, h)
  657. {
  658. c.translate(x, y);
  659. // var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'tabWidth', this.tabWidth))));
  660. // var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'tabHeight', this.tabHeight))));
  661. // var tp = mxUtils.getValue(this.style, 'tabPosition', this.tabPosition);
  662. var rounded = mxUtils.getValue(this.style, 'rounded', false);
  663. var absArcSize = mxUtils.getValue(this.style, 'absoluteArcSize', false);
  664. var arcSize = parseFloat(mxUtils.getValue(this.style, 'arcSize', this.arcSize));
  665. var connPoint = mxUtils.getValue(this.style, 'umlStateConnection', null);
  666. if (!absArcSize)
  667. {
  668. arcSize = Math.min(w, h) * arcSize;
  669. }
  670. arcSize = Math.min(arcSize, w * 0.5, h * 0.5);
  671. if (!rounded)
  672. {
  673. arcSize = 0;
  674. }
  675. var dx = 0;
  676. if (connPoint != null)
  677. {
  678. dx = 10;
  679. }
  680. c.begin();
  681. c.moveTo(dx, arcSize);
  682. c.arcTo(arcSize, arcSize, 0, 0, 1, dx + arcSize, 0);
  683. c.lineTo(w - arcSize, 0);
  684. c.arcTo(arcSize, arcSize, 0, 0, 1, w, arcSize);
  685. c.lineTo(w, h - arcSize);
  686. c.arcTo(arcSize, arcSize, 0, 0, 1, w - arcSize, h);
  687. c.lineTo(dx + arcSize, h);
  688. c.arcTo(arcSize, arcSize, 0, 0, 1, dx, h - arcSize);
  689. c.close();
  690. c.fillAndStroke();
  691. c.setShadow(false);
  692. var sym = mxUtils.getValue(this.style, 'umlStateSymbol', null);
  693. if (sym == 'collapseState')
  694. {
  695. c.roundrect(w - 40, h - 20, 10, 10, 3, 3);
  696. c.stroke();
  697. c.roundrect(w - 20, h - 20, 10, 10, 3, 3);
  698. c.stroke();
  699. c.begin();
  700. c.moveTo(w - 30, h - 15);
  701. c.lineTo(w - 20, h - 15);
  702. c.stroke();
  703. }
  704. if (connPoint == 'connPointRefEntry')
  705. {
  706. c.ellipse(0, h * 0.5 - 10, 20, 20);
  707. c.fillAndStroke();
  708. }
  709. else if (connPoint == 'connPointRefExit')
  710. {
  711. c.ellipse(0, h * 0.5 - 10, 20, 20);
  712. c.fillAndStroke();
  713. c.begin();
  714. c.moveTo(5, h * 0.5 - 5);
  715. c.lineTo(15, h * 0.5 + 5);
  716. c.moveTo(15, h * 0.5 - 5);
  717. c.lineTo(5, h * 0.5 + 5);
  718. c.stroke();
  719. }
  720. };
  721. mxCellRenderer.registerShape('umlState', UMLStateShape);
  722. // Card shape
  723. function CardShape()
  724. {
  725. mxActor.call(this);
  726. };
  727. mxUtils.extend(CardShape, mxActor);
  728. CardShape.prototype.size = 30;
  729. CardShape.prototype.isRoundable = function()
  730. {
  731. return true;
  732. };
  733. CardShape.prototype.redrawPath = function(c, x, y, w, h)
  734. {
  735. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  736. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  737. this.addPoints(c, [new mxPoint(s, 0), new mxPoint(w, 0), new mxPoint(w, h), new mxPoint(0, h), new mxPoint(0, s)],
  738. this.isRounded, arcSize, true);
  739. c.end();
  740. };
  741. mxCellRenderer.registerShape('card', CardShape);
  742. // Tape shape
  743. function TapeShape()
  744. {
  745. mxActor.call(this);
  746. };
  747. mxUtils.extend(TapeShape, mxActor);
  748. TapeShape.prototype.size = 0.4;
  749. TapeShape.prototype.redrawPath = function(c, x, y, w, h)
  750. {
  751. var dy = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  752. var fy = 1.4;
  753. c.moveTo(0, dy / 2);
  754. c.quadTo(w / 4, dy * fy, w / 2, dy / 2);
  755. c.quadTo(w * 3 / 4, dy * (1 - fy), w, dy / 2);
  756. c.lineTo(w, h - dy / 2);
  757. c.quadTo(w * 3 / 4, h - dy * fy, w / 2, h - dy / 2);
  758. c.quadTo(w / 4, h - dy * (1 - fy), 0, h - dy / 2);
  759. c.lineTo(0, dy / 2);
  760. c.close();
  761. c.end();
  762. };
  763. TapeShape.prototype.getLabelBounds = function(rect)
  764. {
  765. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  766. {
  767. var size = mxUtils.getValue(this.style, 'size', this.size);
  768. var w = rect.width;
  769. var h = rect.height;
  770. if (this.direction == null ||
  771. this.direction == mxConstants.DIRECTION_EAST ||
  772. this.direction == mxConstants.DIRECTION_WEST)
  773. {
  774. var dy = h * size;
  775. return new mxRectangle(rect.x, rect.y + dy, w, h - 2 * dy);
  776. }
  777. else
  778. {
  779. var dx = w * size;
  780. return new mxRectangle(rect.x + dx, rect.y, w - 2 * dx, h);
  781. }
  782. }
  783. return rect;
  784. };
  785. mxCellRenderer.registerShape('tape', TapeShape);
  786. // Document shape
  787. function DocumentShape()
  788. {
  789. mxActor.call(this);
  790. };
  791. mxUtils.extend(DocumentShape, mxActor);
  792. DocumentShape.prototype.size = 0.3;
  793. DocumentShape.prototype.getLabelMargins = function(rect)
  794. {
  795. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  796. {
  797. return new mxRectangle(0, 0, 0, parseFloat(mxUtils.getValue(
  798. this.style, 'size', this.size)) * rect.height);
  799. }
  800. return null;
  801. };
  802. DocumentShape.prototype.redrawPath = function(c, x, y, w, h)
  803. {
  804. var dy = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  805. var fy = 1.4;
  806. c.moveTo(0, 0);
  807. c.lineTo(w, 0);
  808. c.lineTo(w, h - dy / 2);
  809. c.quadTo(w * 3 / 4, h - dy * fy, w / 2, h - dy / 2);
  810. c.quadTo(w / 4, h - dy * (1 - fy), 0, h - dy / 2);
  811. c.lineTo(0, dy / 2);
  812. c.close();
  813. c.end();
  814. };
  815. mxCellRenderer.registerShape('document', DocumentShape);
  816. var cylinderGetCylinderSize = mxCylinder.prototype.getCylinderSize;
  817. mxCylinder.prototype.getCylinderSize = function(x, y, w, h)
  818. {
  819. var size = mxUtils.getValue(this.style, 'size');
  820. if (size != null)
  821. {
  822. return h * Math.max(0, Math.min(1, size));
  823. }
  824. else
  825. {
  826. return cylinderGetCylinderSize.apply(this, arguments);
  827. }
  828. };
  829. mxCylinder.prototype.getLabelMargins = function(rect)
  830. {
  831. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  832. {
  833. var size = mxUtils.getValue(this.style, 'size', 0.15) * 2;
  834. return new mxRectangle(0, Math.min(this.maxHeight * this.scale, rect.height * size), 0, 0);
  835. }
  836. return null;
  837. };
  838. CylinderShape3.prototype.getLabelMargins = function(rect)
  839. {
  840. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  841. {
  842. var size = mxUtils.getValue(this.style, 'size', 15);
  843. if (!mxUtils.getValue(this.style, 'lid', true))
  844. {
  845. size /= 2;
  846. }
  847. return new mxRectangle(0, Math.min(rect.height * this.scale, size * 2 * this.scale), 0, Math.max(0, size * 0.3 * this.scale));
  848. }
  849. return null;
  850. };
  851. FolderShape.prototype.getLabelMargins = function(rect)
  852. {
  853. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  854. {
  855. var sizeY = mxUtils.getValue(this.style, 'tabHeight', 15) * this.scale;
  856. if (mxUtils.getValue(this.style, 'labelInHeader', false))
  857. {
  858. var sizeX = mxUtils.getValue(this.style, 'tabWidth', 15) * this.scale;
  859. var sizeY = mxUtils.getValue(this.style, 'tabHeight', 15) * this.scale;
  860. var rounded = mxUtils.getValue(this.style, 'rounded', false);
  861. var absArcSize = mxUtils.getValue(this.style, 'absoluteArcSize', false);
  862. var arcSize = parseFloat(mxUtils.getValue(this.style, 'arcSize', this.arcSize));
  863. if (!absArcSize)
  864. {
  865. arcSize = Math.min(rect.width, rect.height) * arcSize;
  866. }
  867. arcSize = Math.min(arcSize, rect.width * 0.5, (rect.height - sizeY) * 0.5);
  868. if (!rounded)
  869. {
  870. arcSize = 0;
  871. }
  872. if (mxUtils.getValue(this.style, 'tabPosition', this.tabPosition) == 'left')
  873. {
  874. return new mxRectangle(arcSize, 0, Math.min(rect.width, rect.width - sizeX), Math.min(rect.height, rect.height - sizeY));
  875. }
  876. else
  877. {
  878. return new mxRectangle(Math.min(rect.width, rect.width - sizeX), 0, arcSize, Math.min(rect.height, rect.height - sizeY));
  879. }
  880. }
  881. else
  882. {
  883. return new mxRectangle(0, Math.min(rect.height, sizeY), 0, 0);
  884. }
  885. }
  886. return null;
  887. };
  888. UMLStateShape.prototype.getLabelMargins = function(rect)
  889. {
  890. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  891. {
  892. var connPoint = mxUtils.getValue(this.style, 'umlStateConnection', null);
  893. if (connPoint != null)
  894. {
  895. return new mxRectangle(10 * this.scale, 0, 0, 0);
  896. }
  897. }
  898. return null;
  899. };
  900. NoteShape2.prototype.getLabelMargins = function(rect)
  901. {
  902. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  903. {
  904. var size = mxUtils.getValue(this.style, 'size', 15);
  905. return new mxRectangle(0, Math.min(rect.height * this.scale, size * this.scale), 0, Math.max(0, size * this.scale));
  906. }
  907. return null;
  908. };
  909. // Parallelogram shape
  910. function ParallelogramShape()
  911. {
  912. mxActor.call(this);
  913. };
  914. mxUtils.extend(ParallelogramShape, mxActor);
  915. ParallelogramShape.prototype.size = 0.2;
  916. ParallelogramShape.prototype.fixedSize = 20;
  917. ParallelogramShape.prototype.isRoundable = function()
  918. {
  919. return true;
  920. };
  921. ParallelogramShape.prototype.redrawPath = function(c, x, y, w, h)
  922. {
  923. var fixed = mxUtils.getValue(this.style, 'fixedSize', '0') != '0';
  924. var dx = (fixed) ? Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'size', this.fixedSize)))) : w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  925. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  926. this.addPoints(c, [new mxPoint(0, h), new mxPoint(dx, 0), new mxPoint(w, 0), new mxPoint(w - dx, h)],
  927. this.isRounded, arcSize, true);
  928. c.end();
  929. };
  930. mxCellRenderer.registerShape('parallelogram', ParallelogramShape);
  931. // Trapezoid shape
  932. function TrapezoidShape()
  933. {
  934. mxActor.call(this);
  935. };
  936. mxUtils.extend(TrapezoidShape, mxActor);
  937. TrapezoidShape.prototype.size = 0.2;
  938. TrapezoidShape.prototype.fixedSize = 20;
  939. TrapezoidShape.prototype.isRoundable = function()
  940. {
  941. return true;
  942. };
  943. TrapezoidShape.prototype.redrawPath = function(c, x, y, w, h)
  944. {
  945. var fixed = mxUtils.getValue(this.style, 'fixedSize', '0') != '0';
  946. var dx = (fixed) ? Math.max(0, Math.min(w * 0.5, parseFloat(mxUtils.getValue(this.style, 'size', this.fixedSize)))) : w * Math.max(0, Math.min(0.5, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  947. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  948. this.addPoints(c, [new mxPoint(0, h), new mxPoint(dx, 0), new mxPoint(w - dx, 0), new mxPoint(w, h)],
  949. this.isRounded, arcSize, true);
  950. };
  951. mxCellRenderer.registerShape('trapezoid', TrapezoidShape);
  952. // Curly Bracket shape
  953. function CurlyBracketShape()
  954. {
  955. mxActor.call(this);
  956. };
  957. mxUtils.extend(CurlyBracketShape, mxActor);
  958. CurlyBracketShape.prototype.size = 0.5;
  959. CurlyBracketShape.prototype.redrawPath = function(c, x, y, w, h)
  960. {
  961. c.setFillColor(null);
  962. var s = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  963. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  964. this.addPoints(c, [new mxPoint(w, 0), new mxPoint(s, 0), new mxPoint(s, h / 2),
  965. new mxPoint(0, h / 2), new mxPoint(s, h / 2), new mxPoint(s, h),
  966. new mxPoint(w, h)], this.isRounded, arcSize, false);
  967. c.end();
  968. };
  969. mxCellRenderer.registerShape('curlyBracket', CurlyBracketShape);
  970. // Parallel marker shape
  971. function ParallelMarkerShape()
  972. {
  973. mxActor.call(this);
  974. };
  975. mxUtils.extend(ParallelMarkerShape, mxActor);
  976. ParallelMarkerShape.prototype.redrawPath = function(c, x, y, w, h)
  977. {
  978. c.setStrokeWidth(1);
  979. c.setFillColor(this.stroke);
  980. var w2 = w / 5;
  981. c.rect(0, 0, w2, h);
  982. c.fillAndStroke();
  983. c.rect(2 * w2, 0, w2, h);
  984. c.fillAndStroke();
  985. c.rect(4 * w2, 0, w2, h);
  986. c.fillAndStroke();
  987. };
  988. mxCellRenderer.registerShape('parallelMarker', ParallelMarkerShape);
  989. /**
  990. * Adds handJiggle style (jiggle=n sets jiggle)
  991. */
  992. function HandJiggle(canvas, defaultVariation)
  993. {
  994. this.canvas = canvas;
  995. // Avoids "spikes" in the output
  996. this.canvas.setLineJoin('round');
  997. this.canvas.setLineCap('round');
  998. this.defaultVariation = defaultVariation;
  999. this.originalLineTo = this.canvas.lineTo;
  1000. this.canvas.lineTo = mxUtils.bind(this, HandJiggle.prototype.lineTo);
  1001. this.originalMoveTo = this.canvas.moveTo;
  1002. this.canvas.moveTo = mxUtils.bind(this, HandJiggle.prototype.moveTo);
  1003. this.originalClose = this.canvas.close;
  1004. this.canvas.close = mxUtils.bind(this, HandJiggle.prototype.close);
  1005. this.originalQuadTo = this.canvas.quadTo;
  1006. this.canvas.quadTo = mxUtils.bind(this, HandJiggle.prototype.quadTo);
  1007. this.originalCurveTo = this.canvas.curveTo;
  1008. this.canvas.curveTo = mxUtils.bind(this, HandJiggle.prototype.curveTo);
  1009. this.originalArcTo = this.canvas.arcTo;
  1010. this.canvas.arcTo = mxUtils.bind(this, HandJiggle.prototype.arcTo);
  1011. };
  1012. HandJiggle.prototype.moveTo = function(endX, endY)
  1013. {
  1014. this.originalMoveTo.apply(this.canvas, arguments);
  1015. this.lastX = endX;
  1016. this.lastY = endY;
  1017. this.firstX = endX;
  1018. this.firstY = endY;
  1019. };
  1020. HandJiggle.prototype.close = function()
  1021. {
  1022. if (this.firstX != null && this.firstY != null)
  1023. {
  1024. this.lineTo(this.firstX, this.firstY);
  1025. this.originalClose.apply(this.canvas, arguments);
  1026. }
  1027. this.originalClose.apply(this.canvas, arguments);
  1028. };
  1029. HandJiggle.prototype.quadTo = function(x1, y1, x2, y2)
  1030. {
  1031. this.originalQuadTo.apply(this.canvas, arguments);
  1032. this.lastX = x2;
  1033. this.lastY = y2;
  1034. };
  1035. HandJiggle.prototype.curveTo = function(x1, y1, x2, y2, x3, y3)
  1036. {
  1037. this.originalCurveTo.apply(this.canvas, arguments);
  1038. this.lastX = x3;
  1039. this.lastY = y3;
  1040. };
  1041. HandJiggle.prototype.arcTo = function(rx, ry, angle, largeArcFlag, sweepFlag, x, y)
  1042. {
  1043. this.originalArcTo.apply(this.canvas, arguments);
  1044. this.lastX = x;
  1045. this.lastY = y;
  1046. };
  1047. HandJiggle.prototype.lineTo = function(endX, endY)
  1048. {
  1049. // LATER: Check why this.canvas.lastX cannot be used
  1050. if (this.lastX != null && this.lastY != null)
  1051. {
  1052. var dx = Math.abs(endX - this.lastX);
  1053. var dy = Math.abs(endY - this.lastY);
  1054. var dist = Math.sqrt(dx * dx + dy * dy);
  1055. if (dist < 2)
  1056. {
  1057. this.originalLineTo.apply(this.canvas, arguments);
  1058. this.lastX = endX;
  1059. this.lastY = endY;
  1060. return;
  1061. }
  1062. var segs = Math.round(dist / 10);
  1063. var variation = this.defaultVariation;
  1064. if (segs < 5)
  1065. {
  1066. segs = 5;
  1067. variation /= 3;
  1068. }
  1069. function sign(x)
  1070. {
  1071. return typeof x === 'number' ? x ? x < 0 ? -1 : 1 : x === x ? 0 : NaN : NaN;
  1072. }
  1073. var stepX = sign(endX - this.lastX) * dx / segs;
  1074. var stepY = sign(endY - this.lastY) * dy / segs;
  1075. var fx = dx / dist;
  1076. var fy = dy / dist;
  1077. for (var s = 0; s < segs; s++)
  1078. {
  1079. var x = stepX * s + this.lastX;
  1080. var y = stepY * s + this.lastY;
  1081. var offset = (Math.random() - 0.5) * variation;
  1082. this.originalLineTo.call(this.canvas, x - offset * fy, y - offset * fx);
  1083. }
  1084. this.originalLineTo.call(this.canvas, endX, endY);
  1085. this.lastX = endX;
  1086. this.lastY = endY;
  1087. }
  1088. else
  1089. {
  1090. this.originalLineTo.apply(this.canvas, arguments);
  1091. this.lastX = endX;
  1092. this.lastY = endY;
  1093. }
  1094. };
  1095. HandJiggle.prototype.destroy = function()
  1096. {
  1097. this.canvas.lineTo = this.originalLineTo;
  1098. this.canvas.moveTo = this.originalMoveTo;
  1099. this.canvas.close = this.originalClose;
  1100. this.canvas.quadTo = this.originalQuadTo;
  1101. this.canvas.curveTo = this.originalCurveTo;
  1102. this.canvas.arcTo = this.originalArcTo;
  1103. };
  1104. // Installs hand jiggle for comic and sketch style
  1105. mxShape.prototype.defaultJiggle = 1.5;
  1106. var shapeBeforePaint = mxShape.prototype.beforePaint;
  1107. mxShape.prototype.beforePaint = function(c)
  1108. {
  1109. shapeBeforePaint.apply(this, arguments);
  1110. if (c.handJiggle == null)
  1111. {
  1112. c.handJiggle = this.createHandJiggle(c);
  1113. }
  1114. };
  1115. var shapeAfterPaint = mxShape.prototype.afterPaint;
  1116. mxShape.prototype.afterPaint = function(c)
  1117. {
  1118. shapeAfterPaint.apply(this, arguments);
  1119. if (c.handJiggle != null)
  1120. {
  1121. c.handJiggle.destroy();
  1122. delete c.handJiggle;
  1123. }
  1124. };
  1125. // Returns a new HandJiggle canvas
  1126. mxShape.prototype.createComicCanvas = function(c)
  1127. {
  1128. return new HandJiggle(c, mxUtils.getValue(this.style, 'jiggle', this.defaultJiggle));
  1129. };
  1130. // Overrides to avoid call to rect
  1131. mxShape.prototype.createHandJiggle = function(c)
  1132. {
  1133. if (!this.outline && this.style != null && mxUtils.getValue(this.style, 'comic', '0') != '0')
  1134. {
  1135. return this.createComicCanvas(c);
  1136. }
  1137. return null;
  1138. };
  1139. // Sets default jiggle for diamond
  1140. mxRhombus.prototype.defaultJiggle = 2;
  1141. // Overrides to avoid call to rect
  1142. var mxRectangleShapeIsHtmlAllowed0 = mxRectangleShape.prototype.isHtmlAllowed;
  1143. mxRectangleShape.prototype.isHtmlAllowed = function()
  1144. {
  1145. return !this.outline && (this.style == null || (mxUtils.getValue(this.style, 'comic', '0') == '0' &&
  1146. mxUtils.getValue(this.style, 'sketch', (urlParams['rough'] == '1') ? '1' : '0') == '0')) &&
  1147. mxRectangleShapeIsHtmlAllowed0.apply(this, arguments);
  1148. };
  1149. var mxRectangleShapePaintBackground0 = mxRectangleShape.prototype.paintBackground;
  1150. mxRectangleShape.prototype.paintBackground = function(c, x, y, w, h)
  1151. {
  1152. if (c.handJiggle == null || c.handJiggle.constructor != HandJiggle)
  1153. {
  1154. mxRectangleShapePaintBackground0.apply(this, arguments);
  1155. }
  1156. else
  1157. {
  1158. var events = true;
  1159. if (this.style != null)
  1160. {
  1161. events = mxUtils.getValue(this.style, mxConstants.STYLE_POINTER_EVENTS, '1') == '1';
  1162. }
  1163. if (events || (this.fill != null && this.fill != mxConstants.NONE) ||
  1164. (this.stroke != null && this.stroke != mxConstants.NONE))
  1165. {
  1166. if (!events && (this.fill == null || this.fill == mxConstants.NONE))
  1167. {
  1168. c.pointerEvents = false;
  1169. }
  1170. c.begin();
  1171. if (this.isRounded)
  1172. {
  1173. var r = 0;
  1174. if (mxUtils.getValue(this.style, mxConstants.STYLE_ABSOLUTE_ARCSIZE, 0) == '1')
  1175. {
  1176. r = Math.min(w / 2, Math.min(h / 2, mxUtils.getValue(this.style,
  1177. mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2));
  1178. }
  1179. else
  1180. {
  1181. var f = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE,
  1182. mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100;
  1183. r = Math.min(w * f, h * f);
  1184. }
  1185. c.moveTo(x + r, y);
  1186. c.lineTo(x + w - r, y);
  1187. c.quadTo(x + w, y, x + w, y + r);
  1188. c.lineTo(x + w, y + h - r);
  1189. c.quadTo(x + w, y + h, x + w - r, y + h);
  1190. c.lineTo(x + r, y + h);
  1191. c.quadTo(x, y + h, x, y + h - r);
  1192. c.lineTo(x, y + r);
  1193. c.quadTo(x, y, x + r, y);
  1194. }
  1195. else
  1196. {
  1197. c.moveTo(x, y);
  1198. c.lineTo(x + w, y);
  1199. c.lineTo(x + w, y + h);
  1200. c.lineTo(x, y + h);
  1201. c.lineTo(x, y);
  1202. }
  1203. // LATER: Check if close is needed here
  1204. c.close();
  1205. c.end();
  1206. c.fillAndStroke();
  1207. }
  1208. }
  1209. };
  1210. /**
  1211. * Disables glass effect with hand jiggle.
  1212. */
  1213. var mxRectangleShapePaintForeground0 = mxRectangleShape.prototype.paintForeground;
  1214. mxRectangleShape.prototype.paintForeground = function(c, x, y, w, h)
  1215. {
  1216. if (c.handJiggle == null)
  1217. {
  1218. mxRectangleShapePaintForeground0.apply(this, arguments);
  1219. }
  1220. };
  1221. // End of hand jiggle integration
  1222. // Process Shape
  1223. function ProcessShape()
  1224. {
  1225. mxRectangleShape.call(this);
  1226. };
  1227. mxUtils.extend(ProcessShape, mxRectangleShape);
  1228. ProcessShape.prototype.size = 0.1;
  1229. ProcessShape.prototype.fixedSize = false;
  1230. ProcessShape.prototype.isHtmlAllowed = function()
  1231. {
  1232. return false;
  1233. };
  1234. ProcessShape.prototype.getLabelBounds = function(rect)
  1235. {
  1236. if (mxUtils.getValue(this.state.style, mxConstants.STYLE_HORIZONTAL, true) ==
  1237. (this.direction == null ||
  1238. this.direction == mxConstants.DIRECTION_EAST ||
  1239. this.direction == mxConstants.DIRECTION_WEST))
  1240. {
  1241. var w = rect.width;
  1242. var h = rect.height;
  1243. var r = new mxRectangle(rect.x, rect.y, w, h);
  1244. var inset = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1245. if (this.isRounded)
  1246. {
  1247. var f = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE,
  1248. mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100;
  1249. inset = Math.max(inset, Math.min(w * f, h * f));
  1250. }
  1251. r.x += Math.round(inset);
  1252. r.width -= Math.round(2 * inset);
  1253. return r;
  1254. }
  1255. return rect;
  1256. };
  1257. ProcessShape.prototype.paintForeground = function(c, x, y, w, h)
  1258. {
  1259. var isFixedSize = mxUtils.getValue(this.style, 'fixedSize', this.fixedSize);
  1260. var inset = parseFloat(mxUtils.getValue(this.style, 'size', this.size));
  1261. if (isFixedSize)
  1262. {
  1263. inset = Math.max(0, Math.min(w, inset));
  1264. }
  1265. else
  1266. {
  1267. inset = w * Math.max(0, Math.min(1, inset));
  1268. }
  1269. if (this.isRounded)
  1270. {
  1271. var f = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE,
  1272. mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100;
  1273. inset = Math.max(inset, Math.min(w * f, h * f));
  1274. }
  1275. // Crisp rendering of inner lines
  1276. inset = Math.round(inset);
  1277. c.begin();
  1278. c.moveTo(x + inset, y);
  1279. c.lineTo(x + inset, y + h);
  1280. c.moveTo(x + w - inset, y);
  1281. c.lineTo(x + w - inset, y + h);
  1282. c.end();
  1283. c.stroke();
  1284. mxRectangleShape.prototype.paintForeground.apply(this, arguments);
  1285. };
  1286. mxCellRenderer.registerShape('process', ProcessShape);
  1287. // Transparent Shape
  1288. function TransparentShape()
  1289. {
  1290. mxRectangleShape.call(this);
  1291. };
  1292. mxUtils.extend(TransparentShape, mxRectangleShape);
  1293. TransparentShape.prototype.paintBackground = function(c, x, y, w, h)
  1294. {
  1295. c.setFillColor(mxConstants.NONE);
  1296. c.rect(x, y, w, h);
  1297. c.fill();
  1298. };
  1299. TransparentShape.prototype.paintForeground = function(c, x, y, w, h) { };
  1300. mxCellRenderer.registerShape('transparent', TransparentShape);
  1301. // Callout shape
  1302. function CalloutShape()
  1303. {
  1304. mxActor.call(this);
  1305. };
  1306. mxUtils.extend(CalloutShape, mxHexagon);
  1307. CalloutShape.prototype.size = 30;
  1308. CalloutShape.prototype.position = 0.5;
  1309. CalloutShape.prototype.position2 = 0.5;
  1310. CalloutShape.prototype.base = 20;
  1311. CalloutShape.prototype.getLabelMargins = function()
  1312. {
  1313. return new mxRectangle(0, 0, 0, parseFloat(mxUtils.getValue(
  1314. this.style, 'size', this.size)) * this.scale);
  1315. };
  1316. CalloutShape.prototype.isRoundable = function()
  1317. {
  1318. return true;
  1319. };
  1320. CalloutShape.prototype.redrawPath = function(c, x, y, w, h)
  1321. {
  1322. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1323. var s = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1324. var dx = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'position', this.position))));
  1325. var dx2 = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'position2', this.position2))));
  1326. var base = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'base', this.base))));
  1327. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w, 0), new mxPoint(w, h - s),
  1328. new mxPoint(Math.min(w, dx + base), h - s), new mxPoint(dx2, h),
  1329. new mxPoint(Math.max(0, dx), h - s), new mxPoint(0, h - s)],
  1330. this.isRounded, arcSize, true, [4]);
  1331. };
  1332. mxCellRenderer.registerShape('callout', CalloutShape);
  1333. // Step shape
  1334. function StepShape()
  1335. {
  1336. mxActor.call(this);
  1337. };
  1338. mxUtils.extend(StepShape, mxActor);
  1339. StepShape.prototype.size = 0.2;
  1340. StepShape.prototype.fixedSize = 20;
  1341. StepShape.prototype.isRoundable = function()
  1342. {
  1343. return true;
  1344. };
  1345. StepShape.prototype.redrawPath = function(c, x, y, w, h)
  1346. {
  1347. var fixed = mxUtils.getValue(this.style, 'fixedSize', '0') != '0';
  1348. var s = (fixed) ? Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'size', this.fixedSize)))) :
  1349. w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1350. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1351. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w - s, 0), new mxPoint(w, h / 2), new mxPoint(w - s, h),
  1352. new mxPoint(0, h), new mxPoint(s, h / 2)], this.isRounded, arcSize, true);
  1353. c.end();
  1354. };
  1355. mxCellRenderer.registerShape('step', StepShape);
  1356. // Hexagon shape
  1357. function HexagonShape()
  1358. {
  1359. mxActor.call(this);
  1360. };
  1361. mxUtils.extend(HexagonShape, mxHexagon);
  1362. HexagonShape.prototype.size = 0.25;
  1363. HexagonShape.prototype.fixedSize = 20;
  1364. HexagonShape.prototype.isRoundable = function()
  1365. {
  1366. return true;
  1367. };
  1368. HexagonShape.prototype.redrawPath = function(c, x, y, w, h)
  1369. {
  1370. var fixed = mxUtils.getValue(this.style, 'fixedSize', '0') != '0';
  1371. var s = (fixed) ? Math.max(0, Math.min(w * 0.5, parseFloat(mxUtils.getValue(this.style, 'size', this.fixedSize)))) :
  1372. w * Math.max(0, Math.min(1, 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(s, 0), new mxPoint(w - s, 0), new mxPoint(w, 0.5 * h), new mxPoint(w - s, h),
  1375. new mxPoint(s, h), new mxPoint(0, 0.5 * h)], this.isRounded, arcSize, true);
  1376. };
  1377. mxCellRenderer.registerShape('hexagon', HexagonShape);
  1378. // Plus Shape
  1379. function PlusShape()
  1380. {
  1381. mxRectangleShape.call(this);
  1382. };
  1383. mxUtils.extend(PlusShape, mxRectangleShape);
  1384. PlusShape.prototype.isHtmlAllowed = function()
  1385. {
  1386. return false;
  1387. };
  1388. PlusShape.prototype.paintForeground = function(c, x, y, w, h)
  1389. {
  1390. var border = Math.min(w / 5, h / 5) + 1;
  1391. c.begin();
  1392. c.moveTo(x + w / 2, y + border);
  1393. c.lineTo(x + w / 2, y + h - border);
  1394. c.moveTo(x + border, y + h / 2);
  1395. c.lineTo(x + w - border, y + h / 2);
  1396. c.end();
  1397. c.stroke();
  1398. mxRectangleShape.prototype.paintForeground.apply(this, arguments);
  1399. };
  1400. mxCellRenderer.registerShape('plus', PlusShape);
  1401. // Overrides painting of rhombus shape to allow for double style
  1402. var mxRhombusPaintVertexShape = mxRhombus.prototype.paintVertexShape;
  1403. mxRhombus.prototype.getLabelBounds = function(rect)
  1404. {
  1405. if (this.style['double'] == 1)
  1406. {
  1407. var margin = (Math.max(2, this.strokewidth + 1) * 2 + parseFloat(
  1408. this.style[mxConstants.STYLE_MARGIN] || 0)) * this.scale;
  1409. return new mxRectangle(rect.x + margin, rect.y + margin,
  1410. rect.width - 2 * margin, rect.height - 2 * margin);
  1411. }
  1412. return rect;
  1413. };
  1414. mxRhombus.prototype.paintVertexShape = function(c, x, y, w, h)
  1415. {
  1416. mxRhombusPaintVertexShape.apply(this, arguments);
  1417. if (!this.outline && this.style['double'] == 1)
  1418. {
  1419. var margin = Math.max(2, this.strokewidth + 1) * 2 +
  1420. parseFloat(this.style[mxConstants.STYLE_MARGIN] || 0);
  1421. x += margin;
  1422. y += margin;
  1423. w -= 2 * margin;
  1424. h -= 2 * margin;
  1425. if (w > 0 && h > 0)
  1426. {
  1427. c.setShadow(false);
  1428. // Workaround for closure compiler bug where the lines with x and y above
  1429. // are removed if arguments is used as second argument in call below.
  1430. mxRhombusPaintVertexShape.apply(this, [c, x, y, w, h]);
  1431. }
  1432. }
  1433. };
  1434. // CompositeShape
  1435. function ExtendedShape()
  1436. {
  1437. mxRectangleShape.call(this);
  1438. };
  1439. mxUtils.extend(ExtendedShape, mxRectangleShape);
  1440. ExtendedShape.prototype.isHtmlAllowed = function()
  1441. {
  1442. return false;
  1443. };
  1444. ExtendedShape.prototype.getLabelBounds = function(rect)
  1445. {
  1446. if (this.style['double'] == 1)
  1447. {
  1448. var margin = (Math.max(2, this.strokewidth + 1) + parseFloat(
  1449. this.style[mxConstants.STYLE_MARGIN] || 0)) * this.scale;
  1450. return new mxRectangle(rect.x + margin, rect.y + margin,
  1451. rect.width - 2 * margin, rect.height - 2 * margin);
  1452. }
  1453. return rect;
  1454. };
  1455. ExtendedShape.prototype.paintForeground = function(c, x, y, w, h)
  1456. {
  1457. if (this.style != null)
  1458. {
  1459. if (!this.outline && this.style['double'] == 1)
  1460. {
  1461. var margin = Math.max(2, this.strokewidth + 1) + parseFloat(this.style[mxConstants.STYLE_MARGIN] || 0);
  1462. x += margin;
  1463. y += margin;
  1464. w -= 2 * margin;
  1465. h -= 2 * margin;
  1466. if (w > 0 && h > 0)
  1467. {
  1468. mxRectangleShape.prototype.paintBackground.apply(this, arguments);
  1469. }
  1470. }
  1471. c.setDashed(false);
  1472. // Draws the symbols defined in the style. The symbols are
  1473. // numbered from 1...n. Possible postfixes are align,
  1474. // verticalAlign, spacing, arcSpacing, width, height
  1475. var counter = 0;
  1476. var shape = null;
  1477. do
  1478. {
  1479. shape = mxCellRenderer.defaultShapes[this.style['symbol' + counter]];
  1480. if (shape != null)
  1481. {
  1482. var align = this.style['symbol' + counter + 'Align'];
  1483. var valign = this.style['symbol' + counter + 'VerticalAlign'];
  1484. var width = this.style['symbol' + counter + 'Width'];
  1485. var height = this.style['symbol' + counter + 'Height'];
  1486. var spacing = this.style['symbol' + counter + 'Spacing'] || 0;
  1487. var vspacing = this.style['symbol' + counter + 'VSpacing'] || spacing;
  1488. var arcspacing = this.style['symbol' + counter + 'ArcSpacing'];
  1489. if (arcspacing != null)
  1490. {
  1491. var arcSize = this.getArcSize(w + this.strokewidth, h + this.strokewidth) * arcspacing;
  1492. spacing += arcSize;
  1493. vspacing += arcSize;
  1494. }
  1495. var x2 = x;
  1496. var y2 = y;
  1497. if (align == mxConstants.ALIGN_CENTER)
  1498. {
  1499. x2 += (w - width) / 2;
  1500. }
  1501. else if (align == mxConstants.ALIGN_RIGHT)
  1502. {
  1503. x2 += w - width - spacing;
  1504. }
  1505. else
  1506. {
  1507. x2 += spacing;
  1508. }
  1509. if (valign == mxConstants.ALIGN_MIDDLE)
  1510. {
  1511. y2 += (h - height) / 2;
  1512. }
  1513. else if (valign == mxConstants.ALIGN_BOTTOM)
  1514. {
  1515. y2 += h - height - vspacing;
  1516. }
  1517. else
  1518. {
  1519. y2 += vspacing;
  1520. }
  1521. c.save();
  1522. // Small hack to pass style along into subshape
  1523. var tmp = new shape();
  1524. // TODO: Clone style and override settings (eg. strokewidth)
  1525. tmp.style = this.style;
  1526. shape.prototype.paintVertexShape.call(tmp, c, x2, y2, width, height);
  1527. c.restore();
  1528. }
  1529. counter++;
  1530. }
  1531. while (shape != null);
  1532. }
  1533. // Paints glass effect
  1534. mxRectangleShape.prototype.paintForeground.apply(this, arguments);
  1535. };
  1536. mxCellRenderer.registerShape('ext', ExtendedShape);
  1537. // Tape Shape, supports size style
  1538. function MessageShape()
  1539. {
  1540. mxCylinder.call(this);
  1541. };
  1542. mxUtils.extend(MessageShape, mxCylinder);
  1543. MessageShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  1544. {
  1545. if (isForeground)
  1546. {
  1547. path.moveTo(0, 0);
  1548. path.lineTo(w / 2, h / 2);
  1549. path.lineTo(w, 0);
  1550. path.end();
  1551. }
  1552. else
  1553. {
  1554. path.moveTo(0, 0);
  1555. path.lineTo(w, 0);
  1556. path.lineTo(w, h);
  1557. path.lineTo(0, h);
  1558. path.close();
  1559. }
  1560. };
  1561. mxCellRenderer.registerShape('message', MessageShape);
  1562. // UML Actor Shape
  1563. function UmlActorShape()
  1564. {
  1565. mxShape.call(this);
  1566. };
  1567. mxUtils.extend(UmlActorShape, mxShape);
  1568. UmlActorShape.prototype.paintBackground = function(c, x, y, w, h)
  1569. {
  1570. c.translate(x, y);
  1571. // Head
  1572. c.ellipse(w / 4, 0, w / 2, h / 4);
  1573. c.fillAndStroke();
  1574. c.begin();
  1575. c.moveTo(w / 2, h / 4);
  1576. c.lineTo(w / 2, 2 * h / 3);
  1577. // Arms
  1578. c.moveTo(w / 2, h / 3);
  1579. c.lineTo(0, h / 3);
  1580. c.moveTo(w / 2, h / 3);
  1581. c.lineTo(w, h / 3);
  1582. // Legs
  1583. c.moveTo(w / 2, 2 * h / 3);
  1584. c.lineTo(0, h);
  1585. c.moveTo(w / 2, 2 * h / 3);
  1586. c.lineTo(w, h);
  1587. c.end();
  1588. c.stroke();
  1589. };
  1590. // Replaces existing actor shape
  1591. mxCellRenderer.registerShape('umlActor', UmlActorShape);
  1592. // UML Boundary Shape
  1593. function UmlBoundaryShape()
  1594. {
  1595. mxShape.call(this);
  1596. };
  1597. mxUtils.extend(UmlBoundaryShape, mxShape);
  1598. UmlBoundaryShape.prototype.getLabelMargins = function(rect)
  1599. {
  1600. return new mxRectangle(rect.width / 6, 0, 0, 0);
  1601. };
  1602. UmlBoundaryShape.prototype.paintBackground = function(c, x, y, w, h)
  1603. {
  1604. c.translate(x, y);
  1605. // Base line
  1606. c.begin();
  1607. c.moveTo(0, h / 4);
  1608. c.lineTo(0, h * 3 / 4);
  1609. c.end();
  1610. c.stroke();
  1611. // Horizontal line
  1612. c.begin();
  1613. c.moveTo(0, h / 2);
  1614. c.lineTo(w / 6, h / 2);
  1615. c.end();
  1616. c.stroke();
  1617. // Circle
  1618. c.ellipse(w / 6, 0, w * 5 / 6, h);
  1619. c.fillAndStroke();
  1620. };
  1621. // Replaces existing actor shape
  1622. mxCellRenderer.registerShape('umlBoundary', UmlBoundaryShape);
  1623. // UML Entity Shape
  1624. function UmlEntityShape()
  1625. {
  1626. mxEllipse.call(this);
  1627. };
  1628. mxUtils.extend(UmlEntityShape, mxEllipse);
  1629. UmlEntityShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1630. {
  1631. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  1632. c.begin();
  1633. c.moveTo(x + w / 8, y + h);
  1634. c.lineTo(x + w * 7 / 8, y + h);
  1635. c.end();
  1636. c.stroke();
  1637. };
  1638. mxCellRenderer.registerShape('umlEntity', UmlEntityShape);
  1639. // UML Destroy Shape
  1640. function UmlDestroyShape()
  1641. {
  1642. mxShape.call(this);
  1643. };
  1644. mxUtils.extend(UmlDestroyShape, mxShape);
  1645. UmlDestroyShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1646. {
  1647. c.translate(x, y);
  1648. c.begin();
  1649. c.moveTo(w, 0);
  1650. c.lineTo(0, h);
  1651. c.moveTo(0, 0);
  1652. c.lineTo(w, h);
  1653. c.end();
  1654. c.stroke();
  1655. };
  1656. mxCellRenderer.registerShape('umlDestroy', UmlDestroyShape);
  1657. // UML Control Shape
  1658. function UmlControlShape()
  1659. {
  1660. mxShape.call(this);
  1661. };
  1662. mxUtils.extend(UmlControlShape, mxShape);
  1663. UmlControlShape.prototype.getLabelBounds = function(rect)
  1664. {
  1665. return new mxRectangle(rect.x, rect.y + rect.height / 8, rect.width, rect.height * 7 / 8);
  1666. };
  1667. UmlControlShape.prototype.paintBackground = function(c, x, y, w, h)
  1668. {
  1669. c.translate(x, y);
  1670. // Upper line
  1671. c.begin();
  1672. c.moveTo(w * 3 / 8, h / 8 * 1.1);
  1673. c.lineTo(w * 5 / 8, 0);
  1674. c.end();
  1675. c.stroke();
  1676. // Circle
  1677. c.ellipse(0, h / 8, w, h * 7 / 8);
  1678. c.fillAndStroke();
  1679. };
  1680. UmlControlShape.prototype.paintForeground = function(c, x, y, w, h)
  1681. {
  1682. // Lower line
  1683. c.begin();
  1684. c.moveTo(w * 3 / 8, h / 8 * 1.1);
  1685. c.lineTo(w * 5 / 8, h / 4);
  1686. c.end();
  1687. c.stroke();
  1688. };
  1689. // Replaces existing actor shape
  1690. mxCellRenderer.registerShape('umlControl', UmlControlShape);
  1691. // UML Lifeline Shape
  1692. function UmlLifeline()
  1693. {
  1694. mxRectangleShape.call(this);
  1695. };
  1696. mxUtils.extend(UmlLifeline, mxRectangleShape);
  1697. UmlLifeline.prototype.size = 40;
  1698. UmlLifeline.prototype.isHtmlAllowed = function()
  1699. {
  1700. return false;
  1701. };
  1702. UmlLifeline.prototype.getLabelBounds = function(rect)
  1703. {
  1704. var size = Math.max(0, Math.min(rect.height, parseFloat(
  1705. mxUtils.getValue(this.style, 'size', this.size)) * this.scale));
  1706. return new mxRectangle(rect.x, rect.y, rect.width, size);
  1707. };
  1708. UmlLifeline.prototype.paintBackground = function(c, x, y, w, h)
  1709. {
  1710. var size = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1711. var participant = mxUtils.getValue(this.style, 'participant');
  1712. if (participant == null || this.state == null)
  1713. {
  1714. mxRectangleShape.prototype.paintBackground.call(this, c, x, y, w, size);
  1715. }
  1716. else
  1717. {
  1718. var ctor = this.state.view.graph.cellRenderer.getShape(participant);
  1719. if (ctor != null && ctor != UmlLifeline)
  1720. {
  1721. var shape = new ctor();
  1722. shape.apply(this.state);
  1723. c.save();
  1724. shape.paintVertexShape(c, x, y, w, size);
  1725. c.restore();
  1726. }
  1727. }
  1728. if (size < h)
  1729. {
  1730. c.setDashed(true);
  1731. c.begin();
  1732. c.moveTo(x + w / 2, y + size);
  1733. c.lineTo(x + w / 2, y + h);
  1734. c.end();
  1735. c.stroke();
  1736. }
  1737. };
  1738. UmlLifeline.prototype.paintForeground = function(c, x, y, w, h)
  1739. {
  1740. var size = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1741. mxRectangleShape.prototype.paintForeground.call(this, c, x, y, w, Math.min(h, size));
  1742. };
  1743. mxCellRenderer.registerShape('umlLifeline', UmlLifeline);
  1744. // UML Frame Shape
  1745. function UmlFrame()
  1746. {
  1747. mxShape.call(this);
  1748. };
  1749. mxUtils.extend(UmlFrame, mxShape);
  1750. UmlFrame.prototype.width = 60;
  1751. UmlFrame.prototype.height = 30;
  1752. UmlFrame.prototype.corner = 10;
  1753. UmlFrame.prototype.getLabelMargins = function(rect)
  1754. {
  1755. return new mxRectangle(0, 0,
  1756. rect.width - (parseFloat(mxUtils.getValue(this.style, 'width', this.width) * this.scale)),
  1757. rect.height - (parseFloat(mxUtils.getValue(this.style, 'height', this.height) * this.scale)));
  1758. };
  1759. UmlFrame.prototype.paintBackground = function(c, x, y, w, h)
  1760. {
  1761. var co = this.corner;
  1762. var w0 = Math.min(w, Math.max(co, parseFloat(mxUtils.getValue(this.style, 'width', this.width))));
  1763. var h0 = Math.min(h, Math.max(co * 1.5, parseFloat(mxUtils.getValue(this.style, 'height', this.height))));
  1764. var bg = mxUtils.getValue(this.style, mxConstants.STYLE_SWIMLANE_FILLCOLOR, mxConstants.NONE);
  1765. if (bg != mxConstants.NONE)
  1766. {
  1767. c.setFillColor(bg);
  1768. c.rect(x, y, w, h);
  1769. c.fill();
  1770. }
  1771. if (this.fill != null && this.fill != mxConstants.NONE && this.gradient && this.gradient != mxConstants.NONE)
  1772. {
  1773. var b = this.getGradientBounds(c, x, y, w, h);
  1774. c.setGradient(this.fill, this.gradient, x, y, w, h, this.gradientDirection);
  1775. }
  1776. else
  1777. {
  1778. c.setFillColor(this.fill);
  1779. }
  1780. c.begin();
  1781. c.moveTo(x, y);
  1782. c.lineTo(x + w0, y);
  1783. c.lineTo(x + w0, y + Math.max(0, h0 - co * 1.5));
  1784. c.lineTo(x + Math.max(0, w0 - co), y + h0);
  1785. c.lineTo(x, y + h0);
  1786. c.close();
  1787. c.fillAndStroke();
  1788. c.begin();
  1789. c.moveTo(x + w0, y);
  1790. c.lineTo(x + w, y);
  1791. c.lineTo(x + w, y + h);
  1792. c.lineTo(x, y + h);
  1793. c.lineTo(x, y + h0);
  1794. c.stroke();
  1795. };
  1796. mxCellRenderer.registerShape('umlFrame', UmlFrame);
  1797. mxPerimeter.LifelinePerimeter = function (bounds, vertex, next, orthogonal)
  1798. {
  1799. var size = UmlLifeline.prototype.size;
  1800. if (vertex != null)
  1801. {
  1802. size = mxUtils.getValue(vertex.style, 'size', size) * vertex.view.scale;
  1803. }
  1804. var sw = (parseFloat(vertex.style[mxConstants.STYLE_STROKEWIDTH] || 1) * vertex.view.scale / 2) - 1;
  1805. if (next.x < bounds.getCenterX())
  1806. {
  1807. sw += 1;
  1808. sw *= -1;
  1809. }
  1810. return new mxPoint(bounds.getCenterX() + sw, Math.min(bounds.y + bounds.height,
  1811. Math.max(bounds.y + size, next.y)));
  1812. };
  1813. mxStyleRegistry.putValue('lifelinePerimeter', mxPerimeter.LifelinePerimeter);
  1814. mxPerimeter.OrthogonalPerimeter = function (bounds, vertex, next, orthogonal)
  1815. {
  1816. orthogonal = true;
  1817. return mxPerimeter.RectanglePerimeter.apply(this, arguments);
  1818. };
  1819. mxStyleRegistry.putValue('orthogonalPerimeter', mxPerimeter.OrthogonalPerimeter);
  1820. mxPerimeter.BackbonePerimeter = function (bounds, vertex, next, orthogonal)
  1821. {
  1822. var sw = (parseFloat(vertex.style[mxConstants.STYLE_STROKEWIDTH] || 1) * vertex.view.scale / 2) - 1;
  1823. if (vertex.style['backboneSize'] != null)
  1824. {
  1825. sw += (parseFloat(vertex.style['backboneSize']) * vertex.view.scale / 2) - 1;
  1826. }
  1827. if (vertex.style[mxConstants.STYLE_DIRECTION] == 'south' ||
  1828. vertex.style[mxConstants.STYLE_DIRECTION] == 'north')
  1829. {
  1830. if (next.x < bounds.getCenterX())
  1831. {
  1832. sw += 1;
  1833. sw *= -1;
  1834. }
  1835. return new mxPoint(bounds.getCenterX() + sw, Math.min(bounds.y + bounds.height,
  1836. Math.max(bounds.y, next.y)));
  1837. }
  1838. else
  1839. {
  1840. if (next.y < bounds.getCenterY())
  1841. {
  1842. sw += 1;
  1843. sw *= -1;
  1844. }
  1845. return new mxPoint(Math.min(bounds.x + bounds.width, Math.max(bounds.x, next.x)),
  1846. bounds.getCenterY() + sw);
  1847. }
  1848. };
  1849. mxStyleRegistry.putValue('backbonePerimeter', mxPerimeter.BackbonePerimeter);
  1850. // Callout Perimeter
  1851. mxPerimeter.CalloutPerimeter = function (bounds, vertex, next, orthogonal)
  1852. {
  1853. return mxPerimeter.RectanglePerimeter(mxUtils.getDirectedBounds(bounds, new mxRectangle(0, 0, 0,
  1854. Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(vertex.style, 'size',
  1855. CalloutShape.prototype.size)) * vertex.view.scale))),
  1856. vertex.style), vertex, next, orthogonal);
  1857. };
  1858. mxStyleRegistry.putValue('calloutPerimeter', mxPerimeter.CalloutPerimeter);
  1859. // Parallelogram Perimeter
  1860. mxPerimeter.ParallelogramPerimeter = function (bounds, vertex, next, orthogonal)
  1861. {
  1862. var fixed = mxUtils.getValue(vertex.style, 'fixedSize', '0') != '0';
  1863. var size = (fixed) ? ParallelogramShape.prototype.fixedSize : ParallelogramShape.prototype.size;
  1864. if (vertex != null)
  1865. {
  1866. size = mxUtils.getValue(vertex.style, 'size', size);
  1867. }
  1868. if (fixed)
  1869. {
  1870. size *= vertex.view.scale;
  1871. }
  1872. var x = bounds.x;
  1873. var y = bounds.y;
  1874. var w = bounds.width;
  1875. var h = bounds.height;
  1876. var direction = (vertex != null) ? mxUtils.getValue(
  1877. vertex.style, mxConstants.STYLE_DIRECTION,
  1878. mxConstants.DIRECTION_EAST) : mxConstants.DIRECTION_EAST;
  1879. var vertical = direction == mxConstants.DIRECTION_NORTH ||
  1880. direction == mxConstants.DIRECTION_SOUTH;
  1881. var points;
  1882. if (vertical)
  1883. {
  1884. var dy = (fixed) ? Math.max(0, Math.min(h, size)) : h * Math.max(0, Math.min(1, size));
  1885. points = [new mxPoint(x, y), new mxPoint(x + w, y + dy),
  1886. new mxPoint(x + w, y + h), new mxPoint(x, y + h - dy), new mxPoint(x, y)];
  1887. }
  1888. else
  1889. {
  1890. var dx = (fixed) ? Math.max(0, Math.min(w * 0.5, size)) : w * Math.max(0, Math.min(1, size));
  1891. points = [new mxPoint(x + dx, y), new mxPoint(x + w, y),
  1892. new mxPoint(x + w - dx, y + h), new mxPoint(x, y + h), new mxPoint(x + dx, y)];
  1893. }
  1894. var cx = bounds.getCenterX();
  1895. var cy = bounds.getCenterY();
  1896. var p1 = new mxPoint(cx, cy);
  1897. if (orthogonal)
  1898. {
  1899. if (next.x < x || next.x > x + w)
  1900. {
  1901. p1.y = next.y;
  1902. }
  1903. else
  1904. {
  1905. p1.x = next.x;
  1906. }
  1907. }
  1908. return mxUtils.getPerimeterPoint(points, p1, next);
  1909. };
  1910. mxStyleRegistry.putValue('parallelogramPerimeter', mxPerimeter.ParallelogramPerimeter);
  1911. // Trapezoid Perimeter
  1912. mxPerimeter.TrapezoidPerimeter = function (bounds, vertex, next, orthogonal)
  1913. {
  1914. var fixed = mxUtils.getValue(vertex.style, 'fixedSize', '0') != '0';
  1915. var size = (fixed) ? TrapezoidShape.prototype.fixedSize : TrapezoidShape.prototype.size;
  1916. if (vertex != null)
  1917. {
  1918. size = mxUtils.getValue(vertex.style, 'size', size);
  1919. }
  1920. if (fixed)
  1921. {
  1922. size *= vertex.view.scale;
  1923. }
  1924. var x = bounds.x;
  1925. var y = bounds.y;
  1926. var w = bounds.width;
  1927. var h = bounds.height;
  1928. var direction = (vertex != null) ? mxUtils.getValue(
  1929. vertex.style, mxConstants.STYLE_DIRECTION,
  1930. mxConstants.DIRECTION_EAST) : mxConstants.DIRECTION_EAST;
  1931. var points = [];
  1932. if (direction == mxConstants.DIRECTION_EAST)
  1933. {
  1934. var dx = (fixed) ? Math.max(0, Math.min(w * 0.5, size)) : w * Math.max(0, Math.min(1, size));
  1935. points = [new mxPoint(x + dx, y), new mxPoint(x + w - dx, y),
  1936. new mxPoint(x + w, y + h), new mxPoint(x, y + h), new mxPoint(x + dx, y)];
  1937. }
  1938. else if (direction == mxConstants.DIRECTION_WEST)
  1939. {
  1940. var dx = (fixed) ? Math.max(0, Math.min(w, size)) : w * Math.max(0, Math.min(1, size));
  1941. points = [new mxPoint(x, y), new mxPoint(x + w, y),
  1942. new mxPoint(x + w - dx, y + h), new mxPoint(x + dx, y + h), new mxPoint(x, y)];
  1943. }
  1944. else if (direction == mxConstants.DIRECTION_NORTH)
  1945. {
  1946. var dy = (fixed) ? Math.max(0, Math.min(h, size)) : h * Math.max(0, Math.min(1, size));
  1947. points = [new mxPoint(x, y + dy), new mxPoint(x + w, y),
  1948. new mxPoint(x + w, y + h), new mxPoint(x, y + h - dy), new mxPoint(x, y + dy)];
  1949. }
  1950. else
  1951. {
  1952. var dy = (fixed) ? Math.max(0, Math.min(h, size)) : h * Math.max(0, Math.min(1, size));
  1953. points = [new mxPoint(x, y), new mxPoint(x + w, y + dy),
  1954. new mxPoint(x + w, y + h - dy), new mxPoint(x, y + h), new mxPoint(x, y)];
  1955. }
  1956. var cx = bounds.getCenterX();
  1957. var cy = bounds.getCenterY();
  1958. var p1 = new mxPoint(cx, cy);
  1959. if (orthogonal)
  1960. {
  1961. if (next.x < x || next.x > x + w)
  1962. {
  1963. p1.y = next.y;
  1964. }
  1965. else
  1966. {
  1967. p1.x = next.x;
  1968. }
  1969. }
  1970. return mxUtils.getPerimeterPoint(points, p1, next);
  1971. };
  1972. mxStyleRegistry.putValue('trapezoidPerimeter', mxPerimeter.TrapezoidPerimeter);
  1973. // Step Perimeter
  1974. mxPerimeter.StepPerimeter = function (bounds, vertex, next, orthogonal)
  1975. {
  1976. var fixed = mxUtils.getValue(vertex.style, 'fixedSize', '0') != '0';
  1977. var size = (fixed) ? StepShape.prototype.fixedSize : StepShape.prototype.size;
  1978. if (vertex != null)
  1979. {
  1980. size = mxUtils.getValue(vertex.style, 'size', size);
  1981. }
  1982. if (fixed)
  1983. {
  1984. size *= vertex.view.scale;
  1985. }
  1986. var x = bounds.x;
  1987. var y = bounds.y;
  1988. var w = bounds.width;
  1989. var h = bounds.height;
  1990. var cx = bounds.getCenterX();
  1991. var cy = bounds.getCenterY();
  1992. var direction = (vertex != null) ? mxUtils.getValue(
  1993. vertex.style, mxConstants.STYLE_DIRECTION,
  1994. mxConstants.DIRECTION_EAST) : mxConstants.DIRECTION_EAST;
  1995. var points;
  1996. if (direction == mxConstants.DIRECTION_EAST)
  1997. {
  1998. var dx = (fixed) ? Math.max(0, Math.min(w, size)) : w * Math.max(0, Math.min(1, size));
  1999. points = [new mxPoint(x, y), new mxPoint(x + w - dx, y), new mxPoint(x + w, cy),
  2000. new mxPoint(x + w - dx, y + h), new mxPoint(x, y + h),
  2001. new mxPoint(x + dx, cy), new mxPoint(x, y)];
  2002. }
  2003. else if (direction == mxConstants.DIRECTION_WEST)
  2004. {
  2005. var dx = (fixed) ? Math.max(0, Math.min(w, size)) : w * Math.max(0, Math.min(1, size));
  2006. points = [new mxPoint(x + dx, y), new mxPoint(x + w, y), new mxPoint(x + w - dx, cy),
  2007. new mxPoint(x + w, y + h), new mxPoint(x + dx, y + h),
  2008. new mxPoint(x, cy), new mxPoint(x + dx, y)];
  2009. }
  2010. else if (direction == mxConstants.DIRECTION_NORTH)
  2011. {
  2012. var dy = (fixed) ? Math.max(0, Math.min(h, size)) : h * Math.max(0, Math.min(1, size));
  2013. points = [new mxPoint(x, y + dy), new mxPoint(cx, y), new mxPoint(x + w, y + dy),
  2014. new mxPoint(x + w, y + h), new mxPoint(cx, y + h - dy),
  2015. new mxPoint(x, y + h), new mxPoint(x, y + dy)];
  2016. }
  2017. else
  2018. {
  2019. var dy = (fixed) ? Math.max(0, Math.min(h, size)) : h * Math.max(0, Math.min(1, size));
  2020. points = [new mxPoint(x, y), new mxPoint(cx, y + dy), new mxPoint(x + w, y),
  2021. new mxPoint(x + w, y + h - dy), new mxPoint(cx, y + h),
  2022. new mxPoint(x, y + h - dy), new mxPoint(x, y)];
  2023. }
  2024. var p1 = new mxPoint(cx, cy);
  2025. if (orthogonal)
  2026. {
  2027. if (next.x < x || next.x > x + w)
  2028. {
  2029. p1.y = next.y;
  2030. }
  2031. else
  2032. {
  2033. p1.x = next.x;
  2034. }
  2035. }
  2036. return mxUtils.getPerimeterPoint(points, p1, next);
  2037. };
  2038. mxStyleRegistry.putValue('stepPerimeter', mxPerimeter.StepPerimeter);
  2039. // Hexagon Perimeter 2 (keep existing one)
  2040. mxPerimeter.HexagonPerimeter2 = function (bounds, vertex, next, orthogonal)
  2041. {
  2042. var fixed = mxUtils.getValue(vertex.style, 'fixedSize', '0') != '0';
  2043. var size = (fixed) ? HexagonShape.prototype.fixedSize : HexagonShape.prototype.size;
  2044. if (vertex != null)
  2045. {
  2046. size = mxUtils.getValue(vertex.style, 'size', size);
  2047. }
  2048. if (fixed)
  2049. {
  2050. size *= vertex.view.scale;
  2051. }
  2052. var x = bounds.x;
  2053. var y = bounds.y;
  2054. var w = bounds.width;
  2055. var h = bounds.height;
  2056. var cx = bounds.getCenterX();
  2057. var cy = bounds.getCenterY();
  2058. var direction = (vertex != null) ? mxUtils.getValue(
  2059. vertex.style, mxConstants.STYLE_DIRECTION,
  2060. mxConstants.DIRECTION_EAST) : mxConstants.DIRECTION_EAST;
  2061. var vertical = direction == mxConstants.DIRECTION_NORTH ||
  2062. direction == mxConstants.DIRECTION_SOUTH;
  2063. var points;
  2064. if (vertical)
  2065. {
  2066. var dy = (fixed) ? Math.max(0, Math.min(h, size)) : h * Math.max(0, Math.min(1, size));
  2067. points = [new mxPoint(cx, y), new mxPoint(x + w, y + dy), new mxPoint(x + w, y + h - dy),
  2068. new mxPoint(cx, y + h), new mxPoint(x, y + h - dy),
  2069. new mxPoint(x, y + dy), new mxPoint(cx, y)];
  2070. }
  2071. else
  2072. {
  2073. var dx = (fixed) ? Math.max(0, Math.min(w, size)) : w * Math.max(0, Math.min(1, size));
  2074. points = [new mxPoint(x + dx, y), new mxPoint(x + w - dx, y), new mxPoint(x + w, cy),
  2075. new mxPoint(x + w - dx, y + h), new mxPoint(x + dx, y + h),
  2076. new mxPoint(x, cy), new mxPoint(x + dx, y)];
  2077. }
  2078. var p1 = new mxPoint(cx, cy);
  2079. if (orthogonal)
  2080. {
  2081. if (next.x < x || next.x > x + w)
  2082. {
  2083. p1.y = next.y;
  2084. }
  2085. else
  2086. {
  2087. p1.x = next.x;
  2088. }
  2089. }
  2090. return mxUtils.getPerimeterPoint(points, p1, next);
  2091. };
  2092. mxStyleRegistry.putValue('hexagonPerimeter2', mxPerimeter.HexagonPerimeter2);
  2093. // Provided Interface Shape (aka Lollipop)
  2094. function LollipopShape()
  2095. {
  2096. mxShape.call(this);
  2097. };
  2098. mxUtils.extend(LollipopShape, mxShape);
  2099. LollipopShape.prototype.size = 10;
  2100. LollipopShape.prototype.paintBackground = function(c, x, y, w, h)
  2101. {
  2102. var sz = parseFloat(mxUtils.getValue(this.style, 'size', this.size));
  2103. c.translate(x, y);
  2104. c.ellipse((w - sz) / 2, 0, sz, sz);
  2105. c.fillAndStroke();
  2106. c.begin();
  2107. c.moveTo(w / 2, sz);
  2108. c.lineTo(w / 2, h);
  2109. c.end();
  2110. c.stroke();
  2111. };
  2112. mxCellRenderer.registerShape('lollipop', LollipopShape);
  2113. // Required Interface Shape
  2114. function RequiresShape()
  2115. {
  2116. mxShape.call(this);
  2117. };
  2118. mxUtils.extend(RequiresShape, mxShape);
  2119. RequiresShape.prototype.size = 10;
  2120. RequiresShape.prototype.inset = 2;
  2121. RequiresShape.prototype.paintBackground = function(c, x, y, w, h)
  2122. {
  2123. var sz = parseFloat(mxUtils.getValue(this.style, 'size', this.size));
  2124. var inset = parseFloat(mxUtils.getValue(this.style, 'inset', this.inset)) + this.strokewidth;
  2125. c.translate(x, y);
  2126. c.begin();
  2127. c.moveTo(w / 2, sz + inset);
  2128. c.lineTo(w / 2, h);
  2129. c.end();
  2130. c.stroke();
  2131. c.begin();
  2132. c.moveTo((w - sz) / 2 - inset, sz / 2);
  2133. c.quadTo((w - sz) / 2 - inset, sz + inset, w / 2, sz + inset);
  2134. c.quadTo((w + sz) / 2 + inset, sz + inset, (w + sz) / 2 + inset, sz / 2);
  2135. c.end();
  2136. c.stroke();
  2137. };
  2138. mxCellRenderer.registerShape('requires', RequiresShape);
  2139. // Required Interface Shape
  2140. function RequiredInterfaceShape()
  2141. {
  2142. mxShape.call(this);
  2143. };
  2144. mxUtils.extend(RequiredInterfaceShape, mxShape);
  2145. RequiredInterfaceShape.prototype.paintBackground = function(c, x, y, w, h)
  2146. {
  2147. c.translate(x, y);
  2148. c.begin();
  2149. c.moveTo(0, 0);
  2150. c.quadTo(w, 0, w, h / 2);
  2151. c.quadTo(w, h, 0, h);
  2152. c.end();
  2153. c.stroke();
  2154. };
  2155. mxCellRenderer.registerShape('requiredInterface', RequiredInterfaceShape);
  2156. // Provided and Required Interface Shape
  2157. function ProvidedRequiredInterfaceShape()
  2158. {
  2159. mxShape.call(this);
  2160. };
  2161. mxUtils.extend(ProvidedRequiredInterfaceShape, mxShape);
  2162. ProvidedRequiredInterfaceShape.prototype.inset = 2;
  2163. ProvidedRequiredInterfaceShape.prototype.paintBackground = function(c, x, y, w, h)
  2164. {
  2165. var inset = parseFloat(mxUtils.getValue(this.style, 'inset', this.inset)) + this.strokewidth;
  2166. c.translate(x, y);
  2167. c.ellipse(0, inset, w - 2 * inset, h - 2 * inset);
  2168. c.fillAndStroke();
  2169. c.begin();
  2170. c.moveTo(w / 2, 0);
  2171. c.quadTo(w, 0, w, h / 2);
  2172. c.quadTo(w, h, w / 2, h);
  2173. c.end();
  2174. c.stroke();
  2175. };
  2176. mxCellRenderer.registerShape('providedRequiredInterface', ProvidedRequiredInterfaceShape);
  2177. // Module shape
  2178. function ModuleShape()
  2179. {
  2180. mxCylinder.call(this);
  2181. };
  2182. mxUtils.extend(ModuleShape, mxCylinder);
  2183. ModuleShape.prototype.jettyWidth = 20;
  2184. ModuleShape.prototype.jettyHeight = 10;
  2185. ModuleShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  2186. {
  2187. var dx = parseFloat(mxUtils.getValue(this.style, 'jettyWidth', this.jettyWidth));
  2188. var dy = parseFloat(mxUtils.getValue(this.style, 'jettyHeight', this.jettyHeight));
  2189. var x0 = dx / 2;
  2190. var x1 = x0 + dx / 2;
  2191. var y0 = Math.min(dy, h - dy);
  2192. var y1 = Math.min(y0 + 2 * dy, h - dy);
  2193. if (isForeground)
  2194. {
  2195. path.moveTo(x0, y0);
  2196. path.lineTo(x1, y0);
  2197. path.lineTo(x1, y0 + dy);
  2198. path.lineTo(x0, y0 + dy);
  2199. path.moveTo(x0, y1);
  2200. path.lineTo(x1, y1);
  2201. path.lineTo(x1, y1 + dy);
  2202. path.lineTo(x0, y1 + dy);
  2203. path.end();
  2204. }
  2205. else
  2206. {
  2207. path.moveTo(x0, 0);
  2208. path.lineTo(w, 0);
  2209. path.lineTo(w, h);
  2210. path.lineTo(x0, h);
  2211. path.lineTo(x0, y1 + dy);
  2212. path.lineTo(0, y1 + dy);
  2213. path.lineTo(0, y1);
  2214. path.lineTo(x0, y1);
  2215. path.lineTo(x0, y0 + dy);
  2216. path.lineTo(0, y0 + dy);
  2217. path.lineTo(0, y0);
  2218. path.lineTo(x0, y0);
  2219. path.close();
  2220. path.end();
  2221. }
  2222. };
  2223. mxCellRenderer.registerShape('module', ModuleShape);
  2224. // Component shape
  2225. function ComponentShape()
  2226. {
  2227. mxCylinder.call(this);
  2228. };
  2229. mxUtils.extend(ComponentShape, mxCylinder);
  2230. ComponentShape.prototype.jettyWidth = 32;
  2231. ComponentShape.prototype.jettyHeight = 12;
  2232. ComponentShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  2233. {
  2234. var dx = parseFloat(mxUtils.getValue(this.style, 'jettyWidth', this.jettyWidth));
  2235. var dy = parseFloat(mxUtils.getValue(this.style, 'jettyHeight', this.jettyHeight));
  2236. var x0 = dx / 2;
  2237. var x1 = x0 + dx / 2;
  2238. var y0 = 0.3 * h - dy / 2;
  2239. var y1 = 0.7 * h - dy / 2;
  2240. if (isForeground)
  2241. {
  2242. path.moveTo(x0, y0);
  2243. path.lineTo(x1, y0);
  2244. path.lineTo(x1, y0 + dy);
  2245. path.lineTo(x0, y0 + dy);
  2246. path.moveTo(x0, y1);
  2247. path.lineTo(x1, y1);
  2248. path.lineTo(x1, y1 + dy);
  2249. path.lineTo(x0, y1 + dy);
  2250. path.end();
  2251. }
  2252. else
  2253. {
  2254. path.moveTo(x0, 0);
  2255. path.lineTo(w, 0);
  2256. path.lineTo(w, h);
  2257. path.lineTo(x0, h);
  2258. path.lineTo(x0, y1 + dy);
  2259. path.lineTo(0, y1 + dy);
  2260. path.lineTo(0, y1);
  2261. path.lineTo(x0, y1);
  2262. path.lineTo(x0, y0 + dy);
  2263. path.lineTo(0, y0 + dy);
  2264. path.lineTo(0, y0);
  2265. path.lineTo(x0, y0);
  2266. path.close();
  2267. path.end();
  2268. }
  2269. };
  2270. mxCellRenderer.registerShape('component', ComponentShape);
  2271. // Associative entity derived from rectangle shape
  2272. function AssociativeEntity()
  2273. {
  2274. mxRectangleShape.call(this);
  2275. };
  2276. mxUtils.extend(AssociativeEntity, mxRectangleShape);
  2277. AssociativeEntity.prototype.paintForeground = function(c, x, y, w, h)
  2278. {
  2279. var hw = w / 2;
  2280. var hh = h / 2;
  2281. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2282. c.begin();
  2283. this.addPoints(c, [new mxPoint(x + hw, y), new mxPoint(x + w, y + hh), new mxPoint(x + hw, y + h),
  2284. new mxPoint(x, y + hh)], this.isRounded, arcSize, true);
  2285. c.stroke();
  2286. mxRectangleShape.prototype.paintForeground.apply(this, arguments);
  2287. };
  2288. mxCellRenderer.registerShape('associativeEntity', AssociativeEntity);
  2289. // State Shapes derives from double ellipse
  2290. function StateShape()
  2291. {
  2292. mxDoubleEllipse.call(this);
  2293. };
  2294. mxUtils.extend(StateShape, mxDoubleEllipse);
  2295. StateShape.prototype.outerStroke = true;
  2296. StateShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2297. {
  2298. var inset = Math.min(4, Math.min(w / 5, h / 5));
  2299. if (w > 0 && h > 0)
  2300. {
  2301. c.ellipse(x + inset, y + inset, w - 2 * inset, h - 2 * inset);
  2302. c.fillAndStroke();
  2303. }
  2304. c.setShadow(false);
  2305. if (this.outerStroke)
  2306. {
  2307. c.ellipse(x, y, w, h);
  2308. c.stroke();
  2309. }
  2310. };
  2311. mxCellRenderer.registerShape('endState', StateShape);
  2312. function StartStateShape()
  2313. {
  2314. StateShape.call(this);
  2315. };
  2316. mxUtils.extend(StartStateShape, StateShape);
  2317. StartStateShape.prototype.outerStroke = false;
  2318. mxCellRenderer.registerShape('startState', StartStateShape);
  2319. // Link shape
  2320. function LinkShape()
  2321. {
  2322. mxArrowConnector.call(this);
  2323. this.spacing = 0;
  2324. };
  2325. mxUtils.extend(LinkShape, mxArrowConnector);
  2326. LinkShape.prototype.defaultWidth = 4;
  2327. LinkShape.prototype.isOpenEnded = function()
  2328. {
  2329. return true;
  2330. };
  2331. LinkShape.prototype.getEdgeWidth = function()
  2332. {
  2333. return mxUtils.getNumber(this.style, 'width', this.defaultWidth) + Math.max(0, this.strokewidth - 1);
  2334. };
  2335. LinkShape.prototype.isArrowRounded = function()
  2336. {
  2337. return this.isRounded;
  2338. };
  2339. // Registers the link shape
  2340. mxCellRenderer.registerShape('link', LinkShape);
  2341. // Generic arrow
  2342. function FlexArrowShape()
  2343. {
  2344. mxArrowConnector.call(this);
  2345. this.spacing = 0;
  2346. };
  2347. mxUtils.extend(FlexArrowShape, mxArrowConnector);
  2348. FlexArrowShape.prototype.defaultWidth = 10;
  2349. FlexArrowShape.prototype.defaultArrowWidth = 20;
  2350. FlexArrowShape.prototype.getStartArrowWidth = function()
  2351. {
  2352. return this.getEdgeWidth() + mxUtils.getNumber(this.style, 'startWidth', this.defaultArrowWidth);
  2353. };
  2354. FlexArrowShape.prototype.getEndArrowWidth = function()
  2355. {
  2356. return this.getEdgeWidth() + mxUtils.getNumber(this.style, 'endWidth', this.defaultArrowWidth);;
  2357. };
  2358. FlexArrowShape.prototype.getEdgeWidth = function()
  2359. {
  2360. return mxUtils.getNumber(this.style, 'width', this.defaultWidth) + Math.max(0, this.strokewidth - 1);
  2361. };
  2362. // Registers the link shape
  2363. mxCellRenderer.registerShape('flexArrow', FlexArrowShape);
  2364. // Manual Input shape
  2365. function ManualInputShape()
  2366. {
  2367. mxActor.call(this);
  2368. };
  2369. mxUtils.extend(ManualInputShape, mxActor);
  2370. ManualInputShape.prototype.size = 30;
  2371. ManualInputShape.prototype.isRoundable = function()
  2372. {
  2373. return true;
  2374. };
  2375. ManualInputShape.prototype.redrawPath = function(c, x, y, w, h)
  2376. {
  2377. var s = Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)));
  2378. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2379. this.addPoints(c, [new mxPoint(0, h), new mxPoint(0, s), new mxPoint(w, 0), new mxPoint(w, h)],
  2380. this.isRounded, arcSize, true);
  2381. c.end();
  2382. };
  2383. mxCellRenderer.registerShape('manualInput', ManualInputShape);
  2384. // Internal storage
  2385. function InternalStorageShape()
  2386. {
  2387. mxRectangleShape.call(this);
  2388. };
  2389. mxUtils.extend(InternalStorageShape, mxRectangleShape);
  2390. InternalStorageShape.prototype.dx = 20;
  2391. InternalStorageShape.prototype.dy = 20;
  2392. InternalStorageShape.prototype.isHtmlAllowed = function()
  2393. {
  2394. return false;
  2395. };
  2396. InternalStorageShape.prototype.paintForeground = function(c, x, y, w, h)
  2397. {
  2398. mxRectangleShape.prototype.paintForeground.apply(this, arguments);
  2399. var inset = 0;
  2400. if (this.isRounded)
  2401. {
  2402. var f = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE,
  2403. mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100;
  2404. inset = Math.max(inset, Math.min(w * f, h * f));
  2405. }
  2406. var dx = Math.max(inset, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  2407. var dy = Math.max(inset, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  2408. c.begin();
  2409. c.moveTo(x, y + dy);
  2410. c.lineTo(x + w, y + dy);
  2411. c.end();
  2412. c.stroke();
  2413. c.begin();
  2414. c.moveTo(x + dx, y);
  2415. c.lineTo(x + dx, y + h);
  2416. c.end();
  2417. c.stroke();
  2418. };
  2419. mxCellRenderer.registerShape('internalStorage', InternalStorageShape);
  2420. // Internal storage
  2421. function CornerShape()
  2422. {
  2423. mxActor.call(this);
  2424. };
  2425. mxUtils.extend(CornerShape, mxActor);
  2426. CornerShape.prototype.dx = 20;
  2427. CornerShape.prototype.dy = 20;
  2428. // Corner
  2429. CornerShape.prototype.redrawPath = function(c, x, y, w, h)
  2430. {
  2431. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  2432. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  2433. var s = Math.min(w / 2, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  2434. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2435. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w, 0), new mxPoint(w, dy), new mxPoint(dx, dy),
  2436. new mxPoint(dx, h), new mxPoint(0, h)], this.isRounded, arcSize, true);
  2437. c.end();
  2438. };
  2439. mxCellRenderer.registerShape('corner', CornerShape);
  2440. // Crossbar shape
  2441. function CrossbarShape()
  2442. {
  2443. mxActor.call(this);
  2444. };
  2445. mxUtils.extend(CrossbarShape, mxActor);
  2446. CrossbarShape.prototype.redrawPath = function(c, x, y, w, h)
  2447. {
  2448. c.moveTo(0, 0);
  2449. c.lineTo(0, h);
  2450. c.end();
  2451. c.moveTo(w, 0);
  2452. c.lineTo(w, h);
  2453. c.end();
  2454. c.moveTo(0, h / 2);
  2455. c.lineTo(w, h / 2);
  2456. c.end();
  2457. };
  2458. mxCellRenderer.registerShape('crossbar', CrossbarShape);
  2459. // Internal storage
  2460. function TeeShape()
  2461. {
  2462. mxActor.call(this);
  2463. };
  2464. mxUtils.extend(TeeShape, mxActor);
  2465. TeeShape.prototype.dx = 20;
  2466. TeeShape.prototype.dy = 20;
  2467. // Corner
  2468. TeeShape.prototype.redrawPath = function(c, x, y, w, h)
  2469. {
  2470. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  2471. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  2472. var w2 = Math.abs(w - dx) / 2;
  2473. var s = Math.min(w / 2, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  2474. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2475. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w, 0), new mxPoint(w, dy), new mxPoint((w + dx) / 2, dy),
  2476. new mxPoint((w + dx) / 2, h), new mxPoint((w - dx) / 2, h), new mxPoint((w - dx) / 2, dy),
  2477. new mxPoint(0, dy)], this.isRounded, arcSize, true);
  2478. c.end();
  2479. };
  2480. mxCellRenderer.registerShape('tee', TeeShape);
  2481. // Arrow
  2482. function SingleArrowShape()
  2483. {
  2484. mxActor.call(this);
  2485. };
  2486. mxUtils.extend(SingleArrowShape, mxActor);
  2487. SingleArrowShape.prototype.arrowWidth = 0.3;
  2488. SingleArrowShape.prototype.arrowSize = 0.2;
  2489. SingleArrowShape.prototype.redrawPath = function(c, x, y, w, h)
  2490. {
  2491. var aw = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowWidth', this.arrowWidth))));
  2492. var as = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowSize', this.arrowSize))));
  2493. var at = (h - aw) / 2;
  2494. var ab = at + aw;
  2495. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2496. this.addPoints(c, [new mxPoint(0, at), new mxPoint(w - as, at), new mxPoint(w - as, 0), new mxPoint(w, h / 2),
  2497. new mxPoint(w - as, h), new mxPoint(w - as, ab), new mxPoint(0, ab)],
  2498. this.isRounded, arcSize, true);
  2499. c.end();
  2500. };
  2501. mxCellRenderer.registerShape('singleArrow', SingleArrowShape);
  2502. // Arrow
  2503. function DoubleArrowShape()
  2504. {
  2505. mxActor.call(this);
  2506. };
  2507. mxUtils.extend(DoubleArrowShape, mxActor);
  2508. DoubleArrowShape.prototype.redrawPath = function(c, x, y, w, h)
  2509. {
  2510. var aw = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowWidth', SingleArrowShape.prototype.arrowWidth))));
  2511. var as = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowSize', SingleArrowShape.prototype.arrowSize))));
  2512. var at = (h - aw) / 2;
  2513. var ab = at + aw;
  2514. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2515. this.addPoints(c, [new mxPoint(0, h / 2), new mxPoint(as, 0), new mxPoint(as, at), new mxPoint(w - as, at),
  2516. new mxPoint(w - as, 0), new mxPoint(w, h / 2), new mxPoint(w - as, h),
  2517. new mxPoint(w - as, ab), new mxPoint(as, ab), new mxPoint(as, h)],
  2518. this.isRounded, arcSize, true);
  2519. c.end();
  2520. };
  2521. mxCellRenderer.registerShape('doubleArrow', DoubleArrowShape);
  2522. // Data storage
  2523. function DataStorageShape()
  2524. {
  2525. mxActor.call(this);
  2526. };
  2527. mxUtils.extend(DataStorageShape, mxActor);
  2528. DataStorageShape.prototype.size = 0.1;
  2529. DataStorageShape.prototype.fixedSize = 20;
  2530. DataStorageShape.prototype.redrawPath = function(c, x, y, w, h)
  2531. {
  2532. var fixed = mxUtils.getValue(this.style, 'fixedSize', '0') != '0';
  2533. var s = (fixed) ? Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'size', this.fixedSize)))) :
  2534. w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  2535. c.moveTo(s, 0);
  2536. c.lineTo(w, 0);
  2537. c.quadTo(w - s * 2, h / 2, w, h);
  2538. c.lineTo(s, h);
  2539. c.quadTo(s - s * 2, h / 2, s, 0);
  2540. c.close();
  2541. c.end();
  2542. };
  2543. mxCellRenderer.registerShape('dataStorage', DataStorageShape);
  2544. // Or
  2545. function OrShape()
  2546. {
  2547. mxActor.call(this);
  2548. };
  2549. mxUtils.extend(OrShape, mxActor);
  2550. OrShape.prototype.redrawPath = function(c, x, y, w, h)
  2551. {
  2552. c.moveTo(0, 0);
  2553. c.quadTo(w, 0, w, h / 2);
  2554. c.quadTo(w, h, 0, h);
  2555. c.close();
  2556. c.end();
  2557. };
  2558. mxCellRenderer.registerShape('or', OrShape);
  2559. // Xor
  2560. function XorShape()
  2561. {
  2562. mxActor.call(this);
  2563. };
  2564. mxUtils.extend(XorShape, mxActor);
  2565. XorShape.prototype.redrawPath = function(c, x, y, w, h)
  2566. {
  2567. c.moveTo(0, 0);
  2568. c.quadTo(w, 0, w, h / 2);
  2569. c.quadTo(w, h, 0, h);
  2570. c.quadTo(w / 2, h / 2, 0, 0);
  2571. c.close();
  2572. c.end();
  2573. };
  2574. mxCellRenderer.registerShape('xor', XorShape);
  2575. // Loop limit
  2576. function LoopLimitShape()
  2577. {
  2578. mxActor.call(this);
  2579. };
  2580. mxUtils.extend(LoopLimitShape, mxActor);
  2581. LoopLimitShape.prototype.size = 20;
  2582. LoopLimitShape.prototype.isRoundable = function()
  2583. {
  2584. return true;
  2585. };
  2586. LoopLimitShape.prototype.redrawPath = function(c, x, y, w, h)
  2587. {
  2588. var s = Math.min(w / 2, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  2589. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2590. this.addPoints(c, [new mxPoint(s, 0), new mxPoint(w - s, 0), new mxPoint(w, s * 0.8), new mxPoint(w, h),
  2591. new mxPoint(0, h), new mxPoint(0, s * 0.8)], this.isRounded, arcSize, true);
  2592. c.end();
  2593. };
  2594. mxCellRenderer.registerShape('loopLimit', LoopLimitShape);
  2595. // Off page connector
  2596. function OffPageConnectorShape()
  2597. {
  2598. mxActor.call(this);
  2599. };
  2600. mxUtils.extend(OffPageConnectorShape, mxActor);
  2601. OffPageConnectorShape.prototype.size = 3 / 8;
  2602. OffPageConnectorShape.prototype.isRoundable = function()
  2603. {
  2604. return true;
  2605. };
  2606. OffPageConnectorShape.prototype.redrawPath = function(c, x, y, w, h)
  2607. {
  2608. var s = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  2609. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2610. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w, 0), new mxPoint(w, h - s), new mxPoint(w / 2, h),
  2611. new mxPoint(0, h - s)], this.isRounded, arcSize, true);
  2612. c.end();
  2613. };
  2614. mxCellRenderer.registerShape('offPageConnector', OffPageConnectorShape);
  2615. // Internal storage
  2616. function TapeDataShape()
  2617. {
  2618. mxEllipse.call(this);
  2619. };
  2620. mxUtils.extend(TapeDataShape, mxEllipse);
  2621. TapeDataShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2622. {
  2623. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  2624. c.begin();
  2625. c.moveTo(x + w / 2, y + h);
  2626. c.lineTo(x + w, y + h);
  2627. c.end();
  2628. c.stroke();
  2629. };
  2630. mxCellRenderer.registerShape('tapeData', TapeDataShape);
  2631. // OrEllipseShape
  2632. function OrEllipseShape()
  2633. {
  2634. mxEllipse.call(this);
  2635. };
  2636. mxUtils.extend(OrEllipseShape, mxEllipse);
  2637. OrEllipseShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2638. {
  2639. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  2640. c.setShadow(false);
  2641. c.begin();
  2642. c.moveTo(x, y + h / 2);
  2643. c.lineTo(x + w, y + h / 2);
  2644. c.end();
  2645. c.stroke();
  2646. c.begin();
  2647. c.moveTo(x + w / 2, y);
  2648. c.lineTo(x + w / 2, y + h);
  2649. c.end();
  2650. c.stroke();
  2651. };
  2652. mxCellRenderer.registerShape('orEllipse', OrEllipseShape);
  2653. // SumEllipseShape
  2654. function SumEllipseShape()
  2655. {
  2656. mxEllipse.call(this);
  2657. };
  2658. mxUtils.extend(SumEllipseShape, mxEllipse);
  2659. SumEllipseShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2660. {
  2661. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  2662. var s2 = 0.145;
  2663. c.setShadow(false);
  2664. c.begin();
  2665. c.moveTo(x + w * s2, y + h * s2);
  2666. c.lineTo(x + w * (1 - s2), y + h * (1 - s2));
  2667. c.end();
  2668. c.stroke();
  2669. c.begin();
  2670. c.moveTo(x + w * (1 - s2), y + h * s2);
  2671. c.lineTo(x + w * s2, y + h * (1 - s2));
  2672. c.end();
  2673. c.stroke();
  2674. };
  2675. mxCellRenderer.registerShape('sumEllipse', SumEllipseShape);
  2676. // SortShape
  2677. function SortShape()
  2678. {
  2679. mxRhombus.call(this);
  2680. };
  2681. mxUtils.extend(SortShape, mxRhombus);
  2682. SortShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2683. {
  2684. mxRhombus.prototype.paintVertexShape.apply(this, arguments);
  2685. c.setShadow(false);
  2686. c.begin();
  2687. c.moveTo(x, y + h / 2);
  2688. c.lineTo(x + w, y + h / 2);
  2689. c.end();
  2690. c.stroke();
  2691. };
  2692. mxCellRenderer.registerShape('sortShape', SortShape);
  2693. // CollateShape
  2694. function CollateShape()
  2695. {
  2696. mxEllipse.call(this);
  2697. };
  2698. mxUtils.extend(CollateShape, mxEllipse);
  2699. CollateShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2700. {
  2701. c.begin();
  2702. c.moveTo(x, y);
  2703. c.lineTo(x + w, y);
  2704. c.lineTo(x + w / 2, y + h / 2);
  2705. c.close();
  2706. c.fillAndStroke();
  2707. c.begin();
  2708. c.moveTo(x, y + h);
  2709. c.lineTo(x + w, y + h);
  2710. c.lineTo(x + w / 2, y + h / 2);
  2711. c.close();
  2712. c.fillAndStroke();
  2713. };
  2714. mxCellRenderer.registerShape('collate', CollateShape);
  2715. // DimensionShape
  2716. function DimensionShape()
  2717. {
  2718. mxEllipse.call(this);
  2719. };
  2720. mxUtils.extend(DimensionShape, mxEllipse);
  2721. DimensionShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2722. {
  2723. // Arrow size
  2724. var al = 10;
  2725. var cy = y + h - al / 2;
  2726. c.begin();
  2727. c.moveTo(x, y);
  2728. c.lineTo(x, y + h);
  2729. c.moveTo(x, cy);
  2730. c.lineTo(x + al, cy - al / 2);
  2731. c.moveTo(x, cy);
  2732. c.lineTo(x + al, cy + al / 2);
  2733. c.moveTo(x, cy);
  2734. c.lineTo(x + w, cy);
  2735. // Opposite side
  2736. c.moveTo(x + w, y);
  2737. c.lineTo(x + w, y + h);
  2738. c.moveTo(x + w, cy);
  2739. c.lineTo(x + w - al, cy - al / 2);
  2740. c.moveTo(x + w, cy);
  2741. c.lineTo(x + w - al, cy + al / 2);
  2742. c.end();
  2743. c.stroke();
  2744. };
  2745. mxCellRenderer.registerShape('dimension', DimensionShape);
  2746. // PartialRectangleShape
  2747. function PartialRectangleShape()
  2748. {
  2749. mxEllipse.call(this);
  2750. };
  2751. mxUtils.extend(PartialRectangleShape, mxEllipse);
  2752. PartialRectangleShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2753. {
  2754. if (!this.outline)
  2755. {
  2756. c.setStrokeColor(null);
  2757. }
  2758. if (this.style != null)
  2759. {
  2760. var pointerEvents = c.pointerEvents;
  2761. var events = mxUtils.getValue(this.style, mxConstants.STYLE_POINTER_EVENTS, '1') == '1';
  2762. if (!events && (this.fill == null || this.fill == mxConstants.NONE))
  2763. {
  2764. c.pointerEvents = false;
  2765. }
  2766. c.rect(x, y, w, h);
  2767. c.fill();
  2768. c.pointerEvents = pointerEvents;
  2769. c.setStrokeColor(this.stroke);
  2770. c.begin();
  2771. c.moveTo(x, y);
  2772. if (this.outline || mxUtils.getValue(this.style, 'top', '1') == '1')
  2773. {
  2774. c.lineTo(x + w, y);
  2775. }
  2776. else
  2777. {
  2778. c.moveTo(x + w, y);
  2779. }
  2780. if (this.outline || mxUtils.getValue(this.style, 'right', '1') == '1')
  2781. {
  2782. c.lineTo(x + w, y + h);
  2783. }
  2784. else
  2785. {
  2786. c.moveTo(x + w, y + h);
  2787. }
  2788. if (this.outline || mxUtils.getValue(this.style, 'bottom', '1') == '1')
  2789. {
  2790. c.lineTo(x, y + h);
  2791. }
  2792. else
  2793. {
  2794. c.moveTo(x, y + h);
  2795. }
  2796. if (this.outline || mxUtils.getValue(this.style, 'left', '1') == '1')
  2797. {
  2798. c.lineTo(x, y);
  2799. }
  2800. c.end();
  2801. c.stroke();
  2802. }
  2803. };
  2804. mxCellRenderer.registerShape('partialRectangle', PartialRectangleShape);
  2805. // LineEllipseShape
  2806. function LineEllipseShape()
  2807. {
  2808. mxEllipse.call(this);
  2809. };
  2810. mxUtils.extend(LineEllipseShape, mxEllipse);
  2811. LineEllipseShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2812. {
  2813. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  2814. c.setShadow(false);
  2815. c.begin();
  2816. if (mxUtils.getValue(this.style, 'line') == 'vertical')
  2817. {
  2818. c.moveTo(x + w / 2, y);
  2819. c.lineTo(x + w / 2, y + h);
  2820. }
  2821. else
  2822. {
  2823. c.moveTo(x, y + h / 2);
  2824. c.lineTo(x + w, y + h / 2);
  2825. }
  2826. c.end();
  2827. c.stroke();
  2828. };
  2829. mxCellRenderer.registerShape('lineEllipse', LineEllipseShape);
  2830. // Delay
  2831. function DelayShape()
  2832. {
  2833. mxActor.call(this);
  2834. };
  2835. mxUtils.extend(DelayShape, mxActor);
  2836. DelayShape.prototype.redrawPath = function(c, x, y, w, h)
  2837. {
  2838. var dx = Math.min(w, h / 2);
  2839. c.moveTo(0, 0);
  2840. c.lineTo(w - dx, 0);
  2841. c.quadTo(w, 0, w, h / 2);
  2842. c.quadTo(w, h, w - dx, h);
  2843. c.lineTo(0, h);
  2844. c.close();
  2845. c.end();
  2846. };
  2847. mxCellRenderer.registerShape('delay', DelayShape);
  2848. // Cross Shape
  2849. function CrossShape()
  2850. {
  2851. mxActor.call(this);
  2852. };
  2853. mxUtils.extend(CrossShape, mxActor);
  2854. CrossShape.prototype.size = 0.2;
  2855. CrossShape.prototype.redrawPath = function(c, x, y, w, h)
  2856. {
  2857. var m = Math.min(h, w);
  2858. var size = Math.max(0, Math.min(m, m * parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  2859. var t = (h - size) / 2;
  2860. var b = t + size;
  2861. var l = (w - size) / 2;
  2862. var r = l + size;
  2863. c.moveTo(0, t);
  2864. c.lineTo(l, t);
  2865. c.lineTo(l, 0);
  2866. c.lineTo(r, 0);
  2867. c.lineTo(r, t);
  2868. c.lineTo(w, t);
  2869. c.lineTo(w, b);
  2870. c.lineTo(r, b);
  2871. c.lineTo(r, h);
  2872. c.lineTo(l, h);
  2873. c.lineTo(l, b);
  2874. c.lineTo(0, b);
  2875. c.close();
  2876. c.end();
  2877. };
  2878. mxCellRenderer.registerShape('cross', CrossShape);
  2879. // Display
  2880. function DisplayShape()
  2881. {
  2882. mxActor.call(this);
  2883. };
  2884. mxUtils.extend(DisplayShape, mxActor);
  2885. DisplayShape.prototype.size = 0.25;
  2886. DisplayShape.prototype.redrawPath = function(c, x, y, w, h)
  2887. {
  2888. var dx = Math.min(w, h / 2);
  2889. var s = Math.min(w - dx, Math.max(0, parseFloat(mxUtils.getValue(this.style, 'size', this.size))) * w);
  2890. c.moveTo(0, h / 2);
  2891. c.lineTo(s, 0);
  2892. c.lineTo(w - dx, 0);
  2893. c.quadTo(w, 0, w, h / 2);
  2894. c.quadTo(w, h, w - dx, h);
  2895. c.lineTo(s, h);
  2896. c.close();
  2897. c.end();
  2898. };
  2899. mxCellRenderer.registerShape('display', DisplayShape);
  2900. // FilledEdge shape
  2901. function FilledEdge()
  2902. {
  2903. mxConnector.call(this);
  2904. };
  2905. mxUtils.extend(FilledEdge, mxConnector);
  2906. FilledEdge.prototype.origPaintEdgeShape = FilledEdge.prototype.paintEdgeShape;
  2907. FilledEdge.prototype.paintEdgeShape = function(c, pts, rounded)
  2908. {
  2909. // Markers modify incoming points array
  2910. var temp = [];
  2911. for (var i = 0; i < pts.length; i++)
  2912. {
  2913. temp.push(mxUtils.clone(pts[i]));
  2914. }
  2915. // paintEdgeShape resets dashed to false
  2916. var dashed = c.state.dashed;
  2917. var fixDash = c.state.fixDash;
  2918. FilledEdge.prototype.origPaintEdgeShape.apply(this, [c, temp, rounded]);
  2919. if (c.state.strokeWidth >= 3)
  2920. {
  2921. var fillClr = mxUtils.getValue(this.style, 'fillColor', null);
  2922. if (fillClr != null)
  2923. {
  2924. c.setStrokeColor(fillClr);
  2925. c.setStrokeWidth(c.state.strokeWidth - 2);
  2926. c.setDashed(dashed, fixDash);
  2927. FilledEdge.prototype.origPaintEdgeShape.apply(this, [c, pts, rounded]);
  2928. }
  2929. }
  2930. };
  2931. // Registers the link shape
  2932. mxCellRenderer.registerShape('filledEdge', FilledEdge);
  2933. // Implements custom colors for shapes
  2934. if (typeof StyleFormatPanel !== 'undefined')
  2935. {
  2936. (function()
  2937. {
  2938. var styleFormatPanelGetCustomColors = StyleFormatPanel.prototype.getCustomColors;
  2939. StyleFormatPanel.prototype.getCustomColors = function()
  2940. {
  2941. var ss = this.format.getSelectionState();
  2942. var result = styleFormatPanelGetCustomColors.apply(this, arguments);
  2943. if (ss.style.shape == 'umlFrame')
  2944. {
  2945. result.push({title: mxResources.get('laneColor'), key: 'swimlaneFillColor', defaultValue: '#ffffff'});
  2946. }
  2947. return result;
  2948. };
  2949. })();
  2950. }
  2951. // Registers and defines the custom marker
  2952. mxMarker.addMarker('dash', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  2953. {
  2954. var nx = unitX * (size + sw + 1);
  2955. var ny = unitY * (size + sw + 1);
  2956. return function()
  2957. {
  2958. c.begin();
  2959. c.moveTo(pe.x - nx / 2 - ny / 2, pe.y - ny / 2 + nx / 2);
  2960. c.lineTo(pe.x + ny / 2 - 3 * nx / 2, pe.y - 3 * ny / 2 - nx / 2);
  2961. c.stroke();
  2962. };
  2963. });
  2964. // Registers and defines the custom marker
  2965. mxMarker.addMarker('box', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  2966. {
  2967. var nx = unitX * (size + sw + 1);
  2968. var ny = unitY * (size + sw + 1);
  2969. var px = pe.x + nx / 2;
  2970. var py = pe.y + ny / 2;
  2971. pe.x -= nx;
  2972. pe.y -= ny;
  2973. return function()
  2974. {
  2975. c.begin();
  2976. c.moveTo(px - nx / 2 - ny / 2, py - ny / 2 + nx / 2);
  2977. c.lineTo(px - nx / 2 + ny / 2, py - ny / 2 - nx / 2);
  2978. c.lineTo(px + ny / 2 - 3 * nx / 2, py - 3 * ny / 2 - nx / 2);
  2979. c.lineTo(px - ny / 2 - 3 * nx / 2, py - 3 * ny / 2 + nx / 2);
  2980. c.close();
  2981. if (filled)
  2982. {
  2983. c.fillAndStroke();
  2984. }
  2985. else
  2986. {
  2987. c.stroke();
  2988. }
  2989. };
  2990. });
  2991. // Registers and defines the custom marker
  2992. mxMarker.addMarker('cross', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  2993. {
  2994. var nx = unitX * (size + sw + 1);
  2995. var ny = unitY * (size + sw + 1);
  2996. return function()
  2997. {
  2998. c.begin();
  2999. c.moveTo(pe.x - nx / 2 - ny / 2, pe.y - ny / 2 + nx / 2);
  3000. c.lineTo(pe.x + ny / 2 - 3 * nx / 2, pe.y - 3 * ny / 2 - nx / 2);
  3001. c.moveTo(pe.x - nx / 2 + ny / 2, pe.y - ny / 2 - nx / 2);
  3002. c.lineTo(pe.x - ny / 2 - 3 * nx / 2, pe.y - 3 * ny / 2 + nx / 2);
  3003. c.stroke();
  3004. };
  3005. });
  3006. function circleMarker(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  3007. {
  3008. var a = size / 2;
  3009. var size = size + sw;
  3010. var pt = pe.clone();
  3011. pe.x -= unitX * (2 * size + sw);
  3012. pe.y -= unitY * (2 * size + sw);
  3013. unitX = unitX * (size + sw);
  3014. unitY = unitY * (size + sw);
  3015. return function()
  3016. {
  3017. c.ellipse(pt.x - unitX - size, pt.y - unitY - size, 2 * size, 2 * size);
  3018. if (filled)
  3019. {
  3020. c.fillAndStroke();
  3021. }
  3022. else
  3023. {
  3024. c.stroke();
  3025. }
  3026. };
  3027. };
  3028. mxMarker.addMarker('circle', circleMarker);
  3029. mxMarker.addMarker('circlePlus', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  3030. {
  3031. var pt = pe.clone();
  3032. var fn = circleMarker.apply(this, arguments);
  3033. var nx = unitX * (size + 2 * sw); // (size + sw + 1);
  3034. var ny = unitY * (size + 2 * sw); //(size + sw + 1);
  3035. return function()
  3036. {
  3037. fn.apply(this, arguments);
  3038. c.begin();
  3039. c.moveTo(pt.x - unitX * (sw), pt.y - unitY * (sw));
  3040. c.lineTo(pt.x - 2 * nx + unitX * (sw), pt.y - 2 * ny + unitY * (sw));
  3041. c.moveTo(pt.x - nx - ny + unitY * sw, pt.y - ny + nx - unitX * sw);
  3042. c.lineTo(pt.x + ny - nx - unitY * sw, pt.y - ny - nx + unitX * sw);
  3043. c.stroke();
  3044. };
  3045. });
  3046. // Registers and defines the custom marker
  3047. mxMarker.addMarker('halfCircle', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  3048. {
  3049. var nx = unitX * (size + sw + 1);
  3050. var ny = unitY * (size + sw + 1);
  3051. var pt = pe.clone();
  3052. pe.x -= nx;
  3053. pe.y -= ny;
  3054. return function()
  3055. {
  3056. c.begin();
  3057. c.moveTo(pt.x - ny, pt.y + nx);
  3058. c.quadTo(pe.x - ny, pe.y + nx, pe.x, pe.y);
  3059. c.quadTo(pe.x + ny, pe.y - nx, pt.x + ny, pt.y - nx);
  3060. c.stroke();
  3061. };
  3062. });
  3063. mxMarker.addMarker('async', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  3064. {
  3065. // The angle of the forward facing arrow sides against the x axis is
  3066. // 26.565 degrees, 1/sin(26.565) = 2.236 / 2 = 1.118 ( / 2 allows for
  3067. // only half the strokewidth is processed ).
  3068. var endOffsetX = unitX * sw * 1.118;
  3069. var endOffsetY = unitY * sw * 1.118;
  3070. unitX = unitX * (size + sw);
  3071. unitY = unitY * (size + sw);
  3072. var pt = pe.clone();
  3073. pt.x -= endOffsetX;
  3074. pt.y -= endOffsetY;
  3075. var f = 1;
  3076. pe.x += -unitX * f - endOffsetX;
  3077. pe.y += -unitY * f - endOffsetY;
  3078. return function()
  3079. {
  3080. c.begin();
  3081. c.moveTo(pt.x, pt.y);
  3082. if (source)
  3083. {
  3084. c.lineTo(pt.x - unitX - unitY / 2, pt.y - unitY + unitX / 2);
  3085. }
  3086. else
  3087. {
  3088. c.lineTo(pt.x + unitY / 2 - unitX, pt.y - unitY - unitX / 2);
  3089. }
  3090. c.lineTo(pt.x - unitX, pt.y - unitY);
  3091. c.close();
  3092. if (filled)
  3093. {
  3094. c.fillAndStroke();
  3095. }
  3096. else
  3097. {
  3098. c.stroke();
  3099. }
  3100. };
  3101. });
  3102. function createOpenAsyncArrow(widthFactor)
  3103. {
  3104. widthFactor = (widthFactor != null) ? widthFactor : 2;
  3105. return function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  3106. {
  3107. unitX = unitX * (size + sw);
  3108. unitY = unitY * (size + sw);
  3109. var pt = pe.clone();
  3110. return function()
  3111. {
  3112. c.begin();
  3113. c.moveTo(pt.x, pt.y);
  3114. if (source)
  3115. {
  3116. c.lineTo(pt.x - unitX - unitY / widthFactor, pt.y - unitY + unitX / widthFactor);
  3117. }
  3118. else
  3119. {
  3120. c.lineTo(pt.x + unitY / widthFactor - unitX, pt.y - unitY - unitX / widthFactor);
  3121. }
  3122. c.stroke();
  3123. };
  3124. }
  3125. };
  3126. mxMarker.addMarker('openAsync', createOpenAsyncArrow(2));
  3127. function arrow(canvas, shape, type, pe, unitX, unitY, size, source, sw, filled)
  3128. {
  3129. // The angle of the forward facing arrow sides against the x axis is
  3130. // 26.565 degrees, 1/sin(26.565) = 2.236 / 2 = 1.118 ( / 2 allows for
  3131. // only half the strokewidth is processed ).
  3132. var endOffsetX = unitX * sw * 1.118;
  3133. var endOffsetY = unitY * sw * 1.118;
  3134. unitX = unitX * (size + sw);
  3135. unitY = unitY * (size + sw);
  3136. var pt = pe.clone();
  3137. pt.x -= endOffsetX;
  3138. pt.y -= endOffsetY;
  3139. var f = (type != mxConstants.ARROW_CLASSIC && type != mxConstants.ARROW_CLASSIC_THIN) ? 1 : 3 / 4;
  3140. pe.x += -unitX * f - endOffsetX;
  3141. pe.y += -unitY * f - endOffsetY;
  3142. return function()
  3143. {
  3144. canvas.begin();
  3145. canvas.moveTo(pt.x, pt.y);
  3146. canvas.lineTo(pt.x - unitX - unitY / widthFactor, pt.y - unitY + unitX / widthFactor);
  3147. if (type == mxConstants.ARROW_CLASSIC || type == mxConstants.ARROW_CLASSIC_THIN)
  3148. {
  3149. canvas.lineTo(pt.x - unitX * 3 / 4, pt.y - unitY * 3 / 4);
  3150. }
  3151. canvas.lineTo(pt.x + unitY / widthFactor - unitX, pt.y - unitY - unitX / widthFactor);
  3152. canvas.close();
  3153. if (filled)
  3154. {
  3155. canvas.fillAndStroke();
  3156. }
  3157. else
  3158. {
  3159. canvas.stroke();
  3160. }
  3161. };
  3162. }
  3163. // Handlers are only added if mxVertexHandler is defined (ie. not in embedded graph)
  3164. if (typeof mxVertexHandler !== 'undefined')
  3165. {
  3166. function createHandle(state, keys, getPositionFn, setPositionFn, ignoreGrid, redrawEdges, executeFn)
  3167. {
  3168. var handle = new mxHandle(state, null, mxVertexHandler.prototype.secondaryHandleImage);
  3169. handle.execute = function(me)
  3170. {
  3171. for (var i = 0; i < keys.length; i++)
  3172. {
  3173. this.copyStyle(keys[i]);
  3174. }
  3175. if (executeFn)
  3176. {
  3177. executeFn(me);
  3178. }
  3179. };
  3180. handle.getPosition = getPositionFn;
  3181. handle.setPosition = setPositionFn;
  3182. handle.ignoreGrid = (ignoreGrid != null) ? ignoreGrid : true;
  3183. // Overridden to update connected edges
  3184. if (redrawEdges)
  3185. {
  3186. var positionChanged = handle.positionChanged;
  3187. handle.positionChanged = function()
  3188. {
  3189. positionChanged.apply(this, arguments);
  3190. // Redraws connected edges TODO: Include child edges
  3191. state.view.invalidate(this.state.cell);
  3192. state.view.validate();
  3193. };
  3194. }
  3195. return handle;
  3196. };
  3197. function createArcHandle(state, yOffset)
  3198. {
  3199. return createHandle(state, [mxConstants.STYLE_ARCSIZE], function(bounds)
  3200. {
  3201. var tmp = (yOffset != null) ? yOffset : bounds.height / 8;
  3202. if (mxUtils.getValue(state.style, mxConstants.STYLE_ABSOLUTE_ARCSIZE, 0) == '1')
  3203. {
  3204. var arcSize = mxUtils.getValue(state.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  3205. return new mxPoint(bounds.x + bounds.width - Math.min(bounds.width / 2, arcSize), bounds.y + tmp);
  3206. }
  3207. else
  3208. {
  3209. var arcSize = Math.max(0, parseFloat(mxUtils.getValue(state.style,
  3210. mxConstants.STYLE_ARCSIZE, mxConstants.RECTANGLE_ROUNDING_FACTOR * 100))) / 100;
  3211. return new mxPoint(bounds.x + bounds.width - Math.min(Math.max(bounds.width / 2, bounds.height / 2),
  3212. Math.min(bounds.width, bounds.height) * arcSize), bounds.y + tmp);
  3213. }
  3214. }, function(bounds, pt, me)
  3215. {
  3216. if (mxUtils.getValue(state.style, mxConstants.STYLE_ABSOLUTE_ARCSIZE, 0) == '1')
  3217. {
  3218. this.state.style[mxConstants.STYLE_ARCSIZE] = Math.round(Math.max(0, Math.min(bounds.width,
  3219. (bounds.x + bounds.width - pt.x) * 2)));
  3220. }
  3221. else
  3222. {
  3223. var f = Math.min(50, Math.max(0, (bounds.width - pt.x + bounds.x) * 100 /
  3224. Math.min(bounds.width, bounds.height)));
  3225. this.state.style[mxConstants.STYLE_ARCSIZE] = Math.round(f);
  3226. }
  3227. });
  3228. }
  3229. function createArcHandleFunction()
  3230. {
  3231. return function(state)
  3232. {
  3233. var handles = [];
  3234. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  3235. {
  3236. handles.push(createArcHandle(state));
  3237. }
  3238. return handles;
  3239. };
  3240. };
  3241. function createTrapezoidHandleFunction(max, defaultValue, fixedDefaultValue)
  3242. {
  3243. max = (max != null) ? max : 0.5;
  3244. return function(state)
  3245. {
  3246. var handles = [createHandle(state, ['size'], function(bounds)
  3247. {
  3248. var fixed = (fixedDefaultValue != null) ? mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0' : null;
  3249. var size = Math.max(0, parseFloat(mxUtils.getValue(this.state.style, 'size', (fixed) ? fixedDefaultValue : defaultValue)));
  3250. return new mxPoint(bounds.x + Math.min(bounds.width * 0.75 * max, size * ((fixed) ? 0.75 : bounds.width * 0.75)), bounds.y + bounds.height / 4);
  3251. }, function(bounds, pt)
  3252. {
  3253. var fixed = (fixedDefaultValue != null) ? mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0' : null;
  3254. var size = (fixed) ? (pt.x - bounds.x) : Math.max(0, Math.min(max, (pt.x - bounds.x) / bounds.width * 0.75));
  3255. this.state.style['size'] = size;
  3256. }, false, true)];
  3257. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  3258. {
  3259. handles.push(createArcHandle(state));
  3260. }
  3261. return handles;
  3262. };
  3263. };
  3264. function createDisplayHandleFunction(defaultValue, allowArcHandle, max, redrawEdges, fixedDefaultValue)
  3265. {
  3266. max = (max != null) ? max : 0.5;
  3267. return function(state)
  3268. {
  3269. var handles = [createHandle(state, ['size'], function(bounds)
  3270. {
  3271. var fixed = (fixedDefaultValue != null) ? mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0' : null;
  3272. var size = parseFloat(mxUtils.getValue(this.state.style, 'size', (fixed) ? fixedDefaultValue : defaultValue));
  3273. return new mxPoint(bounds.x + Math.max(0, Math.min(bounds.width * 0.5, size * ((fixed) ? 1 : bounds.width))), bounds.getCenterY());
  3274. }, function(bounds, pt, me)
  3275. {
  3276. var fixed = (fixedDefaultValue != null) ? mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0' : null;
  3277. var size = (fixed) ? (pt.x - bounds.x) : Math.max(0, Math.min(max, (pt.x - bounds.x) / bounds.width));
  3278. this.state.style['size'] = size;
  3279. }, false, redrawEdges)];
  3280. if (allowArcHandle && mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  3281. {
  3282. handles.push(createArcHandle(state));
  3283. }
  3284. return handles;
  3285. };
  3286. };
  3287. function createCubeHandleFunction(factor, defaultValue, allowArcHandle)
  3288. {
  3289. return function(state)
  3290. {
  3291. var handles = [createHandle(state, ['size'], function(bounds)
  3292. {
  3293. var size = Math.max(0, Math.min(bounds.width, Math.min(bounds.height, parseFloat(
  3294. mxUtils.getValue(this.state.style, 'size', defaultValue))))) * factor;
  3295. return new mxPoint(bounds.x + size, bounds.y + size);
  3296. }, function(bounds, pt)
  3297. {
  3298. this.state.style['size'] = Math.round(Math.max(0, Math.min(Math.min(bounds.width, pt.x - bounds.x),
  3299. Math.min(bounds.height, pt.y - bounds.y))) / factor);
  3300. }, false)];
  3301. if (allowArcHandle && mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  3302. {
  3303. handles.push(createArcHandle(state));
  3304. }
  3305. return handles;
  3306. };
  3307. };
  3308. function createCylinderHandleFunction(defaultValue)
  3309. {
  3310. return function(state)
  3311. {
  3312. return [createHandle(state, ['size'], function(bounds)
  3313. {
  3314. var size = Math.max(0, Math.min(bounds.height * 0.5, parseFloat(mxUtils.getValue(this.state.style, 'size', defaultValue))));
  3315. return new mxPoint(bounds.x, bounds.y + size);
  3316. }, function(bounds, pt)
  3317. {
  3318. this.state.style['size'] = Math.max(0, pt.y - bounds.y);
  3319. }, true)];
  3320. }
  3321. };
  3322. function createArrowHandleFunction(maxSize)
  3323. {
  3324. return function(state)
  3325. {
  3326. return [createHandle(state, ['arrowWidth', 'arrowSize'], function(bounds)
  3327. {
  3328. var aw = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'arrowWidth', SingleArrowShape.prototype.arrowWidth)));
  3329. var as = Math.max(0, Math.min(maxSize, mxUtils.getValue(this.state.style, 'arrowSize', SingleArrowShape.prototype.arrowSize)));
  3330. return new mxPoint(bounds.x + (1 - as) * bounds.width, bounds.y + (1 - aw) * bounds.height / 2);
  3331. }, function(bounds, pt)
  3332. {
  3333. this.state.style['arrowWidth'] = Math.max(0, Math.min(1, Math.abs(bounds.y + bounds.height / 2 - pt.y) / bounds.height * 2));
  3334. this.state.style['arrowSize'] = Math.max(0, Math.min(maxSize, (bounds.x + bounds.width - pt.x) / (bounds.width)));
  3335. })];
  3336. };
  3337. };
  3338. function createEdgeHandle(state, keys, start, getPosition, setPosition)
  3339. {
  3340. return createHandle(state, keys, function(bounds)
  3341. {
  3342. var pts = state.absolutePoints;
  3343. var n = pts.length - 1;
  3344. var tr = state.view.translate;
  3345. var s = state.view.scale;
  3346. var p0 = (start) ? pts[0] : pts[n];
  3347. var p1 = (start) ? pts[1] : pts[n - 1];
  3348. var dx = (start) ? p1.x - p0.x : p1.x - p0.x;
  3349. var dy = (start) ? p1.y - p0.y : p1.y - p0.y;
  3350. var dist = Math.sqrt(dx * dx + dy * dy);
  3351. var pt = getPosition.call(this, dist, dx / dist, dy / dist, p0, p1);
  3352. return new mxPoint(pt.x / s - tr.x, pt.y / s - tr.y);
  3353. }, function(bounds, pt, me)
  3354. {
  3355. var pts = state.absolutePoints;
  3356. var n = pts.length - 1;
  3357. var tr = state.view.translate;
  3358. var s = state.view.scale;
  3359. var p0 = (start) ? pts[0] : pts[n];
  3360. var p1 = (start) ? pts[1] : pts[n - 1];
  3361. var dx = (start) ? p1.x - p0.x : p1.x - p0.x;
  3362. var dy = (start) ? p1.y - p0.y : p1.y - p0.y;
  3363. var dist = Math.sqrt(dx * dx + dy * dy);
  3364. pt.x = (pt.x + tr.x) * s;
  3365. pt.y = (pt.y + tr.y) * s;
  3366. setPosition.call(this, dist, dx / dist, dy / dist, p0, p1, pt, me);
  3367. });
  3368. };
  3369. function createEdgeWidthHandle(state, start, spacing)
  3370. {
  3371. return createEdgeHandle(state, ['width'], start, function(dist, nx, ny, p0, p1)
  3372. {
  3373. var w = state.shape.getEdgeWidth() * state.view.scale + spacing;
  3374. return new mxPoint(p0.x + nx * dist / 4 + ny * w / 2, p0.y + ny * dist / 4 - nx * w / 2);
  3375. }, function(dist, nx, ny, p0, p1, pt)
  3376. {
  3377. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  3378. state.style['width'] = Math.round(w * 2) / state.view.scale - spacing;
  3379. });
  3380. };
  3381. function ptLineDistance(x1, y1, x2, y2, x0, y0)
  3382. {
  3383. return Math.abs((y2 - y1) * x0 - (x2 - x1) * y0 + x2 * y1 - y2 * x1) / Math.sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
  3384. }
  3385. var handleFactory = {
  3386. 'link': function(state)
  3387. {
  3388. var spacing = 10;
  3389. return [createEdgeWidthHandle(state, true, spacing), createEdgeWidthHandle(state, false, spacing)];
  3390. },
  3391. 'flexArrow': function(state)
  3392. {
  3393. // Do not use state.shape.startSize/endSize since it is cached
  3394. var tol = state.view.graph.gridSize / state.view.scale;
  3395. var handles = [];
  3396. if (mxUtils.getValue(state.style, mxConstants.STYLE_STARTARROW, mxConstants.NONE) != mxConstants.NONE)
  3397. {
  3398. handles.push(createEdgeHandle(state, ['width', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], true, function(dist, nx, ny, p0, p1)
  3399. {
  3400. var w = (state.shape.getEdgeWidth() - state.shape.strokewidth) * state.view.scale;
  3401. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  3402. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) + ny * w / 2,
  3403. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) - nx * w / 2);
  3404. }, function(dist, nx, ny, p0, p1, pt, me)
  3405. {
  3406. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  3407. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  3408. state.style[mxConstants.STYLE_STARTSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  3409. state.style['width'] = Math.round(w * 2) / state.view.scale;
  3410. // Applies to opposite side
  3411. if (mxEvent.isControlDown(me.getEvent()))
  3412. {
  3413. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  3414. }
  3415. // Snaps to end geometry
  3416. if (!mxEvent.isAltDown(me.getEvent()))
  3417. {
  3418. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_STARTSIZE]) - parseFloat(state.style[mxConstants.STYLE_ENDSIZE])) < tol / 6)
  3419. {
  3420. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  3421. }
  3422. }
  3423. }));
  3424. handles.push(createEdgeHandle(state, ['startWidth', 'endWidth', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], true, function(dist, nx, ny, p0, p1)
  3425. {
  3426. var w = (state.shape.getStartArrowWidth() - state.shape.strokewidth) * state.view.scale;
  3427. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  3428. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) + ny * w / 2,
  3429. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) - nx * w / 2);
  3430. }, function(dist, nx, ny, p0, p1, pt, me)
  3431. {
  3432. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  3433. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  3434. state.style[mxConstants.STYLE_STARTSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  3435. state.style['startWidth'] = Math.max(0, Math.round(w * 2) - state.shape.getEdgeWidth()) / state.view.scale;
  3436. // Applies to opposite side
  3437. if (mxEvent.isControlDown(me.getEvent()))
  3438. {
  3439. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  3440. state.style['endWidth'] = state.style['startWidth'];
  3441. }
  3442. // Snaps to endWidth
  3443. if (!mxEvent.isAltDown(me.getEvent()))
  3444. {
  3445. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_STARTSIZE]) - parseFloat(state.style[mxConstants.STYLE_ENDSIZE])) < tol / 6)
  3446. {
  3447. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  3448. }
  3449. if (Math.abs(parseFloat(state.style['startWidth']) - parseFloat(state.style['endWidth'])) < tol)
  3450. {
  3451. state.style['startWidth'] = state.style['endWidth'];
  3452. }
  3453. }
  3454. }));
  3455. }
  3456. if (mxUtils.getValue(state.style, mxConstants.STYLE_ENDARROW, mxConstants.NONE) != mxConstants.NONE)
  3457. {
  3458. handles.push(createEdgeHandle(state, ['width', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], false, function(dist, nx, ny, p0, p1)
  3459. {
  3460. var w = (state.shape.getEdgeWidth() - state.shape.strokewidth) * state.view.scale;
  3461. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_ENDSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  3462. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) - ny * w / 2,
  3463. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) + nx * w / 2);
  3464. }, function(dist, nx, ny, p0, p1, pt, me)
  3465. {
  3466. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  3467. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  3468. state.style[mxConstants.STYLE_ENDSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  3469. state.style['width'] = Math.round(w * 2) / state.view.scale;
  3470. // Applies to opposite side
  3471. if (mxEvent.isControlDown(me.getEvent()))
  3472. {
  3473. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  3474. }
  3475. // Snaps to start geometry
  3476. if (!mxEvent.isAltDown(me.getEvent()))
  3477. {
  3478. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_ENDSIZE]) - parseFloat(state.style[mxConstants.STYLE_STARTSIZE])) < tol / 6)
  3479. {
  3480. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  3481. }
  3482. }
  3483. }));
  3484. handles.push(createEdgeHandle(state, ['startWidth', 'endWidth', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], false, function(dist, nx, ny, p0, p1)
  3485. {
  3486. var w = (state.shape.getEndArrowWidth() - state.shape.strokewidth) * state.view.scale;
  3487. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_ENDSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  3488. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) - ny * w / 2,
  3489. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) + nx * w / 2);
  3490. }, function(dist, nx, ny, p0, p1, pt, me)
  3491. {
  3492. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  3493. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  3494. state.style[mxConstants.STYLE_ENDSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  3495. state.style['endWidth'] = Math.max(0, Math.round(w * 2) - state.shape.getEdgeWidth()) / state.view.scale;
  3496. // Applies to opposite side
  3497. if (mxEvent.isControlDown(me.getEvent()))
  3498. {
  3499. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  3500. state.style['startWidth'] = state.style['endWidth'];
  3501. }
  3502. // Snaps to start geometry
  3503. if (!mxEvent.isAltDown(me.getEvent()))
  3504. {
  3505. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_ENDSIZE]) - parseFloat(state.style[mxConstants.STYLE_STARTSIZE])) < tol / 6)
  3506. {
  3507. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  3508. }
  3509. if (Math.abs(parseFloat(state.style['endWidth']) - parseFloat(state.style['startWidth'])) < tol)
  3510. {
  3511. state.style['endWidth'] = state.style['startWidth'];
  3512. }
  3513. }
  3514. }));
  3515. }
  3516. return handles;
  3517. },
  3518. 'swimlane': function(state)
  3519. {
  3520. var handles = [];
  3521. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED))
  3522. {
  3523. var size = parseFloat(mxUtils.getValue(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_STARTSIZE));
  3524. handles.push(createArcHandle(state, size / 2));
  3525. }
  3526. // Start size handle must be last item in handles for hover to work in tables (see mouse event handler in Graph)
  3527. handles.push(createHandle(state, [mxConstants.STYLE_STARTSIZE], function(bounds)
  3528. {
  3529. var size = parseFloat(mxUtils.getValue(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_STARTSIZE));
  3530. if (mxUtils.getValue(state.style, mxConstants.STYLE_HORIZONTAL, 1) == 1)
  3531. {
  3532. return new mxPoint(bounds.getCenterX(), bounds.y + Math.max(0, Math.min(bounds.height, size)));
  3533. }
  3534. else
  3535. {
  3536. return new mxPoint(bounds.x + Math.max(0, Math.min(bounds.width, size)), bounds.getCenterY());
  3537. }
  3538. }, function(bounds, pt)
  3539. {
  3540. state.style[mxConstants.STYLE_STARTSIZE] =
  3541. (mxUtils.getValue(this.state.style, mxConstants.STYLE_HORIZONTAL, 1) == 1) ?
  3542. Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y))) :
  3543. Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x)));
  3544. }, false, null, function(me)
  3545. {
  3546. if (mxEvent.isControlDown(me.getEvent()))
  3547. {
  3548. var graph = state.view.graph;
  3549. if (graph.isTableRow(state.cell) || graph.isTableCell(state.cell))
  3550. {
  3551. var dir = graph.getSwimlaneDirection(state.style);
  3552. var parent = graph.model.getParent(state.cell);
  3553. var cells = graph.model.getChildCells(parent, true);
  3554. var temp = [];
  3555. for (var i = 0; i < cells.length; i++)
  3556. {
  3557. // Finds siblings with the same direction and to set start size
  3558. if (cells[i] != state.cell && graph.isSwimlane(cells[i]) &&
  3559. graph.getSwimlaneDirection(graph.getCurrentCellStyle(
  3560. cells[i])) == dir)
  3561. {
  3562. temp.push(cells[i]);
  3563. }
  3564. }
  3565. graph.setCellStyles(mxConstants.STYLE_STARTSIZE,
  3566. state.style[mxConstants.STYLE_STARTSIZE], temp);
  3567. }
  3568. }
  3569. }));
  3570. return handles;
  3571. },
  3572. 'label': createArcHandleFunction(),
  3573. 'ext': createArcHandleFunction(),
  3574. 'rectangle': createArcHandleFunction(),
  3575. 'triangle': createArcHandleFunction(),
  3576. 'rhombus': createArcHandleFunction(),
  3577. 'umlLifeline': function(state)
  3578. {
  3579. return [createHandle(state, ['size'], function(bounds)
  3580. {
  3581. var size = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'size', UmlLifeline.prototype.size))));
  3582. return new mxPoint(bounds.getCenterX(), bounds.y + size);
  3583. }, function(bounds, pt)
  3584. {
  3585. this.state.style['size'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  3586. }, false)];
  3587. },
  3588. 'umlFrame': function(state)
  3589. {
  3590. var handles = [createHandle(state, ['width', 'height'], function(bounds)
  3591. {
  3592. var w0 = Math.max(UmlFrame.prototype.corner, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'width', UmlFrame.prototype.width)));
  3593. var h0 = Math.max(UmlFrame.prototype.corner * 1.5, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'height', UmlFrame.prototype.height)));
  3594. return new mxPoint(bounds.x + w0, bounds.y + h0);
  3595. }, function(bounds, pt)
  3596. {
  3597. this.state.style['width'] = Math.round(Math.max(UmlFrame.prototype.corner, Math.min(bounds.width, pt.x - bounds.x)));
  3598. this.state.style['height'] = Math.round(Math.max(UmlFrame.prototype.corner * 1.5, Math.min(bounds.height, pt.y - bounds.y)));
  3599. }, false)];
  3600. return handles;
  3601. },
  3602. 'process': function(state)
  3603. {
  3604. var handles = [createHandle(state, ['size'], function(bounds)
  3605. {
  3606. var fixed = mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0';
  3607. var size = parseFloat(mxUtils.getValue(this.state.style, 'size', ProcessShape.prototype.size));
  3608. return (fixed) ? new mxPoint(bounds.x + size, bounds.y + bounds.height / 4) : new mxPoint(bounds.x + bounds.width * size, bounds.y + bounds.height / 4);
  3609. }, function(bounds, pt)
  3610. {
  3611. var fixed = mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0';
  3612. var size = (fixed) ? Math.max(0, Math.min(bounds.width * 0.5, (pt.x - bounds.x))) : Math.max(0, Math.min(0.5, (pt.x - bounds.x) / bounds.width));
  3613. this.state.style['size'] = size;
  3614. }, false)];
  3615. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  3616. {
  3617. handles.push(createArcHandle(state));
  3618. }
  3619. return handles;
  3620. },
  3621. 'cross': function(state)
  3622. {
  3623. return [createHandle(state, ['size'], function(bounds)
  3624. {
  3625. var m = Math.min(bounds.width, bounds.height);
  3626. var size = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'size', CrossShape.prototype.size))) * m / 2;
  3627. return new mxPoint(bounds.getCenterX() - size, bounds.getCenterY() - size);
  3628. }, function(bounds, pt)
  3629. {
  3630. var m = Math.min(bounds.width, bounds.height);
  3631. this.state.style['size'] = Math.max(0, Math.min(1, Math.min((Math.max(0, bounds.getCenterY() - pt.y) / m) * 2,
  3632. (Math.max(0, bounds.getCenterX() - pt.x) / m) * 2)));
  3633. })];
  3634. },
  3635. 'note': function(state)
  3636. {
  3637. return [createHandle(state, ['size'], function(bounds)
  3638. {
  3639. var size = Math.max(0, Math.min(bounds.width, Math.min(bounds.height, parseFloat(
  3640. mxUtils.getValue(this.state.style, 'size', NoteShape.prototype.size)))));
  3641. return new mxPoint(bounds.x + bounds.width - size, bounds.y + size);
  3642. }, function(bounds, pt)
  3643. {
  3644. this.state.style['size'] = Math.round(Math.max(0, Math.min(Math.min(bounds.width, bounds.x + bounds.width - pt.x),
  3645. Math.min(bounds.height, pt.y - bounds.y))));
  3646. })];
  3647. },
  3648. 'note2': function(state)
  3649. {
  3650. return [createHandle(state, ['size'], function(bounds)
  3651. {
  3652. var size = Math.max(0, Math.min(bounds.width, Math.min(bounds.height, parseFloat(
  3653. mxUtils.getValue(this.state.style, 'size', NoteShape2.prototype.size)))));
  3654. return new mxPoint(bounds.x + bounds.width - size, bounds.y + size);
  3655. }, function(bounds, pt)
  3656. {
  3657. this.state.style['size'] = Math.round(Math.max(0, Math.min(Math.min(bounds.width, bounds.x + bounds.width - pt.x),
  3658. Math.min(bounds.height, pt.y - bounds.y))));
  3659. })];
  3660. },
  3661. 'manualInput': function(state)
  3662. {
  3663. var handles = [createHandle(state, ['size'], function(bounds)
  3664. {
  3665. var size = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'size', ManualInputShape.prototype.size)));
  3666. return new mxPoint(bounds.x + bounds.width / 4, bounds.y + size * 3 / 4);
  3667. }, function(bounds, pt)
  3668. {
  3669. this.state.style['size'] = Math.round(Math.max(0, Math.min(bounds.height, (pt.y - bounds.y) * 4 / 3)));
  3670. }, false)];
  3671. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  3672. {
  3673. handles.push(createArcHandle(state));
  3674. }
  3675. return handles;
  3676. },
  3677. 'dataStorage': function(state)
  3678. {
  3679. return [createHandle(state, ['size'], function(bounds)
  3680. {
  3681. var fixed = mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0';
  3682. var size = parseFloat(mxUtils.getValue(this.state.style, 'size', (fixed) ? DataStorageShape.prototype.fixedSize : DataStorageShape.prototype.size));
  3683. return new mxPoint(bounds.x + bounds.width - size * ((fixed) ? 1 : bounds.width), bounds.getCenterY());
  3684. }, function(bounds, pt)
  3685. {
  3686. var fixed = mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0';
  3687. var size = (fixed) ? Math.max(0, Math.min(bounds.width, (bounds.x + bounds.width - pt.x))) : Math.max(0, Math.min(1, (bounds.x + bounds.width - pt.x) / bounds.width));
  3688. this.state.style['size'] = size;
  3689. }, false)];
  3690. },
  3691. 'callout': function(state)
  3692. {
  3693. var handles = [createHandle(state, ['size', 'position'], function(bounds)
  3694. {
  3695. var size = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'size', CalloutShape.prototype.size)));
  3696. var position = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'position', CalloutShape.prototype.position)));
  3697. var base = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'base', CalloutShape.prototype.base)));
  3698. return new mxPoint(bounds.x + position * bounds.width, bounds.y + bounds.height - size);
  3699. }, function(bounds, pt)
  3700. {
  3701. var base = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'base', CalloutShape.prototype.base)));
  3702. this.state.style['size'] = Math.round(Math.max(0, Math.min(bounds.height, bounds.y + bounds.height - pt.y)));
  3703. this.state.style['position'] = Math.round(Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width)) * 100) / 100;
  3704. }, false), createHandle(state, ['position2'], function(bounds)
  3705. {
  3706. var position2 = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'position2', CalloutShape.prototype.position2)));
  3707. return new mxPoint(bounds.x + position2 * bounds.width, bounds.y + bounds.height);
  3708. }, function(bounds, pt)
  3709. {
  3710. this.state.style['position2'] = Math.round(Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width)) * 100) / 100;
  3711. }, false), createHandle(state, ['base'], function(bounds)
  3712. {
  3713. var size = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'size', CalloutShape.prototype.size)));
  3714. var position = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'position', CalloutShape.prototype.position)));
  3715. var base = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'base', CalloutShape.prototype.base)));
  3716. return new mxPoint(bounds.x + Math.min(bounds.width, position * bounds.width + base), bounds.y + bounds.height - size);
  3717. }, function(bounds, pt)
  3718. {
  3719. var position = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'position', CalloutShape.prototype.position)));
  3720. this.state.style['base'] = Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x - position * bounds.width)));
  3721. }, false)];
  3722. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  3723. {
  3724. handles.push(createArcHandle(state));
  3725. }
  3726. return handles;
  3727. },
  3728. 'internalStorage': function(state)
  3729. {
  3730. var handles = [createHandle(state, ['dx', 'dy'], function(bounds)
  3731. {
  3732. var dx = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'dx', InternalStorageShape.prototype.dx)));
  3733. var dy = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'dy', InternalStorageShape.prototype.dy)));
  3734. return new mxPoint(bounds.x + dx, bounds.y + dy);
  3735. }, function(bounds, pt)
  3736. {
  3737. this.state.style['dx'] = Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x)));
  3738. this.state.style['dy'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  3739. }, false)];
  3740. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  3741. {
  3742. handles.push(createArcHandle(state));
  3743. }
  3744. return handles;
  3745. },
  3746. 'module': function(state)
  3747. {
  3748. var handles = [createHandle(state, ['jettyWidth', 'jettyHeight'], function(bounds)
  3749. {
  3750. var dx = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'jettyWidth', ModuleShape.prototype.jettyWidth)));
  3751. var dy = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'jettyHeight', ModuleShape.prototype.jettyHeight)));
  3752. return new mxPoint(bounds.x + dx / 2, bounds.y + dy * 2);
  3753. }, function(bounds, pt)
  3754. {
  3755. this.state.style['jettyWidth'] = Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x)) * 2);
  3756. this.state.style['jettyHeight'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)) / 2);
  3757. })];
  3758. return handles;
  3759. },
  3760. 'corner': function(state)
  3761. {
  3762. return [createHandle(state, ['dx', 'dy'], function(bounds)
  3763. {
  3764. var dx = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'dx', CornerShape.prototype.dx)));
  3765. var dy = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'dy', CornerShape.prototype.dy)));
  3766. return new mxPoint(bounds.x + dx, bounds.y + dy);
  3767. }, function(bounds, pt)
  3768. {
  3769. this.state.style['dx'] = Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x)));
  3770. this.state.style['dy'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  3771. }, false)];
  3772. },
  3773. 'tee': function(state)
  3774. {
  3775. return [createHandle(state, ['dx', 'dy'], function(bounds)
  3776. {
  3777. var dx = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'dx', TeeShape.prototype.dx)));
  3778. var dy = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'dy', TeeShape.prototype.dy)));
  3779. return new mxPoint(bounds.x + (bounds.width + dx) / 2, bounds.y + dy);
  3780. }, function(bounds, pt)
  3781. {
  3782. this.state.style['dx'] = Math.round(Math.max(0, Math.min(bounds.width / 2, (pt.x - bounds.x - bounds.width / 2)) * 2));
  3783. this.state.style['dy'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  3784. }, false)];
  3785. },
  3786. 'singleArrow': createArrowHandleFunction(1),
  3787. 'doubleArrow': createArrowHandleFunction(0.5),
  3788. 'folder': function(state)
  3789. {
  3790. return [createHandle(state, ['tabWidth', 'tabHeight'], function(bounds)
  3791. {
  3792. var tw = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'tabWidth', FolderShape.prototype.tabWidth)));
  3793. var th = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'tabHeight', FolderShape.prototype.tabHeight)));
  3794. if (mxUtils.getValue(this.state.style, 'tabPosition', FolderShape.prototype.tabPosition) == mxConstants.ALIGN_RIGHT)
  3795. {
  3796. tw = bounds.width - tw;
  3797. }
  3798. return new mxPoint(bounds.x + tw, bounds.y + th);
  3799. }, function(bounds, pt)
  3800. {
  3801. var tw = Math.max(0, Math.min(bounds.width, pt.x - bounds.x));
  3802. if (mxUtils.getValue(this.state.style, 'tabPosition', FolderShape.prototype.tabPosition) == mxConstants.ALIGN_RIGHT)
  3803. {
  3804. tw = bounds.width - tw;
  3805. }
  3806. this.state.style['tabWidth'] = Math.round(tw);
  3807. this.state.style['tabHeight'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  3808. }, false)];
  3809. },
  3810. 'document': function(state)
  3811. {
  3812. return [createHandle(state, ['size'], function(bounds)
  3813. {
  3814. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', DocumentShape.prototype.size))));
  3815. return new mxPoint(bounds.x + 3 * bounds.width / 4, bounds.y + (1 - size) * bounds.height);
  3816. }, function(bounds, pt)
  3817. {
  3818. this.state.style['size'] = Math.max(0, Math.min(1, (bounds.y + bounds.height - pt.y) / bounds.height));
  3819. }, false)];
  3820. },
  3821. 'tape': function(state)
  3822. {
  3823. return [createHandle(state, ['size'], function(bounds)
  3824. {
  3825. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', TapeShape.prototype.size))));
  3826. return new mxPoint(bounds.getCenterX(), bounds.y + size * bounds.height / 2);
  3827. }, function(bounds, pt)
  3828. {
  3829. this.state.style['size'] = Math.max(0, Math.min(1, ((pt.y - bounds.y) / bounds.height) * 2));
  3830. }, false)];
  3831. },
  3832. 'isoCube2' : function(state)
  3833. {
  3834. return [createHandle(state, ['isoAngle'], function(bounds)
  3835. {
  3836. var isoAngle = Math.max(0.01, Math.min(94, parseFloat(mxUtils.getValue(this.state.style, 'isoAngle', IsoCubeShape2.isoAngle)))) * Math.PI / 200 ;
  3837. var isoH = Math.min(bounds.width * Math.tan(isoAngle), bounds.height * 0.5);
  3838. return new mxPoint(bounds.x, bounds.y + isoH);
  3839. }, function(bounds, pt)
  3840. {
  3841. this.state.style['isoAngle'] = Math.max(0, (pt.y - bounds.y) * 50 / bounds.height);
  3842. }, true)];
  3843. },
  3844. 'cylinder2' : createCylinderHandleFunction(CylinderShape.prototype.size),
  3845. 'cylinder3' : createCylinderHandleFunction(CylinderShape3.prototype.size),
  3846. 'offPageConnector': function(state)
  3847. {
  3848. return [createHandle(state, ['size'], function(bounds)
  3849. {
  3850. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', OffPageConnectorShape.prototype.size))));
  3851. return new mxPoint(bounds.getCenterX(), bounds.y + (1 - size) * bounds.height);
  3852. }, function(bounds, pt)
  3853. {
  3854. this.state.style['size'] = Math.max(0, Math.min(1, (bounds.y + bounds.height - pt.y) / bounds.height));
  3855. }, false)];
  3856. },
  3857. 'step': createDisplayHandleFunction(StepShape.prototype.size, true, null, true, StepShape.prototype.fixedSize),
  3858. 'hexagon': createDisplayHandleFunction(HexagonShape.prototype.size, true, 0.5, true, HexagonShape.prototype.fixedSize),
  3859. 'curlyBracket': createDisplayHandleFunction(CurlyBracketShape.prototype.size, false),
  3860. 'display': createDisplayHandleFunction(DisplayShape.prototype.size, false),
  3861. 'cube': createCubeHandleFunction(1, CubeShape.prototype.size, false),
  3862. 'card': createCubeHandleFunction(0.5, CardShape.prototype.size, true),
  3863. 'loopLimit': createCubeHandleFunction(0.5, LoopLimitShape.prototype.size, true),
  3864. 'trapezoid': createTrapezoidHandleFunction(0.5, TrapezoidShape.prototype.size, TrapezoidShape.prototype.fixedSize),
  3865. 'parallelogram': createTrapezoidHandleFunction(1, ParallelogramShape.prototype.size, ParallelogramShape.prototype.fixedSize)
  3866. };
  3867. // Exposes custom handles
  3868. Graph.createHandle = createHandle;
  3869. Graph.handleFactory = handleFactory;
  3870. var vertexHandlerCreateCustomHandles = mxVertexHandler.prototype.createCustomHandles;
  3871. mxVertexHandler.prototype.createCustomHandles = function()
  3872. {
  3873. var handles = vertexHandlerCreateCustomHandles.apply(this, arguments);
  3874. if (this.graph.isCellRotatable(this.state.cell))
  3875. // LATER: Make locked state independent of rotatable flag, fix toggle if default is false
  3876. //if (this.graph.isCellResizable(this.state.cell) || this.graph.isCellMovable(this.state.cell))
  3877. {
  3878. var name = this.state.style['shape'];
  3879. if (mxCellRenderer.defaultShapes[name] == null &&
  3880. mxStencilRegistry.getStencil(name) == null)
  3881. {
  3882. name = mxConstants.SHAPE_RECTANGLE;
  3883. }
  3884. else if (this.state.view.graph.isSwimlane(this.state.cell))
  3885. {
  3886. name = mxConstants.SHAPE_SWIMLANE;
  3887. }
  3888. var fn = handleFactory[name];
  3889. if (fn == null && this.state.shape != null && this.state.shape.isRoundable())
  3890. {
  3891. fn = handleFactory[mxConstants.SHAPE_RECTANGLE];
  3892. }
  3893. if (fn != null)
  3894. {
  3895. var temp = fn(this.state);
  3896. if (temp != null)
  3897. {
  3898. if (handles == null)
  3899. {
  3900. handles = temp;
  3901. }
  3902. else
  3903. {
  3904. handles = handles.concat(temp);
  3905. }
  3906. }
  3907. }
  3908. }
  3909. return handles;
  3910. };
  3911. mxEdgeHandler.prototype.createCustomHandles = function()
  3912. {
  3913. var name = this.state.style['shape'];
  3914. if (mxCellRenderer.defaultShapes[name] == null &&
  3915. mxStencilRegistry.getStencil(name) == null)
  3916. {
  3917. name = mxConstants.SHAPE_CONNECTOR;
  3918. }
  3919. var fn = handleFactory[name];
  3920. if (fn != null)
  3921. {
  3922. return fn(this.state);
  3923. }
  3924. return null;
  3925. }
  3926. }
  3927. else
  3928. {
  3929. // Dummy entries to avoid NPE in embed mode
  3930. Graph.createHandle = function() {};
  3931. Graph.handleFactory = {};
  3932. }
  3933. var isoHVector = new mxPoint(1, 0);
  3934. var isoVVector = new mxPoint(1, 0);
  3935. var alpha1 = mxUtils.toRadians(-30);
  3936. var cos1 = Math.cos(alpha1);
  3937. var sin1 = Math.sin(alpha1);
  3938. isoHVector = mxUtils.getRotatedPoint(isoHVector, cos1, sin1);
  3939. var alpha2 = mxUtils.toRadians(-150);
  3940. var cos2 = Math.cos(alpha2);
  3941. var sin2 = Math.sin(alpha2);
  3942. isoVVector = mxUtils.getRotatedPoint(isoVVector, cos2, sin2);
  3943. mxEdgeStyle.IsometricConnector = function (state, source, target, points, result)
  3944. {
  3945. var view = state.view;
  3946. var pt = (points != null && points.length > 0) ? points[0] : null;
  3947. var pts = state.absolutePoints;
  3948. var p0 = pts[0];
  3949. var pe = pts[pts.length-1];
  3950. if (pt != null)
  3951. {
  3952. pt = view.transformControlPoint(state, pt);
  3953. }
  3954. if (p0 == null)
  3955. {
  3956. if (source != null)
  3957. {
  3958. p0 = new mxPoint(source.getCenterX(), source.getCenterY());
  3959. }
  3960. }
  3961. if (pe == null)
  3962. {
  3963. if (target != null)
  3964. {
  3965. pe = new mxPoint(target.getCenterX(), target.getCenterY());
  3966. }
  3967. }
  3968. var a1 = isoHVector.x;
  3969. var a2 = isoHVector.y;
  3970. var b1 = isoVVector.x;
  3971. var b2 = isoVVector.y;
  3972. var elbow = mxUtils.getValue(state.style, 'elbow', 'horizontal') == 'horizontal';
  3973. if (pe != null && p0 != null)
  3974. {
  3975. var last = p0;
  3976. function isoLineTo(x, y, ignoreFirst)
  3977. {
  3978. var c1 = x - last.x;
  3979. var c2 = y - last.y;
  3980. // Solves for isometric base vectors
  3981. var h = (b2 * c1 - b1 * c2) / (a1 * b2 - a2 * b1);
  3982. var v = (a2 * c1 - a1 * c2) / (a2 * b1 - a1 * b2);
  3983. if (elbow)
  3984. {
  3985. if (ignoreFirst)
  3986. {
  3987. last = new mxPoint(last.x + a1 * h, last.y + a2 * h);
  3988. result.push(last);
  3989. }
  3990. last = new mxPoint(last.x + b1 * v, last.y + b2 * v);
  3991. result.push(last);
  3992. }
  3993. else
  3994. {
  3995. if (ignoreFirst)
  3996. {
  3997. last = new mxPoint(last.x + b1 * v, last.y + b2 * v);
  3998. result.push(last);
  3999. }
  4000. last = new mxPoint(last.x + a1 * h, last.y + a2 * h);
  4001. result.push(last);
  4002. }
  4003. };
  4004. if (pt == null)
  4005. {
  4006. pt = new mxPoint(p0.x + (pe.x - p0.x) / 2, p0.y + (pe.y - p0.y) / 2);
  4007. }
  4008. isoLineTo(pt.x, pt.y, true);
  4009. isoLineTo(pe.x, pe.y, false);
  4010. }
  4011. };
  4012. mxStyleRegistry.putValue('isometricEdgeStyle', mxEdgeStyle.IsometricConnector);
  4013. var graphCreateEdgeHandler = Graph.prototype.createEdgeHandler;
  4014. Graph.prototype.createEdgeHandler = function(state, edgeStyle)
  4015. {
  4016. if (edgeStyle == mxEdgeStyle.IsometricConnector)
  4017. {
  4018. var handler = new mxElbowEdgeHandler(state);
  4019. handler.snapToTerminals = false;
  4020. return handler;
  4021. }
  4022. return graphCreateEdgeHandler.apply(this, arguments);
  4023. };
  4024. // Defines connection points for all shapes
  4025. IsoRectangleShape.prototype.constraints = [];
  4026. IsoCubeShape.prototype.getConstraints = function(style, w, h)
  4027. {
  4028. var constr = [];
  4029. var tan30 = Math.tan(mxUtils.toRadians(30));
  4030. var tan30Dx = (0.5 - tan30) / 2;
  4031. var m = Math.min(w, h / (0.5 + tan30));
  4032. var dx = (w - m) / 2;
  4033. var dy = (h - m) / 2;
  4034. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, dy + 0.25 * m));
  4035. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + 0.5 * m, dy + m * tan30Dx));
  4036. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + m, dy + 0.25 * m));
  4037. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + m, dy + 0.75 * m));
  4038. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + 0.5 * m, dy + (1 - tan30Dx) * m));
  4039. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, dy + 0.75 * m));
  4040. return (constr);
  4041. };
  4042. IsoCubeShape2.prototype.getConstraints = function(style, w, h)
  4043. {
  4044. var constr = [];
  4045. var isoAngle = Math.max(0.01, Math.min(94, parseFloat(mxUtils.getValue(this.style, 'isoAngle', this.isoAngle)))) * Math.PI / 200 ;
  4046. var isoH = Math.min(w * Math.tan(isoAngle), h * 0.5);
  4047. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  4048. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, isoH));
  4049. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  4050. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h - isoH));
  4051. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  4052. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - isoH));
  4053. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  4054. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, isoH));
  4055. return (constr);
  4056. }
  4057. CalloutShape.prototype.getConstraints = function(style, w, h)
  4058. {
  4059. var constr = [];
  4060. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  4061. var s = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  4062. var dx = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'position', this.position))));
  4063. var dx2 = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'position2', this.position2))));
  4064. var base = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'base', this.base))));
  4065. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  4066. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
  4067. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  4068. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
  4069. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  4070. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - s) * 0.5));
  4071. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h - s));
  4072. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2, h));
  4073. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - s));
  4074. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - s) * 0.5));
  4075. if (w >= s * 2)
  4076. {
  4077. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  4078. }
  4079. return (constr);
  4080. };
  4081. mxRectangleShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0), true),
  4082. new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  4083. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  4084. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  4085. new mxConnectionConstraint(new mxPoint(1, 0), true),
  4086. new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  4087. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  4088. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  4089. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  4090. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  4091. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  4092. new mxConnectionConstraint(new mxPoint(0, 1), true),
  4093. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  4094. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  4095. new mxConnectionConstraint(new mxPoint(0.75, 1), true),
  4096. new mxConnectionConstraint(new mxPoint(1, 1), true)];
  4097. mxEllipse.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0), true), new mxConnectionConstraint(new mxPoint(1, 0), true),
  4098. new mxConnectionConstraint(new mxPoint(0, 1), true), new mxConnectionConstraint(new mxPoint(1, 1), true),
  4099. new mxConnectionConstraint(new mxPoint(0.5, 0), true), new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  4100. new mxConnectionConstraint(new mxPoint(0, 0.5), true), new mxConnectionConstraint(new mxPoint(1, 0.5))];
  4101. PartialRectangleShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  4102. mxImageShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  4103. mxSwimlane.prototype.constraints = mxRectangleShape.prototype.constraints;
  4104. PlusShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  4105. mxLabel.prototype.constraints = mxRectangleShape.prototype.constraints;
  4106. NoteShape.prototype.getConstraints = function(style, w, h)
  4107. {
  4108. var constr = [];
  4109. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  4110. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  4111. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - s) * 0.5, 0));
  4112. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - s, 0));
  4113. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - s * 0.5, s * 0.5));
  4114. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, s));
  4115. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h + s) * 0.5 ));
  4116. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  4117. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  4118. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  4119. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  4120. if (w >= s * 2)
  4121. {
  4122. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  4123. }
  4124. return (constr);
  4125. };
  4126. CardShape.prototype.getConstraints = function(style, w, h)
  4127. {
  4128. var constr = [];
  4129. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  4130. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  4131. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + s) * 0.5, 0));
  4132. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, s, 0));
  4133. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, s * 0.5, s * 0.5));
  4134. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, s));
  4135. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h + s) * 0.5 ));
  4136. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  4137. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  4138. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  4139. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  4140. if (w >= s * 2)
  4141. {
  4142. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  4143. }
  4144. return (constr);
  4145. };
  4146. CubeShape.prototype.getConstraints = function(style, w, h)
  4147. {
  4148. var constr = [];
  4149. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  4150. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  4151. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - s) * 0.5, 0));
  4152. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - s, 0));
  4153. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - s * 0.5, s * 0.5));
  4154. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, s));
  4155. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h + s) * 0.5));
  4156. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  4157. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + s) * 0.5, h));
  4158. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, s, h));
  4159. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, s * 0.5, h - s * 0.5));
  4160. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - s));
  4161. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - s) * 0.5));
  4162. return (constr);
  4163. };
  4164. CylinderShape3.prototype.getConstraints = function(style, w, h)
  4165. {
  4166. var constr = [];
  4167. var s = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  4168. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  4169. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  4170. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  4171. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  4172. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, s));
  4173. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, 0, s));
  4174. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false, null, 0, -s));
  4175. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false, null, 0, -s));
  4176. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, s + (h * 0.5 - s) * 0.5));
  4177. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, 0, s + (h * 0.5 - s) * 0.5));
  4178. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, 0, h - s - (h * 0.5 - s) * 0.5));
  4179. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - s - (h * 0.5 - s) * 0.5));
  4180. constr.push(new mxConnectionConstraint(new mxPoint(0.145, 0), false, null, 0, s * 0.29));
  4181. constr.push(new mxConnectionConstraint(new mxPoint(0.855, 0), false, null, 0, s * 0.29));
  4182. constr.push(new mxConnectionConstraint(new mxPoint(0.855, 1), false, null, 0, -s * 0.29));
  4183. constr.push(new mxConnectionConstraint(new mxPoint(0.145, 1), false, null, 0, -s * 0.29));
  4184. return (constr);
  4185. };
  4186. FolderShape.prototype.getConstraints = function(style, w, h)
  4187. {
  4188. var constr = [];
  4189. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'tabWidth', this.tabWidth))));
  4190. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'tabHeight', this.tabHeight))));
  4191. var tp = mxUtils.getValue(this.style, 'tabPosition', this.tabPosition);
  4192. if (tp == 'left')
  4193. {
  4194. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  4195. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx * 0.5, 0));
  4196. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, 0));
  4197. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, dy));
  4198. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + dx) * 0.5, dy));
  4199. }
  4200. else
  4201. {
  4202. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  4203. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx * 0.5, 0));
  4204. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, 0));
  4205. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, dy));
  4206. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - dx) * 0.5, dy));
  4207. }
  4208. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy));
  4209. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dy) * 0.25 + dy));
  4210. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dy) * 0.5 + dy));
  4211. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dy) * 0.75 + dy));
  4212. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h));
  4213. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy));
  4214. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dy) * 0.25 + dy));
  4215. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dy) * 0.5 + dy));
  4216. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dy) * 0.75 + dy));
  4217. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h));
  4218. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));
  4219. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  4220. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));
  4221. return (constr);
  4222. }
  4223. InternalStorageShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  4224. DataStorageShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  4225. TapeDataShape.prototype.constraints = mxEllipse.prototype.constraints;
  4226. OrEllipseShape.prototype.constraints = mxEllipse.prototype.constraints;
  4227. SumEllipseShape.prototype.constraints = mxEllipse.prototype.constraints;
  4228. LineEllipseShape.prototype.constraints = mxEllipse.prototype.constraints;
  4229. ManualInputShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  4230. DelayShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  4231. DisplayShape.prototype.getConstraints = function(style, w, h)
  4232. {
  4233. var constr = [];
  4234. var dx = Math.min(w, h / 2);
  4235. var s = Math.min(w - dx, Math.max(0, parseFloat(mxUtils.getValue(this.style, 'size', this.size))) * w);
  4236. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false, null));
  4237. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, s, 0));
  4238. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (s + w - dx) * 0.5, 0));
  4239. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, 0));
  4240. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false, null));
  4241. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, h));
  4242. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (s + w - dx) * 0.5, h));
  4243. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, s, h));
  4244. return (constr);
  4245. };
  4246. ModuleShape.prototype.getConstraints = function(style, w, h)
  4247. {
  4248. var x0 = parseFloat(mxUtils.getValue(style, 'jettyWidth', ModuleShape.prototype.jettyWidth)) / 2;
  4249. var dy = parseFloat(mxUtils.getValue(style, 'jettyHeight', ModuleShape.prototype.jettyHeight));
  4250. var constr = [new mxConnectionConstraint(new mxPoint(0, 0), false, null, x0),
  4251. new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  4252. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  4253. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  4254. new mxConnectionConstraint(new mxPoint(1, 0), true),
  4255. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  4256. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  4257. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  4258. new mxConnectionConstraint(new mxPoint(0, 1), false, null, x0),
  4259. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  4260. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  4261. new mxConnectionConstraint(new mxPoint(0.75, 1), true),
  4262. new mxConnectionConstraint(new mxPoint(1, 1), true),
  4263. new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, Math.min(h - 0.5 * dy, 1.5 * dy)),
  4264. new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, Math.min(h - 0.5 * dy, 3.5 * dy))];
  4265. if (h > 5 * dy)
  4266. {
  4267. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.75), false, null, x0));
  4268. }
  4269. if (h > 8 * dy)
  4270. {
  4271. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false, null, x0));
  4272. }
  4273. if (h > 15 * dy)
  4274. {
  4275. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.25), false, null, x0));
  4276. }
  4277. return constr;
  4278. };
  4279. LoopLimitShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  4280. OffPageConnectorShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  4281. mxCylinder.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.15, 0.05), false),
  4282. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  4283. new mxConnectionConstraint(new mxPoint(0.85, 0.05), false),
  4284. new mxConnectionConstraint(new mxPoint(0, 0.3), true),
  4285. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  4286. new mxConnectionConstraint(new mxPoint(0, 0.7), true),
  4287. new mxConnectionConstraint(new mxPoint(1, 0.3), true),
  4288. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  4289. new mxConnectionConstraint(new mxPoint(1, 0.7), true),
  4290. new mxConnectionConstraint(new mxPoint(0.15, 0.95), false),
  4291. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  4292. new mxConnectionConstraint(new mxPoint(0.85, 0.95), false)];
  4293. UmlActorShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0.1), false),
  4294. new mxConnectionConstraint(new mxPoint(0.5, 0), false),
  4295. new mxConnectionConstraint(new mxPoint(0.75, 0.1), false),
  4296. new mxConnectionConstraint(new mxPoint(0, 1/3), false),
  4297. new mxConnectionConstraint(new mxPoint(0, 1), false),
  4298. new mxConnectionConstraint(new mxPoint(1, 1/3), false),
  4299. new mxConnectionConstraint(new mxPoint(1, 1), false),
  4300. new mxConnectionConstraint(new mxPoint(0.5, 0.5), false)];
  4301. ComponentShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  4302. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  4303. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  4304. new mxConnectionConstraint(new mxPoint(0, 0.3), true),
  4305. new mxConnectionConstraint(new mxPoint(0, 0.7), true),
  4306. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  4307. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  4308. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  4309. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  4310. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  4311. new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
  4312. mxActor.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  4313. new mxConnectionConstraint(new mxPoint(0.25, 0.2), false),
  4314. new mxConnectionConstraint(new mxPoint(0.1, 0.5), false),
  4315. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  4316. new mxConnectionConstraint(new mxPoint(0.75, 0.25), false),
  4317. new mxConnectionConstraint(new mxPoint(0.9, 0.5), false),
  4318. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  4319. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  4320. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  4321. new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
  4322. SwitchShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0), false),
  4323. new mxConnectionConstraint(new mxPoint(0.5, 0.25), false),
  4324. new mxConnectionConstraint(new mxPoint(1, 0), false),
  4325. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  4326. new mxConnectionConstraint(new mxPoint(0.75, 0.5), false),
  4327. new mxConnectionConstraint(new mxPoint(0, 1), false),
  4328. new mxConnectionConstraint(new mxPoint(0.5, 0.75), false),
  4329. new mxConnectionConstraint(new mxPoint(1, 1), false)];
  4330. TapeShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.35), false),
  4331. new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  4332. new mxConnectionConstraint(new mxPoint(0, 0.65), false),
  4333. new mxConnectionConstraint(new mxPoint(1, 0.35), false),
  4334. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  4335. new mxConnectionConstraint(new mxPoint(1, 0.65), false),
  4336. new mxConnectionConstraint(new mxPoint(0.25, 1), false),
  4337. new mxConnectionConstraint(new mxPoint(0.75, 0), false)];
  4338. StepShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  4339. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  4340. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  4341. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  4342. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  4343. new mxConnectionConstraint(new mxPoint(0.75, 1), true),
  4344. new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  4345. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  4346. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  4347. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  4348. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  4349. new mxConnectionConstraint(new mxPoint(1, 0.75), true)];
  4350. mxLine.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  4351. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  4352. new mxConnectionConstraint(new mxPoint(0.75, 0.5), false),
  4353. new mxConnectionConstraint(new mxPoint(1, 0.5), false)];
  4354. LollipopShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.5, 0), false),
  4355. new mxConnectionConstraint(new mxPoint(0.5, 1), false)];
  4356. mxDoubleEllipse.prototype.constraints = mxEllipse.prototype.constraints;
  4357. mxRhombus.prototype.constraints = mxEllipse.prototype.constraints;
  4358. mxTriangle.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  4359. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  4360. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  4361. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  4362. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  4363. new mxConnectionConstraint(new mxPoint(1, 0.5), true)];
  4364. mxHexagon.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.375, 0), true),
  4365. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  4366. new mxConnectionConstraint(new mxPoint(0.625, 0), true),
  4367. new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  4368. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  4369. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  4370. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  4371. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  4372. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  4373. new mxConnectionConstraint(new mxPoint(0.375, 1), true),
  4374. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  4375. new mxConnectionConstraint(new mxPoint(0.625, 1), true)];
  4376. mxCloud.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0.25), false),
  4377. new mxConnectionConstraint(new mxPoint(0.4, 0.1), false),
  4378. new mxConnectionConstraint(new mxPoint(0.16, 0.55), false),
  4379. new mxConnectionConstraint(new mxPoint(0.07, 0.4), false),
  4380. new mxConnectionConstraint(new mxPoint(0.31, 0.8), false),
  4381. new mxConnectionConstraint(new mxPoint(0.13, 0.77), false),
  4382. new mxConnectionConstraint(new mxPoint(0.8, 0.8), false),
  4383. new mxConnectionConstraint(new mxPoint(0.55, 0.95), false),
  4384. new mxConnectionConstraint(new mxPoint(0.875, 0.5), false),
  4385. new mxConnectionConstraint(new mxPoint(0.96, 0.7), false),
  4386. new mxConnectionConstraint(new mxPoint(0.625, 0.2), false),
  4387. new mxConnectionConstraint(new mxPoint(0.88, 0.25), false)];
  4388. ParallelogramShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  4389. TrapezoidShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  4390. DocumentShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  4391. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  4392. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  4393. new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  4394. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  4395. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  4396. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  4397. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  4398. new mxConnectionConstraint(new mxPoint(1, 0.75), true)];
  4399. mxArrow.prototype.constraints = null;
  4400. TeeShape.prototype.getConstraints = function(style, w, h)
  4401. {
  4402. var constr = [];
  4403. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  4404. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  4405. var w2 = Math.abs(w - dx) / 2;
  4406. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  4407. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  4408. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  4409. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy * 0.5));
  4410. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy));
  4411. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.75 + dx * 0.25, dy));
  4412. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + dx) * 0.5, dy));
  4413. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + dx) * 0.5, (h + dy) * 0.5));
  4414. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + dx) * 0.5, h));
  4415. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  4416. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - dx) * 0.5, h));
  4417. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - dx) * 0.5, (h + dy) * 0.5));
  4418. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - dx) * 0.5, dy));
  4419. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.25 - dx * 0.25, dy));
  4420. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy));
  4421. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy * 0.5));
  4422. return (constr);
  4423. };
  4424. CornerShape.prototype.getConstraints = function(style, w, h)
  4425. {
  4426. var constr = [];
  4427. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  4428. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  4429. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  4430. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  4431. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  4432. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy * 0.5));
  4433. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy));
  4434. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + dx) * 0.5, dy));
  4435. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, dy));
  4436. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, (h + dy) * 0.5));
  4437. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, h));
  4438. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx * 0.5, h));
  4439. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  4440. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  4441. return (constr);
  4442. };
  4443. CrossbarShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0), false),
  4444. new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  4445. new mxConnectionConstraint(new mxPoint(0, 1), false),
  4446. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  4447. new mxConnectionConstraint(new mxPoint(0.5, 0.5), false),
  4448. new mxConnectionConstraint(new mxPoint(0.75, 0.5), false),
  4449. new mxConnectionConstraint(new mxPoint(1, 0), false),
  4450. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  4451. new mxConnectionConstraint(new mxPoint(1, 1), false)];
  4452. SingleArrowShape.prototype.getConstraints = function(style, w, h)
  4453. {
  4454. var constr = [];
  4455. var aw = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowWidth', this.arrowWidth))));
  4456. var as = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowSize', this.arrowSize))));
  4457. var at = (h - aw) / 2;
  4458. var ab = at + aw;
  4459. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  4460. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, at));
  4461. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - as) * 0.5, at));
  4462. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - as, 0));
  4463. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  4464. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - as, h));
  4465. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - as) * 0.5, h - at));
  4466. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - at));
  4467. return (constr);
  4468. };
  4469. DoubleArrowShape.prototype.getConstraints = function(style, w, h)
  4470. {
  4471. var constr = [];
  4472. var aw = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowWidth', SingleArrowShape.prototype.arrowWidth))));
  4473. var as = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowSize', SingleArrowShape.prototype.arrowSize))));
  4474. var at = (h - aw) / 2;
  4475. var ab = at + aw;
  4476. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  4477. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, as, 0));
  4478. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5, at));
  4479. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - as, 0));
  4480. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  4481. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - as, h));
  4482. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5, h - at));
  4483. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, as, h));
  4484. return (constr);
  4485. };
  4486. CrossShape.prototype.getConstraints = function(style, w, h)
  4487. {
  4488. var constr = [];
  4489. var m = Math.min(h, w);
  4490. var size = Math.max(0, Math.min(m, m * parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  4491. var t = (h - size) / 2;
  4492. var b = t + size;
  4493. var l = (w - size) / 2;
  4494. var r = l + size;
  4495. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l, t * 0.5));
  4496. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l, 0));
  4497. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  4498. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r, 0));
  4499. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r, t * 0.5));
  4500. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r, t));
  4501. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l, h - t * 0.5));
  4502. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l, h));
  4503. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  4504. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r, h));
  4505. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r, h - t * 0.5));
  4506. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r, b));
  4507. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + r) * 0.5, t));
  4508. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, t));
  4509. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  4510. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, b));
  4511. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + r) * 0.5, b));
  4512. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l, b));
  4513. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l * 0.5, t));
  4514. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, t));
  4515. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  4516. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, b));
  4517. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l * 0.5, b));
  4518. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l, t));
  4519. return (constr);
  4520. };
  4521. UmlLifeline.prototype.constraints = null;
  4522. OrShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.25), false),
  4523. new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  4524. new mxConnectionConstraint(new mxPoint(0, 0.75), false),
  4525. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  4526. new mxConnectionConstraint(new mxPoint(0.7, 0.1), false),
  4527. new mxConnectionConstraint(new mxPoint(0.7, 0.9), false)];
  4528. XorShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.175, 0.25), false),
  4529. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  4530. new mxConnectionConstraint(new mxPoint(0.175, 0.75), false),
  4531. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  4532. new mxConnectionConstraint(new mxPoint(0.7, 0.1), false),
  4533. new mxConnectionConstraint(new mxPoint(0.7, 0.9), false)];
  4534. RequiredInterfaceShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  4535. new mxConnectionConstraint(new mxPoint(1, 0.5), false)];
  4536. ProvidedRequiredInterfaceShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  4537. new mxConnectionConstraint(new mxPoint(1, 0.5), false)];
  4538. })();