Shapes.js 226 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008
  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. /**
  152. * Returns the given table as an array of arrays of cells.
  153. */
  154. TableShape.prototype.getTableLines = function(x0, y0, horizontal, vertical)
  155. {
  156. var hl = [];
  157. var vl = [];
  158. if (horizontal || vertical)
  159. {
  160. var lastRow = null;
  161. var graph = this.state.view.graph;
  162. var rows = graph.model.getChildCells(this.state.cell, true);
  163. var start = graph.getActualStartSize(this.state.cell, true);
  164. x0 += start.x;
  165. y0 += start.y;
  166. for (var i = 0; i < rows.length; i++)
  167. {
  168. var cols = graph.model.getChildCells(rows[i], true);
  169. start = graph.getActualStartSize(rows[i], true);
  170. var lastCol = null;
  171. var row = [];
  172. for (var j = 0; j < cols.length; j++)
  173. {
  174. var col = {rospan: 1, colspan: 1};
  175. var geo = graph.getCellGeometry(cols[j]);
  176. geo = (geo.alternateBounds != null) ? geo.alternateBounds : geo;
  177. col.point = new mxPoint(geo.width + (lastCol != null ? lastCol.point.x : x0 + start.x),
  178. geo.height + (lastRow != null ? lastRow[0].point.y : y0 + start.y));
  179. if (lastRow != null && lastRow[j] != null && lastRow[j].rowspan > 1)
  180. {
  181. col.rowspan = lastRow[j].rowspan - 1;
  182. col.colspan = lastRow[j].colspan;
  183. }
  184. else
  185. {
  186. if (lastCol != null && lastCol.colspan > 1)
  187. {
  188. col.rowspan = lastCol.rowspan;
  189. col.colspan = lastCol.colspan - 1;
  190. }
  191. else
  192. {
  193. var style = graph.getCurrentCellStyle(cols[j], true);
  194. if (style != null)
  195. {
  196. col.rowspan = parseInt(style['rowspan'] || 1);
  197. col.colspan = parseInt(style['colspan'] || 1);
  198. }
  199. }
  200. }
  201. row.push(col);
  202. lastCol = col;
  203. // Constructs horizontal lines
  204. if (horizontal && i < rows.length - 1)
  205. {
  206. if (hl[i] == null)
  207. {
  208. hl[i] = [new mxPoint(x0, col.point.y)];
  209. }
  210. if (col.rowspan > 1)
  211. {
  212. hl[i].push(null);
  213. }
  214. hl[i].push(col.point);
  215. }
  216. // Constructs vertical lines
  217. if (vertical && j < cols.length - 1)
  218. {
  219. if (vl[j] == null)
  220. {
  221. vl[j] = [new mxPoint(col.point.x, y0)];
  222. }
  223. if (col.colspan > 1)
  224. {
  225. vl[j].push(null);
  226. }
  227. vl[j].push(col.point);
  228. }
  229. }
  230. lastRow = row;
  231. }
  232. }
  233. return hl.concat(vl);
  234. };
  235. TableShape.prototype.paintTableForeground = function(c, x, y, w, h)
  236. {
  237. var lines = this.getTableLines(x, y,
  238. mxUtils.getValue(this.state.style, 'rowLines', '1') != '0',
  239. mxUtils.getValue(this.state.style, 'columnLines', '1') != '0');
  240. for (var i = 0; i < lines.length; i++)
  241. {
  242. if (lines[i] != null)
  243. {
  244. var last = null;
  245. c.begin();
  246. for (var j = 0; j < lines[i].length; j++)
  247. {
  248. var curr = lines[i][j];
  249. if (curr != null)
  250. {
  251. if (last == null)
  252. {
  253. c.moveTo(curr.x, curr.y);
  254. }
  255. else if (last != null)
  256. {
  257. c.lineTo(curr.x, curr.y);
  258. }
  259. }
  260. last = curr;
  261. }
  262. c.end();
  263. c.stroke();
  264. }
  265. }
  266. }
  267. mxCellRenderer.registerShape('table', TableShape);
  268. // Cube Shape, supports size style
  269. function CubeShape()
  270. {
  271. mxCylinder.call(this);
  272. };
  273. mxUtils.extend(CubeShape, mxCylinder);
  274. CubeShape.prototype.size = 20;
  275. CubeShape.prototype.darkOpacity = 0;
  276. CubeShape.prototype.darkOpacity2 = 0;
  277. CubeShape.prototype.paintVertexShape = function(c, x, y, w, h)
  278. {
  279. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  280. var op = Math.max(-1, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'darkOpacity', this.darkOpacity))));
  281. var op2 = Math.max(-1, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'darkOpacity2', this.darkOpacity2))));
  282. c.translate(x, y);
  283. c.begin();
  284. c.moveTo(0, 0);
  285. c.lineTo(w - s, 0);
  286. c.lineTo(w, s);
  287. c.lineTo(w, h);
  288. c.lineTo(s, h);
  289. c.lineTo(0, h - s);
  290. c.lineTo(0, 0);
  291. c.close();
  292. c.end();
  293. c.fillAndStroke();
  294. if (!this.outline)
  295. {
  296. c.setShadow(false);
  297. if (op != 0)
  298. {
  299. c.setFillAlpha(Math.abs(op));
  300. c.setFillColor((op < 0) ? '#FFFFFF' : '#000000');
  301. c.begin();
  302. c.moveTo(0, 0);
  303. c.lineTo(w - s, 0);
  304. c.lineTo(w, s);
  305. c.lineTo(s, s);
  306. c.close();
  307. c.fill();
  308. }
  309. if (op2 != 0)
  310. {
  311. c.setFillAlpha(Math.abs(op2));
  312. c.setFillColor((op2 < 0) ? '#FFFFFF' : '#000000');
  313. c.begin();
  314. c.moveTo(0, 0);
  315. c.lineTo(s, s);
  316. c.lineTo(s, h);
  317. c.lineTo(0, h - s);
  318. c.close();
  319. c.fill();
  320. }
  321. c.begin();
  322. c.moveTo(s, h);
  323. c.lineTo(s, s);
  324. c.lineTo(0, 0);
  325. c.moveTo(s, s);
  326. c.lineTo(w, s);
  327. c.end();
  328. c.stroke();
  329. }
  330. };
  331. CubeShape.prototype.getLabelMargins = function(rect)
  332. {
  333. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  334. {
  335. var s = parseFloat(mxUtils.getValue(this.style, 'size', this.size)) * this.scale;
  336. return new mxRectangle(s, s, 0, 0);
  337. }
  338. return null;
  339. };
  340. mxCellRenderer.registerShape('cube', CubeShape);
  341. var tan30 = Math.tan(mxUtils.toRadians(30));
  342. var tan30Dx = (0.5 - tan30) / 2;
  343. mxCellRenderer.registerShape('isoRectangle', IsoRectangleShape);
  344. // Cube Shape, supports size style
  345. function WaypointShape()
  346. {
  347. mxCylinder.call(this);
  348. };
  349. mxUtils.extend(WaypointShape, mxCylinder);
  350. WaypointShape.prototype.size = 6;
  351. WaypointShape.prototype.paintVertexShape = function(c, x, y, w, h)
  352. {
  353. c.setFillColor(this.stroke);
  354. var s = Math.max(0, parseFloat(mxUtils.getValue(this.style, 'size', this.size)) - 2) + 2 * this.strokewidth;
  355. c.ellipse(x + (w - s) * 0.5, y + (h - s) * 0.5, s, s);
  356. c.fill();
  357. c.setFillColor(mxConstants.NONE);
  358. c.rect(x, y, w, h);
  359. c.fill();
  360. };
  361. mxCellRenderer.registerShape('waypoint', WaypointShape);
  362. // Cube Shape, supports size style
  363. function IsoRectangleShape()
  364. {
  365. mxActor.call(this);
  366. };
  367. mxUtils.extend(IsoRectangleShape, mxActor);
  368. IsoRectangleShape.prototype.size = 20;
  369. IsoRectangleShape.prototype.redrawPath = function(path, x, y, w, h)
  370. {
  371. var m = Math.min(w, h / tan30);
  372. path.translate((w - m) / 2, (h - m) / 2 + m / 4);
  373. path.moveTo(0, 0.25 * m);
  374. path.lineTo(0.5 * m, m * tan30Dx);
  375. path.lineTo(m, 0.25 * m);
  376. path.lineTo(0.5 * m, (0.5 - tan30Dx) * m);
  377. path.lineTo(0, 0.25 * m);
  378. path.close();
  379. path.end();
  380. };
  381. mxCellRenderer.registerShape('isoRectangle', IsoRectangleShape);
  382. // Cube Shape, supports size style
  383. function IsoCubeShape()
  384. {
  385. mxCylinder.call(this);
  386. };
  387. mxUtils.extend(IsoCubeShape, mxCylinder);
  388. IsoCubeShape.prototype.size = 20;
  389. IsoCubeShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  390. {
  391. var m = Math.min(w, h / (0.5 + tan30));
  392. if (isForeground)
  393. {
  394. path.moveTo(0, 0.25 * m);
  395. path.lineTo(0.5 * m, (0.5 - tan30Dx) * m);
  396. path.lineTo(m, 0.25 * m);
  397. path.moveTo(0.5 * m, (0.5 - tan30Dx) * m);
  398. path.lineTo(0.5 * m, (1 - tan30Dx) * m);
  399. path.end();
  400. }
  401. else
  402. {
  403. path.translate((w - m) / 2, (h - m) / 2);
  404. path.moveTo(0, 0.25 * m);
  405. path.lineTo(0.5 * m, m * tan30Dx);
  406. path.lineTo(m, 0.25 * m);
  407. path.lineTo(m, 0.75 * m);
  408. path.lineTo(0.5 * m, (1 - tan30Dx) * m);
  409. path.lineTo(0, 0.75 * m);
  410. path.close();
  411. path.end();
  412. }
  413. };
  414. mxCellRenderer.registerShape('isoCube', IsoCubeShape);
  415. // DataStore Shape, supports size style
  416. function DataStoreShape()
  417. {
  418. mxCylinder.call(this);
  419. };
  420. mxUtils.extend(DataStoreShape, mxCylinder);
  421. DataStoreShape.prototype.redrawPath = function(c, x, y, w, h, isForeground)
  422. {
  423. var dy = Math.min(h / 2, Math.round(h / 8) + this.strokewidth - 1);
  424. if ((isForeground && this.fill != null) || (!isForeground && this.fill == null))
  425. {
  426. c.moveTo(0, dy);
  427. c.curveTo(0, 2 * dy, w, 2 * dy, w, dy);
  428. // Needs separate shapes for correct hit-detection
  429. if (!isForeground)
  430. {
  431. c.stroke();
  432. c.begin();
  433. }
  434. c.translate(0, dy / 2);
  435. c.moveTo(0, dy);
  436. c.curveTo(0, 2 * dy, w, 2 * dy, w, dy);
  437. // Needs separate shapes for correct hit-detection
  438. if (!isForeground)
  439. {
  440. c.stroke();
  441. c.begin();
  442. }
  443. c.translate(0, dy / 2);
  444. c.moveTo(0, dy);
  445. c.curveTo(0, 2 * dy, w, 2 * dy, w, dy);
  446. // Needs separate shapes for correct hit-detection
  447. if (!isForeground)
  448. {
  449. c.stroke();
  450. c.begin();
  451. }
  452. c.translate(0, -dy);
  453. }
  454. if (!isForeground)
  455. {
  456. c.moveTo(0, dy);
  457. c.curveTo(0, -dy / 3, w, -dy / 3, w, dy);
  458. c.lineTo(w, h - dy);
  459. c.curveTo(w, h + dy / 3, 0, h + dy / 3, 0, h - dy);
  460. c.close();
  461. }
  462. };
  463. DataStoreShape.prototype.getLabelMargins = function(rect)
  464. {
  465. return new mxRectangle(0, 2.5 * Math.min(rect.height / 2,
  466. Math.round(rect.height / 8) + this.strokewidth - 1), 0, 0);
  467. }
  468. mxCellRenderer.registerShape('datastore', DataStoreShape);
  469. // Note Shape, supports size style
  470. function NoteShape()
  471. {
  472. mxCylinder.call(this);
  473. };
  474. mxUtils.extend(NoteShape, mxCylinder);
  475. NoteShape.prototype.size = 30;
  476. NoteShape.prototype.darkOpacity = 0;
  477. NoteShape.prototype.paintVertexShape = function(c, x, y, w, h)
  478. {
  479. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  480. var op = Math.max(-1, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'darkOpacity', this.darkOpacity))));
  481. c.translate(x, y);
  482. c.begin();
  483. c.moveTo(0, 0);
  484. c.lineTo(w - s, 0);
  485. c.lineTo(w, s);
  486. c.lineTo(w, h);
  487. c.lineTo(0, h);
  488. c.lineTo(0, 0);
  489. c.close();
  490. c.end();
  491. c.fillAndStroke();
  492. if (!this.outline)
  493. {
  494. c.setShadow(false);
  495. if (op != 0)
  496. {
  497. c.setFillAlpha(Math.abs(op));
  498. c.setFillColor((op < 0) ? '#FFFFFF' : '#000000');
  499. c.begin();
  500. c.moveTo(w - s, 0);
  501. c.lineTo(w - s, s);
  502. c.lineTo(w, s);
  503. c.close();
  504. c.fill();
  505. }
  506. c.begin();
  507. c.moveTo(w - s, 0);
  508. c.lineTo(w - s, s);
  509. c.lineTo(w, s);
  510. c.end();
  511. c.stroke();
  512. }
  513. };
  514. mxCellRenderer.registerShape('note', NoteShape);
  515. // Note Shape, supports size style
  516. function NoteShape2()
  517. {
  518. NoteShape.call(this);
  519. };
  520. mxUtils.extend(NoteShape2, NoteShape);
  521. mxCellRenderer.registerShape('note2', NoteShape2);
  522. NoteShape2.prototype.getLabelMargins = function(rect)
  523. {
  524. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  525. {
  526. var size = mxUtils.getValue(this.style, 'size', 15);
  527. return new mxRectangle(0, Math.min(rect.height * this.scale, size * this.scale), 0, 0);
  528. }
  529. return null;
  530. };
  531. // Flexible cube Shape
  532. function IsoCubeShape2()
  533. {
  534. mxShape.call(this);
  535. };
  536. mxUtils.extend(IsoCubeShape2, mxShape);
  537. IsoCubeShape2.prototype.isoAngle = 15;
  538. IsoCubeShape2.prototype.paintVertexShape = function(c, x, y, w, h)
  539. {
  540. var isoAngle = Math.max(0.01, Math.min(94, parseFloat(mxUtils.getValue(this.style, 'isoAngle', this.isoAngle)))) * Math.PI / 200 ;
  541. var isoH = Math.min(w * Math.tan(isoAngle), h * 0.5);
  542. c.translate(x,y);
  543. c.begin();
  544. c.moveTo(w * 0.5, 0);
  545. c.lineTo(w, isoH);
  546. c.lineTo(w, h - isoH);
  547. c.lineTo(w * 0.5, h);
  548. c.lineTo(0, h - isoH);
  549. c.lineTo(0, isoH);
  550. c.close();
  551. c.fillAndStroke();
  552. c.setShadow(false);
  553. c.begin();
  554. c.moveTo(0, isoH);
  555. c.lineTo(w * 0.5, 2 * isoH);
  556. c.lineTo(w, isoH);
  557. c.moveTo(w * 0.5, 2 * isoH);
  558. c.lineTo(w * 0.5, h);
  559. c.stroke();
  560. };
  561. mxCellRenderer.registerShape('isoCube2', IsoCubeShape2);
  562. // (LEGACY) Flexible cylinder Shape
  563. function CylinderShape()
  564. {
  565. mxShape.call(this);
  566. };
  567. mxUtils.extend(CylinderShape, mxShape);
  568. CylinderShape.prototype.size = 15;
  569. CylinderShape.prototype.paintVertexShape = function(c, x, y, w, h)
  570. {
  571. var size = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  572. c.translate(x,y);
  573. if (size == 0)
  574. {
  575. c.rect(0, 0, w, h);
  576. c.fillAndStroke();
  577. }
  578. else
  579. {
  580. c.begin();
  581. c.moveTo(0, size);
  582. c.arcTo(w * 0.5, size, 0, 0, 1, w * 0.5, 0);
  583. c.arcTo(w * 0.5, size, 0, 0, 1, w, size);
  584. c.lineTo(w, h - size);
  585. c.arcTo(w * 0.5, size, 0, 0, 1, w * 0.5, h);
  586. c.arcTo(w * 0.5, size, 0, 0, 1, 0, h - size);
  587. c.close();
  588. c.fillAndStroke();
  589. c.setShadow(false);
  590. c.begin();
  591. c.moveTo(w, size);
  592. c.arcTo(w * 0.5, size, 0, 0, 1, w * 0.5, 2 * size);
  593. c.arcTo(w * 0.5, size, 0, 0, 1, 0, size);
  594. c.stroke();
  595. }
  596. };
  597. mxCellRenderer.registerShape('cylinder2', CylinderShape);
  598. // Flexible cylinder3 Shape with offset label
  599. function CylinderShape3(bounds, fill, stroke, strokewidth)
  600. {
  601. mxShape.call(this);
  602. this.bounds = bounds;
  603. this.fill = fill;
  604. this.stroke = stroke;
  605. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  606. };
  607. mxUtils.extend(CylinderShape3, mxCylinder);
  608. CylinderShape3.prototype.size = 15;
  609. CylinderShape3.prototype.paintVertexShape = function(c, x, y, w, h)
  610. {
  611. var size = Math.max(0, Math.min(h * 0.5, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  612. var lid = mxUtils.getValue(this.style, 'lid', true);
  613. c.translate(x,y);
  614. if (size == 0)
  615. {
  616. c.rect(0, 0, w, h);
  617. c.fillAndStroke();
  618. }
  619. else
  620. {
  621. c.begin();
  622. if (lid)
  623. {
  624. c.moveTo(0, size);
  625. c.arcTo(w * 0.5, size, 0, 0, 1, w * 0.5, 0);
  626. c.arcTo(w * 0.5, size, 0, 0, 1, w, size);
  627. }
  628. else
  629. {
  630. c.moveTo(0, 0);
  631. c.arcTo(w * 0.5, size, 0, 0, 0, w * 0.5, size);
  632. c.arcTo(w * 0.5, size, 0, 0, 0, w, 0);
  633. }
  634. c.lineTo(w, h - size);
  635. c.arcTo(w * 0.5, size, 0, 0, 1, w * 0.5, h);
  636. c.arcTo(w * 0.5, size, 0, 0, 1, 0, h - size);
  637. c.close();
  638. c.fillAndStroke();
  639. c.setShadow(false);
  640. if (lid)
  641. {
  642. c.begin();
  643. c.moveTo(w, size);
  644. c.arcTo(w * 0.5, size, 0, 0, 1, w * 0.5, 2 * size);
  645. c.arcTo(w * 0.5, size, 0, 0, 1, 0, size);
  646. c.stroke();
  647. }
  648. }
  649. };
  650. mxCellRenderer.registerShape('cylinder3', CylinderShape3);
  651. // Switch Shape, supports size style
  652. function SwitchShape()
  653. {
  654. mxActor.call(this);
  655. };
  656. mxUtils.extend(SwitchShape, mxActor);
  657. SwitchShape.prototype.redrawPath = function(c, x, y, w, h)
  658. {
  659. var curve = 0.5;
  660. c.moveTo(0, 0);
  661. c.quadTo(w / 2, h * curve, w, 0);
  662. c.quadTo(w * (1 - curve), h / 2, w, h);
  663. c.quadTo(w / 2, h * (1 - curve), 0, h);
  664. c.quadTo(w * curve, h / 2, 0, 0);
  665. c.end();
  666. };
  667. mxCellRenderer.registerShape('switch', SwitchShape);
  668. // Folder Shape, supports tabWidth, tabHeight styles
  669. function FolderShape()
  670. {
  671. mxCylinder.call(this);
  672. };
  673. mxUtils.extend(FolderShape, mxCylinder);
  674. FolderShape.prototype.tabWidth = 60;
  675. FolderShape.prototype.tabHeight = 20;
  676. FolderShape.prototype.tabPosition = 'right';
  677. FolderShape.prototype.arcSize = 0.1;
  678. FolderShape.prototype.paintVertexShape = function(c, x, y, w, h)
  679. {
  680. c.translate(x, y);
  681. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'tabWidth', this.tabWidth))));
  682. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'tabHeight', this.tabHeight))));
  683. var tp = mxUtils.getValue(this.style, 'tabPosition', this.tabPosition);
  684. var rounded = mxUtils.getValue(this.style, 'rounded', false);
  685. var absArcSize = mxUtils.getValue(this.style, 'absoluteArcSize', false);
  686. var arcSize = parseFloat(mxUtils.getValue(this.style, 'arcSize', this.arcSize));
  687. if (!absArcSize)
  688. {
  689. arcSize = Math.min(w, h) * arcSize;
  690. }
  691. arcSize = Math.min(arcSize, w * 0.5, (h - dy) * 0.5);
  692. dx = Math.max(dx, arcSize);
  693. dx = Math.min(w - arcSize, dx);
  694. if (!rounded)
  695. {
  696. arcSize = 0;
  697. }
  698. c.begin();
  699. if (tp == 'left')
  700. {
  701. c.moveTo(Math.max(arcSize, 0), dy);
  702. c.lineTo(Math.max(arcSize, 0), 0);
  703. c.lineTo(dx, 0);
  704. c.lineTo(dx, dy);
  705. }
  706. // Right is default
  707. else
  708. {
  709. c.moveTo(w - dx, dy);
  710. c.lineTo(w - dx, 0);
  711. c.lineTo(w - Math.max(arcSize, 0), 0);
  712. c.lineTo(w - Math.max(arcSize, 0), dy);
  713. }
  714. if (rounded)
  715. {
  716. c.moveTo(0, arcSize + dy);
  717. c.arcTo(arcSize, arcSize, 0, 0, 1, arcSize, dy);
  718. c.lineTo(w - arcSize, dy);
  719. c.arcTo(arcSize, arcSize, 0, 0, 1, w, arcSize + dy);
  720. c.lineTo(w, h - arcSize);
  721. c.arcTo(arcSize, arcSize, 0, 0, 1, w - arcSize, h);
  722. c.lineTo(arcSize, h);
  723. c.arcTo(arcSize, arcSize, 0, 0, 1, 0, h - arcSize);
  724. }
  725. else
  726. {
  727. c.moveTo(0, dy);
  728. c.lineTo(w, dy);
  729. c.lineTo(w, h);
  730. c.lineTo(0, h);
  731. }
  732. c.close();
  733. c.fillAndStroke();
  734. c.setShadow(false);
  735. var sym = mxUtils.getValue(this.style, 'folderSymbol', null);
  736. if (sym == 'triangle')
  737. {
  738. c.begin();
  739. c.moveTo(w - 30, dy + 20);
  740. c.lineTo(w - 20, dy + 10);
  741. c.lineTo(w - 10, dy + 20);
  742. c.close();
  743. c.stroke();
  744. }
  745. };
  746. mxCellRenderer.registerShape('folder', FolderShape);
  747. FolderShape.prototype.getLabelMargins = function(rect)
  748. {
  749. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  750. {
  751. var sizeY = mxUtils.getValue(this.style, 'tabHeight', 15) * this.scale;
  752. if (mxUtils.getValue(this.style, 'labelInHeader', false))
  753. {
  754. var sizeX = mxUtils.getValue(this.style, 'tabWidth', 15) * this.scale;
  755. var sizeY = mxUtils.getValue(this.style, 'tabHeight', 15) * this.scale;
  756. var rounded = mxUtils.getValue(this.style, 'rounded', false);
  757. var absArcSize = mxUtils.getValue(this.style, 'absoluteArcSize', false);
  758. var arcSize = parseFloat(mxUtils.getValue(this.style, 'arcSize', this.arcSize));
  759. if (!absArcSize)
  760. {
  761. arcSize = Math.min(rect.width, rect.height) * arcSize;
  762. }
  763. arcSize = Math.min(arcSize, rect.width * 0.5, (rect.height - sizeY) * 0.5);
  764. if (!rounded)
  765. {
  766. arcSize = 0;
  767. }
  768. if (mxUtils.getValue(this.style, 'tabPosition', this.tabPosition) == 'left')
  769. {
  770. return new mxRectangle(arcSize, 0, Math.min(rect.width, rect.width - sizeX), Math.min(rect.height, rect.height - sizeY));
  771. }
  772. else
  773. {
  774. return new mxRectangle(Math.min(rect.width, rect.width - sizeX), 0, arcSize, Math.min(rect.height, rect.height - sizeY));
  775. }
  776. }
  777. else
  778. {
  779. return new mxRectangle(0, Math.min(rect.height, sizeY), 0, 0);
  780. }
  781. }
  782. return null;
  783. };
  784. //**********************************************************************************************************************************************************
  785. //UML State shape
  786. //**********************************************************************************************************************************************************
  787. function UMLStateShape()
  788. {
  789. mxCylinder.call(this);
  790. };
  791. mxUtils.extend(UMLStateShape, mxCylinder);
  792. UMLStateShape.prototype.arcSize = 0.1;
  793. UMLStateShape.prototype.paintVertexShape = function(c, x, y, w, h)
  794. {
  795. c.translate(x, y);
  796. var rounded = mxUtils.getValue(this.style, 'rounded', false);
  797. var absArcSize = mxUtils.getValue(this.style, 'absoluteArcSize', false);
  798. var arcSize = parseFloat(mxUtils.getValue(this.style, 'arcSize', this.arcSize));
  799. var connPoint = mxUtils.getValue(this.style, 'umlStateConnection', null);
  800. if (!absArcSize)
  801. {
  802. arcSize = Math.min(w, h) * arcSize;
  803. }
  804. arcSize = Math.min(arcSize, w * 0.5, h * 0.5);
  805. if (!rounded)
  806. {
  807. arcSize = 0;
  808. }
  809. var dx = 0;
  810. if (connPoint != null)
  811. {
  812. dx = 10;
  813. }
  814. c.begin();
  815. c.moveTo(dx, arcSize);
  816. c.arcTo(arcSize, arcSize, 0, 0, 1, dx + arcSize, 0);
  817. c.lineTo(w - arcSize, 0);
  818. c.arcTo(arcSize, arcSize, 0, 0, 1, w, arcSize);
  819. c.lineTo(w, h - arcSize);
  820. c.arcTo(arcSize, arcSize, 0, 0, 1, w - arcSize, h);
  821. c.lineTo(dx + arcSize, h);
  822. c.arcTo(arcSize, arcSize, 0, 0, 1, dx, h - arcSize);
  823. c.close();
  824. c.fillAndStroke();
  825. c.setShadow(false);
  826. var sym = mxUtils.getValue(this.style, 'umlStateSymbol', null);
  827. if (sym == 'collapseState')
  828. {
  829. c.roundrect(w - 40, h - 20, 10, 10, 3, 3);
  830. c.stroke();
  831. c.roundrect(w - 20, h - 20, 10, 10, 3, 3);
  832. c.stroke();
  833. c.begin();
  834. c.moveTo(w - 30, h - 15);
  835. c.lineTo(w - 20, h - 15);
  836. c.stroke();
  837. }
  838. if (connPoint == 'connPointRefEntry')
  839. {
  840. c.ellipse(0, h * 0.5 - 10, 20, 20);
  841. c.fillAndStroke();
  842. }
  843. else if (connPoint == 'connPointRefExit')
  844. {
  845. c.ellipse(0, h * 0.5 - 10, 20, 20);
  846. c.fillAndStroke();
  847. c.begin();
  848. c.moveTo(5, h * 0.5 - 5);
  849. c.lineTo(15, h * 0.5 + 5);
  850. c.moveTo(15, h * 0.5 - 5);
  851. c.lineTo(5, h * 0.5 + 5);
  852. c.stroke();
  853. }
  854. };
  855. UMLStateShape.prototype.getLabelMargins = function(rect)
  856. {
  857. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  858. {
  859. var connPoint = mxUtils.getValue(this.style, 'umlStateConnection', null);
  860. if (connPoint != null)
  861. {
  862. return new mxRectangle(10 * this.scale, 0, 0, 0);
  863. }
  864. }
  865. return null;
  866. };
  867. mxCellRenderer.registerShape('umlState', UMLStateShape);
  868. // Card shape
  869. function CardShape()
  870. {
  871. mxActor.call(this);
  872. };
  873. mxUtils.extend(CardShape, mxActor);
  874. CardShape.prototype.size = 30;
  875. CardShape.prototype.isRoundable = function()
  876. {
  877. return true;
  878. };
  879. CardShape.prototype.redrawPath = function(c, x, y, w, h)
  880. {
  881. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  882. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  883. this.addPoints(c, [new mxPoint(s, 0), new mxPoint(w, 0), new mxPoint(w, h), new mxPoint(0, h), new mxPoint(0, s)],
  884. this.isRounded, arcSize, true);
  885. c.end();
  886. };
  887. mxCellRenderer.registerShape('card', CardShape);
  888. // Tape shape
  889. function TapeShape()
  890. {
  891. mxActor.call(this);
  892. };
  893. mxUtils.extend(TapeShape, mxActor);
  894. TapeShape.prototype.size = 0.4;
  895. TapeShape.prototype.redrawPath = function(c, x, y, w, h)
  896. {
  897. var dy = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  898. var fy = 1.4;
  899. c.moveTo(0, dy / 2);
  900. c.quadTo(w / 4, dy * fy, w / 2, dy / 2);
  901. c.quadTo(w * 3 / 4, dy * (1 - fy), w, dy / 2);
  902. c.lineTo(w, h - dy / 2);
  903. c.quadTo(w * 3 / 4, h - dy * fy, w / 2, h - dy / 2);
  904. c.quadTo(w / 4, h - dy * (1 - fy), 0, h - dy / 2);
  905. c.lineTo(0, dy / 2);
  906. c.close();
  907. c.end();
  908. };
  909. TapeShape.prototype.getLabelBounds = function(rect)
  910. {
  911. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  912. {
  913. var size = mxUtils.getValue(this.style, 'size', this.size);
  914. var w = rect.width;
  915. var h = rect.height;
  916. if (this.direction == null ||
  917. this.direction == mxConstants.DIRECTION_EAST ||
  918. this.direction == mxConstants.DIRECTION_WEST)
  919. {
  920. var dy = h * size;
  921. return new mxRectangle(rect.x, rect.y + dy, w, h - 2 * dy);
  922. }
  923. else
  924. {
  925. var dx = w * size;
  926. return new mxRectangle(rect.x + dx, rect.y, w - 2 * dx, h);
  927. }
  928. }
  929. return rect;
  930. };
  931. mxCellRenderer.registerShape('tape', TapeShape);
  932. // Document shape
  933. function DocumentShape()
  934. {
  935. mxActor.call(this);
  936. };
  937. mxUtils.extend(DocumentShape, mxActor);
  938. DocumentShape.prototype.size = 0.3;
  939. DocumentShape.prototype.getLabelMargins = function(rect)
  940. {
  941. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  942. {
  943. return new mxRectangle(0, 0, 0, parseFloat(mxUtils.getValue(
  944. this.style, 'size', this.size)) * rect.height);
  945. }
  946. return null;
  947. };
  948. DocumentShape.prototype.redrawPath = function(c, x, y, w, h)
  949. {
  950. var dy = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  951. var fy = 1.4;
  952. c.moveTo(0, 0);
  953. c.lineTo(w, 0);
  954. c.lineTo(w, h - dy / 2);
  955. c.quadTo(w * 3 / 4, h - dy * fy, w / 2, h - dy / 2);
  956. c.quadTo(w / 4, h - dy * (1 - fy), 0, h - dy / 2);
  957. c.lineTo(0, dy / 2);
  958. c.close();
  959. c.end();
  960. };
  961. mxCellRenderer.registerShape('document', DocumentShape);
  962. var cylinderGetCylinderSize = mxCylinder.prototype.getCylinderSize;
  963. mxCylinder.prototype.getCylinderSize = function(x, y, w, h)
  964. {
  965. var size = mxUtils.getValue(this.style, 'size');
  966. if (size != null)
  967. {
  968. return h * Math.max(0, Math.min(1, size));
  969. }
  970. else
  971. {
  972. return cylinderGetCylinderSize.apply(this, arguments);
  973. }
  974. };
  975. mxCylinder.prototype.getLabelMargins = function(rect)
  976. {
  977. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  978. {
  979. var size = mxUtils.getValue(this.style, 'size', 0.15) * 2;
  980. return new mxRectangle(0, Math.min(this.maxHeight * this.scale, rect.height * size), 0, 0);
  981. }
  982. return null;
  983. };
  984. CylinderShape3.prototype.getLabelMargins = function(rect)
  985. {
  986. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  987. {
  988. var size = mxUtils.getValue(this.style, 'size', 15);
  989. if (!mxUtils.getValue(this.style, 'lid', true))
  990. {
  991. size /= 2;
  992. }
  993. return new mxRectangle(0, Math.min(rect.height * this.scale, size * 2 * this.scale), 0, Math.max(0, size * 0.3 * this.scale));
  994. }
  995. return null;
  996. };
  997. FolderShape.prototype.getLabelMargins = function(rect)
  998. {
  999. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  1000. {
  1001. var sizeY = mxUtils.getValue(this.style, 'tabHeight', 15) * this.scale;
  1002. if (mxUtils.getValue(this.style, 'labelInHeader', false))
  1003. {
  1004. var sizeX = mxUtils.getValue(this.style, 'tabWidth', 15) * this.scale;
  1005. var sizeY = mxUtils.getValue(this.style, 'tabHeight', 15) * this.scale;
  1006. var rounded = mxUtils.getValue(this.style, 'rounded', false);
  1007. var absArcSize = mxUtils.getValue(this.style, 'absoluteArcSize', false);
  1008. var arcSize = parseFloat(mxUtils.getValue(this.style, 'arcSize', this.arcSize));
  1009. if (!absArcSize)
  1010. {
  1011. arcSize = Math.min(rect.width, rect.height) * arcSize;
  1012. }
  1013. arcSize = Math.min(arcSize, rect.width * 0.5, (rect.height - sizeY) * 0.5);
  1014. if (!rounded)
  1015. {
  1016. arcSize = 0;
  1017. }
  1018. if (mxUtils.getValue(this.style, 'tabPosition', this.tabPosition) == 'left')
  1019. {
  1020. return new mxRectangle(arcSize, 0, Math.min(rect.width, rect.width - sizeX), Math.min(rect.height, rect.height - sizeY));
  1021. }
  1022. else
  1023. {
  1024. return new mxRectangle(Math.min(rect.width, rect.width - sizeX), 0, arcSize, Math.min(rect.height, rect.height - sizeY));
  1025. }
  1026. }
  1027. else
  1028. {
  1029. return new mxRectangle(0, Math.min(rect.height, sizeY), 0, 0);
  1030. }
  1031. }
  1032. return null;
  1033. };
  1034. UMLStateShape.prototype.getLabelMargins = function(rect)
  1035. {
  1036. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  1037. {
  1038. var connPoint = mxUtils.getValue(this.style, 'umlStateConnection', null);
  1039. if (connPoint != null)
  1040. {
  1041. return new mxRectangle(10 * this.scale, 0, 0, 0);
  1042. }
  1043. }
  1044. return null;
  1045. };
  1046. NoteShape2.prototype.getLabelMargins = function(rect)
  1047. {
  1048. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  1049. {
  1050. var size = mxUtils.getValue(this.style, 'size', 15);
  1051. return new mxRectangle(0, Math.min(rect.height * this.scale, size * this.scale), 0, Math.max(0, size * this.scale));
  1052. }
  1053. return null;
  1054. };
  1055. // Parallelogram shape
  1056. function ParallelogramShape()
  1057. {
  1058. mxActor.call(this);
  1059. };
  1060. mxUtils.extend(ParallelogramShape, mxActor);
  1061. ParallelogramShape.prototype.size = 0.2;
  1062. ParallelogramShape.prototype.fixedSize = 20;
  1063. ParallelogramShape.prototype.isRoundable = function()
  1064. {
  1065. return true;
  1066. };
  1067. ParallelogramShape.prototype.redrawPath = function(c, x, y, w, h)
  1068. {
  1069. var fixed = mxUtils.getValue(this.style, 'fixedSize', '0') != '0';
  1070. 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))));
  1071. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1072. this.addPoints(c, [new mxPoint(0, h), new mxPoint(dx, 0), new mxPoint(w, 0), new mxPoint(w - dx, h)],
  1073. this.isRounded, arcSize, true);
  1074. c.end();
  1075. };
  1076. mxCellRenderer.registerShape('parallelogram', ParallelogramShape);
  1077. // Trapezoid shape
  1078. function TrapezoidShape()
  1079. {
  1080. mxActor.call(this);
  1081. };
  1082. mxUtils.extend(TrapezoidShape, mxActor);
  1083. TrapezoidShape.prototype.size = 0.2;
  1084. TrapezoidShape.prototype.fixedSize = 20;
  1085. TrapezoidShape.prototype.isRoundable = function()
  1086. {
  1087. return true;
  1088. };
  1089. TrapezoidShape.prototype.redrawPath = function(c, x, y, w, h)
  1090. {
  1091. var fixed = mxUtils.getValue(this.style, 'fixedSize', '0') != '0';
  1092. 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))));
  1093. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1094. this.addPoints(c, [new mxPoint(0, h), new mxPoint(dx, 0), new mxPoint(w - dx, 0), new mxPoint(w, h)],
  1095. this.isRounded, arcSize, true);
  1096. };
  1097. mxCellRenderer.registerShape('trapezoid', TrapezoidShape);
  1098. // Curly Bracket shape
  1099. function CurlyBracketShape()
  1100. {
  1101. mxActor.call(this);
  1102. };
  1103. mxUtils.extend(CurlyBracketShape, mxActor);
  1104. CurlyBracketShape.prototype.size = 0.5;
  1105. CurlyBracketShape.prototype.redrawPath = function(c, x, y, w, h)
  1106. {
  1107. c.setFillColor(null);
  1108. var s = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1109. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1110. this.addPoints(c, [new mxPoint(w, 0), new mxPoint(s, 0), new mxPoint(s, h / 2),
  1111. new mxPoint(0, h / 2), new mxPoint(s, h / 2), new mxPoint(s, h),
  1112. new mxPoint(w, h)], this.isRounded, arcSize, false);
  1113. c.end();
  1114. };
  1115. mxCellRenderer.registerShape('curlyBracket', CurlyBracketShape);
  1116. // Parallel marker shape
  1117. function ParallelMarkerShape()
  1118. {
  1119. mxActor.call(this);
  1120. };
  1121. mxUtils.extend(ParallelMarkerShape, mxActor);
  1122. ParallelMarkerShape.prototype.redrawPath = function(c, x, y, w, h)
  1123. {
  1124. c.setStrokeWidth(1);
  1125. c.setFillColor(this.stroke);
  1126. var w2 = w / 5;
  1127. c.rect(0, 0, w2, h);
  1128. c.fillAndStroke();
  1129. c.rect(2 * w2, 0, w2, h);
  1130. c.fillAndStroke();
  1131. c.rect(4 * w2, 0, w2, h);
  1132. c.fillAndStroke();
  1133. };
  1134. mxCellRenderer.registerShape('parallelMarker', ParallelMarkerShape);
  1135. /**
  1136. * Adds handJiggle style (jiggle=n sets jiggle)
  1137. */
  1138. function HandJiggle(canvas, defaultVariation)
  1139. {
  1140. this.canvas = canvas;
  1141. // Avoids "spikes" in the output
  1142. this.canvas.setLineJoin('round');
  1143. this.canvas.setLineCap('round');
  1144. this.defaultVariation = defaultVariation;
  1145. this.originalLineTo = this.canvas.lineTo;
  1146. this.canvas.lineTo = mxUtils.bind(this, HandJiggle.prototype.lineTo);
  1147. this.originalMoveTo = this.canvas.moveTo;
  1148. this.canvas.moveTo = mxUtils.bind(this, HandJiggle.prototype.moveTo);
  1149. this.originalClose = this.canvas.close;
  1150. this.canvas.close = mxUtils.bind(this, HandJiggle.prototype.close);
  1151. this.originalQuadTo = this.canvas.quadTo;
  1152. this.canvas.quadTo = mxUtils.bind(this, HandJiggle.prototype.quadTo);
  1153. this.originalCurveTo = this.canvas.curveTo;
  1154. this.canvas.curveTo = mxUtils.bind(this, HandJiggle.prototype.curveTo);
  1155. this.originalArcTo = this.canvas.arcTo;
  1156. this.canvas.arcTo = mxUtils.bind(this, HandJiggle.prototype.arcTo);
  1157. };
  1158. HandJiggle.prototype.moveTo = function(endX, endY)
  1159. {
  1160. this.originalMoveTo.apply(this.canvas, arguments);
  1161. this.lastX = endX;
  1162. this.lastY = endY;
  1163. this.firstX = endX;
  1164. this.firstY = endY;
  1165. };
  1166. HandJiggle.prototype.close = function()
  1167. {
  1168. if (this.firstX != null && this.firstY != null)
  1169. {
  1170. this.lineTo(this.firstX, this.firstY);
  1171. this.originalClose.apply(this.canvas, arguments);
  1172. }
  1173. this.originalClose.apply(this.canvas, arguments);
  1174. };
  1175. HandJiggle.prototype.quadTo = function(x1, y1, x2, y2)
  1176. {
  1177. this.originalQuadTo.apply(this.canvas, arguments);
  1178. this.lastX = x2;
  1179. this.lastY = y2;
  1180. };
  1181. HandJiggle.prototype.curveTo = function(x1, y1, x2, y2, x3, y3)
  1182. {
  1183. this.originalCurveTo.apply(this.canvas, arguments);
  1184. this.lastX = x3;
  1185. this.lastY = y3;
  1186. };
  1187. HandJiggle.prototype.arcTo = function(rx, ry, angle, largeArcFlag, sweepFlag, x, y)
  1188. {
  1189. this.originalArcTo.apply(this.canvas, arguments);
  1190. this.lastX = x;
  1191. this.lastY = y;
  1192. };
  1193. HandJiggle.prototype.lineTo = function(endX, endY)
  1194. {
  1195. // LATER: Check why this.canvas.lastX cannot be used
  1196. if (this.lastX != null && this.lastY != null)
  1197. {
  1198. var dx = Math.abs(endX - this.lastX);
  1199. var dy = Math.abs(endY - this.lastY);
  1200. var dist = Math.sqrt(dx * dx + dy * dy);
  1201. if (dist < 2)
  1202. {
  1203. this.originalLineTo.apply(this.canvas, arguments);
  1204. this.lastX = endX;
  1205. this.lastY = endY;
  1206. return;
  1207. }
  1208. var segs = Math.round(dist / 10);
  1209. var variation = this.defaultVariation;
  1210. if (segs < 5)
  1211. {
  1212. segs = 5;
  1213. variation /= 3;
  1214. }
  1215. function sign(x)
  1216. {
  1217. return typeof x === 'number' ? x ? x < 0 ? -1 : 1 : x === x ? 0 : NaN : NaN;
  1218. }
  1219. var stepX = sign(endX - this.lastX) * dx / segs;
  1220. var stepY = sign(endY - this.lastY) * dy / segs;
  1221. var fx = dx / dist;
  1222. var fy = dy / dist;
  1223. for (var s = 0; s < segs; s++)
  1224. {
  1225. var x = stepX * s + this.lastX;
  1226. var y = stepY * s + this.lastY;
  1227. var offset = (Math.random() - 0.5) * variation;
  1228. this.originalLineTo.call(this.canvas, x - offset * fy, y - offset * fx);
  1229. }
  1230. this.originalLineTo.call(this.canvas, endX, endY);
  1231. this.lastX = endX;
  1232. this.lastY = endY;
  1233. }
  1234. else
  1235. {
  1236. this.originalLineTo.apply(this.canvas, arguments);
  1237. this.lastX = endX;
  1238. this.lastY = endY;
  1239. }
  1240. };
  1241. HandJiggle.prototype.destroy = function()
  1242. {
  1243. this.canvas.lineTo = this.originalLineTo;
  1244. this.canvas.moveTo = this.originalMoveTo;
  1245. this.canvas.close = this.originalClose;
  1246. this.canvas.quadTo = this.originalQuadTo;
  1247. this.canvas.curveTo = this.originalCurveTo;
  1248. this.canvas.arcTo = this.originalArcTo;
  1249. };
  1250. // Installs hand jiggle for comic and sketch style
  1251. mxShape.prototype.defaultJiggle = 1.5;
  1252. var shapeBeforePaint = mxShape.prototype.beforePaint;
  1253. mxShape.prototype.beforePaint = function(c)
  1254. {
  1255. shapeBeforePaint.apply(this, arguments);
  1256. if (c.handJiggle == null)
  1257. {
  1258. c.handJiggle = this.createHandJiggle(c);
  1259. }
  1260. };
  1261. var shapeAfterPaint = mxShape.prototype.afterPaint;
  1262. mxShape.prototype.afterPaint = function(c)
  1263. {
  1264. shapeAfterPaint.apply(this, arguments);
  1265. if (c.handJiggle != null)
  1266. {
  1267. c.handJiggle.destroy();
  1268. delete c.handJiggle;
  1269. }
  1270. };
  1271. // Returns a new HandJiggle canvas
  1272. mxShape.prototype.createComicCanvas = function(c)
  1273. {
  1274. return new HandJiggle(c, mxUtils.getValue(this.style, 'jiggle', this.defaultJiggle));
  1275. };
  1276. // Overrides to avoid call to rect
  1277. mxShape.prototype.createHandJiggle = function(c)
  1278. {
  1279. if (!this.outline && this.style != null && mxUtils.getValue(this.style, 'comic', '0') != '0')
  1280. {
  1281. return this.createComicCanvas(c);
  1282. }
  1283. return null;
  1284. };
  1285. // Sets default jiggle for diamond
  1286. mxRhombus.prototype.defaultJiggle = 2;
  1287. // Overrides to avoid call to rect
  1288. var mxRectangleShapeIsHtmlAllowed0 = mxRectangleShape.prototype.isHtmlAllowed;
  1289. mxRectangleShape.prototype.isHtmlAllowed = function()
  1290. {
  1291. return !this.outline && (this.style == null || (mxUtils.getValue(this.style, 'comic', '0') == '0' &&
  1292. mxUtils.getValue(this.style, 'sketch', (urlParams['rough'] == '1') ? '1' : '0') == '0')) &&
  1293. mxRectangleShapeIsHtmlAllowed0.apply(this, arguments);
  1294. };
  1295. var mxRectangleShapePaintBackground0 = mxRectangleShape.prototype.paintBackground;
  1296. mxRectangleShape.prototype.paintBackground = function(c, x, y, w, h)
  1297. {
  1298. if (c.handJiggle == null || c.handJiggle.constructor != HandJiggle)
  1299. {
  1300. mxRectangleShapePaintBackground0.apply(this, arguments);
  1301. }
  1302. else
  1303. {
  1304. var events = true;
  1305. if (this.style != null)
  1306. {
  1307. events = mxUtils.getValue(this.style, mxConstants.STYLE_POINTER_EVENTS, '1') == '1';
  1308. }
  1309. if (events || (this.fill != null && this.fill != mxConstants.NONE) ||
  1310. (this.stroke != null && this.stroke != mxConstants.NONE))
  1311. {
  1312. if (!events && (this.fill == null || this.fill == mxConstants.NONE))
  1313. {
  1314. c.pointerEvents = false;
  1315. }
  1316. c.begin();
  1317. if (this.isRounded)
  1318. {
  1319. var r = 0;
  1320. if (mxUtils.getValue(this.style, mxConstants.STYLE_ABSOLUTE_ARCSIZE, 0) == '1')
  1321. {
  1322. r = Math.min(w / 2, Math.min(h / 2, mxUtils.getValue(this.style,
  1323. mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2));
  1324. }
  1325. else
  1326. {
  1327. var f = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE,
  1328. mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100;
  1329. r = Math.min(w * f, h * f);
  1330. }
  1331. c.moveTo(x + r, y);
  1332. c.lineTo(x + w - r, y);
  1333. c.quadTo(x + w, y, x + w, y + r);
  1334. c.lineTo(x + w, y + h - r);
  1335. c.quadTo(x + w, y + h, x + w - r, y + h);
  1336. c.lineTo(x + r, y + h);
  1337. c.quadTo(x, y + h, x, y + h - r);
  1338. c.lineTo(x, y + r);
  1339. c.quadTo(x, y, x + r, y);
  1340. }
  1341. else
  1342. {
  1343. c.moveTo(x, y);
  1344. c.lineTo(x + w, y);
  1345. c.lineTo(x + w, y + h);
  1346. c.lineTo(x, y + h);
  1347. c.lineTo(x, y);
  1348. }
  1349. // LATER: Check if close is needed here
  1350. c.close();
  1351. c.end();
  1352. c.fillAndStroke();
  1353. }
  1354. }
  1355. };
  1356. // End of hand jiggle integration
  1357. // Process Shape
  1358. function ProcessShape()
  1359. {
  1360. mxRectangleShape.call(this);
  1361. };
  1362. mxUtils.extend(ProcessShape, mxRectangleShape);
  1363. ProcessShape.prototype.size = 0.1;
  1364. ProcessShape.prototype.fixedSize = false;
  1365. ProcessShape.prototype.isHtmlAllowed = function()
  1366. {
  1367. return false;
  1368. };
  1369. ProcessShape.prototype.getLabelBounds = function(rect)
  1370. {
  1371. if (mxUtils.getValue(this.state.style, mxConstants.STYLE_HORIZONTAL, true) ==
  1372. (this.direction == null ||
  1373. this.direction == mxConstants.DIRECTION_EAST ||
  1374. this.direction == mxConstants.DIRECTION_WEST))
  1375. {
  1376. var w = rect.width;
  1377. var h = rect.height;
  1378. var r = new mxRectangle(rect.x, rect.y, w, h);
  1379. var inset = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1380. if (this.isRounded)
  1381. {
  1382. var f = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE,
  1383. mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100;
  1384. inset = Math.max(inset, Math.min(w * f, h * f));
  1385. }
  1386. r.x += Math.round(inset);
  1387. r.width -= Math.round(2 * inset);
  1388. return r;
  1389. }
  1390. return rect;
  1391. };
  1392. ProcessShape.prototype.paintForeground = function(c, x, y, w, h)
  1393. {
  1394. var isFixedSize = mxUtils.getValue(this.style, 'fixedSize', this.fixedSize);
  1395. var inset = parseFloat(mxUtils.getValue(this.style, 'size', this.size));
  1396. if (isFixedSize)
  1397. {
  1398. inset = Math.max(0, Math.min(w, inset));
  1399. }
  1400. else
  1401. {
  1402. inset = w * Math.max(0, Math.min(1, inset));
  1403. }
  1404. if (this.isRounded)
  1405. {
  1406. var f = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE,
  1407. mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100;
  1408. inset = Math.max(inset, Math.min(w * f, h * f));
  1409. }
  1410. // Crisp rendering of inner lines
  1411. inset = Math.round(inset);
  1412. c.begin();
  1413. c.moveTo(x + inset, y);
  1414. c.lineTo(x + inset, y + h);
  1415. c.moveTo(x + w - inset, y);
  1416. c.lineTo(x + w - inset, y + h);
  1417. c.end();
  1418. c.stroke();
  1419. mxRectangleShape.prototype.paintForeground.apply(this, arguments);
  1420. };
  1421. mxCellRenderer.registerShape('process', ProcessShape);
  1422. //Register the same shape with another name for backwards compatibility
  1423. mxCellRenderer.registerShape('process2', ProcessShape);
  1424. // Transparent Shape
  1425. function TransparentShape()
  1426. {
  1427. mxRectangleShape.call(this);
  1428. };
  1429. mxUtils.extend(TransparentShape, mxRectangleShape);
  1430. TransparentShape.prototype.paintBackground = function(c, x, y, w, h)
  1431. {
  1432. c.setFillColor(mxConstants.NONE);
  1433. c.rect(x, y, w, h);
  1434. c.fill();
  1435. };
  1436. TransparentShape.prototype.paintForeground = function(c, x, y, w, h) { };
  1437. mxCellRenderer.registerShape('transparent', TransparentShape);
  1438. // Callout shape
  1439. function CalloutShape()
  1440. {
  1441. mxActor.call(this);
  1442. };
  1443. mxUtils.extend(CalloutShape, mxHexagon);
  1444. CalloutShape.prototype.size = 30;
  1445. CalloutShape.prototype.position = 0.5;
  1446. CalloutShape.prototype.position2 = 0.5;
  1447. CalloutShape.prototype.base = 20;
  1448. CalloutShape.prototype.getLabelMargins = function()
  1449. {
  1450. return new mxRectangle(0, 0, 0, parseFloat(mxUtils.getValue(
  1451. this.style, 'size', this.size)) * this.scale);
  1452. };
  1453. CalloutShape.prototype.isRoundable = function()
  1454. {
  1455. return true;
  1456. };
  1457. CalloutShape.prototype.redrawPath = function(c, x, y, w, h)
  1458. {
  1459. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1460. var s = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1461. var dx = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'position', this.position))));
  1462. var dx2 = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'position2', this.position2))));
  1463. var base = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'base', this.base))));
  1464. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w, 0), new mxPoint(w, h - s),
  1465. new mxPoint(Math.min(w, dx + base), h - s), new mxPoint(dx2, h),
  1466. new mxPoint(Math.max(0, dx), h - s), new mxPoint(0, h - s)],
  1467. this.isRounded, arcSize, true, [4]);
  1468. };
  1469. mxCellRenderer.registerShape('callout', CalloutShape);
  1470. // Step shape
  1471. function StepShape()
  1472. {
  1473. mxActor.call(this);
  1474. };
  1475. mxUtils.extend(StepShape, mxActor);
  1476. StepShape.prototype.size = 0.2;
  1477. StepShape.prototype.fixedSize = 20;
  1478. StepShape.prototype.isRoundable = function()
  1479. {
  1480. return true;
  1481. };
  1482. StepShape.prototype.redrawPath = function(c, x, y, w, h)
  1483. {
  1484. var fixed = mxUtils.getValue(this.style, 'fixedSize', '0') != '0';
  1485. var s = (fixed) ? Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'size', this.fixedSize)))) :
  1486. w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1487. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1488. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w - s, 0), new mxPoint(w, h / 2), new mxPoint(w - s, h),
  1489. new mxPoint(0, h), new mxPoint(s, h / 2)], this.isRounded, arcSize, true);
  1490. c.end();
  1491. };
  1492. mxCellRenderer.registerShape('step', StepShape);
  1493. // Hexagon shape
  1494. function HexagonShape()
  1495. {
  1496. mxActor.call(this);
  1497. };
  1498. mxUtils.extend(HexagonShape, mxHexagon);
  1499. HexagonShape.prototype.size = 0.25;
  1500. HexagonShape.prototype.fixedSize = 20;
  1501. HexagonShape.prototype.isRoundable = function()
  1502. {
  1503. return true;
  1504. };
  1505. HexagonShape.prototype.redrawPath = function(c, x, y, w, h)
  1506. {
  1507. var fixed = mxUtils.getValue(this.style, 'fixedSize', '0') != '0';
  1508. var s = (fixed) ? Math.max(0, Math.min(w * 0.5, parseFloat(mxUtils.getValue(this.style, 'size', this.fixedSize)))) :
  1509. w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1510. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  1511. this.addPoints(c, [new mxPoint(s, 0), new mxPoint(w - s, 0), new mxPoint(w, 0.5 * h), new mxPoint(w - s, h),
  1512. new mxPoint(s, h), new mxPoint(0, 0.5 * h)], this.isRounded, arcSize, true);
  1513. };
  1514. mxCellRenderer.registerShape('hexagon', HexagonShape);
  1515. // Plus Shape
  1516. function PlusShape()
  1517. {
  1518. mxRectangleShape.call(this);
  1519. };
  1520. mxUtils.extend(PlusShape, mxRectangleShape);
  1521. PlusShape.prototype.isHtmlAllowed = function()
  1522. {
  1523. return false;
  1524. };
  1525. PlusShape.prototype.paintForeground = function(c, x, y, w, h)
  1526. {
  1527. var border = Math.min(w / 5, h / 5) + 1;
  1528. c.begin();
  1529. c.moveTo(x + w / 2, y + border);
  1530. c.lineTo(x + w / 2, y + h - border);
  1531. c.moveTo(x + border, y + h / 2);
  1532. c.lineTo(x + w - border, y + h / 2);
  1533. c.end();
  1534. c.stroke();
  1535. mxRectangleShape.prototype.paintForeground.apply(this, arguments);
  1536. };
  1537. mxCellRenderer.registerShape('plus', PlusShape);
  1538. // Overrides painting of rhombus shape to allow for double style
  1539. var mxRhombusPaintVertexShape = mxRhombus.prototype.paintVertexShape;
  1540. mxRhombus.prototype.getLabelBounds = function(rect)
  1541. {
  1542. if (this.style['double'] == 1)
  1543. {
  1544. var margin = (Math.max(2, this.strokewidth + 1) * 2 + parseFloat(
  1545. this.style[mxConstants.STYLE_MARGIN] || 0)) * this.scale;
  1546. return new mxRectangle(rect.x + margin, rect.y + margin,
  1547. rect.width - 2 * margin, rect.height - 2 * margin);
  1548. }
  1549. return rect;
  1550. };
  1551. mxRhombus.prototype.paintVertexShape = function(c, x, y, w, h)
  1552. {
  1553. mxRhombusPaintVertexShape.apply(this, arguments);
  1554. if (!this.outline && this.style['double'] == 1)
  1555. {
  1556. var margin = Math.max(2, this.strokewidth + 1) * 2 +
  1557. parseFloat(this.style[mxConstants.STYLE_MARGIN] || 0);
  1558. x += margin;
  1559. y += margin;
  1560. w -= 2 * margin;
  1561. h -= 2 * margin;
  1562. if (w > 0 && h > 0)
  1563. {
  1564. c.setShadow(false);
  1565. // Workaround for closure compiler bug where the lines with x and y above
  1566. // are removed if arguments is used as second argument in call below.
  1567. mxRhombusPaintVertexShape.apply(this, [c, x, y, w, h]);
  1568. }
  1569. }
  1570. };
  1571. // CompositeShape
  1572. function ExtendedShape()
  1573. {
  1574. mxRectangleShape.call(this);
  1575. };
  1576. mxUtils.extend(ExtendedShape, mxRectangleShape);
  1577. ExtendedShape.prototype.isHtmlAllowed = function()
  1578. {
  1579. return false;
  1580. };
  1581. ExtendedShape.prototype.getLabelBounds = function(rect)
  1582. {
  1583. if (this.style['double'] == 1)
  1584. {
  1585. var margin = (Math.max(2, this.strokewidth + 1) + parseFloat(
  1586. this.style[mxConstants.STYLE_MARGIN] || 0)) * this.scale;
  1587. return new mxRectangle(rect.x + margin, rect.y + margin,
  1588. rect.width - 2 * margin, rect.height - 2 * margin);
  1589. }
  1590. return rect;
  1591. };
  1592. ExtendedShape.prototype.paintForeground = function(c, x, y, w, h)
  1593. {
  1594. if (this.style != null)
  1595. {
  1596. if (!this.outline && this.style['double'] == 1)
  1597. {
  1598. var margin = Math.max(2, this.strokewidth + 1) + parseFloat(this.style[mxConstants.STYLE_MARGIN] || 0);
  1599. x += margin;
  1600. y += margin;
  1601. w -= 2 * margin;
  1602. h -= 2 * margin;
  1603. if (w > 0 && h > 0)
  1604. {
  1605. mxRectangleShape.prototype.paintBackground.apply(this, arguments);
  1606. }
  1607. }
  1608. c.setDashed(false);
  1609. // Draws the symbols defined in the style. The symbols are
  1610. // numbered from 1...n. Possible postfixes are align,
  1611. // verticalAlign, spacing, arcSpacing, width, height
  1612. var counter = 0;
  1613. var shape = null;
  1614. do
  1615. {
  1616. shape = mxCellRenderer.defaultShapes[this.style['symbol' + counter]];
  1617. if (shape != null)
  1618. {
  1619. var align = this.style['symbol' + counter + 'Align'];
  1620. var valign = this.style['symbol' + counter + 'VerticalAlign'];
  1621. var width = this.style['symbol' + counter + 'Width'];
  1622. var height = this.style['symbol' + counter + 'Height'];
  1623. var spacing = this.style['symbol' + counter + 'Spacing'] || 0;
  1624. var vspacing = this.style['symbol' + counter + 'VSpacing'] || spacing;
  1625. var arcspacing = this.style['symbol' + counter + 'ArcSpacing'];
  1626. if (arcspacing != null)
  1627. {
  1628. var arcSize = this.getArcSize(w + this.strokewidth, h + this.strokewidth) * arcspacing;
  1629. spacing += arcSize;
  1630. vspacing += arcSize;
  1631. }
  1632. var x2 = x;
  1633. var y2 = y;
  1634. if (align == mxConstants.ALIGN_CENTER)
  1635. {
  1636. x2 += (w - width) / 2;
  1637. }
  1638. else if (align == mxConstants.ALIGN_RIGHT)
  1639. {
  1640. x2 += w - width - spacing;
  1641. }
  1642. else
  1643. {
  1644. x2 += spacing;
  1645. }
  1646. if (valign == mxConstants.ALIGN_MIDDLE)
  1647. {
  1648. y2 += (h - height) / 2;
  1649. }
  1650. else if (valign == mxConstants.ALIGN_BOTTOM)
  1651. {
  1652. y2 += h - height - vspacing;
  1653. }
  1654. else
  1655. {
  1656. y2 += vspacing;
  1657. }
  1658. c.save();
  1659. // Small hack to pass style along into subshape
  1660. var tmp = new shape();
  1661. // TODO: Clone style and override settings (eg. strokewidth)
  1662. tmp.style = this.style;
  1663. shape.prototype.paintVertexShape.call(tmp, c, x2, y2, width, height);
  1664. c.restore();
  1665. }
  1666. counter++;
  1667. }
  1668. while (shape != null);
  1669. }
  1670. // Paints glass effect
  1671. mxRectangleShape.prototype.paintForeground.apply(this, arguments);
  1672. };
  1673. mxCellRenderer.registerShape('ext', ExtendedShape);
  1674. // Tape Shape, supports size style
  1675. function MessageShape()
  1676. {
  1677. mxCylinder.call(this);
  1678. };
  1679. mxUtils.extend(MessageShape, mxCylinder);
  1680. MessageShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  1681. {
  1682. if (isForeground)
  1683. {
  1684. path.moveTo(0, 0);
  1685. path.lineTo(w / 2, h / 2);
  1686. path.lineTo(w, 0);
  1687. path.end();
  1688. }
  1689. else
  1690. {
  1691. path.moveTo(0, 0);
  1692. path.lineTo(w, 0);
  1693. path.lineTo(w, h);
  1694. path.lineTo(0, h);
  1695. path.close();
  1696. }
  1697. };
  1698. mxCellRenderer.registerShape('message', MessageShape);
  1699. // UML Actor Shape
  1700. function UmlActorShape()
  1701. {
  1702. mxShape.call(this);
  1703. };
  1704. mxUtils.extend(UmlActorShape, mxShape);
  1705. UmlActorShape.prototype.paintBackground = function(c, x, y, w, h)
  1706. {
  1707. c.translate(x, y);
  1708. // Head
  1709. c.ellipse(w / 4, 0, w / 2, h / 4);
  1710. c.fillAndStroke();
  1711. c.begin();
  1712. c.moveTo(w / 2, h / 4);
  1713. c.lineTo(w / 2, 2 * h / 3);
  1714. // Arms
  1715. c.moveTo(w / 2, h / 3);
  1716. c.lineTo(0, h / 3);
  1717. c.moveTo(w / 2, h / 3);
  1718. c.lineTo(w, h / 3);
  1719. // Legs
  1720. c.moveTo(w / 2, 2 * h / 3);
  1721. c.lineTo(0, h);
  1722. c.moveTo(w / 2, 2 * h / 3);
  1723. c.lineTo(w, h);
  1724. c.end();
  1725. c.stroke();
  1726. };
  1727. // Replaces existing actor shape
  1728. mxCellRenderer.registerShape('umlActor', UmlActorShape);
  1729. ////////////// UML Boundary Shape ///////////////
  1730. function UmlBoundaryShape()
  1731. {
  1732. mxShape.call(this);
  1733. };
  1734. mxUtils.extend(UmlBoundaryShape, mxShape);
  1735. UmlBoundaryShape.prototype.getLabelMargins = function(rect)
  1736. {
  1737. return new mxRectangle(rect.width / 6, 0, 0, 0);
  1738. };
  1739. UmlBoundaryShape.prototype.paintBackground = function(c, x, y, w, h)
  1740. {
  1741. c.translate(x, y);
  1742. // Base line
  1743. c.begin();
  1744. c.moveTo(0, h / 4);
  1745. c.lineTo(0, h * 3 / 4);
  1746. c.end();
  1747. c.stroke();
  1748. // Horizontal line
  1749. c.begin();
  1750. c.moveTo(0, h / 2);
  1751. c.lineTo(w / 6, h / 2);
  1752. c.end();
  1753. c.stroke();
  1754. // Circle
  1755. c.ellipse(w / 6, 0, w * 5 / 6, h);
  1756. c.fillAndStroke();
  1757. };
  1758. mxCellRenderer.registerShape('umlBoundary', UmlBoundaryShape);
  1759. // UML Entity Shape
  1760. function UmlEntityShape()
  1761. {
  1762. mxEllipse.call(this);
  1763. };
  1764. mxUtils.extend(UmlEntityShape, mxEllipse);
  1765. UmlEntityShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1766. {
  1767. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  1768. c.begin();
  1769. c.moveTo(x + w / 8, y + h);
  1770. c.lineTo(x + w * 7 / 8, y + h);
  1771. c.end();
  1772. c.stroke();
  1773. };
  1774. mxCellRenderer.registerShape('umlEntity', UmlEntityShape);
  1775. // UML Destroy Shape
  1776. function UmlDestroyShape()
  1777. {
  1778. mxShape.call(this);
  1779. };
  1780. mxUtils.extend(UmlDestroyShape, mxShape);
  1781. UmlDestroyShape.prototype.paintVertexShape = function(c, x, y, w, h)
  1782. {
  1783. c.translate(x, y);
  1784. c.begin();
  1785. c.moveTo(w, 0);
  1786. c.lineTo(0, h);
  1787. c.moveTo(0, 0);
  1788. c.lineTo(w, h);
  1789. c.end();
  1790. c.stroke();
  1791. };
  1792. mxCellRenderer.registerShape('umlDestroy', UmlDestroyShape);
  1793. // UML Control Shape
  1794. function UmlControlShape()
  1795. {
  1796. mxShape.call(this);
  1797. };
  1798. mxUtils.extend(UmlControlShape, mxShape);
  1799. UmlControlShape.prototype.getLabelBounds = function(rect)
  1800. {
  1801. return new mxRectangle(rect.x, rect.y + rect.height / 8, rect.width, rect.height * 7 / 8);
  1802. };
  1803. UmlControlShape.prototype.paintBackground = function(c, x, y, w, h)
  1804. {
  1805. c.translate(x, y);
  1806. // Upper line
  1807. c.begin();
  1808. c.moveTo(w * 3 / 8, h / 8 * 1.1);
  1809. c.lineTo(w * 5 / 8, 0);
  1810. c.end();
  1811. c.stroke();
  1812. // Circle
  1813. c.ellipse(0, h / 8, w, h * 7 / 8);
  1814. c.fillAndStroke();
  1815. };
  1816. UmlControlShape.prototype.paintForeground = function(c, x, y, w, h)
  1817. {
  1818. // Lower line
  1819. c.begin();
  1820. c.moveTo(w * 3 / 8, h / 8 * 1.1);
  1821. c.lineTo(w * 5 / 8, h / 4);
  1822. c.end();
  1823. c.stroke();
  1824. };
  1825. // Replaces existing actor shape
  1826. mxCellRenderer.registerShape('umlControl', UmlControlShape);
  1827. // UML Lifeline Shape
  1828. function UmlLifeline()
  1829. {
  1830. mxRectangleShape.call(this);
  1831. };
  1832. mxUtils.extend(UmlLifeline, mxRectangleShape);
  1833. UmlLifeline.prototype.size = 40;
  1834. UmlLifeline.prototype.isHtmlAllowed = function()
  1835. {
  1836. return false;
  1837. };
  1838. UmlLifeline.prototype.getLabelBounds = function(rect)
  1839. {
  1840. var size = Math.max(0, Math.min(rect.height, parseFloat(
  1841. mxUtils.getValue(this.style, 'size', this.size)) * this.scale));
  1842. return new mxRectangle(rect.x, rect.y, rect.width, size);
  1843. };
  1844. UmlLifeline.prototype.paintBackground = function(c, x, y, w, h)
  1845. {
  1846. var size = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1847. var participant = mxUtils.getValue(this.style, 'participant');
  1848. if (participant == null || this.state == null)
  1849. {
  1850. mxRectangleShape.prototype.paintBackground.call(this, c, x, y, w, size);
  1851. }
  1852. else
  1853. {
  1854. var ctor = this.state.view.graph.cellRenderer.getShape(participant);
  1855. if (ctor != null && ctor != UmlLifeline)
  1856. {
  1857. var shape = new ctor();
  1858. shape.apply(this.state);
  1859. c.save();
  1860. shape.paintVertexShape(c, x, y, w, size);
  1861. c.restore();
  1862. }
  1863. }
  1864. if (size < h)
  1865. {
  1866. c.setDashed(mxUtils.getValue(this.style, 'lifelineDashed', '1') == '1');
  1867. c.begin();
  1868. c.moveTo(x + w / 2, y + size);
  1869. c.lineTo(x + w / 2, y + h);
  1870. c.end();
  1871. c.stroke();
  1872. }
  1873. };
  1874. UmlLifeline.prototype.paintForeground = function(c, x, y, w, h)
  1875. {
  1876. var size = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1877. mxRectangleShape.prototype.paintForeground.call(this, c, x, y, w, Math.min(h, size));
  1878. };
  1879. mxCellRenderer.registerShape('umlLifeline', UmlLifeline);
  1880. // UML Frame Shape
  1881. function UmlFrame()
  1882. {
  1883. mxShape.call(this);
  1884. };
  1885. mxUtils.extend(UmlFrame, mxShape);
  1886. UmlFrame.prototype.width = 60;
  1887. UmlFrame.prototype.height = 30;
  1888. UmlFrame.prototype.corner = 10;
  1889. UmlFrame.prototype.getLabelMargins = function(rect)
  1890. {
  1891. return new mxRectangle(0, 0,
  1892. rect.width - (parseFloat(mxUtils.getValue(this.style, 'width', this.width) * this.scale)),
  1893. rect.height - (parseFloat(mxUtils.getValue(this.style, 'height', this.height) * this.scale)));
  1894. };
  1895. UmlFrame.prototype.paintBackground = function(c, x, y, w, h)
  1896. {
  1897. var co = this.corner;
  1898. var w0 = Math.min(w, Math.max(co, parseFloat(mxUtils.getValue(this.style, 'width', this.width))));
  1899. var h0 = Math.min(h, Math.max(co * 1.5, parseFloat(mxUtils.getValue(this.style, 'height', this.height))));
  1900. var bg = mxUtils.getValue(this.style, mxConstants.STYLE_SWIMLANE_FILLCOLOR, mxConstants.NONE);
  1901. if (bg != mxConstants.NONE)
  1902. {
  1903. c.setFillColor(bg);
  1904. c.rect(x, y, w, h);
  1905. c.fill();
  1906. }
  1907. if (this.fill != null && this.fill != mxConstants.NONE && this.gradient && this.gradient != mxConstants.NONE)
  1908. {
  1909. var b = this.getGradientBounds(c, x, y, w, h);
  1910. c.setGradient(this.fill, this.gradient, x, y, w, h, this.gradientDirection);
  1911. }
  1912. else
  1913. {
  1914. c.setFillColor(this.fill);
  1915. }
  1916. c.begin();
  1917. c.moveTo(x, y);
  1918. c.lineTo(x + w0, y);
  1919. c.lineTo(x + w0, y + Math.max(0, h0 - co * 1.5));
  1920. c.lineTo(x + Math.max(0, w0 - co), y + h0);
  1921. c.lineTo(x, y + h0);
  1922. c.close();
  1923. c.fillAndStroke();
  1924. c.begin();
  1925. c.moveTo(x + w0, y);
  1926. c.lineTo(x + w, y);
  1927. c.lineTo(x + w, y + h);
  1928. c.lineTo(x, y + h);
  1929. c.lineTo(x, y + h0);
  1930. c.stroke();
  1931. };
  1932. mxCellRenderer.registerShape('umlFrame', UmlFrame);
  1933. mxPerimeter.CenterPerimeter = function (bounds, vertex, next, orthogonal)
  1934. {
  1935. return new mxPoint(bounds.getCenterX(), bounds.getCenterY());
  1936. };
  1937. mxStyleRegistry.putValue('centerPerimeter', mxPerimeter.CenterPerimeter);
  1938. mxPerimeter.LifelinePerimeter = function (bounds, vertex, next, orthogonal)
  1939. {
  1940. var size = UmlLifeline.prototype.size;
  1941. if (vertex != null)
  1942. {
  1943. size = mxUtils.getValue(vertex.style, 'size', size) * vertex.view.scale;
  1944. }
  1945. var sw = (parseFloat(vertex.style[mxConstants.STYLE_STROKEWIDTH] || 1) * vertex.view.scale / 2) - 1;
  1946. if (next.x < bounds.getCenterX())
  1947. {
  1948. sw += 1;
  1949. sw *= -1;
  1950. }
  1951. return new mxPoint(bounds.getCenterX() + sw, Math.min(bounds.y + bounds.height,
  1952. Math.max(bounds.y + size, next.y)));
  1953. };
  1954. mxStyleRegistry.putValue('lifelinePerimeter', mxPerimeter.LifelinePerimeter);
  1955. mxPerimeter.OrthogonalPerimeter = function (bounds, vertex, next, orthogonal)
  1956. {
  1957. orthogonal = true;
  1958. return mxPerimeter.RectanglePerimeter.apply(this, arguments);
  1959. };
  1960. mxStyleRegistry.putValue('orthogonalPerimeter', mxPerimeter.OrthogonalPerimeter);
  1961. mxPerimeter.BackbonePerimeter = function (bounds, vertex, next, orthogonal)
  1962. {
  1963. var sw = (parseFloat(vertex.style[mxConstants.STYLE_STROKEWIDTH] || 1) * vertex.view.scale / 2) - 1;
  1964. if (vertex.style['backboneSize'] != null)
  1965. {
  1966. sw += (parseFloat(vertex.style['backboneSize']) * vertex.view.scale / 2) - 1;
  1967. }
  1968. if (vertex.style[mxConstants.STYLE_DIRECTION] == 'south' ||
  1969. vertex.style[mxConstants.STYLE_DIRECTION] == 'north')
  1970. {
  1971. if (next.x < bounds.getCenterX())
  1972. {
  1973. sw += 1;
  1974. sw *= -1;
  1975. }
  1976. return new mxPoint(bounds.getCenterX() + sw, Math.min(bounds.y + bounds.height,
  1977. Math.max(bounds.y, next.y)));
  1978. }
  1979. else
  1980. {
  1981. if (next.y < bounds.getCenterY())
  1982. {
  1983. sw += 1;
  1984. sw *= -1;
  1985. }
  1986. return new mxPoint(Math.min(bounds.x + bounds.width, Math.max(bounds.x, next.x)),
  1987. bounds.getCenterY() + sw);
  1988. }
  1989. };
  1990. mxStyleRegistry.putValue('backbonePerimeter', mxPerimeter.BackbonePerimeter);
  1991. // Callout Perimeter
  1992. mxPerimeter.CalloutPerimeter = function (bounds, vertex, next, orthogonal)
  1993. {
  1994. return mxPerimeter.RectanglePerimeter(mxUtils.getDirectedBounds(bounds, new mxRectangle(0, 0, 0,
  1995. Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(vertex.style, 'size',
  1996. CalloutShape.prototype.size)) * vertex.view.scale))),
  1997. vertex.style), vertex, next, orthogonal);
  1998. };
  1999. mxStyleRegistry.putValue('calloutPerimeter', mxPerimeter.CalloutPerimeter);
  2000. // Parallelogram Perimeter
  2001. mxPerimeter.ParallelogramPerimeter = function (bounds, vertex, next, orthogonal)
  2002. {
  2003. var fixed = mxUtils.getValue(vertex.style, 'fixedSize', '0') != '0';
  2004. var size = (fixed) ? ParallelogramShape.prototype.fixedSize : ParallelogramShape.prototype.size;
  2005. if (vertex != null)
  2006. {
  2007. size = mxUtils.getValue(vertex.style, 'size', size);
  2008. }
  2009. if (fixed)
  2010. {
  2011. size *= vertex.view.scale;
  2012. }
  2013. var x = bounds.x;
  2014. var y = bounds.y;
  2015. var w = bounds.width;
  2016. var h = bounds.height;
  2017. var direction = (vertex != null) ? mxUtils.getValue(
  2018. vertex.style, mxConstants.STYLE_DIRECTION,
  2019. mxConstants.DIRECTION_EAST) : mxConstants.DIRECTION_EAST;
  2020. var vertical = direction == mxConstants.DIRECTION_NORTH ||
  2021. direction == mxConstants.DIRECTION_SOUTH;
  2022. var points;
  2023. if (vertical)
  2024. {
  2025. var dy = (fixed) ? Math.max(0, Math.min(h, size)) : h * Math.max(0, Math.min(1, size));
  2026. points = [new mxPoint(x, y), new mxPoint(x + w, y + dy),
  2027. new mxPoint(x + w, y + h), new mxPoint(x, y + h - dy), new mxPoint(x, y)];
  2028. }
  2029. else
  2030. {
  2031. var dx = (fixed) ? Math.max(0, Math.min(w * 0.5, size)) : w * Math.max(0, Math.min(1, size));
  2032. points = [new mxPoint(x + dx, y), new mxPoint(x + w, y),
  2033. new mxPoint(x + w - dx, y + h), new mxPoint(x, y + h), new mxPoint(x + dx, y)];
  2034. }
  2035. var cx = bounds.getCenterX();
  2036. var cy = bounds.getCenterY();
  2037. var p1 = new mxPoint(cx, cy);
  2038. if (orthogonal)
  2039. {
  2040. if (next.x < x || next.x > x + w)
  2041. {
  2042. p1.y = next.y;
  2043. }
  2044. else
  2045. {
  2046. p1.x = next.x;
  2047. }
  2048. }
  2049. return mxUtils.getPerimeterPoint(points, p1, next);
  2050. };
  2051. mxStyleRegistry.putValue('parallelogramPerimeter', mxPerimeter.ParallelogramPerimeter);
  2052. // Trapezoid Perimeter
  2053. mxPerimeter.TrapezoidPerimeter = function (bounds, vertex, next, orthogonal)
  2054. {
  2055. var fixed = mxUtils.getValue(vertex.style, 'fixedSize', '0') != '0';
  2056. var size = (fixed) ? TrapezoidShape.prototype.fixedSize : TrapezoidShape.prototype.size;
  2057. if (vertex != null)
  2058. {
  2059. size = mxUtils.getValue(vertex.style, 'size', size);
  2060. }
  2061. if (fixed)
  2062. {
  2063. size *= vertex.view.scale;
  2064. }
  2065. var x = bounds.x;
  2066. var y = bounds.y;
  2067. var w = bounds.width;
  2068. var h = bounds.height;
  2069. var direction = (vertex != null) ? mxUtils.getValue(
  2070. vertex.style, mxConstants.STYLE_DIRECTION,
  2071. mxConstants.DIRECTION_EAST) : mxConstants.DIRECTION_EAST;
  2072. var points = [];
  2073. if (direction == mxConstants.DIRECTION_EAST)
  2074. {
  2075. var dx = (fixed) ? Math.max(0, Math.min(w * 0.5, size)) : w * Math.max(0, Math.min(1, size));
  2076. points = [new mxPoint(x + dx, y), new mxPoint(x + w - dx, y),
  2077. new mxPoint(x + w, y + h), new mxPoint(x, y + h), new mxPoint(x + dx, y)];
  2078. }
  2079. else if (direction == mxConstants.DIRECTION_WEST)
  2080. {
  2081. var dx = (fixed) ? Math.max(0, Math.min(w, size)) : w * Math.max(0, Math.min(1, size));
  2082. points = [new mxPoint(x, y), new mxPoint(x + w, y),
  2083. new mxPoint(x + w - dx, y + h), new mxPoint(x + dx, y + h), new mxPoint(x, y)];
  2084. }
  2085. else if (direction == mxConstants.DIRECTION_NORTH)
  2086. {
  2087. var dy = (fixed) ? Math.max(0, Math.min(h, size)) : h * Math.max(0, Math.min(1, size));
  2088. points = [new mxPoint(x, y + dy), new mxPoint(x + w, y),
  2089. new mxPoint(x + w, y + h), new mxPoint(x, y + h - dy), new mxPoint(x, y + dy)];
  2090. }
  2091. else
  2092. {
  2093. var dy = (fixed) ? Math.max(0, Math.min(h, size)) : h * Math.max(0, Math.min(1, size));
  2094. points = [new mxPoint(x, y), new mxPoint(x + w, y + dy),
  2095. new mxPoint(x + w, y + h - dy), new mxPoint(x, y + h), new mxPoint(x, y)];
  2096. }
  2097. var cx = bounds.getCenterX();
  2098. var cy = bounds.getCenterY();
  2099. var p1 = new mxPoint(cx, cy);
  2100. if (orthogonal)
  2101. {
  2102. if (next.x < x || next.x > x + w)
  2103. {
  2104. p1.y = next.y;
  2105. }
  2106. else
  2107. {
  2108. p1.x = next.x;
  2109. }
  2110. }
  2111. return mxUtils.getPerimeterPoint(points, p1, next);
  2112. };
  2113. mxStyleRegistry.putValue('trapezoidPerimeter', mxPerimeter.TrapezoidPerimeter);
  2114. // Step Perimeter
  2115. mxPerimeter.StepPerimeter = function (bounds, vertex, next, orthogonal)
  2116. {
  2117. var fixed = mxUtils.getValue(vertex.style, 'fixedSize', '0') != '0';
  2118. var size = (fixed) ? StepShape.prototype.fixedSize : StepShape.prototype.size;
  2119. if (vertex != null)
  2120. {
  2121. size = mxUtils.getValue(vertex.style, 'size', size);
  2122. }
  2123. if (fixed)
  2124. {
  2125. size *= vertex.view.scale;
  2126. }
  2127. var x = bounds.x;
  2128. var y = bounds.y;
  2129. var w = bounds.width;
  2130. var h = bounds.height;
  2131. var cx = bounds.getCenterX();
  2132. var cy = bounds.getCenterY();
  2133. var direction = (vertex != null) ? mxUtils.getValue(
  2134. vertex.style, mxConstants.STYLE_DIRECTION,
  2135. mxConstants.DIRECTION_EAST) : mxConstants.DIRECTION_EAST;
  2136. var points;
  2137. if (direction == mxConstants.DIRECTION_EAST)
  2138. {
  2139. var dx = (fixed) ? Math.max(0, Math.min(w, size)) : w * Math.max(0, Math.min(1, size));
  2140. points = [new mxPoint(x, y), new mxPoint(x + w - dx, y), new mxPoint(x + w, cy),
  2141. new mxPoint(x + w - dx, y + h), new mxPoint(x, y + h),
  2142. new mxPoint(x + dx, cy), new mxPoint(x, y)];
  2143. }
  2144. else if (direction == mxConstants.DIRECTION_WEST)
  2145. {
  2146. var dx = (fixed) ? Math.max(0, Math.min(w, size)) : w * Math.max(0, Math.min(1, size));
  2147. points = [new mxPoint(x + dx, y), new mxPoint(x + w, y), new mxPoint(x + w - dx, cy),
  2148. new mxPoint(x + w, y + h), new mxPoint(x + dx, y + h),
  2149. new mxPoint(x, cy), new mxPoint(x + dx, y)];
  2150. }
  2151. else if (direction == mxConstants.DIRECTION_NORTH)
  2152. {
  2153. var dy = (fixed) ? Math.max(0, Math.min(h, size)) : h * Math.max(0, Math.min(1, size));
  2154. points = [new mxPoint(x, y + dy), new mxPoint(cx, y), new mxPoint(x + w, y + dy),
  2155. new mxPoint(x + w, y + h), new mxPoint(cx, y + h - dy),
  2156. new mxPoint(x, y + h), new mxPoint(x, y + dy)];
  2157. }
  2158. else
  2159. {
  2160. var dy = (fixed) ? Math.max(0, Math.min(h, size)) : h * Math.max(0, Math.min(1, size));
  2161. points = [new mxPoint(x, y), new mxPoint(cx, y + dy), new mxPoint(x + w, y),
  2162. new mxPoint(x + w, y + h - dy), new mxPoint(cx, y + h),
  2163. new mxPoint(x, y + h - dy), new mxPoint(x, y)];
  2164. }
  2165. var p1 = new mxPoint(cx, cy);
  2166. if (orthogonal)
  2167. {
  2168. if (next.x < x || next.x > x + w)
  2169. {
  2170. p1.y = next.y;
  2171. }
  2172. else
  2173. {
  2174. p1.x = next.x;
  2175. }
  2176. }
  2177. return mxUtils.getPerimeterPoint(points, p1, next);
  2178. };
  2179. mxStyleRegistry.putValue('stepPerimeter', mxPerimeter.StepPerimeter);
  2180. // Hexagon Perimeter 2 (keep existing one)
  2181. mxPerimeter.HexagonPerimeter2 = function (bounds, vertex, next, orthogonal)
  2182. {
  2183. var fixed = mxUtils.getValue(vertex.style, 'fixedSize', '0') != '0';
  2184. var size = (fixed) ? HexagonShape.prototype.fixedSize : HexagonShape.prototype.size;
  2185. if (vertex != null)
  2186. {
  2187. size = mxUtils.getValue(vertex.style, 'size', size);
  2188. }
  2189. if (fixed)
  2190. {
  2191. size *= vertex.view.scale;
  2192. }
  2193. var x = bounds.x;
  2194. var y = bounds.y;
  2195. var w = bounds.width;
  2196. var h = bounds.height;
  2197. var cx = bounds.getCenterX();
  2198. var cy = bounds.getCenterY();
  2199. var direction = (vertex != null) ? mxUtils.getValue(
  2200. vertex.style, mxConstants.STYLE_DIRECTION,
  2201. mxConstants.DIRECTION_EAST) : mxConstants.DIRECTION_EAST;
  2202. var vertical = direction == mxConstants.DIRECTION_NORTH ||
  2203. direction == mxConstants.DIRECTION_SOUTH;
  2204. var points;
  2205. if (vertical)
  2206. {
  2207. var dy = (fixed) ? Math.max(0, Math.min(h, size)) : h * Math.max(0, Math.min(1, size));
  2208. points = [new mxPoint(cx, y), new mxPoint(x + w, y + dy), new mxPoint(x + w, y + h - dy),
  2209. new mxPoint(cx, y + h), new mxPoint(x, y + h - dy),
  2210. new mxPoint(x, y + dy), new mxPoint(cx, y)];
  2211. }
  2212. else
  2213. {
  2214. var dx = (fixed) ? Math.max(0, Math.min(w, size)) : w * Math.max(0, Math.min(1, size));
  2215. points = [new mxPoint(x + dx, y), new mxPoint(x + w - dx, y), new mxPoint(x + w, cy),
  2216. new mxPoint(x + w - dx, y + h), new mxPoint(x + dx, y + h),
  2217. new mxPoint(x, cy), new mxPoint(x + dx, y)];
  2218. }
  2219. var p1 = new mxPoint(cx, cy);
  2220. if (orthogonal)
  2221. {
  2222. if (next.x < x || next.x > x + w)
  2223. {
  2224. p1.y = next.y;
  2225. }
  2226. else
  2227. {
  2228. p1.x = next.x;
  2229. }
  2230. }
  2231. return mxUtils.getPerimeterPoint(points, p1, next);
  2232. };
  2233. mxStyleRegistry.putValue('hexagonPerimeter2', mxPerimeter.HexagonPerimeter2);
  2234. // Provided Interface Shape (aka Lollipop)
  2235. function LollipopShape()
  2236. {
  2237. mxShape.call(this);
  2238. };
  2239. mxUtils.extend(LollipopShape, mxShape);
  2240. LollipopShape.prototype.size = 10;
  2241. LollipopShape.prototype.paintBackground = function(c, x, y, w, h)
  2242. {
  2243. var sz = parseFloat(mxUtils.getValue(this.style, 'size', this.size));
  2244. c.translate(x, y);
  2245. c.ellipse((w - sz) / 2, 0, sz, sz);
  2246. c.fillAndStroke();
  2247. c.begin();
  2248. c.moveTo(w / 2, sz);
  2249. c.lineTo(w / 2, h);
  2250. c.end();
  2251. c.stroke();
  2252. };
  2253. mxCellRenderer.registerShape('lollipop', LollipopShape);
  2254. // Required Interface Shape
  2255. function RequiresShape()
  2256. {
  2257. mxShape.call(this);
  2258. };
  2259. mxUtils.extend(RequiresShape, mxShape);
  2260. RequiresShape.prototype.size = 10;
  2261. RequiresShape.prototype.inset = 2;
  2262. RequiresShape.prototype.paintBackground = function(c, x, y, w, h)
  2263. {
  2264. var sz = parseFloat(mxUtils.getValue(this.style, 'size', this.size));
  2265. var inset = parseFloat(mxUtils.getValue(this.style, 'inset', this.inset)) + this.strokewidth;
  2266. c.translate(x, y);
  2267. c.begin();
  2268. c.moveTo(w / 2, sz + inset);
  2269. c.lineTo(w / 2, h);
  2270. c.end();
  2271. c.stroke();
  2272. c.begin();
  2273. c.moveTo((w - sz) / 2 - inset, sz / 2);
  2274. c.quadTo((w - sz) / 2 - inset, sz + inset, w / 2, sz + inset);
  2275. c.quadTo((w + sz) / 2 + inset, sz + inset, (w + sz) / 2 + inset, sz / 2);
  2276. c.end();
  2277. c.stroke();
  2278. };
  2279. mxCellRenderer.registerShape('requires', RequiresShape);
  2280. // Required Interface Shape
  2281. function RequiredInterfaceShape()
  2282. {
  2283. mxShape.call(this);
  2284. };
  2285. mxUtils.extend(RequiredInterfaceShape, mxShape);
  2286. RequiredInterfaceShape.prototype.paintBackground = function(c, x, y, w, h)
  2287. {
  2288. c.translate(x, y);
  2289. c.begin();
  2290. c.moveTo(0, 0);
  2291. c.quadTo(w, 0, w, h / 2);
  2292. c.quadTo(w, h, 0, h);
  2293. c.end();
  2294. c.stroke();
  2295. };
  2296. mxCellRenderer.registerShape('requiredInterface', RequiredInterfaceShape);
  2297. // Provided and Required Interface Shape
  2298. function ProvidedRequiredInterfaceShape()
  2299. {
  2300. mxShape.call(this);
  2301. };
  2302. mxUtils.extend(ProvidedRequiredInterfaceShape, mxShape);
  2303. ProvidedRequiredInterfaceShape.prototype.inset = 2;
  2304. ProvidedRequiredInterfaceShape.prototype.paintBackground = function(c, x, y, w, h)
  2305. {
  2306. var inset = parseFloat(mxUtils.getValue(this.style, 'inset', this.inset)) + this.strokewidth;
  2307. c.translate(x, y);
  2308. c.ellipse(0, inset, w - 2 * inset, h - 2 * inset);
  2309. c.fillAndStroke();
  2310. c.begin();
  2311. c.moveTo(w / 2, 0);
  2312. c.quadTo(w, 0, w, h / 2);
  2313. c.quadTo(w, h, w / 2, h);
  2314. c.end();
  2315. c.stroke();
  2316. };
  2317. mxCellRenderer.registerShape('providedRequiredInterface', ProvidedRequiredInterfaceShape);
  2318. // Module shape
  2319. function ModuleShape()
  2320. {
  2321. mxCylinder.call(this);
  2322. };
  2323. mxUtils.extend(ModuleShape, mxCylinder);
  2324. ModuleShape.prototype.jettyWidth = 20;
  2325. ModuleShape.prototype.jettyHeight = 10;
  2326. ModuleShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  2327. {
  2328. var dx = parseFloat(mxUtils.getValue(this.style, 'jettyWidth', this.jettyWidth));
  2329. var dy = parseFloat(mxUtils.getValue(this.style, 'jettyHeight', this.jettyHeight));
  2330. var x0 = dx / 2;
  2331. var x1 = x0 + dx / 2;
  2332. var y0 = Math.min(dy, h - dy);
  2333. var y1 = Math.min(y0 + 2 * dy, h - dy);
  2334. if (isForeground)
  2335. {
  2336. path.moveTo(x0, y0);
  2337. path.lineTo(x1, y0);
  2338. path.lineTo(x1, y0 + dy);
  2339. path.lineTo(x0, y0 + dy);
  2340. path.moveTo(x0, y1);
  2341. path.lineTo(x1, y1);
  2342. path.lineTo(x1, y1 + dy);
  2343. path.lineTo(x0, y1 + dy);
  2344. path.end();
  2345. }
  2346. else
  2347. {
  2348. path.moveTo(x0, 0);
  2349. path.lineTo(w, 0);
  2350. path.lineTo(w, h);
  2351. path.lineTo(x0, h);
  2352. path.lineTo(x0, y1 + dy);
  2353. path.lineTo(0, y1 + dy);
  2354. path.lineTo(0, y1);
  2355. path.lineTo(x0, y1);
  2356. path.lineTo(x0, y0 + dy);
  2357. path.lineTo(0, y0 + dy);
  2358. path.lineTo(0, y0);
  2359. path.lineTo(x0, y0);
  2360. path.close();
  2361. path.end();
  2362. }
  2363. };
  2364. mxCellRenderer.registerShape('module', ModuleShape);
  2365. // Component shape
  2366. function ComponentShape()
  2367. {
  2368. mxCylinder.call(this);
  2369. };
  2370. mxUtils.extend(ComponentShape, mxCylinder);
  2371. ComponentShape.prototype.jettyWidth = 32;
  2372. ComponentShape.prototype.jettyHeight = 12;
  2373. ComponentShape.prototype.redrawPath = function(path, x, y, w, h, isForeground)
  2374. {
  2375. var dx = parseFloat(mxUtils.getValue(this.style, 'jettyWidth', this.jettyWidth));
  2376. var dy = parseFloat(mxUtils.getValue(this.style, 'jettyHeight', this.jettyHeight));
  2377. var x0 = dx / 2;
  2378. var x1 = x0 + dx / 2;
  2379. var y0 = 0.3 * h - dy / 2;
  2380. var y1 = 0.7 * h - dy / 2;
  2381. if (isForeground)
  2382. {
  2383. path.moveTo(x0, y0);
  2384. path.lineTo(x1, y0);
  2385. path.lineTo(x1, y0 + dy);
  2386. path.lineTo(x0, y0 + dy);
  2387. path.moveTo(x0, y1);
  2388. path.lineTo(x1, y1);
  2389. path.lineTo(x1, y1 + dy);
  2390. path.lineTo(x0, y1 + dy);
  2391. path.end();
  2392. }
  2393. else
  2394. {
  2395. path.moveTo(x0, 0);
  2396. path.lineTo(w, 0);
  2397. path.lineTo(w, h);
  2398. path.lineTo(x0, h);
  2399. path.lineTo(x0, y1 + dy);
  2400. path.lineTo(0, y1 + dy);
  2401. path.lineTo(0, y1);
  2402. path.lineTo(x0, y1);
  2403. path.lineTo(x0, y0 + dy);
  2404. path.lineTo(0, y0 + dy);
  2405. path.lineTo(0, y0);
  2406. path.lineTo(x0, y0);
  2407. path.close();
  2408. path.end();
  2409. }
  2410. };
  2411. mxCellRenderer.registerShape('component', ComponentShape);
  2412. // Associative entity derived from rectangle shape
  2413. function AssociativeEntity()
  2414. {
  2415. mxRectangleShape.call(this);
  2416. };
  2417. mxUtils.extend(AssociativeEntity, mxRectangleShape);
  2418. AssociativeEntity.prototype.paintForeground = function(c, x, y, w, h)
  2419. {
  2420. var hw = w / 2;
  2421. var hh = h / 2;
  2422. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2423. c.begin();
  2424. this.addPoints(c, [new mxPoint(x + hw, y), new mxPoint(x + w, y + hh), new mxPoint(x + hw, y + h),
  2425. new mxPoint(x, y + hh)], this.isRounded, arcSize, true);
  2426. c.stroke();
  2427. mxRectangleShape.prototype.paintForeground.apply(this, arguments);
  2428. };
  2429. mxCellRenderer.registerShape('associativeEntity', AssociativeEntity);
  2430. // State Shapes derives from double ellipse
  2431. function StateShape()
  2432. {
  2433. mxDoubleEllipse.call(this);
  2434. };
  2435. mxUtils.extend(StateShape, mxDoubleEllipse);
  2436. StateShape.prototype.outerStroke = true;
  2437. StateShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2438. {
  2439. var inset = Math.min(4, Math.min(w / 5, h / 5));
  2440. if (w > 0 && h > 0)
  2441. {
  2442. c.ellipse(x + inset, y + inset, w - 2 * inset, h - 2 * inset);
  2443. c.fillAndStroke();
  2444. }
  2445. c.setShadow(false);
  2446. if (this.outerStroke)
  2447. {
  2448. c.ellipse(x, y, w, h);
  2449. c.stroke();
  2450. }
  2451. };
  2452. mxCellRenderer.registerShape('endState', StateShape);
  2453. function StartStateShape()
  2454. {
  2455. StateShape.call(this);
  2456. };
  2457. mxUtils.extend(StartStateShape, StateShape);
  2458. StartStateShape.prototype.outerStroke = false;
  2459. mxCellRenderer.registerShape('startState', StartStateShape);
  2460. // Link shape
  2461. function LinkShape()
  2462. {
  2463. mxArrowConnector.call(this);
  2464. this.spacing = 0;
  2465. };
  2466. mxUtils.extend(LinkShape, mxArrowConnector);
  2467. LinkShape.prototype.defaultWidth = 4;
  2468. LinkShape.prototype.isOpenEnded = function()
  2469. {
  2470. return true;
  2471. };
  2472. LinkShape.prototype.getEdgeWidth = function()
  2473. {
  2474. return mxUtils.getNumber(this.style, 'width', this.defaultWidth) + Math.max(0, this.strokewidth - 1);
  2475. };
  2476. LinkShape.prototype.isArrowRounded = function()
  2477. {
  2478. return this.isRounded;
  2479. };
  2480. // Registers the link shape
  2481. mxCellRenderer.registerShape('link', LinkShape);
  2482. // Generic arrow
  2483. function FlexArrowShape()
  2484. {
  2485. mxArrowConnector.call(this);
  2486. this.spacing = 0;
  2487. };
  2488. mxUtils.extend(FlexArrowShape, mxArrowConnector);
  2489. FlexArrowShape.prototype.defaultWidth = 10;
  2490. FlexArrowShape.prototype.defaultArrowWidth = 20;
  2491. FlexArrowShape.prototype.getStartArrowWidth = function()
  2492. {
  2493. return this.getEdgeWidth() + mxUtils.getNumber(this.style, 'startWidth', this.defaultArrowWidth);
  2494. };
  2495. FlexArrowShape.prototype.getEndArrowWidth = function()
  2496. {
  2497. return this.getEdgeWidth() + mxUtils.getNumber(this.style, 'endWidth', this.defaultArrowWidth);;
  2498. };
  2499. FlexArrowShape.prototype.getEdgeWidth = function()
  2500. {
  2501. return mxUtils.getNumber(this.style, 'width', this.defaultWidth) + Math.max(0, this.strokewidth - 1);
  2502. };
  2503. // Registers the link shape
  2504. mxCellRenderer.registerShape('flexArrow', FlexArrowShape);
  2505. // Manual Input shape
  2506. function ManualInputShape()
  2507. {
  2508. mxActor.call(this);
  2509. };
  2510. mxUtils.extend(ManualInputShape, mxActor);
  2511. ManualInputShape.prototype.size = 30;
  2512. ManualInputShape.prototype.isRoundable = function()
  2513. {
  2514. return true;
  2515. };
  2516. ManualInputShape.prototype.redrawPath = function(c, x, y, w, h)
  2517. {
  2518. var s = Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)));
  2519. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2520. this.addPoints(c, [new mxPoint(0, h), new mxPoint(0, s), new mxPoint(w, 0), new mxPoint(w, h)],
  2521. this.isRounded, arcSize, true);
  2522. c.end();
  2523. };
  2524. mxCellRenderer.registerShape('manualInput', ManualInputShape);
  2525. // Internal storage
  2526. function InternalStorageShape()
  2527. {
  2528. mxRectangleShape.call(this);
  2529. };
  2530. mxUtils.extend(InternalStorageShape, mxRectangleShape);
  2531. InternalStorageShape.prototype.dx = 20;
  2532. InternalStorageShape.prototype.dy = 20;
  2533. InternalStorageShape.prototype.isHtmlAllowed = function()
  2534. {
  2535. return false;
  2536. };
  2537. InternalStorageShape.prototype.paintForeground = function(c, x, y, w, h)
  2538. {
  2539. mxRectangleShape.prototype.paintForeground.apply(this, arguments);
  2540. var inset = 0;
  2541. if (this.isRounded)
  2542. {
  2543. var f = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE,
  2544. mxConstants.RECTANGLE_ROUNDING_FACTOR * 100) / 100;
  2545. inset = Math.max(inset, Math.min(w * f, h * f));
  2546. }
  2547. var dx = Math.max(inset, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  2548. var dy = Math.max(inset, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  2549. c.begin();
  2550. c.moveTo(x, y + dy);
  2551. c.lineTo(x + w, y + dy);
  2552. c.end();
  2553. c.stroke();
  2554. c.begin();
  2555. c.moveTo(x + dx, y);
  2556. c.lineTo(x + dx, y + h);
  2557. c.end();
  2558. c.stroke();
  2559. };
  2560. mxCellRenderer.registerShape('internalStorage', InternalStorageShape);
  2561. // Internal storage
  2562. function CornerShape()
  2563. {
  2564. mxActor.call(this);
  2565. };
  2566. mxUtils.extend(CornerShape, mxActor);
  2567. CornerShape.prototype.dx = 20;
  2568. CornerShape.prototype.dy = 20;
  2569. // Corner
  2570. CornerShape.prototype.redrawPath = function(c, x, y, w, h)
  2571. {
  2572. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  2573. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  2574. var s = Math.min(w / 2, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  2575. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2576. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w, 0), new mxPoint(w, dy), new mxPoint(dx, dy),
  2577. new mxPoint(dx, h), new mxPoint(0, h)], this.isRounded, arcSize, true);
  2578. c.end();
  2579. };
  2580. mxCellRenderer.registerShape('corner', CornerShape);
  2581. // Crossbar shape
  2582. function CrossbarShape()
  2583. {
  2584. mxActor.call(this);
  2585. };
  2586. mxUtils.extend(CrossbarShape, mxActor);
  2587. CrossbarShape.prototype.redrawPath = function(c, x, y, w, h)
  2588. {
  2589. c.moveTo(0, 0);
  2590. c.lineTo(0, h);
  2591. c.end();
  2592. c.moveTo(w, 0);
  2593. c.lineTo(w, h);
  2594. c.end();
  2595. c.moveTo(0, h / 2);
  2596. c.lineTo(w, h / 2);
  2597. c.end();
  2598. };
  2599. mxCellRenderer.registerShape('crossbar', CrossbarShape);
  2600. // Internal storage
  2601. function TeeShape()
  2602. {
  2603. mxActor.call(this);
  2604. };
  2605. mxUtils.extend(TeeShape, mxActor);
  2606. TeeShape.prototype.dx = 20;
  2607. TeeShape.prototype.dy = 20;
  2608. // Corner
  2609. TeeShape.prototype.redrawPath = function(c, x, y, w, h)
  2610. {
  2611. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  2612. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  2613. var w2 = Math.abs(w - dx) / 2;
  2614. var s = Math.min(w / 2, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  2615. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2616. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w, 0), new mxPoint(w, dy), new mxPoint((w + dx) / 2, dy),
  2617. new mxPoint((w + dx) / 2, h), new mxPoint((w - dx) / 2, h), new mxPoint((w - dx) / 2, dy),
  2618. new mxPoint(0, dy)], this.isRounded, arcSize, true);
  2619. c.end();
  2620. };
  2621. mxCellRenderer.registerShape('tee', TeeShape);
  2622. // Arrow
  2623. function SingleArrowShape()
  2624. {
  2625. mxActor.call(this);
  2626. };
  2627. mxUtils.extend(SingleArrowShape, mxActor);
  2628. SingleArrowShape.prototype.arrowWidth = 0.3;
  2629. SingleArrowShape.prototype.arrowSize = 0.2;
  2630. SingleArrowShape.prototype.redrawPath = function(c, x, y, w, h)
  2631. {
  2632. var aw = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowWidth', this.arrowWidth))));
  2633. var as = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowSize', this.arrowSize))));
  2634. var at = (h - aw) / 2;
  2635. var ab = at + aw;
  2636. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2637. this.addPoints(c, [new mxPoint(0, at), new mxPoint(w - as, at), new mxPoint(w - as, 0), new mxPoint(w, h / 2),
  2638. new mxPoint(w - as, h), new mxPoint(w - as, ab), new mxPoint(0, ab)],
  2639. this.isRounded, arcSize, true);
  2640. c.end();
  2641. };
  2642. mxCellRenderer.registerShape('singleArrow', SingleArrowShape);
  2643. // Arrow
  2644. function DoubleArrowShape()
  2645. {
  2646. mxActor.call(this);
  2647. };
  2648. mxUtils.extend(DoubleArrowShape, mxActor);
  2649. DoubleArrowShape.prototype.redrawPath = function(c, x, y, w, h)
  2650. {
  2651. var aw = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowWidth', SingleArrowShape.prototype.arrowWidth))));
  2652. var as = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowSize', SingleArrowShape.prototype.arrowSize))));
  2653. var at = (h - aw) / 2;
  2654. var ab = at + aw;
  2655. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2656. this.addPoints(c, [new mxPoint(0, h / 2), new mxPoint(as, 0), new mxPoint(as, at), new mxPoint(w - as, at),
  2657. new mxPoint(w - as, 0), new mxPoint(w, h / 2), new mxPoint(w - as, h),
  2658. new mxPoint(w - as, ab), new mxPoint(as, ab), new mxPoint(as, h)],
  2659. this.isRounded, arcSize, true);
  2660. c.end();
  2661. };
  2662. mxCellRenderer.registerShape('doubleArrow', DoubleArrowShape);
  2663. // Data storage
  2664. function DataStorageShape()
  2665. {
  2666. mxActor.call(this);
  2667. };
  2668. mxUtils.extend(DataStorageShape, mxActor);
  2669. DataStorageShape.prototype.size = 0.1;
  2670. DataStorageShape.prototype.fixedSize = 20;
  2671. DataStorageShape.prototype.redrawPath = function(c, x, y, w, h)
  2672. {
  2673. var fixed = mxUtils.getValue(this.style, 'fixedSize', '0') != '0';
  2674. var s = (fixed) ? Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'size', this.fixedSize)))) :
  2675. w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  2676. c.moveTo(s, 0);
  2677. c.lineTo(w, 0);
  2678. c.quadTo(w - s * 2, h / 2, w, h);
  2679. c.lineTo(s, h);
  2680. c.quadTo(s - s * 2, h / 2, s, 0);
  2681. c.close();
  2682. c.end();
  2683. };
  2684. mxCellRenderer.registerShape('dataStorage', DataStorageShape);
  2685. // Or
  2686. function OrShape()
  2687. {
  2688. mxActor.call(this);
  2689. };
  2690. mxUtils.extend(OrShape, mxActor);
  2691. OrShape.prototype.redrawPath = function(c, x, y, w, h)
  2692. {
  2693. c.moveTo(0, 0);
  2694. c.quadTo(w, 0, w, h / 2);
  2695. c.quadTo(w, h, 0, h);
  2696. c.close();
  2697. c.end();
  2698. };
  2699. mxCellRenderer.registerShape('or', OrShape);
  2700. // Xor
  2701. function XorShape()
  2702. {
  2703. mxActor.call(this);
  2704. };
  2705. mxUtils.extend(XorShape, mxActor);
  2706. XorShape.prototype.redrawPath = function(c, x, y, w, h)
  2707. {
  2708. c.moveTo(0, 0);
  2709. c.quadTo(w, 0, w, h / 2);
  2710. c.quadTo(w, h, 0, h);
  2711. c.quadTo(w / 2, h / 2, 0, 0);
  2712. c.close();
  2713. c.end();
  2714. };
  2715. mxCellRenderer.registerShape('xor', XorShape);
  2716. // Loop limit
  2717. function LoopLimitShape()
  2718. {
  2719. mxActor.call(this);
  2720. };
  2721. mxUtils.extend(LoopLimitShape, mxActor);
  2722. LoopLimitShape.prototype.size = 20;
  2723. LoopLimitShape.prototype.isRoundable = function()
  2724. {
  2725. return true;
  2726. };
  2727. LoopLimitShape.prototype.redrawPath = function(c, x, y, w, h)
  2728. {
  2729. var s = Math.min(w / 2, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  2730. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2731. this.addPoints(c, [new mxPoint(s, 0), new mxPoint(w - s, 0), new mxPoint(w, s * 0.8), new mxPoint(w, h),
  2732. new mxPoint(0, h), new mxPoint(0, s * 0.8)], this.isRounded, arcSize, true);
  2733. c.end();
  2734. };
  2735. mxCellRenderer.registerShape('loopLimit', LoopLimitShape);
  2736. // Off page connector
  2737. function OffPageConnectorShape()
  2738. {
  2739. mxActor.call(this);
  2740. };
  2741. mxUtils.extend(OffPageConnectorShape, mxActor);
  2742. OffPageConnectorShape.prototype.size = 3 / 8;
  2743. OffPageConnectorShape.prototype.isRoundable = function()
  2744. {
  2745. return true;
  2746. };
  2747. OffPageConnectorShape.prototype.redrawPath = function(c, x, y, w, h)
  2748. {
  2749. var s = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  2750. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  2751. this.addPoints(c, [new mxPoint(0, 0), new mxPoint(w, 0), new mxPoint(w, h - s), new mxPoint(w / 2, h),
  2752. new mxPoint(0, h - s)], this.isRounded, arcSize, true);
  2753. c.end();
  2754. };
  2755. mxCellRenderer.registerShape('offPageConnector', OffPageConnectorShape);
  2756. // Internal storage
  2757. function TapeDataShape()
  2758. {
  2759. mxEllipse.call(this);
  2760. };
  2761. mxUtils.extend(TapeDataShape, mxEllipse);
  2762. TapeDataShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2763. {
  2764. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  2765. c.begin();
  2766. c.moveTo(x + w / 2, y + h);
  2767. c.lineTo(x + w, y + h);
  2768. c.end();
  2769. c.stroke();
  2770. };
  2771. mxCellRenderer.registerShape('tapeData', TapeDataShape);
  2772. // OrEllipseShape
  2773. function OrEllipseShape()
  2774. {
  2775. mxEllipse.call(this);
  2776. };
  2777. mxUtils.extend(OrEllipseShape, mxEllipse);
  2778. OrEllipseShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2779. {
  2780. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  2781. c.setShadow(false);
  2782. c.begin();
  2783. c.moveTo(x, y + h / 2);
  2784. c.lineTo(x + w, y + h / 2);
  2785. c.end();
  2786. c.stroke();
  2787. c.begin();
  2788. c.moveTo(x + w / 2, y);
  2789. c.lineTo(x + w / 2, y + h);
  2790. c.end();
  2791. c.stroke();
  2792. };
  2793. mxCellRenderer.registerShape('orEllipse', OrEllipseShape);
  2794. // SumEllipseShape
  2795. function SumEllipseShape()
  2796. {
  2797. mxEllipse.call(this);
  2798. };
  2799. mxUtils.extend(SumEllipseShape, mxEllipse);
  2800. SumEllipseShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2801. {
  2802. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  2803. var s2 = 0.145;
  2804. c.setShadow(false);
  2805. c.begin();
  2806. c.moveTo(x + w * s2, y + h * s2);
  2807. c.lineTo(x + w * (1 - s2), y + h * (1 - s2));
  2808. c.end();
  2809. c.stroke();
  2810. c.begin();
  2811. c.moveTo(x + w * (1 - s2), y + h * s2);
  2812. c.lineTo(x + w * s2, y + h * (1 - s2));
  2813. c.end();
  2814. c.stroke();
  2815. };
  2816. mxCellRenderer.registerShape('sumEllipse', SumEllipseShape);
  2817. // SortShape
  2818. function SortShape()
  2819. {
  2820. mxRhombus.call(this);
  2821. };
  2822. mxUtils.extend(SortShape, mxRhombus);
  2823. SortShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2824. {
  2825. mxRhombus.prototype.paintVertexShape.apply(this, arguments);
  2826. c.setShadow(false);
  2827. c.begin();
  2828. c.moveTo(x, y + h / 2);
  2829. c.lineTo(x + w, y + h / 2);
  2830. c.end();
  2831. c.stroke();
  2832. };
  2833. mxCellRenderer.registerShape('sortShape', SortShape);
  2834. // CollateShape
  2835. function CollateShape()
  2836. {
  2837. mxEllipse.call(this);
  2838. };
  2839. mxUtils.extend(CollateShape, mxEllipse);
  2840. CollateShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2841. {
  2842. c.begin();
  2843. c.moveTo(x, y);
  2844. c.lineTo(x + w, y);
  2845. c.lineTo(x + w / 2, y + h / 2);
  2846. c.close();
  2847. c.fillAndStroke();
  2848. c.begin();
  2849. c.moveTo(x, y + h);
  2850. c.lineTo(x + w, y + h);
  2851. c.lineTo(x + w / 2, y + h / 2);
  2852. c.close();
  2853. c.fillAndStroke();
  2854. };
  2855. mxCellRenderer.registerShape('collate', CollateShape);
  2856. // DimensionShape
  2857. function DimensionShape()
  2858. {
  2859. mxEllipse.call(this);
  2860. };
  2861. mxUtils.extend(DimensionShape, mxEllipse);
  2862. DimensionShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2863. {
  2864. // Arrow size
  2865. var al = 10;
  2866. var cy = y + h - al / 2;
  2867. c.begin();
  2868. c.moveTo(x, y);
  2869. c.lineTo(x, y + h);
  2870. c.moveTo(x, cy);
  2871. c.lineTo(x + al, cy - al / 2);
  2872. c.moveTo(x, cy);
  2873. c.lineTo(x + al, cy + al / 2);
  2874. c.moveTo(x, cy);
  2875. c.lineTo(x + w, cy);
  2876. // Opposite side
  2877. c.moveTo(x + w, y);
  2878. c.lineTo(x + w, y + h);
  2879. c.moveTo(x + w, cy);
  2880. c.lineTo(x + w - al, cy - al / 2);
  2881. c.moveTo(x + w, cy);
  2882. c.lineTo(x + w - al, cy + al / 2);
  2883. c.end();
  2884. c.stroke();
  2885. };
  2886. mxCellRenderer.registerShape('dimension', DimensionShape);
  2887. // PartialRectangleShape
  2888. function PartialRectangleShape()
  2889. {
  2890. mxEllipse.call(this);
  2891. };
  2892. mxUtils.extend(PartialRectangleShape, mxEllipse);
  2893. PartialRectangleShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2894. {
  2895. if (!this.outline)
  2896. {
  2897. c.setStrokeColor(null);
  2898. }
  2899. if (this.style != null)
  2900. {
  2901. var pointerEvents = c.pointerEvents;
  2902. var events = mxUtils.getValue(this.style, mxConstants.STYLE_POINTER_EVENTS, '1') == '1';
  2903. if (!events && (this.fill == null || this.fill == mxConstants.NONE))
  2904. {
  2905. c.pointerEvents = false;
  2906. }
  2907. c.rect(x, y, w, h);
  2908. c.fill();
  2909. c.pointerEvents = pointerEvents;
  2910. c.setStrokeColor(this.stroke);
  2911. c.begin();
  2912. c.moveTo(x, y);
  2913. if (this.outline || mxUtils.getValue(this.style, 'top', '1') == '1')
  2914. {
  2915. c.lineTo(x + w, y);
  2916. }
  2917. else
  2918. {
  2919. c.moveTo(x + w, y);
  2920. }
  2921. if (this.outline || mxUtils.getValue(this.style, 'right', '1') == '1')
  2922. {
  2923. c.lineTo(x + w, y + h);
  2924. }
  2925. else
  2926. {
  2927. c.moveTo(x + w, y + h);
  2928. }
  2929. if (this.outline || mxUtils.getValue(this.style, 'bottom', '1') == '1')
  2930. {
  2931. c.lineTo(x, y + h);
  2932. }
  2933. else
  2934. {
  2935. c.moveTo(x, y + h);
  2936. }
  2937. if (this.outline || mxUtils.getValue(this.style, 'left', '1') == '1')
  2938. {
  2939. c.lineTo(x, y);
  2940. }
  2941. c.end();
  2942. c.stroke();
  2943. }
  2944. };
  2945. mxCellRenderer.registerShape('partialRectangle', PartialRectangleShape);
  2946. // LineEllipseShape
  2947. function LineEllipseShape()
  2948. {
  2949. mxEllipse.call(this);
  2950. };
  2951. mxUtils.extend(LineEllipseShape, mxEllipse);
  2952. LineEllipseShape.prototype.paintVertexShape = function(c, x, y, w, h)
  2953. {
  2954. mxEllipse.prototype.paintVertexShape.apply(this, arguments);
  2955. c.setShadow(false);
  2956. c.begin();
  2957. if (mxUtils.getValue(this.style, 'line') == 'vertical')
  2958. {
  2959. c.moveTo(x + w / 2, y);
  2960. c.lineTo(x + w / 2, y + h);
  2961. }
  2962. else
  2963. {
  2964. c.moveTo(x, y + h / 2);
  2965. c.lineTo(x + w, y + h / 2);
  2966. }
  2967. c.end();
  2968. c.stroke();
  2969. };
  2970. mxCellRenderer.registerShape('lineEllipse', LineEllipseShape);
  2971. // Delay
  2972. function DelayShape()
  2973. {
  2974. mxActor.call(this);
  2975. };
  2976. mxUtils.extend(DelayShape, mxActor);
  2977. DelayShape.prototype.redrawPath = function(c, x, y, w, h)
  2978. {
  2979. var dx = Math.min(w, h / 2);
  2980. c.moveTo(0, 0);
  2981. c.lineTo(w - dx, 0);
  2982. c.quadTo(w, 0, w, h / 2);
  2983. c.quadTo(w, h, w - dx, h);
  2984. c.lineTo(0, h);
  2985. c.close();
  2986. c.end();
  2987. };
  2988. mxCellRenderer.registerShape('delay', DelayShape);
  2989. // Cross Shape
  2990. function CrossShape()
  2991. {
  2992. mxActor.call(this);
  2993. };
  2994. mxUtils.extend(CrossShape, mxActor);
  2995. CrossShape.prototype.size = 0.2;
  2996. CrossShape.prototype.redrawPath = function(c, x, y, w, h)
  2997. {
  2998. var m = Math.min(h, w);
  2999. var size = Math.max(0, Math.min(m, m * parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  3000. var t = (h - size) / 2;
  3001. var b = t + size;
  3002. var l = (w - size) / 2;
  3003. var r = l + size;
  3004. c.moveTo(0, t);
  3005. c.lineTo(l, t);
  3006. c.lineTo(l, 0);
  3007. c.lineTo(r, 0);
  3008. c.lineTo(r, t);
  3009. c.lineTo(w, t);
  3010. c.lineTo(w, b);
  3011. c.lineTo(r, b);
  3012. c.lineTo(r, h);
  3013. c.lineTo(l, h);
  3014. c.lineTo(l, b);
  3015. c.lineTo(0, b);
  3016. c.close();
  3017. c.end();
  3018. };
  3019. mxCellRenderer.registerShape('cross', CrossShape);
  3020. // Display
  3021. function DisplayShape()
  3022. {
  3023. mxActor.call(this);
  3024. };
  3025. mxUtils.extend(DisplayShape, mxActor);
  3026. DisplayShape.prototype.size = 0.25;
  3027. DisplayShape.prototype.redrawPath = function(c, x, y, w, h)
  3028. {
  3029. var dx = Math.min(w, h / 2);
  3030. var s = Math.min(w - dx, Math.max(0, parseFloat(mxUtils.getValue(this.style, 'size', this.size))) * w);
  3031. c.moveTo(0, h / 2);
  3032. c.lineTo(s, 0);
  3033. c.lineTo(w - dx, 0);
  3034. c.quadTo(w, 0, w, h / 2);
  3035. c.quadTo(w, h, w - dx, h);
  3036. c.lineTo(s, h);
  3037. c.close();
  3038. c.end();
  3039. };
  3040. mxCellRenderer.registerShape('display', DisplayShape);
  3041. //**********************************************************************************************************************************************************
  3042. //Rectangle v2
  3043. //**********************************************************************************************************************************************************
  3044. /**
  3045. * Extends mxShape.
  3046. */
  3047. function mxShapeBasicRect2(bounds, fill, stroke, strokewidth)
  3048. {
  3049. mxShape.call(this);
  3050. this.bounds = bounds;
  3051. this.fill = fill;
  3052. this.stroke = stroke;
  3053. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  3054. this.rectStyle = 'square';
  3055. this.size = 10;
  3056. this.absoluteCornerSize = true;
  3057. this.indent = 2;
  3058. this.rectOutline = 'single';
  3059. };
  3060. /**
  3061. * Extends mxShape.
  3062. */
  3063. mxUtils.extend(mxShapeBasicRect2, mxActor);
  3064. mxShapeBasicRect2.prototype.cst = {RECT2 : 'mxgraph.basic.rect'};
  3065. mxShapeBasicRect2.prototype.customProperties = [
  3066. {name: 'rectStyle', dispName: 'Style', type: 'enum', defVal:'square',
  3067. enumList:[
  3068. {val:'square', dispName:'Square'},
  3069. {val:'rounded', dispName:'Round'},
  3070. {val:'snip', dispName:'Snip'},
  3071. {val:'invRound', dispName:'Inv. Round'},
  3072. {val:'fold', dispName:'Fold'}
  3073. ]},
  3074. {name: 'size', dispName: 'Corner Size', type: 'float', defVal:10},
  3075. {name: 'absoluteCornerSize', dispName: 'Abs. Corner Size', type: 'bool', defVal:true},
  3076. {name: 'indent', dispName:'Indent', type:'float', defVal:2},
  3077. {name: 'rectOutline', dispName: 'Outline', type: 'enum', defVal:'single',
  3078. enumList:[
  3079. {val:'single', dispName:'Single'},
  3080. {val:'double', dispName:'Double'},
  3081. {val:'frame', dispName:'Frame'}
  3082. ]},
  3083. {name: 'fillColor2', dispName:'Inside Fill Color', type:'color', defVal:'none'},
  3084. {name: 'gradientColor2', dispName:'Inside Gradient Color', type:'color', defVal:'none'},
  3085. {name: 'gradientDirection2', dispName: 'Inside Gradient Direction', type: 'enum', defVal:'south',
  3086. enumList:[
  3087. {val:'south', dispName:'South'},
  3088. {val:'west', dispName:'West'},
  3089. {val:'north', dispName:'North'},
  3090. {val:'east', dispName:'East'}
  3091. ]},
  3092. {name: 'top', dispName:'Top Line', type:'bool', defVal:true},
  3093. {name: 'right', dispName:'Right', type:'bool', defVal:true},
  3094. {name: 'bottom', dispName:'Bottom Line', type:'bool', defVal:true},
  3095. {name: 'left', dispName:'Left ', type:'bool', defVal:true},
  3096. {name: 'topLeftStyle', dispName: 'Top Left Style', type: 'enum', defVal:'default',
  3097. enumList:[
  3098. {val:'default', dispName:'Default'},
  3099. {val:'square', dispName:'Square'},
  3100. {val:'rounded', dispName:'Round'},
  3101. {val:'snip', dispName:'Snip'},
  3102. {val:'invRound', dispName:'Inv. Round'},
  3103. {val:'fold', dispName:'Fold'}
  3104. ]},
  3105. {name: 'topRightStyle', dispName: 'Top Right Style', type: 'enum', defVal:'default',
  3106. enumList:[
  3107. {val:'default', dispName:'Default'},
  3108. {val:'square', dispName:'Square'},
  3109. {val:'rounded', dispName:'Round'},
  3110. {val:'snip', dispName:'Snip'},
  3111. {val:'invRound', dispName:'Inv. Round'},
  3112. {val:'fold', dispName:'Fold'}
  3113. ]},
  3114. {name: 'bottomRightStyle', dispName: 'Bottom Right Style', type: 'enum', defVal:'default',
  3115. enumList:[
  3116. {val:'default', dispName:'Default'},
  3117. {val:'square', dispName:'Square'},
  3118. {val:'rounded', dispName:'Round'},
  3119. {val:'snip', dispName:'Snip'},
  3120. {val:'invRound', dispName:'Inv. Round'},
  3121. {val:'fold', dispName:'Fold'}
  3122. ]},
  3123. {name: 'bottomLeftStyle', dispName: 'Bottom Left Style', type: 'enum', defVal:'default',
  3124. enumList:[
  3125. {val:'default', dispName:'Default'},
  3126. {val:'square', dispName:'Square'},
  3127. {val:'rounded', dispName:'Round'},
  3128. {val:'snip', dispName:'Snip'},
  3129. {val:'invRound', dispName:'Inv. Round'},
  3130. {val:'fold', dispName:'Fold'}
  3131. ]},
  3132. ];
  3133. /**
  3134. * Function: paintVertexShape
  3135. *
  3136. * Paints the vertex shape.
  3137. */
  3138. mxShapeBasicRect2.prototype.paintVertexShape = function(c, x, y, w, h)
  3139. {
  3140. c.translate(x, y);
  3141. this.strictDrawShape(c, 0, 0, w, h);
  3142. }
  3143. //
  3144. mxShapeBasicRect2.prototype.strictDrawShape = function(c, x, y, w, h, os)
  3145. {
  3146. // read styles or optionally override them externally via "os" variable
  3147. var rectStyle = (os && os.rectStyle) ? os.rectStyle : mxUtils.getValue(this.style, 'rectStyle', this.rectStyle);
  3148. var absoluteCornerSize = (os && os.absoluteCornerSize) ? os.absoluteCornerSize : mxUtils.getValue(this.style, 'absoluteCornerSize', this.absoluteCornerSize);
  3149. var size = (os && os.size) ? os.size : Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  3150. var rectOutline = (os && os.rectOutline) ? os.rectOutline : mxUtils.getValue(this.style, 'rectOutline', this.rectOutline);
  3151. var indent = (os && os.indent) ? os.indent : Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'indent', this.indent))));
  3152. var dashed = (os && os.dashed) ? os.dashed : mxUtils.getValue(this.style, 'dashed', false);
  3153. var dashPattern = (os && os.dashPattern) ? os.dashPattern : mxUtils.getValue(this.style, 'dashPattern', null);
  3154. var relIndent = (os && os.relIndent) ? os.relIndent : Math.max(0, Math.min(50, indent));
  3155. var top = (os && os.top) ? os.top : mxUtils.getValue(this.style, 'top', true);
  3156. var right = (os && os.right) ? os.right : mxUtils.getValue(this.style, 'right', true);
  3157. var bottom = (os && os.bottom) ? os.bottom : mxUtils.getValue(this.style, 'bottom', true);
  3158. var left = (os && os.left) ? os.left : mxUtils.getValue(this.style, 'left', true);
  3159. var topLeftStyle = (os && os.topLeftStyle) ? os.topLeftStyle : mxUtils.getValue(this.style, 'topLeftStyle', 'default');
  3160. var topRightStyle = (os && os.topRightStyle) ? os.topRightStyle : mxUtils.getValue(this.style, 'topRightStyle', 'default');
  3161. var bottomRightStyle = (os && os.bottomRightStyle) ? os.bottomRightStyle : mxUtils.getValue(this.style, 'bottomRightStyle', 'default');
  3162. var bottomLeftStyle = (os && os.bottomLeftStyle) ? os.bottomLeftStyle : mxUtils.getValue(this.style, 'bottomLeftStyle', 'default');
  3163. var fillColor = (os && os.fillColor) ? os.fillColor : mxUtils.getValue(this.style, 'fillColor', '#ffffff');
  3164. var strokeColor = (os && os.strokeColor) ? os.strokeColor : mxUtils.getValue(this.style, 'strokeColor', '#000000');
  3165. var strokeWidth = (os && os.strokeWidth) ? os.strokeWidth : mxUtils.getValue(this.style, 'strokeWidth', '1');
  3166. var fillColor2 = (os && os.fillColor2) ? os.fillColor2 : mxUtils.getValue(this.style, 'fillColor2', 'none');
  3167. var gradientColor2 = (os && os.gradientColor2) ? os.gradientColor2 : mxUtils.getValue(this.style, 'gradientColor2', 'none');
  3168. var gdir2 = (os && os.gradientDirection2) ? os.gradientDirection2 : mxUtils.getValue(this.style, 'gradientDirection2', 'south');
  3169. var opacity = (os && os.opacity) ? os.opacity : mxUtils.getValue(this.style, 'opacity', '100');
  3170. var relSize = Math.max(0, Math.min(50, size));
  3171. var sc = mxShapeBasicRect2.prototype;
  3172. c.setDashed(dashed);
  3173. if (dashPattern && dashPattern != '')
  3174. {
  3175. c.setDashPattern(dashPattern);
  3176. }
  3177. c.setStrokeWidth(strokeWidth);
  3178. size = Math.min(h * 0.5, w * 0.5, size);
  3179. if (!absoluteCornerSize)
  3180. {
  3181. size = relSize * Math.min(w, h) / 100;
  3182. }
  3183. size = Math.min(size, Math.min(w, h) * 0.5);
  3184. if (!absoluteCornerSize)
  3185. {
  3186. indent = Math.min(relIndent * Math.min(w, h) / 100);
  3187. }
  3188. indent = Math.min(indent, Math.min(w, h) * 0.5 - size);
  3189. if ((top || right || bottom || left) && rectOutline != 'frame')
  3190. {
  3191. //outline fill
  3192. c.begin();
  3193. if (!top)
  3194. {
  3195. c.moveTo(0,0);
  3196. }
  3197. else
  3198. {
  3199. sc.moveNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3200. }
  3201. if (top)
  3202. {
  3203. sc.paintNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3204. }
  3205. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3206. if (right)
  3207. {
  3208. sc.paintNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3209. }
  3210. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3211. if (bottom)
  3212. {
  3213. sc.paintSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3214. }
  3215. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3216. if (left)
  3217. {
  3218. sc.paintSW(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom);
  3219. }
  3220. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3221. c.close();
  3222. c.fill();
  3223. c.setShadow(false);
  3224. //inner fill
  3225. c.setFillColor(fillColor2);
  3226. var op1 = opacity;
  3227. var op2 = opacity;
  3228. if (fillColor2 == 'none')
  3229. {
  3230. op1 = 0;
  3231. }
  3232. if (gradientColor2 == 'none')
  3233. {
  3234. op2 = 0;
  3235. }
  3236. c.setGradient(fillColor2, gradientColor2, 0, 0, w, h, gdir2, op1, op2);
  3237. c.begin();
  3238. if (!top)
  3239. {
  3240. c.moveTo(indent,0);
  3241. }
  3242. else
  3243. {
  3244. sc.moveNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, top, left);
  3245. }
  3246. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3247. if (left && bottom)
  3248. {
  3249. sc.paintSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom);
  3250. }
  3251. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3252. if (bottom && right)
  3253. {
  3254. sc.paintSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent);
  3255. }
  3256. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3257. if (right && top)
  3258. {
  3259. sc.paintNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent);
  3260. }
  3261. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3262. if (top && left)
  3263. {
  3264. sc.paintNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent);
  3265. }
  3266. c.fill();
  3267. if (fillColor == 'none')
  3268. {
  3269. c.begin();
  3270. sc.paintFolds(c, x, y, w, h, rectStyle, topLeftStyle, topRightStyle, bottomRightStyle, bottomLeftStyle, size, top, right, bottom, left);
  3271. c.stroke();
  3272. }
  3273. }
  3274. //draw all the combinations
  3275. if (!top && !right && !bottom && left)
  3276. {
  3277. if (rectOutline != 'frame')
  3278. {
  3279. c.begin();
  3280. sc.moveSW(c, x, y, w, h, rectStyle, topLeftStyle, size, bottom);
  3281. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3282. if (rectOutline == 'double')
  3283. {
  3284. sc.moveNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, top, left);
  3285. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3286. }
  3287. c.stroke();
  3288. }
  3289. else
  3290. {
  3291. c.begin();
  3292. sc.moveSW(c, x, y, w, h, rectStyle, topLeftStyle, size, bottom);
  3293. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3294. sc.lineNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, top, left);
  3295. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3296. c.close();
  3297. c.fillAndStroke();
  3298. }
  3299. }
  3300. else if (!top && !right && bottom && !left)
  3301. {
  3302. if (rectOutline != 'frame')
  3303. {
  3304. c.begin();
  3305. sc.moveSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3306. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3307. if (rectOutline == 'double')
  3308. {
  3309. sc.moveSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, left);
  3310. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3311. }
  3312. c.stroke();
  3313. }
  3314. else
  3315. {
  3316. c.begin();
  3317. sc.moveSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3318. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3319. sc.lineSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, left);
  3320. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3321. c.close();
  3322. c.fillAndStroke();
  3323. }
  3324. }
  3325. else if (!top && !right && bottom && left)
  3326. {
  3327. if (rectOutline != 'frame')
  3328. {
  3329. c.begin();
  3330. sc.moveSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3331. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3332. sc.paintSW(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom);
  3333. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3334. if (rectOutline == 'double')
  3335. {
  3336. sc.moveNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, top, left);
  3337. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3338. sc.paintSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom);
  3339. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3340. }
  3341. c.stroke();
  3342. }
  3343. else
  3344. {
  3345. c.begin();
  3346. sc.moveSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3347. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3348. sc.paintSW(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom);
  3349. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3350. sc.lineNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, top, left);
  3351. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3352. sc.paintSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom);
  3353. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3354. c.close();
  3355. c.fillAndStroke();
  3356. }
  3357. }
  3358. else if (!top && right && !bottom && !left)
  3359. {
  3360. if (rectOutline != 'frame')
  3361. {
  3362. c.begin();
  3363. sc.moveNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3364. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3365. if (rectOutline == 'double')
  3366. {
  3367. sc.moveSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, bottom);
  3368. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3369. }
  3370. c.stroke();
  3371. }
  3372. else
  3373. {
  3374. c.begin();
  3375. sc.moveNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3376. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3377. sc.lineSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, bottom);
  3378. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3379. c.close();
  3380. c.fillAndStroke();
  3381. }
  3382. }
  3383. else if (!top && right && !bottom && left)
  3384. {
  3385. if (rectOutline != 'frame')
  3386. {
  3387. c.begin();
  3388. sc.moveSW(c, x, y, w, h, rectStyle, topLeftStyle, size, bottom);
  3389. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3390. if (rectOutline == 'double')
  3391. {
  3392. sc.moveNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, top, left);
  3393. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3394. }
  3395. c.stroke();
  3396. c.begin();
  3397. sc.moveNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3398. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3399. if (rectOutline == 'double')
  3400. {
  3401. sc.moveSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, bottom);
  3402. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3403. }
  3404. c.stroke();
  3405. }
  3406. else
  3407. {
  3408. c.begin();
  3409. sc.moveSW(c, x, y, w, h, rectStyle, topLeftStyle, size, bottom);
  3410. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3411. sc.lineNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, top, left);
  3412. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3413. c.close();
  3414. c.fillAndStroke();
  3415. c.begin();
  3416. sc.moveNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3417. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3418. sc.lineSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, bottom);
  3419. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3420. c.close();
  3421. c.fillAndStroke();
  3422. }
  3423. }
  3424. else if (!top && right && bottom && !left)
  3425. {
  3426. if (rectOutline != 'frame')
  3427. {
  3428. c.begin();
  3429. sc.moveNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3430. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3431. sc.paintSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3432. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3433. if (rectOutline == 'double')
  3434. {
  3435. sc.moveSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, left);
  3436. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3437. sc.paintSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent);
  3438. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3439. }
  3440. c.stroke();
  3441. }
  3442. else
  3443. {
  3444. c.begin();
  3445. sc.moveNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3446. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3447. sc.paintSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3448. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3449. sc.lineSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, left);
  3450. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3451. sc.paintSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent);
  3452. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3453. c.close();
  3454. c.fillAndStroke();
  3455. }
  3456. }
  3457. else if (!top && right && bottom && left)
  3458. {
  3459. if (rectOutline != 'frame')
  3460. {
  3461. c.begin();
  3462. sc.moveNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3463. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3464. sc.paintSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3465. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3466. sc.paintSW(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom);
  3467. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3468. if (rectOutline == 'double')
  3469. {
  3470. sc.moveNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, top, left);
  3471. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3472. sc.paintSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom);
  3473. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3474. sc.paintSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent);
  3475. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3476. }
  3477. c.stroke();
  3478. }
  3479. else
  3480. {
  3481. c.begin();
  3482. sc.moveNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3483. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3484. sc.paintSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3485. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3486. sc.paintSW(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom);
  3487. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3488. sc.lineNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, top, left);
  3489. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3490. sc.paintSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom);
  3491. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3492. sc.paintSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent);
  3493. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3494. c.close();
  3495. c.fillAndStroke();
  3496. }
  3497. }
  3498. else if (top && !right && !bottom && !left)
  3499. {
  3500. if (rectOutline != 'frame')
  3501. {
  3502. c.begin();
  3503. sc.moveNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3504. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3505. if (rectOutline == 'double')
  3506. {
  3507. sc.moveNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, right);
  3508. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3509. }
  3510. c.stroke();
  3511. }
  3512. else
  3513. {
  3514. c.begin();
  3515. sc.moveNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3516. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3517. sc.lineNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, right);
  3518. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3519. c.close();
  3520. c.fillAndStroke();
  3521. }
  3522. }
  3523. else if (top && !right && !bottom && left)
  3524. {
  3525. if (rectOutline != 'frame')
  3526. {
  3527. c.begin();
  3528. sc.moveSW(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom);
  3529. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3530. sc.paintNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3531. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3532. if (rectOutline == 'double')
  3533. {
  3534. sc.moveNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, right);
  3535. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3536. sc.paintNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent);
  3537. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3538. }
  3539. c.stroke();
  3540. }
  3541. else
  3542. {
  3543. c.begin();
  3544. sc.moveSW(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom);
  3545. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3546. sc.paintNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3547. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3548. sc.lineNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, right);
  3549. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3550. sc.paintNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent);
  3551. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3552. c.close();
  3553. c.fillAndStroke();
  3554. }
  3555. }
  3556. else if (top && !right && bottom && !left)
  3557. {
  3558. if (rectOutline != 'frame')
  3559. {
  3560. c.begin();
  3561. sc.moveNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3562. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3563. if (rectOutline == 'double')
  3564. {
  3565. sc.moveNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, right);
  3566. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3567. }
  3568. c.stroke();
  3569. c.begin();
  3570. sc.moveSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3571. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3572. if (rectOutline == 'double')
  3573. {
  3574. sc.moveSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, left);
  3575. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3576. }
  3577. c.stroke();
  3578. }
  3579. else
  3580. {
  3581. c.begin();
  3582. sc.moveNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3583. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3584. sc.lineNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, right);
  3585. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3586. c.close();
  3587. c.fillAndStroke();
  3588. c.begin();
  3589. sc.moveSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3590. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3591. sc.lineSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, left);
  3592. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3593. c.close();
  3594. c.fillAndStroke();
  3595. }
  3596. }
  3597. else if (top && !right && bottom && left)
  3598. {
  3599. if (rectOutline != 'frame')
  3600. {
  3601. c.begin();
  3602. sc.moveSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3603. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3604. sc.paintSW(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom);
  3605. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3606. sc.paintNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3607. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3608. if (rectOutline == 'double')
  3609. {
  3610. sc.moveNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, right);
  3611. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3612. sc.paintNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent);
  3613. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3614. sc.paintSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom);
  3615. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3616. }
  3617. c.stroke();
  3618. }
  3619. else
  3620. {
  3621. c.begin();
  3622. sc.moveSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3623. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3624. sc.paintSW(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom);
  3625. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3626. sc.paintNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3627. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3628. sc.lineNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, right);
  3629. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3630. sc.paintNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent);
  3631. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3632. sc.paintSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom);
  3633. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3634. c.close();
  3635. c.fillAndStroke();
  3636. }
  3637. }
  3638. else if (top && right && !bottom && !left)
  3639. {
  3640. if (rectOutline != 'frame')
  3641. {
  3642. c.begin();
  3643. sc.moveNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3644. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3645. sc.paintNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3646. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3647. if (rectOutline == 'double')
  3648. {
  3649. sc.moveSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, bottom);
  3650. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3651. sc.paintNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent);
  3652. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3653. }
  3654. c.stroke();
  3655. }
  3656. else
  3657. {
  3658. c.begin();
  3659. sc.moveNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3660. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3661. sc.paintNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3662. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3663. sc.lineSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, bottom);
  3664. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3665. sc.paintNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent);
  3666. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3667. c.close();
  3668. c.fillAndStroke();
  3669. }
  3670. }
  3671. else if (top && right && !bottom && left)
  3672. {
  3673. if (rectOutline != 'frame')
  3674. {
  3675. c.begin();
  3676. sc.moveSW(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom);
  3677. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3678. sc.paintNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3679. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3680. sc.paintNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3681. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3682. if (rectOutline == 'double')
  3683. {
  3684. sc.moveSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, bottom);
  3685. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3686. sc.paintNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent);
  3687. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3688. sc.paintNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent);
  3689. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3690. }
  3691. c.stroke();
  3692. }
  3693. else
  3694. {
  3695. c.begin();
  3696. sc.moveSW(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom);
  3697. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3698. sc.paintNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3699. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3700. sc.paintNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3701. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3702. sc.lineSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, bottom);
  3703. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3704. sc.paintNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent);
  3705. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3706. sc.paintNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent);
  3707. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3708. c.close();
  3709. c.fillAndStroke();
  3710. }
  3711. }
  3712. else if (top && right && bottom && !left)
  3713. {
  3714. if (rectOutline != 'frame')
  3715. {
  3716. c.begin();
  3717. sc.moveNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3718. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3719. sc.paintNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3720. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3721. sc.paintSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3722. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3723. if (rectOutline == 'double')
  3724. {
  3725. sc.moveSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, left);
  3726. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3727. sc.paintSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent);
  3728. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3729. sc.paintNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent);
  3730. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3731. }
  3732. c.stroke();
  3733. }
  3734. else
  3735. {
  3736. c.begin();
  3737. sc.moveNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3738. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3739. sc.paintNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3740. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3741. sc.paintSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3742. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3743. sc.lineSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, left);
  3744. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3745. sc.paintSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent);
  3746. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3747. sc.paintNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent);
  3748. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3749. c.close();
  3750. c.fillAndStroke();
  3751. }
  3752. }
  3753. else if (top && right && bottom && left)
  3754. {
  3755. if (rectOutline != 'frame')
  3756. {
  3757. c.begin();
  3758. sc.moveNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3759. sc.paintNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3760. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3761. sc.paintNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3762. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3763. sc.paintSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3764. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3765. sc.paintSW(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom);
  3766. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3767. c.close();
  3768. if (rectOutline == 'double')
  3769. {
  3770. sc.moveSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, left);
  3771. sc.paintSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom);
  3772. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3773. sc.paintSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent);
  3774. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3775. sc.paintNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent);
  3776. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3777. sc.paintNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent);
  3778. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3779. c.close();
  3780. }
  3781. c.stroke();
  3782. }
  3783. else
  3784. {
  3785. c.begin();
  3786. sc.moveNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3787. sc.paintNW(c, x, y, w, h, rectStyle, topLeftStyle, size, left);
  3788. sc.paintTop(c, x, y, w, h, rectStyle, topRightStyle, size, right);
  3789. sc.paintNE(c, x, y, w, h, rectStyle, topRightStyle, size, top);
  3790. sc.paintRight(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom);
  3791. sc.paintSE(c, x, y, w, h, rectStyle, bottomRightStyle, size, right);
  3792. sc.paintBottom(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left);
  3793. sc.paintSW(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom);
  3794. sc.paintLeft(c, x, y, w, h, rectStyle, topLeftStyle, size, top);
  3795. c.close();
  3796. sc.moveSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, left);
  3797. sc.paintSWInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom);
  3798. sc.paintBottomInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom);
  3799. sc.paintSEInner(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent);
  3800. sc.paintRightInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right);
  3801. sc.paintNEInner(c, x, y, w, h, rectStyle, topRightStyle, size, indent);
  3802. sc.paintTopInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top);
  3803. sc.paintNWInner(c, x, y, w, h, rectStyle, topLeftStyle, size, indent);
  3804. sc.paintLeftInner(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left);
  3805. c.close();
  3806. c.fillAndStroke();
  3807. }
  3808. }
  3809. c.begin();
  3810. sc.paintFolds(c, x, y, w, h, rectStyle, topLeftStyle, topRightStyle, bottomRightStyle, bottomLeftStyle, size, top, right, bottom, left);
  3811. c.stroke();
  3812. };
  3813. mxShapeBasicRect2.prototype.moveNW = function(c, x, y, w, h, rectStyle, topLeftStyle, size, left)
  3814. {
  3815. if((topLeftStyle == 'square' || (topLeftStyle == 'default' && rectStyle == 'square' )) || !left)
  3816. {
  3817. c.moveTo(0, 0);
  3818. }
  3819. else
  3820. {
  3821. c.moveTo(0, size);
  3822. }
  3823. };
  3824. mxShapeBasicRect2.prototype.moveNE = function(c, x, y, w, h, rectStyle, topRightStyle, size, top)
  3825. {
  3826. if((topRightStyle == 'square' || (topRightStyle == 'default' && rectStyle == 'square' )) || !top)
  3827. {
  3828. c.moveTo(w, 0);
  3829. }
  3830. else
  3831. {
  3832. c.moveTo(w - size, 0);
  3833. }
  3834. };
  3835. mxShapeBasicRect2.prototype.moveSE = function(c, x, y, w, h, rectStyle, bottomRightStyle, size, right)
  3836. {
  3837. if((bottomRightStyle == 'square' || (bottomRightStyle == 'default' && rectStyle == 'square' )) || !right)
  3838. {
  3839. c.moveTo(w, h);
  3840. }
  3841. else
  3842. {
  3843. c.moveTo(w, h - size);
  3844. }
  3845. };
  3846. mxShapeBasicRect2.prototype.moveSW = function(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom)
  3847. {
  3848. if((bottomLeftStyle == 'square' || (bottomLeftStyle == 'default' && rectStyle == 'square' )) || !bottom)
  3849. {
  3850. c.moveTo(0, h);
  3851. }
  3852. else
  3853. {
  3854. c.moveTo(size, h);
  3855. }
  3856. };
  3857. mxShapeBasicRect2.prototype.paintNW = function(c, x, y, w, h, rectStyle, topLeftStyle, size, left)
  3858. {
  3859. if (!left)
  3860. {
  3861. c.lineTo(0, 0);
  3862. }
  3863. else if((topLeftStyle == 'rounded' || (topLeftStyle == 'default' && rectStyle == 'rounded' )) ||
  3864. (topLeftStyle == 'invRound' || (topLeftStyle == 'default' && rectStyle == 'invRound' )) )
  3865. {
  3866. var inv = 0;
  3867. if (topLeftStyle == 'rounded' || (topLeftStyle == 'default' && rectStyle == 'rounded' ))
  3868. {
  3869. inv = 1;
  3870. }
  3871. c.arcTo(size, size, 0, 0, inv, size, 0);
  3872. }
  3873. else if((topLeftStyle == 'snip' || (topLeftStyle == 'default' && rectStyle == 'snip' )) ||
  3874. (topLeftStyle == 'fold' || (topLeftStyle == 'default' && rectStyle == 'fold' )))
  3875. {
  3876. c.lineTo(size, 0);
  3877. }
  3878. };
  3879. mxShapeBasicRect2.prototype.paintTop = function(c, x, y, w, h, rectStyle, topRightStyle, size, right)
  3880. {
  3881. if((topRightStyle == 'square' || (topRightStyle == 'default' && rectStyle == 'square' )) || !right)
  3882. {
  3883. c.lineTo(w, 0);
  3884. }
  3885. else
  3886. {
  3887. c.lineTo(w - size, 0);
  3888. }
  3889. };
  3890. mxShapeBasicRect2.prototype.paintNE = function(c, x, y, w, h, rectStyle, topRightStyle, size, top)
  3891. {
  3892. if (!top)
  3893. {
  3894. c.lineTo(w, 0);
  3895. }
  3896. else if((topRightStyle == 'rounded' || (topRightStyle == 'default' && rectStyle == 'rounded' )) ||
  3897. (topRightStyle == 'invRound' || (topRightStyle == 'default' && rectStyle == 'invRound' )) )
  3898. {
  3899. var inv = 0;
  3900. if (topRightStyle == 'rounded' || (topRightStyle == 'default' && rectStyle == 'rounded' ))
  3901. {
  3902. inv = 1;
  3903. }
  3904. c.arcTo(size, size, 0, 0, inv, w, size);
  3905. }
  3906. else if((topRightStyle == 'snip' || (topRightStyle == 'default' && rectStyle == 'snip' )) ||
  3907. (topRightStyle == 'fold' || (topRightStyle == 'default' && rectStyle == 'fold' )))
  3908. {
  3909. c.lineTo(w, size);
  3910. }
  3911. };
  3912. mxShapeBasicRect2.prototype.paintRight = function(c, x, y, w, h, rectStyle, bottomRightStyle, size, bottom)
  3913. {
  3914. if((bottomRightStyle == 'square' || (bottomRightStyle == 'default' && rectStyle == 'square' )) || !bottom)
  3915. {
  3916. c.lineTo(w, h);
  3917. }
  3918. else
  3919. {
  3920. c.lineTo(w, h - size);
  3921. }
  3922. };
  3923. mxShapeBasicRect2.prototype.paintLeft = function(c, x, y, w, h, rectStyle, topLeftStyle, size, top)
  3924. {
  3925. if((topLeftStyle == 'square' || (topLeftStyle == 'default' && rectStyle == 'square' )) || !top)
  3926. {
  3927. c.lineTo(0, 0);
  3928. }
  3929. else
  3930. {
  3931. c.lineTo(0, size);
  3932. }
  3933. };
  3934. mxShapeBasicRect2.prototype.paintSE = function(c, x, y, w, h, rectStyle, bottomRightStyle, size, right)
  3935. {
  3936. if (!right)
  3937. {
  3938. c.lineTo(w, h);
  3939. }
  3940. else if((bottomRightStyle == 'rounded' || (bottomRightStyle == 'default' && rectStyle == 'rounded' )) ||
  3941. (bottomRightStyle == 'invRound' || (bottomRightStyle == 'default' && rectStyle == 'invRound' )) )
  3942. {
  3943. var inv = 0;
  3944. if (bottomRightStyle == 'rounded' || (bottomRightStyle == 'default' && rectStyle == 'rounded' ))
  3945. {
  3946. inv = 1;
  3947. }
  3948. c.arcTo(size, size, 0, 0, inv, w - size, h);
  3949. }
  3950. else if((bottomRightStyle == 'snip' || (bottomRightStyle == 'default' && rectStyle == 'snip' )) ||
  3951. (bottomRightStyle == 'fold' || (bottomRightStyle == 'default' && rectStyle == 'fold' )))
  3952. {
  3953. c.lineTo(w - size, h);
  3954. }
  3955. };
  3956. mxShapeBasicRect2.prototype.paintBottom = function(c, x, y, w, h, rectStyle, bottomLeftStyle, size, left)
  3957. {
  3958. if((bottomLeftStyle == 'square' || (bottomLeftStyle == 'default' && rectStyle == 'square' )) || !left)
  3959. {
  3960. c.lineTo(0, h);
  3961. }
  3962. else
  3963. {
  3964. c.lineTo(size, h);
  3965. }
  3966. };
  3967. mxShapeBasicRect2.prototype.paintSW = function(c, x, y, w, h, rectStyle, bottomLeftStyle, size, bottom)
  3968. {
  3969. if (!bottom)
  3970. {
  3971. c.lineTo(0, h);
  3972. }
  3973. else if((bottomLeftStyle == 'rounded' || (bottomLeftStyle == 'default' && rectStyle == 'rounded' )) ||
  3974. (bottomLeftStyle == 'invRound' || (bottomLeftStyle == 'default' && rectStyle == 'invRound' )) )
  3975. {
  3976. var inv = 0;
  3977. if (bottomLeftStyle == 'rounded' || (bottomLeftStyle == 'default' && rectStyle == 'rounded' ))
  3978. {
  3979. inv = 1;
  3980. }
  3981. c.arcTo(size, size, 0, 0, inv, 0, h - size);
  3982. }
  3983. else if((bottomLeftStyle == 'snip' || (bottomLeftStyle == 'default' && rectStyle == 'snip' )) ||
  3984. (bottomLeftStyle == 'fold' || (bottomLeftStyle == 'default' && rectStyle == 'fold' )))
  3985. {
  3986. c.lineTo(0, h - size);
  3987. }
  3988. };
  3989. mxShapeBasicRect2.prototype.paintNWInner = function(c, x, y, w, h, rectStyle, topLeftStyle, size, indent)
  3990. {
  3991. if(topLeftStyle == 'rounded' || (topLeftStyle == 'default' && rectStyle == 'rounded' ))
  3992. {
  3993. c.arcTo(size - indent * 0.5, size - indent * 0.5, 0, 0, 0, indent, indent * 0.5 + size);
  3994. }
  3995. else if(topLeftStyle == 'invRound' || (topLeftStyle == 'default' && rectStyle == 'invRound' ))
  3996. {
  3997. c.arcTo(size + indent, size + indent, 0, 0, 1, indent, indent + size);
  3998. }
  3999. else if(topLeftStyle == 'snip' || (topLeftStyle == 'default' && rectStyle == 'snip' ))
  4000. {
  4001. c.lineTo(indent, indent * 0.5 + size);
  4002. }
  4003. else if(topLeftStyle == 'fold' || (topLeftStyle == 'default' && rectStyle == 'fold' ))
  4004. {
  4005. c.lineTo(indent + size, indent + size);
  4006. c.lineTo(indent, indent + size);
  4007. }
  4008. };
  4009. mxShapeBasicRect2.prototype.paintTopInner = function(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, left, top)
  4010. {
  4011. if (!left && !top)
  4012. {
  4013. c.lineTo(0, 0);
  4014. }
  4015. else if (!left && top)
  4016. {
  4017. c.lineTo(0, indent);
  4018. }
  4019. else if (left && !top)
  4020. {
  4021. c.lineTo(indent, 0);
  4022. }
  4023. else if (!left)
  4024. {
  4025. c.lineTo(0, indent);
  4026. }
  4027. else if(topLeftStyle == 'square' || (topLeftStyle == 'default' && rectStyle == 'square' ))
  4028. {
  4029. c.lineTo(indent, indent);
  4030. }
  4031. else if((topLeftStyle == 'rounded' || (topLeftStyle == 'default' && rectStyle == 'rounded' )) ||
  4032. (topLeftStyle == 'snip' || (topLeftStyle == 'default' && rectStyle == 'snip' )))
  4033. {
  4034. c.lineTo(size + indent * 0.5, indent);
  4035. }
  4036. else
  4037. {
  4038. c.lineTo(size + indent, indent);
  4039. }
  4040. };
  4041. mxShapeBasicRect2.prototype.paintNEInner = function(c, x, y, w, h, rectStyle, topRightStyle, size, indent)
  4042. {
  4043. if(topRightStyle == 'rounded' || (topRightStyle == 'default' && rectStyle == 'rounded' ))
  4044. {
  4045. c.arcTo(size - indent * 0.5, size - indent * 0.5, 0, 0, 0, w - size - indent * 0.5, indent);
  4046. }
  4047. else if(topRightStyle == 'invRound' || (topRightStyle == 'default' && rectStyle == 'invRound' ))
  4048. {
  4049. c.arcTo(size + indent, size + indent, 0, 0, 1, w - size - indent, indent);
  4050. }
  4051. else if(topRightStyle == 'snip' || (topRightStyle == 'default' && rectStyle == 'snip' ))
  4052. {
  4053. c.lineTo(w - size - indent * 0.5, indent);
  4054. }
  4055. else if(topRightStyle == 'fold' || (topRightStyle == 'default' && rectStyle == 'fold' ))
  4056. {
  4057. c.lineTo(w - size - indent, size + indent);
  4058. c.lineTo(w - size - indent, indent);
  4059. }
  4060. };
  4061. mxShapeBasicRect2.prototype.paintRightInner = function(c, x, y, w, h, rectStyle, topRightStyle, size, indent, top, right)
  4062. {
  4063. if (!top && !right)
  4064. {
  4065. c.lineTo(w, 0);
  4066. }
  4067. else if (!top && right)
  4068. {
  4069. c.lineTo(w - indent, 0);
  4070. }
  4071. else if (top && !right)
  4072. {
  4073. c.lineTo(w, indent);
  4074. }
  4075. else if (!top)
  4076. {
  4077. c.lineTo(w - indent, 0);
  4078. }
  4079. else if(topRightStyle == 'square' || (topRightStyle == 'default' && rectStyle == 'square' ))
  4080. {
  4081. c.lineTo(w - indent, indent);
  4082. }
  4083. else if((topRightStyle == 'rounded' || (topRightStyle == 'default' && rectStyle == 'rounded' )) ||
  4084. (topRightStyle == 'snip' || (topRightStyle == 'default' && rectStyle == 'snip' )))
  4085. {
  4086. c.lineTo(w - indent, size + indent * 0.5);
  4087. }
  4088. else
  4089. {
  4090. c.lineTo(w - indent, size + indent);
  4091. }
  4092. };
  4093. mxShapeBasicRect2.prototype.paintLeftInner = function(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom, left)
  4094. {
  4095. if (!bottom && !left)
  4096. {
  4097. c.lineTo(0, h);
  4098. }
  4099. else if (!bottom && left)
  4100. {
  4101. c.lineTo(indent, h);
  4102. }
  4103. else if (bottom && !left)
  4104. {
  4105. c.lineTo(0, h - indent);
  4106. }
  4107. else if (!bottom)
  4108. {
  4109. c.lineTo(indent, h);
  4110. }
  4111. else if(bottomLeftStyle == 'square' || (bottomLeftStyle == 'default' && rectStyle == 'square' ))
  4112. {
  4113. c.lineTo(indent, h - indent);
  4114. }
  4115. else if((bottomLeftStyle == 'rounded' || (bottomLeftStyle == 'default' && rectStyle == 'rounded' )) ||
  4116. (bottomLeftStyle == 'snip' || (bottomLeftStyle == 'default' && rectStyle == 'snip' )))
  4117. {
  4118. c.lineTo(indent, h - size - indent * 0.5);
  4119. }
  4120. else
  4121. {
  4122. c.lineTo(indent, h - size - indent);
  4123. }
  4124. };
  4125. mxShapeBasicRect2.prototype.paintSEInner = function(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent)
  4126. {
  4127. if(bottomRightStyle == 'rounded' || (bottomRightStyle == 'default' && rectStyle == 'rounded' ))
  4128. {
  4129. c.arcTo(size - indent * 0.5, size - indent * 0.5, 0, 0, 0, w - indent, h - size - indent * 0.5);
  4130. }
  4131. else if(bottomRightStyle == 'invRound' || (bottomRightStyle == 'default' && rectStyle == 'invRound' ))
  4132. {
  4133. c.arcTo(size + indent, size + indent, 0, 0, 1, w - indent, h - size - indent);
  4134. }
  4135. else if(bottomRightStyle == 'snip' || (bottomRightStyle == 'default' && rectStyle == 'snip' ))
  4136. {
  4137. c.lineTo(w - indent, h - size - indent * 0.5);
  4138. }
  4139. else if(bottomRightStyle == 'fold' || (bottomRightStyle == 'default' && rectStyle == 'fold' ))
  4140. {
  4141. c.lineTo(w - size - indent, h - size - indent);
  4142. c.lineTo(w - indent, h - size - indent);
  4143. }
  4144. };
  4145. mxShapeBasicRect2.prototype.paintBottomInner = function(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, right, bottom)
  4146. {
  4147. if (!right && !bottom)
  4148. {
  4149. c.lineTo(w, h);
  4150. }
  4151. else if (!right && bottom)
  4152. {
  4153. c.lineTo(w, h - indent);
  4154. }
  4155. else if (right && !bottom)
  4156. {
  4157. c.lineTo(w - indent, h);
  4158. }
  4159. else if((bottomRightStyle == 'square' || (bottomRightStyle == 'default' && rectStyle == 'square' )) || !right)
  4160. {
  4161. c.lineTo(w - indent, h - indent);
  4162. }
  4163. else if((bottomRightStyle == 'rounded' || (bottomRightStyle == 'default' && rectStyle == 'rounded' )) ||
  4164. (bottomRightStyle == 'snip' || (bottomRightStyle == 'default' && rectStyle == 'snip' )))
  4165. {
  4166. c.lineTo(w - size - indent * 0.5, h - indent);
  4167. }
  4168. else
  4169. {
  4170. c.lineTo(w - size - indent, h - indent);
  4171. }
  4172. };
  4173. mxShapeBasicRect2.prototype.paintSWInner = function(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, bottom)
  4174. {
  4175. if (!bottom)
  4176. {
  4177. c.lineTo(indent, h);
  4178. }
  4179. else if(bottomLeftStyle == 'square' || (bottomLeftStyle == 'default' && rectStyle == 'square' ))
  4180. {
  4181. c.lineTo(indent, h - indent);
  4182. }
  4183. else if(bottomLeftStyle == 'rounded' || (bottomLeftStyle == 'default' && rectStyle == 'rounded' ))
  4184. {
  4185. c.arcTo(size - indent * 0.5, size - indent * 0.5, 0, 0, 0, size + indent * 0.5, h - indent);
  4186. }
  4187. else if(bottomLeftStyle == 'invRound' || (bottomLeftStyle == 'default' && rectStyle == 'invRound' ))
  4188. {
  4189. c.arcTo(size + indent, size + indent, 0, 0, 1, size + indent, h - indent);
  4190. }
  4191. else if(bottomLeftStyle == 'snip' || (bottomLeftStyle == 'default' && rectStyle == 'snip' ))
  4192. {
  4193. c.lineTo(size + indent * 0.5, h - indent);
  4194. }
  4195. else if(bottomLeftStyle == 'fold' || (bottomLeftStyle == 'default' && rectStyle == 'fold' ))
  4196. {
  4197. c.lineTo(indent + size, h - size - indent);
  4198. c.lineTo(indent + size, h - indent);
  4199. }
  4200. };
  4201. mxShapeBasicRect2.prototype.moveSWInner = function(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, left)
  4202. {
  4203. if (!left)
  4204. {
  4205. c.moveTo(0, h - indent);
  4206. }
  4207. else if(bottomLeftStyle == 'square' || (bottomLeftStyle == 'default' && rectStyle == 'square' ))
  4208. {
  4209. c.moveTo(indent, h - indent);
  4210. }
  4211. else if((bottomLeftStyle == 'rounded' || (bottomLeftStyle == 'default' && rectStyle == 'rounded' )) ||
  4212. (bottomLeftStyle == 'snip' || (bottomLeftStyle == 'default' && rectStyle == 'snip' )))
  4213. {
  4214. c.moveTo(indent, h - size - indent * 0.5);
  4215. }
  4216. else if((bottomLeftStyle == 'invRound' || (bottomLeftStyle == 'default' && rectStyle == 'invRound' )) ||
  4217. (bottomLeftStyle == 'fold' || (bottomLeftStyle == 'default' && rectStyle == 'fold' )))
  4218. {
  4219. c.moveTo(indent, h - size - indent);
  4220. }
  4221. };
  4222. mxShapeBasicRect2.prototype.lineSWInner = function(c, x, y, w, h, rectStyle, bottomLeftStyle, size, indent, left)
  4223. {
  4224. if (!left)
  4225. {
  4226. c.lineTo(0, h - indent);
  4227. }
  4228. else if(bottomLeftStyle == 'square' || (bottomLeftStyle == 'default' && rectStyle == 'square' ))
  4229. {
  4230. c.lineTo(indent, h - indent);
  4231. }
  4232. else if((bottomLeftStyle == 'rounded' || (bottomLeftStyle == 'default' && rectStyle == 'rounded' )) ||
  4233. (bottomLeftStyle == 'snip' || (bottomLeftStyle == 'default' && rectStyle == 'snip' )))
  4234. {
  4235. c.lineTo(indent, h - size - indent * 0.5);
  4236. }
  4237. else if((bottomLeftStyle == 'invRound' || (bottomLeftStyle == 'default' && rectStyle == 'invRound' )) ||
  4238. (bottomLeftStyle == 'fold' || (bottomLeftStyle == 'default' && rectStyle == 'fold' )))
  4239. {
  4240. c.lineTo(indent, h - size - indent);
  4241. }
  4242. };
  4243. mxShapeBasicRect2.prototype.moveSEInner = function(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, bottom)
  4244. {
  4245. if (!bottom)
  4246. {
  4247. c.moveTo(w - indent, h);
  4248. }
  4249. else if(bottomRightStyle == 'square' || (bottomRightStyle == 'default' && rectStyle == 'square' ))
  4250. {
  4251. c.moveTo(w - indent, h - indent);
  4252. }
  4253. else if((bottomRightStyle == 'rounded' || (bottomRightStyle == 'default' && rectStyle == 'rounded' )) ||
  4254. (bottomRightStyle == 'snip' || (bottomRightStyle == 'default' && rectStyle == 'snip' )))
  4255. {
  4256. c.moveTo(w - indent, h - size - indent * 0.5);
  4257. }
  4258. else if((bottomRightStyle == 'invRound' || (bottomRightStyle == 'default' && rectStyle == 'invRound' )) ||
  4259. (bottomRightStyle == 'fold' || (bottomRightStyle == 'default' && rectStyle == 'fold' )))
  4260. {
  4261. c.moveTo(w - indent, h - size - indent);
  4262. }
  4263. };
  4264. mxShapeBasicRect2.prototype.lineSEInner = function(c, x, y, w, h, rectStyle, bottomRightStyle, size, indent, bottom)
  4265. {
  4266. if (!bottom)
  4267. {
  4268. c.lineTo(w - indent, h);
  4269. }
  4270. else if(bottomRightStyle == 'square' || (bottomRightStyle == 'default' && rectStyle == 'square' ))
  4271. {
  4272. c.lineTo(w - indent, h - indent);
  4273. }
  4274. else if((bottomRightStyle == 'rounded' || (bottomRightStyle == 'default' && rectStyle == 'rounded' )) ||
  4275. (bottomRightStyle == 'snip' || (bottomRightStyle == 'default' && rectStyle == 'snip' )))
  4276. {
  4277. c.lineTo(w - indent, h - size - indent * 0.5);
  4278. }
  4279. else if((bottomRightStyle == 'invRound' || (bottomRightStyle == 'default' && rectStyle == 'invRound' )) ||
  4280. (bottomRightStyle == 'fold' || (bottomRightStyle == 'default' && rectStyle == 'fold' )))
  4281. {
  4282. c.lineTo(w - indent, h - size - indent);
  4283. }
  4284. };
  4285. mxShapeBasicRect2.prototype.moveNEInner = function(c, x, y, w, h, rectStyle, topRightStyle, size, indent, right)
  4286. {
  4287. if (!right)
  4288. {
  4289. c.moveTo(w, indent);
  4290. }
  4291. else if((topRightStyle == 'square' || (topRightStyle == 'default' && rectStyle == 'square' )) || right)
  4292. {
  4293. c.moveTo(w - indent, indent);
  4294. }
  4295. else if((topRightStyle == 'rounded' || (topRightStyle == 'default' && rectStyle == 'rounded' )) ||
  4296. (topRightStyle == 'snip' || (topRightStyle == 'default' && rectStyle == 'snip' )))
  4297. {
  4298. c.moveTo(w - indent, size + indent * 0.5);
  4299. }
  4300. else if((topRightStyle == 'invRound' || (topRightStyle == 'default' && rectStyle == 'invRound' )) ||
  4301. (topRightStyle == 'fold' || (topRightStyle == 'default' && rectStyle == 'fold' )))
  4302. {
  4303. c.moveTo(w - indent, size + indent);
  4304. }
  4305. };
  4306. mxShapeBasicRect2.prototype.lineNEInner = function(c, x, y, w, h, rectStyle, topRightStyle, size, indent, right)
  4307. {
  4308. if (!right)
  4309. {
  4310. c.lineTo(w, indent);
  4311. }
  4312. else if((topRightStyle == 'square' || (topRightStyle == 'default' && rectStyle == 'square' )) || right)
  4313. {
  4314. c.lineTo(w - indent, indent);
  4315. }
  4316. else if((topRightStyle == 'rounded' || (topRightStyle == 'default' && rectStyle == 'rounded' )) ||
  4317. (topRightStyle == 'snip' || (topRightStyle == 'default' && rectStyle == 'snip' )))
  4318. {
  4319. c.lineTo(w - indent, size + indent * 0.5);
  4320. }
  4321. else if((topRightStyle == 'invRound' || (topRightStyle == 'default' && rectStyle == 'invRound' )) ||
  4322. (topRightStyle == 'fold' || (topRightStyle == 'default' && rectStyle == 'fold' )))
  4323. {
  4324. c.lineTo(w - indent, size + indent);
  4325. }
  4326. };
  4327. mxShapeBasicRect2.prototype.moveNWInner = function(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, top, left)
  4328. {
  4329. if (!top && !left)
  4330. {
  4331. c.moveTo(0, 0);
  4332. }
  4333. else if (!top && left)
  4334. {
  4335. c.moveTo(indent, 0);
  4336. }
  4337. else if (top && !left)
  4338. {
  4339. c.moveTo(0, indent);
  4340. }
  4341. else if(topLeftStyle == 'square' || (topLeftStyle == 'default' && rectStyle == 'square' ))
  4342. {
  4343. c.moveTo(indent, indent);
  4344. }
  4345. else if((topLeftStyle == 'rounded' || (topLeftStyle == 'default' && rectStyle == 'rounded' )) ||
  4346. (topLeftStyle == 'snip' || (topLeftStyle == 'default' && rectStyle == 'snip' )))
  4347. {
  4348. c.moveTo(indent, size + indent * 0.5);
  4349. }
  4350. else if((topLeftStyle == 'invRound' || (topLeftStyle == 'default' && rectStyle == 'invRound' )) ||
  4351. (topLeftStyle == 'fold' || (topLeftStyle == 'default' && rectStyle == 'fold' )))
  4352. {
  4353. c.moveTo(indent, size + indent);
  4354. }
  4355. };
  4356. mxShapeBasicRect2.prototype.lineNWInner = function(c, x, y, w, h, rectStyle, topLeftStyle, size, indent, top, left)
  4357. {
  4358. if (!top && !left)
  4359. {
  4360. c.lineTo(0, 0);
  4361. }
  4362. else if (!top && left)
  4363. {
  4364. c.lineTo(indent, 0);
  4365. }
  4366. else if (top && !left)
  4367. {
  4368. c.lineTo(0, indent);
  4369. }
  4370. else if(topLeftStyle == 'square' || (topLeftStyle == 'default' && rectStyle == 'square' ))
  4371. {
  4372. c.lineTo(indent, indent);
  4373. }
  4374. else if((topLeftStyle == 'rounded' || (topLeftStyle == 'default' && rectStyle == 'rounded' )) ||
  4375. (topLeftStyle == 'snip' || (topLeftStyle == 'default' && rectStyle == 'snip' )))
  4376. {
  4377. c.lineTo(indent, size + indent * 0.5);
  4378. }
  4379. else if((topLeftStyle == 'invRound' || (topLeftStyle == 'default' && rectStyle == 'invRound' )) ||
  4380. (topLeftStyle == 'fold' || (topLeftStyle == 'default' && rectStyle == 'fold' )))
  4381. {
  4382. c.lineTo(indent, size + indent);
  4383. }
  4384. };
  4385. mxShapeBasicRect2.prototype.paintFolds = function(c, x, y, w, h, rectStyle, topLeftStyle, topRightStyle, bottomRightStyle, bottomLeftStyle, size, top, right, bottom, left)
  4386. {
  4387. if (rectStyle == 'fold' || topLeftStyle == 'fold' || topRightStyle == 'fold' || bottomRightStyle == 'fold' || bottomLeftStyle == 'fold')
  4388. {
  4389. if ((topLeftStyle == 'fold' || (topLeftStyle == 'default' && rectStyle == 'fold' )) && (top && left))
  4390. {
  4391. c.moveTo(0, size);
  4392. c.lineTo(size, size);
  4393. c.lineTo(size, 0);
  4394. }
  4395. if ((topRightStyle == 'fold' || (topRightStyle == 'default' && rectStyle == 'fold' )) && (top && right))
  4396. {
  4397. c.moveTo(w - size, 0);
  4398. c.lineTo(w - size, size);
  4399. c.lineTo(w, size);
  4400. }
  4401. if ((bottomRightStyle == 'fold' || (bottomRightStyle == 'default' && rectStyle == 'fold' )) && (bottom && right))
  4402. {
  4403. c.moveTo(w - size, h);
  4404. c.lineTo(w - size, h - size);
  4405. c.lineTo(w, h - size);
  4406. }
  4407. if ((bottomLeftStyle == 'fold' || (bottomLeftStyle == 'default' && rectStyle == 'fold' )) && (bottom && left))
  4408. {
  4409. c.moveTo(0, h - size);
  4410. c.lineTo(size, h - size);
  4411. c.lineTo(size, h);
  4412. }
  4413. }
  4414. };
  4415. mxCellRenderer.registerShape(mxShapeBasicRect2.prototype.cst.RECT2, mxShapeBasicRect2);
  4416. mxShapeBasicRect2.prototype.constraints = null;
  4417. // FilledEdge shape
  4418. function FilledEdge()
  4419. {
  4420. mxConnector.call(this);
  4421. };
  4422. mxUtils.extend(FilledEdge, mxConnector);
  4423. FilledEdge.prototype.origPaintEdgeShape = FilledEdge.prototype.paintEdgeShape;
  4424. FilledEdge.prototype.paintEdgeShape = function(c, pts, rounded)
  4425. {
  4426. // Markers modify incoming points array
  4427. var temp = [];
  4428. for (var i = 0; i < pts.length; i++)
  4429. {
  4430. temp.push(mxUtils.clone(pts[i]));
  4431. }
  4432. // paintEdgeShape resets dashed to false
  4433. var dashed = c.state.dashed;
  4434. var fixDash = c.state.fixDash;
  4435. FilledEdge.prototype.origPaintEdgeShape.apply(this, [c, temp, rounded]);
  4436. if (c.state.strokeWidth >= 3)
  4437. {
  4438. var fillClr = mxUtils.getValue(this.style, 'fillColor', null);
  4439. if (fillClr != null)
  4440. {
  4441. c.setStrokeColor(fillClr);
  4442. c.setStrokeWidth(c.state.strokeWidth - 2);
  4443. c.setDashed(dashed, fixDash);
  4444. FilledEdge.prototype.origPaintEdgeShape.apply(this, [c, pts, rounded]);
  4445. }
  4446. }
  4447. };
  4448. // Registers the link shape
  4449. mxCellRenderer.registerShape('filledEdge', FilledEdge);
  4450. // Implements custom colors for shapes
  4451. if (typeof StyleFormatPanel !== 'undefined')
  4452. {
  4453. (function()
  4454. {
  4455. var styleFormatPanelGetCustomColors = StyleFormatPanel.prototype.getCustomColors;
  4456. StyleFormatPanel.prototype.getCustomColors = function()
  4457. {
  4458. var ss = this.format.getSelectionState();
  4459. var result = styleFormatPanelGetCustomColors.apply(this, arguments);
  4460. if (ss.style.shape == 'umlFrame')
  4461. {
  4462. result.push({title: mxResources.get('laneColor'), key: 'swimlaneFillColor', defaultValue: '#ffffff'});
  4463. }
  4464. return result;
  4465. };
  4466. })();
  4467. }
  4468. // Registers and defines the custom marker
  4469. mxMarker.addMarker('dash', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  4470. {
  4471. var nx = unitX * (size + sw + 1);
  4472. var ny = unitY * (size + sw + 1);
  4473. return function()
  4474. {
  4475. c.begin();
  4476. c.moveTo(pe.x - nx / 2 - ny / 2, pe.y - ny / 2 + nx / 2);
  4477. c.lineTo(pe.x + ny / 2 - 3 * nx / 2, pe.y - 3 * ny / 2 - nx / 2);
  4478. c.stroke();
  4479. };
  4480. });
  4481. // Registers and defines the custom marker
  4482. mxMarker.addMarker('box', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  4483. {
  4484. var nx = unitX * (size + sw + 1);
  4485. var ny = unitY * (size + sw + 1);
  4486. var px = pe.x + nx / 2;
  4487. var py = pe.y + ny / 2;
  4488. pe.x -= nx;
  4489. pe.y -= ny;
  4490. return function()
  4491. {
  4492. c.begin();
  4493. c.moveTo(px - nx / 2 - ny / 2, py - ny / 2 + nx / 2);
  4494. c.lineTo(px - nx / 2 + ny / 2, py - ny / 2 - nx / 2);
  4495. c.lineTo(px + ny / 2 - 3 * nx / 2, py - 3 * ny / 2 - nx / 2);
  4496. c.lineTo(px - ny / 2 - 3 * nx / 2, py - 3 * ny / 2 + nx / 2);
  4497. c.close();
  4498. if (filled)
  4499. {
  4500. c.fillAndStroke();
  4501. }
  4502. else
  4503. {
  4504. c.stroke();
  4505. }
  4506. };
  4507. });
  4508. // Registers and defines the custom marker
  4509. mxMarker.addMarker('cross', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  4510. {
  4511. var nx = unitX * (size + sw + 1);
  4512. var ny = unitY * (size + sw + 1);
  4513. return function()
  4514. {
  4515. c.begin();
  4516. c.moveTo(pe.x - nx / 2 - ny / 2, pe.y - ny / 2 + nx / 2);
  4517. c.lineTo(pe.x + ny / 2 - 3 * nx / 2, pe.y - 3 * ny / 2 - nx / 2);
  4518. c.moveTo(pe.x - nx / 2 + ny / 2, pe.y - ny / 2 - nx / 2);
  4519. c.lineTo(pe.x - ny / 2 - 3 * nx / 2, pe.y - 3 * ny / 2 + nx / 2);
  4520. c.stroke();
  4521. };
  4522. });
  4523. function circleMarker(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  4524. {
  4525. var a = size / 2;
  4526. var size = size + sw;
  4527. var pt = pe.clone();
  4528. pe.x -= unitX * (2 * size + sw);
  4529. pe.y -= unitY * (2 * size + sw);
  4530. unitX = unitX * (size + sw);
  4531. unitY = unitY * (size + sw);
  4532. return function()
  4533. {
  4534. c.ellipse(pt.x - unitX - size, pt.y - unitY - size, 2 * size, 2 * size);
  4535. if (filled)
  4536. {
  4537. c.fillAndStroke();
  4538. }
  4539. else
  4540. {
  4541. c.stroke();
  4542. }
  4543. };
  4544. };
  4545. mxMarker.addMarker('circle', circleMarker);
  4546. mxMarker.addMarker('circlePlus', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  4547. {
  4548. var pt = pe.clone();
  4549. var fn = circleMarker.apply(this, arguments);
  4550. var nx = unitX * (size + 2 * sw); // (size + sw + 1);
  4551. var ny = unitY * (size + 2 * sw); //(size + sw + 1);
  4552. return function()
  4553. {
  4554. fn.apply(this, arguments);
  4555. c.begin();
  4556. c.moveTo(pt.x - unitX * (sw), pt.y - unitY * (sw));
  4557. c.lineTo(pt.x - 2 * nx + unitX * (sw), pt.y - 2 * ny + unitY * (sw));
  4558. c.moveTo(pt.x - nx - ny + unitY * sw, pt.y - ny + nx - unitX * sw);
  4559. c.lineTo(pt.x + ny - nx - unitY * sw, pt.y - ny - nx + unitX * sw);
  4560. c.stroke();
  4561. };
  4562. });
  4563. // Registers and defines the custom marker
  4564. mxMarker.addMarker('halfCircle', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  4565. {
  4566. var nx = unitX * (size + sw + 1);
  4567. var ny = unitY * (size + sw + 1);
  4568. var pt = pe.clone();
  4569. pe.x -= nx;
  4570. pe.y -= ny;
  4571. return function()
  4572. {
  4573. c.begin();
  4574. c.moveTo(pt.x - ny, pt.y + nx);
  4575. c.quadTo(pe.x - ny, pe.y + nx, pe.x, pe.y);
  4576. c.quadTo(pe.x + ny, pe.y - nx, pt.x + ny, pt.y - nx);
  4577. c.stroke();
  4578. };
  4579. });
  4580. mxMarker.addMarker('async', function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  4581. {
  4582. // The angle of the forward facing arrow sides against the x axis is
  4583. // 26.565 degrees, 1/sin(26.565) = 2.236 / 2 = 1.118 ( / 2 allows for
  4584. // only half the strokewidth is processed ).
  4585. var endOffsetX = unitX * sw * 1.118;
  4586. var endOffsetY = unitY * sw * 1.118;
  4587. unitX = unitX * (size + sw);
  4588. unitY = unitY * (size + sw);
  4589. var pt = pe.clone();
  4590. pt.x -= endOffsetX;
  4591. pt.y -= endOffsetY;
  4592. var f = 1;
  4593. pe.x += -unitX * f - endOffsetX;
  4594. pe.y += -unitY * f - endOffsetY;
  4595. return function()
  4596. {
  4597. c.begin();
  4598. c.moveTo(pt.x, pt.y);
  4599. if (source)
  4600. {
  4601. c.lineTo(pt.x - unitX - unitY / 2, pt.y - unitY + unitX / 2);
  4602. }
  4603. else
  4604. {
  4605. c.lineTo(pt.x + unitY / 2 - unitX, pt.y - unitY - unitX / 2);
  4606. }
  4607. c.lineTo(pt.x - unitX, pt.y - unitY);
  4608. c.close();
  4609. if (filled)
  4610. {
  4611. c.fillAndStroke();
  4612. }
  4613. else
  4614. {
  4615. c.stroke();
  4616. }
  4617. };
  4618. });
  4619. function createOpenAsyncArrow(widthFactor)
  4620. {
  4621. widthFactor = (widthFactor != null) ? widthFactor : 2;
  4622. return function(c, shape, type, pe, unitX, unitY, size, source, sw, filled)
  4623. {
  4624. unitX = unitX * (size + sw);
  4625. unitY = unitY * (size + sw);
  4626. var pt = pe.clone();
  4627. return function()
  4628. {
  4629. c.begin();
  4630. c.moveTo(pt.x, pt.y);
  4631. if (source)
  4632. {
  4633. c.lineTo(pt.x - unitX - unitY / widthFactor, pt.y - unitY + unitX / widthFactor);
  4634. }
  4635. else
  4636. {
  4637. c.lineTo(pt.x + unitY / widthFactor - unitX, pt.y - unitY - unitX / widthFactor);
  4638. }
  4639. c.stroke();
  4640. };
  4641. }
  4642. };
  4643. mxMarker.addMarker('openAsync', createOpenAsyncArrow(2));
  4644. function arrow(canvas, shape, type, pe, unitX, unitY, size, source, sw, filled)
  4645. {
  4646. // The angle of the forward facing arrow sides against the x axis is
  4647. // 26.565 degrees, 1/sin(26.565) = 2.236 / 2 = 1.118 ( / 2 allows for
  4648. // only half the strokewidth is processed ).
  4649. var endOffsetX = unitX * sw * 1.118;
  4650. var endOffsetY = unitY * sw * 1.118;
  4651. unitX = unitX * (size + sw);
  4652. unitY = unitY * (size + sw);
  4653. var pt = pe.clone();
  4654. pt.x -= endOffsetX;
  4655. pt.y -= endOffsetY;
  4656. var f = (type != mxConstants.ARROW_CLASSIC && type != mxConstants.ARROW_CLASSIC_THIN) ? 1 : 3 / 4;
  4657. pe.x += -unitX * f - endOffsetX;
  4658. pe.y += -unitY * f - endOffsetY;
  4659. return function()
  4660. {
  4661. canvas.begin();
  4662. canvas.moveTo(pt.x, pt.y);
  4663. canvas.lineTo(pt.x - unitX - unitY / widthFactor, pt.y - unitY + unitX / widthFactor);
  4664. if (type == mxConstants.ARROW_CLASSIC || type == mxConstants.ARROW_CLASSIC_THIN)
  4665. {
  4666. canvas.lineTo(pt.x - unitX * 3 / 4, pt.y - unitY * 3 / 4);
  4667. }
  4668. canvas.lineTo(pt.x + unitY / widthFactor - unitX, pt.y - unitY - unitX / widthFactor);
  4669. canvas.close();
  4670. if (filled)
  4671. {
  4672. canvas.fillAndStroke();
  4673. }
  4674. else
  4675. {
  4676. canvas.stroke();
  4677. }
  4678. };
  4679. }
  4680. // Handlers are only added if mxVertexHandler is defined (ie. not in embedded graph)
  4681. if (typeof mxVertexHandler !== 'undefined')
  4682. {
  4683. function createHandle(state, keys, getPositionFn, setPositionFn, ignoreGrid, redrawEdges, executeFn)
  4684. {
  4685. var handle = new mxHandle(state, null, mxVertexHandler.prototype.secondaryHandleImage);
  4686. handle.execute = function(me)
  4687. {
  4688. for (var i = 0; i < keys.length; i++)
  4689. {
  4690. this.copyStyle(keys[i]);
  4691. }
  4692. if (executeFn)
  4693. {
  4694. executeFn(me);
  4695. }
  4696. };
  4697. handle.getPosition = getPositionFn;
  4698. handle.setPosition = setPositionFn;
  4699. handle.ignoreGrid = (ignoreGrid != null) ? ignoreGrid : true;
  4700. // Overridden to update connected edges
  4701. if (redrawEdges)
  4702. {
  4703. var positionChanged = handle.positionChanged;
  4704. handle.positionChanged = function()
  4705. {
  4706. positionChanged.apply(this, arguments);
  4707. // Redraws connected edges TODO: Include child edges
  4708. state.view.invalidate(this.state.cell);
  4709. state.view.validate();
  4710. };
  4711. }
  4712. return handle;
  4713. };
  4714. function createArcHandle(state, yOffset)
  4715. {
  4716. return createHandle(state, [mxConstants.STYLE_ARCSIZE], function(bounds)
  4717. {
  4718. var tmp = (yOffset != null) ? yOffset : bounds.height / 8;
  4719. if (mxUtils.getValue(state.style, mxConstants.STYLE_ABSOLUTE_ARCSIZE, 0) == '1')
  4720. {
  4721. var arcSize = mxUtils.getValue(state.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  4722. return new mxPoint(bounds.x + bounds.width - Math.min(bounds.width / 2, arcSize), bounds.y + tmp);
  4723. }
  4724. else
  4725. {
  4726. var arcSize = Math.max(0, parseFloat(mxUtils.getValue(state.style,
  4727. mxConstants.STYLE_ARCSIZE, mxConstants.RECTANGLE_ROUNDING_FACTOR * 100))) / 100;
  4728. return new mxPoint(bounds.x + bounds.width - Math.min(Math.max(bounds.width / 2, bounds.height / 2),
  4729. Math.min(bounds.width, bounds.height) * arcSize), bounds.y + tmp);
  4730. }
  4731. }, function(bounds, pt, me)
  4732. {
  4733. if (mxUtils.getValue(state.style, mxConstants.STYLE_ABSOLUTE_ARCSIZE, 0) == '1')
  4734. {
  4735. this.state.style[mxConstants.STYLE_ARCSIZE] = Math.round(Math.max(0, Math.min(bounds.width,
  4736. (bounds.x + bounds.width - pt.x) * 2)));
  4737. }
  4738. else
  4739. {
  4740. var f = Math.min(50, Math.max(0, (bounds.width - pt.x + bounds.x) * 100 /
  4741. Math.min(bounds.width, bounds.height)));
  4742. this.state.style[mxConstants.STYLE_ARCSIZE] = Math.round(f);
  4743. }
  4744. });
  4745. }
  4746. function createArcHandleFunction()
  4747. {
  4748. return function(state)
  4749. {
  4750. var handles = [];
  4751. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  4752. {
  4753. handles.push(createArcHandle(state));
  4754. }
  4755. return handles;
  4756. };
  4757. };
  4758. function createTrapezoidHandleFunction(max, defaultValue, fixedDefaultValue)
  4759. {
  4760. max = (max != null) ? max : 0.5;
  4761. return function(state)
  4762. {
  4763. var handles = [createHandle(state, ['size'], function(bounds)
  4764. {
  4765. var fixed = (fixedDefaultValue != null) ? mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0' : null;
  4766. var size = Math.max(0, parseFloat(mxUtils.getValue(this.state.style, 'size', (fixed) ? fixedDefaultValue : defaultValue)));
  4767. 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);
  4768. }, function(bounds, pt)
  4769. {
  4770. var fixed = (fixedDefaultValue != null) ? mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0' : null;
  4771. var size = (fixed) ? (pt.x - bounds.x) : Math.max(0, Math.min(max, (pt.x - bounds.x) / bounds.width * 0.75));
  4772. this.state.style['size'] = size;
  4773. }, false, true)];
  4774. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  4775. {
  4776. handles.push(createArcHandle(state));
  4777. }
  4778. return handles;
  4779. };
  4780. };
  4781. function createDisplayHandleFunction(defaultValue, allowArcHandle, max, redrawEdges, fixedDefaultValue)
  4782. {
  4783. max = (max != null) ? max : 0.5;
  4784. return function(state)
  4785. {
  4786. var handles = [createHandle(state, ['size'], function(bounds)
  4787. {
  4788. var fixed = (fixedDefaultValue != null) ? mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0' : null;
  4789. var size = parseFloat(mxUtils.getValue(this.state.style, 'size', (fixed) ? fixedDefaultValue : defaultValue));
  4790. return new mxPoint(bounds.x + Math.max(0, Math.min(bounds.width * 0.5, size * ((fixed) ? 1 : bounds.width))), bounds.getCenterY());
  4791. }, function(bounds, pt, me)
  4792. {
  4793. var fixed = (fixedDefaultValue != null) ? mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0' : null;
  4794. var size = (fixed) ? (pt.x - bounds.x) : Math.max(0, Math.min(max, (pt.x - bounds.x) / bounds.width));
  4795. this.state.style['size'] = size;
  4796. }, false, redrawEdges)];
  4797. if (allowArcHandle && mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  4798. {
  4799. handles.push(createArcHandle(state));
  4800. }
  4801. return handles;
  4802. };
  4803. };
  4804. function createCubeHandleFunction(factor, defaultValue, allowArcHandle)
  4805. {
  4806. return function(state)
  4807. {
  4808. var handles = [createHandle(state, ['size'], function(bounds)
  4809. {
  4810. var size = Math.max(0, Math.min(bounds.width, Math.min(bounds.height, parseFloat(
  4811. mxUtils.getValue(this.state.style, 'size', defaultValue))))) * factor;
  4812. return new mxPoint(bounds.x + size, bounds.y + size);
  4813. }, function(bounds, pt)
  4814. {
  4815. this.state.style['size'] = Math.round(Math.max(0, Math.min(Math.min(bounds.width, pt.x - bounds.x),
  4816. Math.min(bounds.height, pt.y - bounds.y))) / factor);
  4817. }, false)];
  4818. if (allowArcHandle && mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  4819. {
  4820. handles.push(createArcHandle(state));
  4821. }
  4822. return handles;
  4823. };
  4824. };
  4825. function createCylinderHandleFunction(defaultValue)
  4826. {
  4827. return function(state)
  4828. {
  4829. return [createHandle(state, ['size'], function(bounds)
  4830. {
  4831. var size = Math.max(0, Math.min(bounds.height * 0.5, parseFloat(mxUtils.getValue(this.state.style, 'size', defaultValue))));
  4832. return new mxPoint(bounds.x, bounds.y + size);
  4833. }, function(bounds, pt)
  4834. {
  4835. this.state.style['size'] = Math.max(0, pt.y - bounds.y);
  4836. }, true)];
  4837. }
  4838. };
  4839. function createArrowHandleFunction(maxSize)
  4840. {
  4841. return function(state)
  4842. {
  4843. return [createHandle(state, ['arrowWidth', 'arrowSize'], function(bounds)
  4844. {
  4845. var aw = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'arrowWidth', SingleArrowShape.prototype.arrowWidth)));
  4846. var as = Math.max(0, Math.min(maxSize, mxUtils.getValue(this.state.style, 'arrowSize', SingleArrowShape.prototype.arrowSize)));
  4847. return new mxPoint(bounds.x + (1 - as) * bounds.width, bounds.y + (1 - aw) * bounds.height / 2);
  4848. }, function(bounds, pt)
  4849. {
  4850. this.state.style['arrowWidth'] = Math.max(0, Math.min(1, Math.abs(bounds.y + bounds.height / 2 - pt.y) / bounds.height * 2));
  4851. this.state.style['arrowSize'] = Math.max(0, Math.min(maxSize, (bounds.x + bounds.width - pt.x) / (bounds.width)));
  4852. })];
  4853. };
  4854. };
  4855. function createEdgeHandle(state, keys, start, getPosition, setPosition)
  4856. {
  4857. return createHandle(state, keys, function(bounds)
  4858. {
  4859. var pts = state.absolutePoints;
  4860. var n = pts.length - 1;
  4861. var tr = state.view.translate;
  4862. var s = state.view.scale;
  4863. var p0 = (start) ? pts[0] : pts[n];
  4864. var p1 = (start) ? pts[1] : pts[n - 1];
  4865. var dx = (start) ? p1.x - p0.x : p1.x - p0.x;
  4866. var dy = (start) ? p1.y - p0.y : p1.y - p0.y;
  4867. var dist = Math.sqrt(dx * dx + dy * dy);
  4868. var pt = getPosition.call(this, dist, dx / dist, dy / dist, p0, p1);
  4869. return new mxPoint(pt.x / s - tr.x, pt.y / s - tr.y);
  4870. }, function(bounds, pt, me)
  4871. {
  4872. var pts = state.absolutePoints;
  4873. var n = pts.length - 1;
  4874. var tr = state.view.translate;
  4875. var s = state.view.scale;
  4876. var p0 = (start) ? pts[0] : pts[n];
  4877. var p1 = (start) ? pts[1] : pts[n - 1];
  4878. var dx = (start) ? p1.x - p0.x : p1.x - p0.x;
  4879. var dy = (start) ? p1.y - p0.y : p1.y - p0.y;
  4880. var dist = Math.sqrt(dx * dx + dy * dy);
  4881. pt.x = (pt.x + tr.x) * s;
  4882. pt.y = (pt.y + tr.y) * s;
  4883. setPosition.call(this, dist, dx / dist, dy / dist, p0, p1, pt, me);
  4884. });
  4885. };
  4886. function createEdgeWidthHandle(state, start, spacing)
  4887. {
  4888. return createEdgeHandle(state, ['width'], start, function(dist, nx, ny, p0, p1)
  4889. {
  4890. var w = state.shape.getEdgeWidth() * state.view.scale + spacing;
  4891. return new mxPoint(p0.x + nx * dist / 4 + ny * w / 2, p0.y + ny * dist / 4 - nx * w / 2);
  4892. }, function(dist, nx, ny, p0, p1, pt)
  4893. {
  4894. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  4895. state.style['width'] = Math.round(w * 2) / state.view.scale - spacing;
  4896. });
  4897. };
  4898. function ptLineDistance(x1, y1, x2, y2, x0, y0)
  4899. {
  4900. return Math.abs((y2 - y1) * x0 - (x2 - x1) * y0 + x2 * y1 - y2 * x1) / Math.sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
  4901. }
  4902. var handleFactory = {
  4903. 'link': function(state)
  4904. {
  4905. var spacing = 10;
  4906. return [createEdgeWidthHandle(state, true, spacing), createEdgeWidthHandle(state, false, spacing)];
  4907. },
  4908. 'flexArrow': function(state)
  4909. {
  4910. // Do not use state.shape.startSize/endSize since it is cached
  4911. var tol = state.view.graph.gridSize / state.view.scale;
  4912. var handles = [];
  4913. if (mxUtils.getValue(state.style, mxConstants.STYLE_STARTARROW, mxConstants.NONE) != mxConstants.NONE)
  4914. {
  4915. handles.push(createEdgeHandle(state, ['width', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], true, function(dist, nx, ny, p0, p1)
  4916. {
  4917. var w = (state.shape.getEdgeWidth() - state.shape.strokewidth) * state.view.scale;
  4918. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  4919. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) + ny * w / 2,
  4920. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) - nx * w / 2);
  4921. }, function(dist, nx, ny, p0, p1, pt, me)
  4922. {
  4923. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  4924. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  4925. state.style[mxConstants.STYLE_STARTSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  4926. state.style['width'] = Math.round(w * 2) / state.view.scale;
  4927. // Applies to opposite side
  4928. if (mxEvent.isControlDown(me.getEvent()))
  4929. {
  4930. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  4931. }
  4932. // Snaps to end geometry
  4933. if (!mxEvent.isAltDown(me.getEvent()))
  4934. {
  4935. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_STARTSIZE]) - parseFloat(state.style[mxConstants.STYLE_ENDSIZE])) < tol / 6)
  4936. {
  4937. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  4938. }
  4939. }
  4940. }));
  4941. handles.push(createEdgeHandle(state, ['startWidth', 'endWidth', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], true, function(dist, nx, ny, p0, p1)
  4942. {
  4943. var w = (state.shape.getStartArrowWidth() - state.shape.strokewidth) * state.view.scale;
  4944. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  4945. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) + ny * w / 2,
  4946. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) - nx * w / 2);
  4947. }, function(dist, nx, ny, p0, p1, pt, me)
  4948. {
  4949. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  4950. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  4951. state.style[mxConstants.STYLE_STARTSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  4952. state.style['startWidth'] = Math.max(0, Math.round(w * 2) - state.shape.getEdgeWidth()) / state.view.scale;
  4953. // Applies to opposite side
  4954. if (mxEvent.isControlDown(me.getEvent()))
  4955. {
  4956. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  4957. state.style['endWidth'] = state.style['startWidth'];
  4958. }
  4959. // Snaps to endWidth
  4960. if (!mxEvent.isAltDown(me.getEvent()))
  4961. {
  4962. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_STARTSIZE]) - parseFloat(state.style[mxConstants.STYLE_ENDSIZE])) < tol / 6)
  4963. {
  4964. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  4965. }
  4966. if (Math.abs(parseFloat(state.style['startWidth']) - parseFloat(state.style['endWidth'])) < tol)
  4967. {
  4968. state.style['startWidth'] = state.style['endWidth'];
  4969. }
  4970. }
  4971. }));
  4972. }
  4973. if (mxUtils.getValue(state.style, mxConstants.STYLE_ENDARROW, mxConstants.NONE) != mxConstants.NONE)
  4974. {
  4975. handles.push(createEdgeHandle(state, ['width', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], false, function(dist, nx, ny, p0, p1)
  4976. {
  4977. var w = (state.shape.getEdgeWidth() - state.shape.strokewidth) * state.view.scale;
  4978. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_ENDSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  4979. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) - ny * w / 2,
  4980. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) + nx * w / 2);
  4981. }, function(dist, nx, ny, p0, p1, pt, me)
  4982. {
  4983. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  4984. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  4985. state.style[mxConstants.STYLE_ENDSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  4986. state.style['width'] = Math.round(w * 2) / state.view.scale;
  4987. // Applies to opposite side
  4988. if (mxEvent.isControlDown(me.getEvent()))
  4989. {
  4990. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  4991. }
  4992. // Snaps to start geometry
  4993. if (!mxEvent.isAltDown(me.getEvent()))
  4994. {
  4995. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_ENDSIZE]) - parseFloat(state.style[mxConstants.STYLE_STARTSIZE])) < tol / 6)
  4996. {
  4997. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  4998. }
  4999. }
  5000. }));
  5001. handles.push(createEdgeHandle(state, ['startWidth', 'endWidth', mxConstants.STYLE_STARTSIZE, mxConstants.STYLE_ENDSIZE], false, function(dist, nx, ny, p0, p1)
  5002. {
  5003. var w = (state.shape.getEndArrowWidth() - state.shape.strokewidth) * state.view.scale;
  5004. var l = mxUtils.getNumber(state.style, mxConstants.STYLE_ENDSIZE, mxConstants.ARROW_SIZE / 5) * 3 * state.view.scale;
  5005. return new mxPoint(p0.x + nx * (l + state.shape.strokewidth * state.view.scale) - ny * w / 2,
  5006. p0.y + ny * (l + state.shape.strokewidth * state.view.scale) + nx * w / 2);
  5007. }, function(dist, nx, ny, p0, p1, pt, me)
  5008. {
  5009. var w = Math.sqrt(mxUtils.ptSegDistSq(p0.x, p0.y, p1.x, p1.y, pt.x, pt.y));
  5010. var l = mxUtils.ptLineDist(p0.x, p0.y, p0.x + ny, p0.y - nx, pt.x, pt.y);
  5011. state.style[mxConstants.STYLE_ENDSIZE] = Math.round((l - state.shape.strokewidth) * 100 / 3) / 100 / state.view.scale;
  5012. state.style['endWidth'] = Math.max(0, Math.round(w * 2) - state.shape.getEdgeWidth()) / state.view.scale;
  5013. // Applies to opposite side
  5014. if (mxEvent.isControlDown(me.getEvent()))
  5015. {
  5016. state.style[mxConstants.STYLE_STARTSIZE] = state.style[mxConstants.STYLE_ENDSIZE];
  5017. state.style['startWidth'] = state.style['endWidth'];
  5018. }
  5019. // Snaps to start geometry
  5020. if (!mxEvent.isAltDown(me.getEvent()))
  5021. {
  5022. if (Math.abs(parseFloat(state.style[mxConstants.STYLE_ENDSIZE]) - parseFloat(state.style[mxConstants.STYLE_STARTSIZE])) < tol / 6)
  5023. {
  5024. state.style[mxConstants.STYLE_ENDSIZE] = state.style[mxConstants.STYLE_STARTSIZE];
  5025. }
  5026. if (Math.abs(parseFloat(state.style['endWidth']) - parseFloat(state.style['startWidth'])) < tol)
  5027. {
  5028. state.style['endWidth'] = state.style['startWidth'];
  5029. }
  5030. }
  5031. }));
  5032. }
  5033. return handles;
  5034. },
  5035. 'swimlane': function(state)
  5036. {
  5037. var handles = [];
  5038. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED))
  5039. {
  5040. var size = parseFloat(mxUtils.getValue(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_STARTSIZE));
  5041. handles.push(createArcHandle(state, size / 2));
  5042. }
  5043. // Start size handle must be last item in handles for hover to work in tables (see mouse event handler in Graph)
  5044. handles.push(createHandle(state, [mxConstants.STYLE_STARTSIZE], function(bounds)
  5045. {
  5046. var size = parseFloat(mxUtils.getValue(state.style, mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_STARTSIZE));
  5047. if (mxUtils.getValue(state.style, mxConstants.STYLE_HORIZONTAL, 1) == 1)
  5048. {
  5049. return new mxPoint(bounds.getCenterX(), bounds.y + Math.max(0, Math.min(bounds.height, size)));
  5050. }
  5051. else
  5052. {
  5053. return new mxPoint(bounds.x + Math.max(0, Math.min(bounds.width, size)), bounds.getCenterY());
  5054. }
  5055. }, function(bounds, pt)
  5056. {
  5057. state.style[mxConstants.STYLE_STARTSIZE] =
  5058. (mxUtils.getValue(this.state.style, mxConstants.STYLE_HORIZONTAL, 1) == 1) ?
  5059. Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y))) :
  5060. Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x)));
  5061. }, false, null, function(me)
  5062. {
  5063. if (mxEvent.isControlDown(me.getEvent()))
  5064. {
  5065. var graph = state.view.graph;
  5066. if (graph.isTableRow(state.cell) || graph.isTableCell(state.cell))
  5067. {
  5068. var dir = graph.getSwimlaneDirection(state.style);
  5069. var parent = graph.model.getParent(state.cell);
  5070. var cells = graph.model.getChildCells(parent, true);
  5071. var temp = [];
  5072. for (var i = 0; i < cells.length; i++)
  5073. {
  5074. // Finds siblings with the same direction and to set start size
  5075. if (cells[i] != state.cell && graph.isSwimlane(cells[i]) &&
  5076. graph.getSwimlaneDirection(graph.getCurrentCellStyle(
  5077. cells[i])) == dir)
  5078. {
  5079. temp.push(cells[i]);
  5080. }
  5081. }
  5082. graph.setCellStyles(mxConstants.STYLE_STARTSIZE,
  5083. state.style[mxConstants.STYLE_STARTSIZE], temp);
  5084. }
  5085. }
  5086. }));
  5087. return handles;
  5088. },
  5089. 'label': createArcHandleFunction(),
  5090. 'ext': createArcHandleFunction(),
  5091. 'rectangle': createArcHandleFunction(),
  5092. 'triangle': createArcHandleFunction(),
  5093. 'rhombus': createArcHandleFunction(),
  5094. 'umlLifeline': function(state)
  5095. {
  5096. return [createHandle(state, ['size'], function(bounds)
  5097. {
  5098. var size = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'size', UmlLifeline.prototype.size))));
  5099. return new mxPoint(bounds.getCenterX(), bounds.y + size);
  5100. }, function(bounds, pt)
  5101. {
  5102. this.state.style['size'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  5103. }, false)];
  5104. },
  5105. 'umlFrame': function(state)
  5106. {
  5107. var handles = [createHandle(state, ['width', 'height'], function(bounds)
  5108. {
  5109. var w0 = Math.max(UmlFrame.prototype.corner, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'width', UmlFrame.prototype.width)));
  5110. var h0 = Math.max(UmlFrame.prototype.corner * 1.5, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'height', UmlFrame.prototype.height)));
  5111. return new mxPoint(bounds.x + w0, bounds.y + h0);
  5112. }, function(bounds, pt)
  5113. {
  5114. this.state.style['width'] = Math.round(Math.max(UmlFrame.prototype.corner, Math.min(bounds.width, pt.x - bounds.x)));
  5115. this.state.style['height'] = Math.round(Math.max(UmlFrame.prototype.corner * 1.5, Math.min(bounds.height, pt.y - bounds.y)));
  5116. }, false)];
  5117. return handles;
  5118. },
  5119. 'process': function(state)
  5120. {
  5121. var handles = [createHandle(state, ['size'], function(bounds)
  5122. {
  5123. var fixed = mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0';
  5124. var size = parseFloat(mxUtils.getValue(this.state.style, 'size', ProcessShape.prototype.size));
  5125. return (fixed) ? new mxPoint(bounds.x + size, bounds.y + bounds.height / 4) : new mxPoint(bounds.x + bounds.width * size, bounds.y + bounds.height / 4);
  5126. }, function(bounds, pt)
  5127. {
  5128. var fixed = mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0';
  5129. 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));
  5130. this.state.style['size'] = size;
  5131. }, false)];
  5132. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  5133. {
  5134. handles.push(createArcHandle(state));
  5135. }
  5136. return handles;
  5137. },
  5138. 'cross': function(state)
  5139. {
  5140. return [createHandle(state, ['size'], function(bounds)
  5141. {
  5142. var m = Math.min(bounds.width, bounds.height);
  5143. var size = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'size', CrossShape.prototype.size))) * m / 2;
  5144. return new mxPoint(bounds.getCenterX() - size, bounds.getCenterY() - size);
  5145. }, function(bounds, pt)
  5146. {
  5147. var m = Math.min(bounds.width, bounds.height);
  5148. this.state.style['size'] = Math.max(0, Math.min(1, Math.min((Math.max(0, bounds.getCenterY() - pt.y) / m) * 2,
  5149. (Math.max(0, bounds.getCenterX() - pt.x) / m) * 2)));
  5150. })];
  5151. },
  5152. 'note': function(state)
  5153. {
  5154. return [createHandle(state, ['size'], function(bounds)
  5155. {
  5156. var size = Math.max(0, Math.min(bounds.width, Math.min(bounds.height, parseFloat(
  5157. mxUtils.getValue(this.state.style, 'size', NoteShape.prototype.size)))));
  5158. return new mxPoint(bounds.x + bounds.width - size, bounds.y + size);
  5159. }, function(bounds, pt)
  5160. {
  5161. this.state.style['size'] = Math.round(Math.max(0, Math.min(Math.min(bounds.width, bounds.x + bounds.width - pt.x),
  5162. Math.min(bounds.height, pt.y - bounds.y))));
  5163. })];
  5164. },
  5165. 'note2': function(state)
  5166. {
  5167. return [createHandle(state, ['size'], function(bounds)
  5168. {
  5169. var size = Math.max(0, Math.min(bounds.width, Math.min(bounds.height, parseFloat(
  5170. mxUtils.getValue(this.state.style, 'size', NoteShape2.prototype.size)))));
  5171. return new mxPoint(bounds.x + bounds.width - size, bounds.y + size);
  5172. }, function(bounds, pt)
  5173. {
  5174. this.state.style['size'] = Math.round(Math.max(0, Math.min(Math.min(bounds.width, bounds.x + bounds.width - pt.x),
  5175. Math.min(bounds.height, pt.y - bounds.y))));
  5176. })];
  5177. },
  5178. 'manualInput': function(state)
  5179. {
  5180. var handles = [createHandle(state, ['size'], function(bounds)
  5181. {
  5182. var size = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'size', ManualInputShape.prototype.size)));
  5183. return new mxPoint(bounds.x + bounds.width / 4, bounds.y + size * 3 / 4);
  5184. }, function(bounds, pt)
  5185. {
  5186. this.state.style['size'] = Math.round(Math.max(0, Math.min(bounds.height, (pt.y - bounds.y) * 4 / 3)));
  5187. }, false)];
  5188. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  5189. {
  5190. handles.push(createArcHandle(state));
  5191. }
  5192. return handles;
  5193. },
  5194. 'dataStorage': function(state)
  5195. {
  5196. return [createHandle(state, ['size'], function(bounds)
  5197. {
  5198. var fixed = mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0';
  5199. var size = parseFloat(mxUtils.getValue(this.state.style, 'size', (fixed) ? DataStorageShape.prototype.fixedSize : DataStorageShape.prototype.size));
  5200. return new mxPoint(bounds.x + bounds.width - size * ((fixed) ? 1 : bounds.width), bounds.getCenterY());
  5201. }, function(bounds, pt)
  5202. {
  5203. var fixed = mxUtils.getValue(this.state.style, 'fixedSize', '0') != '0';
  5204. 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));
  5205. this.state.style['size'] = size;
  5206. }, false)];
  5207. },
  5208. 'callout': function(state)
  5209. {
  5210. var handles = [createHandle(state, ['size', 'position'], function(bounds)
  5211. {
  5212. var size = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'size', CalloutShape.prototype.size)));
  5213. var position = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'position', CalloutShape.prototype.position)));
  5214. var base = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'base', CalloutShape.prototype.base)));
  5215. return new mxPoint(bounds.x + position * bounds.width, bounds.y + bounds.height - size);
  5216. }, function(bounds, pt)
  5217. {
  5218. var base = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'base', CalloutShape.prototype.base)));
  5219. this.state.style['size'] = Math.round(Math.max(0, Math.min(bounds.height, bounds.y + bounds.height - pt.y)));
  5220. this.state.style['position'] = Math.round(Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width)) * 100) / 100;
  5221. }, false), createHandle(state, ['position2'], function(bounds)
  5222. {
  5223. var position2 = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'position2', CalloutShape.prototype.position2)));
  5224. return new mxPoint(bounds.x + position2 * bounds.width, bounds.y + bounds.height);
  5225. }, function(bounds, pt)
  5226. {
  5227. this.state.style['position2'] = Math.round(Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width)) * 100) / 100;
  5228. }, false), createHandle(state, ['base'], function(bounds)
  5229. {
  5230. var size = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'size', CalloutShape.prototype.size)));
  5231. var position = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'position', CalloutShape.prototype.position)));
  5232. var base = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'base', CalloutShape.prototype.base)));
  5233. return new mxPoint(bounds.x + Math.min(bounds.width, position * bounds.width + base), bounds.y + bounds.height - size);
  5234. }, function(bounds, pt)
  5235. {
  5236. var position = Math.max(0, Math.min(1, mxUtils.getValue(this.state.style, 'position', CalloutShape.prototype.position)));
  5237. this.state.style['base'] = Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x - position * bounds.width)));
  5238. }, false)];
  5239. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  5240. {
  5241. handles.push(createArcHandle(state));
  5242. }
  5243. return handles;
  5244. },
  5245. 'internalStorage': function(state)
  5246. {
  5247. var handles = [createHandle(state, ['dx', 'dy'], function(bounds)
  5248. {
  5249. var dx = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'dx', InternalStorageShape.prototype.dx)));
  5250. var dy = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'dy', InternalStorageShape.prototype.dy)));
  5251. return new mxPoint(bounds.x + dx, bounds.y + dy);
  5252. }, function(bounds, pt)
  5253. {
  5254. this.state.style['dx'] = Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x)));
  5255. this.state.style['dy'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  5256. }, false)];
  5257. if (mxUtils.getValue(state.style, mxConstants.STYLE_ROUNDED, false))
  5258. {
  5259. handles.push(createArcHandle(state));
  5260. }
  5261. return handles;
  5262. },
  5263. 'module': function(state)
  5264. {
  5265. var handles = [createHandle(state, ['jettyWidth', 'jettyHeight'], function(bounds)
  5266. {
  5267. var dx = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'jettyWidth', ModuleShape.prototype.jettyWidth)));
  5268. var dy = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'jettyHeight', ModuleShape.prototype.jettyHeight)));
  5269. return new mxPoint(bounds.x + dx / 2, bounds.y + dy * 2);
  5270. }, function(bounds, pt)
  5271. {
  5272. this.state.style['jettyWidth'] = Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x)) * 2);
  5273. this.state.style['jettyHeight'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)) / 2);
  5274. })];
  5275. return handles;
  5276. },
  5277. 'corner': function(state)
  5278. {
  5279. return [createHandle(state, ['dx', 'dy'], function(bounds)
  5280. {
  5281. var dx = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'dx', CornerShape.prototype.dx)));
  5282. var dy = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'dy', CornerShape.prototype.dy)));
  5283. return new mxPoint(bounds.x + dx, bounds.y + dy);
  5284. }, function(bounds, pt)
  5285. {
  5286. this.state.style['dx'] = Math.round(Math.max(0, Math.min(bounds.width, pt.x - bounds.x)));
  5287. this.state.style['dy'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  5288. }, false)];
  5289. },
  5290. 'tee': function(state)
  5291. {
  5292. return [createHandle(state, ['dx', 'dy'], function(bounds)
  5293. {
  5294. var dx = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'dx', TeeShape.prototype.dx)));
  5295. var dy = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'dy', TeeShape.prototype.dy)));
  5296. return new mxPoint(bounds.x + (bounds.width + dx) / 2, bounds.y + dy);
  5297. }, function(bounds, pt)
  5298. {
  5299. this.state.style['dx'] = Math.round(Math.max(0, Math.min(bounds.width / 2, (pt.x - bounds.x - bounds.width / 2)) * 2));
  5300. this.state.style['dy'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  5301. }, false)];
  5302. },
  5303. 'singleArrow': createArrowHandleFunction(1),
  5304. 'doubleArrow': createArrowHandleFunction(0.5),
  5305. 'folder': function(state)
  5306. {
  5307. return [createHandle(state, ['tabWidth', 'tabHeight'], function(bounds)
  5308. {
  5309. var tw = Math.max(0, Math.min(bounds.width, mxUtils.getValue(this.state.style, 'tabWidth', FolderShape.prototype.tabWidth)));
  5310. var th = Math.max(0, Math.min(bounds.height, mxUtils.getValue(this.state.style, 'tabHeight', FolderShape.prototype.tabHeight)));
  5311. if (mxUtils.getValue(this.state.style, 'tabPosition', FolderShape.prototype.tabPosition) == mxConstants.ALIGN_RIGHT)
  5312. {
  5313. tw = bounds.width - tw;
  5314. }
  5315. return new mxPoint(bounds.x + tw, bounds.y + th);
  5316. }, function(bounds, pt)
  5317. {
  5318. var tw = Math.max(0, Math.min(bounds.width, pt.x - bounds.x));
  5319. if (mxUtils.getValue(this.state.style, 'tabPosition', FolderShape.prototype.tabPosition) == mxConstants.ALIGN_RIGHT)
  5320. {
  5321. tw = bounds.width - tw;
  5322. }
  5323. this.state.style['tabWidth'] = Math.round(tw);
  5324. this.state.style['tabHeight'] = Math.round(Math.max(0, Math.min(bounds.height, pt.y - bounds.y)));
  5325. }, false)];
  5326. },
  5327. 'document': function(state)
  5328. {
  5329. return [createHandle(state, ['size'], function(bounds)
  5330. {
  5331. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', DocumentShape.prototype.size))));
  5332. return new mxPoint(bounds.x + 3 * bounds.width / 4, bounds.y + (1 - size) * bounds.height);
  5333. }, function(bounds, pt)
  5334. {
  5335. this.state.style['size'] = Math.max(0, Math.min(1, (bounds.y + bounds.height - pt.y) / bounds.height));
  5336. }, false)];
  5337. },
  5338. 'tape': function(state)
  5339. {
  5340. return [createHandle(state, ['size'], function(bounds)
  5341. {
  5342. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', TapeShape.prototype.size))));
  5343. return new mxPoint(bounds.getCenterX(), bounds.y + size * bounds.height / 2);
  5344. }, function(bounds, pt)
  5345. {
  5346. this.state.style['size'] = Math.max(0, Math.min(1, ((pt.y - bounds.y) / bounds.height) * 2));
  5347. }, false)];
  5348. },
  5349. 'isoCube2' : function(state)
  5350. {
  5351. return [createHandle(state, ['isoAngle'], function(bounds)
  5352. {
  5353. var isoAngle = Math.max(0.01, Math.min(94, parseFloat(mxUtils.getValue(this.state.style, 'isoAngle', IsoCubeShape2.isoAngle)))) * Math.PI / 200 ;
  5354. var isoH = Math.min(bounds.width * Math.tan(isoAngle), bounds.height * 0.5);
  5355. return new mxPoint(bounds.x, bounds.y + isoH);
  5356. }, function(bounds, pt)
  5357. {
  5358. this.state.style['isoAngle'] = Math.max(0, (pt.y - bounds.y) * 50 / bounds.height);
  5359. }, true)];
  5360. },
  5361. 'cylinder2' : createCylinderHandleFunction(CylinderShape.prototype.size),
  5362. 'cylinder3' : createCylinderHandleFunction(CylinderShape3.prototype.size),
  5363. 'offPageConnector': function(state)
  5364. {
  5365. return [createHandle(state, ['size'], function(bounds)
  5366. {
  5367. var size = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'size', OffPageConnectorShape.prototype.size))));
  5368. return new mxPoint(bounds.getCenterX(), bounds.y + (1 - size) * bounds.height);
  5369. }, function(bounds, pt)
  5370. {
  5371. this.state.style['size'] = Math.max(0, Math.min(1, (bounds.y + bounds.height - pt.y) / bounds.height));
  5372. }, false)];
  5373. },
  5374. 'mxgraph.basic.rect': function(state)
  5375. {
  5376. var handles = [Graph.createHandle(state, ['size'], function(bounds)
  5377. {
  5378. var size = Math.max(0, Math.min(bounds.width / 2, bounds.height / 2, parseFloat(mxUtils.getValue(this.state.style, 'size', this.size))));
  5379. return new mxPoint(bounds.x + size, bounds.y + size);
  5380. }, function(bounds, pt)
  5381. {
  5382. this.state.style['size'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, pt.x - bounds.x))) / 100;
  5383. })];
  5384. var handle2 = Graph.createHandle(state, ['indent'], function(bounds)
  5385. {
  5386. var dx2 = Math.max(0, Math.min(100, parseFloat(mxUtils.getValue(this.state.style, 'indent', this.dx2))));
  5387. return new mxPoint(bounds.x + bounds.width * 0.75, bounds.y + dx2 * bounds.height / 200);
  5388. }, function(bounds, pt)
  5389. {
  5390. this.state.style['indent'] = Math.round(100 * Math.max(0, Math.min(100, 200 * (pt.y - bounds.y) / bounds.height))) / 100;
  5391. });
  5392. handles.push(handle2);
  5393. return handles;
  5394. },
  5395. 'step': createDisplayHandleFunction(StepShape.prototype.size, true, null, true, StepShape.prototype.fixedSize),
  5396. 'hexagon': createDisplayHandleFunction(HexagonShape.prototype.size, true, 0.5, true, HexagonShape.prototype.fixedSize),
  5397. 'curlyBracket': createDisplayHandleFunction(CurlyBracketShape.prototype.size, false),
  5398. 'display': createDisplayHandleFunction(DisplayShape.prototype.size, false),
  5399. 'cube': createCubeHandleFunction(1, CubeShape.prototype.size, false),
  5400. 'card': createCubeHandleFunction(0.5, CardShape.prototype.size, true),
  5401. 'loopLimit': createCubeHandleFunction(0.5, LoopLimitShape.prototype.size, true),
  5402. 'trapezoid': createTrapezoidHandleFunction(0.5, TrapezoidShape.prototype.size, TrapezoidShape.prototype.fixedSize),
  5403. 'parallelogram': createTrapezoidHandleFunction(1, ParallelogramShape.prototype.size, ParallelogramShape.prototype.fixedSize)
  5404. };
  5405. // Exposes custom handles
  5406. Graph.createHandle = createHandle;
  5407. Graph.handleFactory = handleFactory;
  5408. var vertexHandlerCreateCustomHandles = mxVertexHandler.prototype.createCustomHandles;
  5409. mxVertexHandler.prototype.createCustomHandles = function()
  5410. {
  5411. var handles = vertexHandlerCreateCustomHandles.apply(this, arguments);
  5412. if (this.graph.isCellRotatable(this.state.cell))
  5413. // LATER: Make locked state independent of rotatable flag, fix toggle if default is false
  5414. //if (this.graph.isCellResizable(this.state.cell) || this.graph.isCellMovable(this.state.cell))
  5415. {
  5416. var name = this.state.style['shape'];
  5417. if (mxCellRenderer.defaultShapes[name] == null &&
  5418. mxStencilRegistry.getStencil(name) == null)
  5419. {
  5420. name = mxConstants.SHAPE_RECTANGLE;
  5421. }
  5422. else if (this.state.view.graph.isSwimlane(this.state.cell))
  5423. {
  5424. name = mxConstants.SHAPE_SWIMLANE;
  5425. }
  5426. var fn = handleFactory[name];
  5427. if (fn == null && this.state.shape != null && this.state.shape.isRoundable())
  5428. {
  5429. fn = handleFactory[mxConstants.SHAPE_RECTANGLE];
  5430. }
  5431. if (fn != null)
  5432. {
  5433. var temp = fn(this.state);
  5434. if (temp != null)
  5435. {
  5436. if (handles == null)
  5437. {
  5438. handles = temp;
  5439. }
  5440. else
  5441. {
  5442. handles = handles.concat(temp);
  5443. }
  5444. }
  5445. }
  5446. }
  5447. return handles;
  5448. };
  5449. mxEdgeHandler.prototype.createCustomHandles = function()
  5450. {
  5451. var name = this.state.style['shape'];
  5452. if (mxCellRenderer.defaultShapes[name] == null &&
  5453. mxStencilRegistry.getStencil(name) == null)
  5454. {
  5455. name = mxConstants.SHAPE_CONNECTOR;
  5456. }
  5457. var fn = handleFactory[name];
  5458. if (fn != null)
  5459. {
  5460. return fn(this.state);
  5461. }
  5462. return null;
  5463. }
  5464. }
  5465. else
  5466. {
  5467. // Dummy entries to avoid NPE in embed mode
  5468. Graph.createHandle = function() {};
  5469. Graph.handleFactory = {};
  5470. }
  5471. var isoHVector = new mxPoint(1, 0);
  5472. var isoVVector = new mxPoint(1, 0);
  5473. var alpha1 = mxUtils.toRadians(-30);
  5474. var cos1 = Math.cos(alpha1);
  5475. var sin1 = Math.sin(alpha1);
  5476. isoHVector = mxUtils.getRotatedPoint(isoHVector, cos1, sin1);
  5477. var alpha2 = mxUtils.toRadians(-150);
  5478. var cos2 = Math.cos(alpha2);
  5479. var sin2 = Math.sin(alpha2);
  5480. isoVVector = mxUtils.getRotatedPoint(isoVVector, cos2, sin2);
  5481. mxEdgeStyle.IsometricConnector = function (state, source, target, points, result)
  5482. {
  5483. var view = state.view;
  5484. var pt = (points != null && points.length > 0) ? points[0] : null;
  5485. var pts = state.absolutePoints;
  5486. var p0 = pts[0];
  5487. var pe = pts[pts.length-1];
  5488. if (pt != null)
  5489. {
  5490. pt = view.transformControlPoint(state, pt);
  5491. }
  5492. if (p0 == null)
  5493. {
  5494. if (source != null)
  5495. {
  5496. p0 = new mxPoint(source.getCenterX(), source.getCenterY());
  5497. }
  5498. }
  5499. if (pe == null)
  5500. {
  5501. if (target != null)
  5502. {
  5503. pe = new mxPoint(target.getCenterX(), target.getCenterY());
  5504. }
  5505. }
  5506. var a1 = isoHVector.x;
  5507. var a2 = isoHVector.y;
  5508. var b1 = isoVVector.x;
  5509. var b2 = isoVVector.y;
  5510. var elbow = mxUtils.getValue(state.style, 'elbow', 'horizontal') == 'horizontal';
  5511. if (pe != null && p0 != null)
  5512. {
  5513. var last = p0;
  5514. function isoLineTo(x, y, ignoreFirst)
  5515. {
  5516. var c1 = x - last.x;
  5517. var c2 = y - last.y;
  5518. // Solves for isometric base vectors
  5519. var h = (b2 * c1 - b1 * c2) / (a1 * b2 - a2 * b1);
  5520. var v = (a2 * c1 - a1 * c2) / (a2 * b1 - a1 * b2);
  5521. if (elbow)
  5522. {
  5523. if (ignoreFirst)
  5524. {
  5525. last = new mxPoint(last.x + a1 * h, last.y + a2 * h);
  5526. result.push(last);
  5527. }
  5528. last = new mxPoint(last.x + b1 * v, last.y + b2 * v);
  5529. result.push(last);
  5530. }
  5531. else
  5532. {
  5533. if (ignoreFirst)
  5534. {
  5535. last = new mxPoint(last.x + b1 * v, last.y + b2 * v);
  5536. result.push(last);
  5537. }
  5538. last = new mxPoint(last.x + a1 * h, last.y + a2 * h);
  5539. result.push(last);
  5540. }
  5541. };
  5542. if (pt == null)
  5543. {
  5544. pt = new mxPoint(p0.x + (pe.x - p0.x) / 2, p0.y + (pe.y - p0.y) / 2);
  5545. }
  5546. isoLineTo(pt.x, pt.y, true);
  5547. isoLineTo(pe.x, pe.y, false);
  5548. }
  5549. };
  5550. mxStyleRegistry.putValue('isometricEdgeStyle', mxEdgeStyle.IsometricConnector);
  5551. var graphCreateEdgeHandler = Graph.prototype.createEdgeHandler;
  5552. Graph.prototype.createEdgeHandler = function(state, edgeStyle)
  5553. {
  5554. if (edgeStyle == mxEdgeStyle.IsometricConnector)
  5555. {
  5556. var handler = new mxElbowEdgeHandler(state);
  5557. handler.snapToTerminals = false;
  5558. return handler;
  5559. }
  5560. return graphCreateEdgeHandler.apply(this, arguments);
  5561. };
  5562. // Defines connection points for all shapes
  5563. IsoRectangleShape.prototype.constraints = [];
  5564. IsoCubeShape.prototype.getConstraints = function(style, w, h)
  5565. {
  5566. var constr = [];
  5567. var tan30 = Math.tan(mxUtils.toRadians(30));
  5568. var tan30Dx = (0.5 - tan30) / 2;
  5569. var m = Math.min(w, h / (0.5 + tan30));
  5570. var dx = (w - m) / 2;
  5571. var dy = (h - m) / 2;
  5572. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, dy + 0.25 * m));
  5573. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + 0.5 * m, dy + m * tan30Dx));
  5574. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + m, dy + 0.25 * m));
  5575. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + m, dy + 0.75 * m));
  5576. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx + 0.5 * m, dy + (1 - tan30Dx) * m));
  5577. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, dy + 0.75 * m));
  5578. return (constr);
  5579. };
  5580. IsoCubeShape2.prototype.getConstraints = function(style, w, h)
  5581. {
  5582. var constr = [];
  5583. var isoAngle = Math.max(0.01, Math.min(94, parseFloat(mxUtils.getValue(this.style, 'isoAngle', this.isoAngle)))) * Math.PI / 200 ;
  5584. var isoH = Math.min(w * Math.tan(isoAngle), h * 0.5);
  5585. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  5586. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, isoH));
  5587. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  5588. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h - isoH));
  5589. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  5590. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - isoH));
  5591. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  5592. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, isoH));
  5593. return (constr);
  5594. }
  5595. CalloutShape.prototype.getConstraints = function(style, w, h)
  5596. {
  5597. var constr = [];
  5598. var arcSize = mxUtils.getValue(this.style, mxConstants.STYLE_ARCSIZE, mxConstants.LINE_ARCSIZE) / 2;
  5599. var s = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  5600. var dx = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'position', this.position))));
  5601. var dx2 = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'position2', this.position2))));
  5602. var base = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'base', this.base))));
  5603. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  5604. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
  5605. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  5606. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
  5607. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  5608. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - s) * 0.5));
  5609. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h - s));
  5610. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2, h));
  5611. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - s));
  5612. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - s) * 0.5));
  5613. if (w >= s * 2)
  5614. {
  5615. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  5616. }
  5617. return (constr);
  5618. };
  5619. mxRectangleShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0), true),
  5620. new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  5621. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  5622. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  5623. new mxConnectionConstraint(new mxPoint(1, 0), true),
  5624. new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  5625. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  5626. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  5627. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  5628. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  5629. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  5630. new mxConnectionConstraint(new mxPoint(0, 1), true),
  5631. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  5632. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  5633. new mxConnectionConstraint(new mxPoint(0.75, 1), true),
  5634. new mxConnectionConstraint(new mxPoint(1, 1), true)];
  5635. mxEllipse.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0), true), new mxConnectionConstraint(new mxPoint(1, 0), true),
  5636. new mxConnectionConstraint(new mxPoint(0, 1), true), new mxConnectionConstraint(new mxPoint(1, 1), true),
  5637. new mxConnectionConstraint(new mxPoint(0.5, 0), true), new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  5638. new mxConnectionConstraint(new mxPoint(0, 0.5), true), new mxConnectionConstraint(new mxPoint(1, 0.5))];
  5639. PartialRectangleShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  5640. mxImageShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  5641. mxSwimlane.prototype.constraints = mxRectangleShape.prototype.constraints;
  5642. PlusShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  5643. mxLabel.prototype.constraints = mxRectangleShape.prototype.constraints;
  5644. NoteShape.prototype.getConstraints = function(style, w, h)
  5645. {
  5646. var constr = [];
  5647. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  5648. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  5649. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - s) * 0.5, 0));
  5650. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - s, 0));
  5651. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - s * 0.5, s * 0.5));
  5652. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, s));
  5653. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h + s) * 0.5 ));
  5654. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  5655. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  5656. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  5657. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  5658. if (w >= s * 2)
  5659. {
  5660. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  5661. }
  5662. return (constr);
  5663. };
  5664. CardShape.prototype.getConstraints = function(style, w, h)
  5665. {
  5666. var constr = [];
  5667. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  5668. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  5669. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + s) * 0.5, 0));
  5670. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, s, 0));
  5671. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, s * 0.5, s * 0.5));
  5672. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, s));
  5673. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h + s) * 0.5 ));
  5674. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  5675. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  5676. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  5677. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  5678. if (w >= s * 2)
  5679. {
  5680. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  5681. }
  5682. return (constr);
  5683. };
  5684. CubeShape.prototype.getConstraints = function(style, w, h)
  5685. {
  5686. var constr = [];
  5687. var s = Math.max(0, Math.min(w, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size)))));
  5688. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  5689. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - s) * 0.5, 0));
  5690. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - s, 0));
  5691. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - s * 0.5, s * 0.5));
  5692. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, s));
  5693. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h + s) * 0.5));
  5694. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  5695. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + s) * 0.5, h));
  5696. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, s, h));
  5697. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, s * 0.5, h - s * 0.5));
  5698. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - s));
  5699. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - s) * 0.5));
  5700. return (constr);
  5701. };
  5702. CylinderShape3.prototype.getConstraints = function(style, w, h)
  5703. {
  5704. var constr = [];
  5705. var s = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  5706. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  5707. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  5708. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  5709. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  5710. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, s));
  5711. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, 0, s));
  5712. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false, null, 0, -s));
  5713. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false, null, 0, -s));
  5714. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, s + (h * 0.5 - s) * 0.5));
  5715. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, 0, s + (h * 0.5 - s) * 0.5));
  5716. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, 0, h - s - (h * 0.5 - s) * 0.5));
  5717. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - s - (h * 0.5 - s) * 0.5));
  5718. constr.push(new mxConnectionConstraint(new mxPoint(0.145, 0), false, null, 0, s * 0.29));
  5719. constr.push(new mxConnectionConstraint(new mxPoint(0.855, 0), false, null, 0, s * 0.29));
  5720. constr.push(new mxConnectionConstraint(new mxPoint(0.855, 1), false, null, 0, -s * 0.29));
  5721. constr.push(new mxConnectionConstraint(new mxPoint(0.145, 1), false, null, 0, -s * 0.29));
  5722. return (constr);
  5723. };
  5724. FolderShape.prototype.getConstraints = function(style, w, h)
  5725. {
  5726. var constr = [];
  5727. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'tabWidth', this.tabWidth))));
  5728. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'tabHeight', this.tabHeight))));
  5729. var tp = mxUtils.getValue(this.style, 'tabPosition', this.tabPosition);
  5730. if (tp == 'left')
  5731. {
  5732. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  5733. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx * 0.5, 0));
  5734. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, 0));
  5735. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, dy));
  5736. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + dx) * 0.5, dy));
  5737. }
  5738. else
  5739. {
  5740. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  5741. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx * 0.5, 0));
  5742. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, 0));
  5743. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, dy));
  5744. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - dx) * 0.5, dy));
  5745. }
  5746. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy));
  5747. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dy) * 0.25 + dy));
  5748. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dy) * 0.5 + dy));
  5749. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dy) * 0.75 + dy));
  5750. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h));
  5751. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy));
  5752. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dy) * 0.25 + dy));
  5753. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dy) * 0.5 + dy));
  5754. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dy) * 0.75 + dy));
  5755. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h));
  5756. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));
  5757. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  5758. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));
  5759. return (constr);
  5760. }
  5761. InternalStorageShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  5762. DataStorageShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  5763. TapeDataShape.prototype.constraints = mxEllipse.prototype.constraints;
  5764. OrEllipseShape.prototype.constraints = mxEllipse.prototype.constraints;
  5765. SumEllipseShape.prototype.constraints = mxEllipse.prototype.constraints;
  5766. LineEllipseShape.prototype.constraints = mxEllipse.prototype.constraints;
  5767. ManualInputShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  5768. DelayShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  5769. DisplayShape.prototype.getConstraints = function(style, w, h)
  5770. {
  5771. var constr = [];
  5772. var dx = Math.min(w, h / 2);
  5773. var s = Math.min(w - dx, Math.max(0, parseFloat(mxUtils.getValue(this.style, 'size', this.size))) * w);
  5774. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false, null));
  5775. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, s, 0));
  5776. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (s + w - dx) * 0.5, 0));
  5777. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, 0));
  5778. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false, null));
  5779. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, h));
  5780. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (s + w - dx) * 0.5, h));
  5781. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, s, h));
  5782. return (constr);
  5783. };
  5784. ModuleShape.prototype.getConstraints = function(style, w, h)
  5785. {
  5786. var x0 = parseFloat(mxUtils.getValue(style, 'jettyWidth', ModuleShape.prototype.jettyWidth)) / 2;
  5787. var dy = parseFloat(mxUtils.getValue(style, 'jettyHeight', ModuleShape.prototype.jettyHeight));
  5788. var constr = [new mxConnectionConstraint(new mxPoint(0, 0), false, null, x0),
  5789. new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  5790. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  5791. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  5792. new mxConnectionConstraint(new mxPoint(1, 0), true),
  5793. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  5794. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  5795. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  5796. new mxConnectionConstraint(new mxPoint(0, 1), false, null, x0),
  5797. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  5798. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  5799. new mxConnectionConstraint(new mxPoint(0.75, 1), true),
  5800. new mxConnectionConstraint(new mxPoint(1, 1), true),
  5801. new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, Math.min(h - 0.5 * dy, 1.5 * dy)),
  5802. new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, Math.min(h - 0.5 * dy, 3.5 * dy))];
  5803. if (h > 5 * dy)
  5804. {
  5805. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.75), false, null, x0));
  5806. }
  5807. if (h > 8 * dy)
  5808. {
  5809. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false, null, x0));
  5810. }
  5811. if (h > 15 * dy)
  5812. {
  5813. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.25), false, null, x0));
  5814. }
  5815. return constr;
  5816. };
  5817. LoopLimitShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  5818. OffPageConnectorShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  5819. mxCylinder.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.15, 0.05), false),
  5820. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  5821. new mxConnectionConstraint(new mxPoint(0.85, 0.05), false),
  5822. new mxConnectionConstraint(new mxPoint(0, 0.3), true),
  5823. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  5824. new mxConnectionConstraint(new mxPoint(0, 0.7), true),
  5825. new mxConnectionConstraint(new mxPoint(1, 0.3), true),
  5826. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  5827. new mxConnectionConstraint(new mxPoint(1, 0.7), true),
  5828. new mxConnectionConstraint(new mxPoint(0.15, 0.95), false),
  5829. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  5830. new mxConnectionConstraint(new mxPoint(0.85, 0.95), false)];
  5831. UmlActorShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0.1), false),
  5832. new mxConnectionConstraint(new mxPoint(0.5, 0), false),
  5833. new mxConnectionConstraint(new mxPoint(0.75, 0.1), false),
  5834. new mxConnectionConstraint(new mxPoint(0, 1/3), false),
  5835. new mxConnectionConstraint(new mxPoint(0, 1), false),
  5836. new mxConnectionConstraint(new mxPoint(1, 1/3), false),
  5837. new mxConnectionConstraint(new mxPoint(1, 1), false),
  5838. new mxConnectionConstraint(new mxPoint(0.5, 0.5), false)];
  5839. ComponentShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  5840. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  5841. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  5842. new mxConnectionConstraint(new mxPoint(0, 0.3), true),
  5843. new mxConnectionConstraint(new mxPoint(0, 0.7), true),
  5844. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  5845. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  5846. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  5847. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  5848. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  5849. new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
  5850. mxActor.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  5851. new mxConnectionConstraint(new mxPoint(0.25, 0.2), false),
  5852. new mxConnectionConstraint(new mxPoint(0.1, 0.5), false),
  5853. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  5854. new mxConnectionConstraint(new mxPoint(0.75, 0.25), false),
  5855. new mxConnectionConstraint(new mxPoint(0.9, 0.5), false),
  5856. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  5857. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  5858. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  5859. new mxConnectionConstraint(new mxPoint(0.75, 1), true)];
  5860. SwitchShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0), false),
  5861. new mxConnectionConstraint(new mxPoint(0.5, 0.25), false),
  5862. new mxConnectionConstraint(new mxPoint(1, 0), false),
  5863. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  5864. new mxConnectionConstraint(new mxPoint(0.75, 0.5), false),
  5865. new mxConnectionConstraint(new mxPoint(0, 1), false),
  5866. new mxConnectionConstraint(new mxPoint(0.5, 0.75), false),
  5867. new mxConnectionConstraint(new mxPoint(1, 1), false)];
  5868. TapeShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.35), false),
  5869. new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  5870. new mxConnectionConstraint(new mxPoint(0, 0.65), false),
  5871. new mxConnectionConstraint(new mxPoint(1, 0.35), false),
  5872. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  5873. new mxConnectionConstraint(new mxPoint(1, 0.65), false),
  5874. new mxConnectionConstraint(new mxPoint(0.25, 1), false),
  5875. new mxConnectionConstraint(new mxPoint(0.75, 0), false)];
  5876. StepShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  5877. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  5878. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  5879. new mxConnectionConstraint(new mxPoint(0.25, 1), true),
  5880. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  5881. new mxConnectionConstraint(new mxPoint(0.75, 1), true),
  5882. new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  5883. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  5884. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  5885. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  5886. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  5887. new mxConnectionConstraint(new mxPoint(1, 0.75), true)];
  5888. mxLine.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  5889. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  5890. new mxConnectionConstraint(new mxPoint(0.75, 0.5), false),
  5891. new mxConnectionConstraint(new mxPoint(1, 0.5), false)];
  5892. LollipopShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.5, 0), false),
  5893. new mxConnectionConstraint(new mxPoint(0.5, 1), false)];
  5894. mxDoubleEllipse.prototype.constraints = mxEllipse.prototype.constraints;
  5895. mxRhombus.prototype.constraints = mxEllipse.prototype.constraints;
  5896. mxTriangle.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  5897. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  5898. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  5899. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  5900. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  5901. new mxConnectionConstraint(new mxPoint(1, 0.5), true)];
  5902. mxHexagon.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.375, 0), true),
  5903. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  5904. new mxConnectionConstraint(new mxPoint(0.625, 0), true),
  5905. new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  5906. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  5907. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  5908. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  5909. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  5910. new mxConnectionConstraint(new mxPoint(1, 0.75), true),
  5911. new mxConnectionConstraint(new mxPoint(0.375, 1), true),
  5912. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  5913. new mxConnectionConstraint(new mxPoint(0.625, 1), true)];
  5914. mxCloud.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0.25), false),
  5915. new mxConnectionConstraint(new mxPoint(0.4, 0.1), false),
  5916. new mxConnectionConstraint(new mxPoint(0.16, 0.55), false),
  5917. new mxConnectionConstraint(new mxPoint(0.07, 0.4), false),
  5918. new mxConnectionConstraint(new mxPoint(0.31, 0.8), false),
  5919. new mxConnectionConstraint(new mxPoint(0.13, 0.77), false),
  5920. new mxConnectionConstraint(new mxPoint(0.8, 0.8), false),
  5921. new mxConnectionConstraint(new mxPoint(0.55, 0.95), false),
  5922. new mxConnectionConstraint(new mxPoint(0.875, 0.5), false),
  5923. new mxConnectionConstraint(new mxPoint(0.96, 0.7), false),
  5924. new mxConnectionConstraint(new mxPoint(0.625, 0.2), false),
  5925. new mxConnectionConstraint(new mxPoint(0.88, 0.25), false)];
  5926. ParallelogramShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  5927. TrapezoidShape.prototype.constraints = mxRectangleShape.prototype.constraints;
  5928. DocumentShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true),
  5929. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  5930. new mxConnectionConstraint(new mxPoint(0.75, 0), true),
  5931. new mxConnectionConstraint(new mxPoint(0, 0.25), true),
  5932. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  5933. new mxConnectionConstraint(new mxPoint(0, 0.75), true),
  5934. new mxConnectionConstraint(new mxPoint(1, 0.25), true),
  5935. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  5936. new mxConnectionConstraint(new mxPoint(1, 0.75), true)];
  5937. mxArrow.prototype.constraints = null;
  5938. TeeShape.prototype.getConstraints = function(style, w, h)
  5939. {
  5940. var constr = [];
  5941. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  5942. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  5943. var w2 = Math.abs(w - dx) / 2;
  5944. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  5945. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  5946. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  5947. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy * 0.5));
  5948. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy));
  5949. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.75 + dx * 0.25, dy));
  5950. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + dx) * 0.5, dy));
  5951. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + dx) * 0.5, (h + dy) * 0.5));
  5952. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + dx) * 0.5, h));
  5953. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  5954. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - dx) * 0.5, h));
  5955. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - dx) * 0.5, (h + dy) * 0.5));
  5956. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - dx) * 0.5, dy));
  5957. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.25 - dx * 0.25, dy));
  5958. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy));
  5959. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy * 0.5));
  5960. return (constr);
  5961. };
  5962. CornerShape.prototype.getConstraints = function(style, w, h)
  5963. {
  5964. var constr = [];
  5965. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  5966. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  5967. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  5968. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  5969. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  5970. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy * 0.5));
  5971. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy));
  5972. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + dx) * 0.5, dy));
  5973. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, dy));
  5974. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, (h + dy) * 0.5));
  5975. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, h));
  5976. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx * 0.5, h));
  5977. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  5978. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  5979. return (constr);
  5980. };
  5981. CrossbarShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0), false),
  5982. new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  5983. new mxConnectionConstraint(new mxPoint(0, 1), false),
  5984. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  5985. new mxConnectionConstraint(new mxPoint(0.5, 0.5), false),
  5986. new mxConnectionConstraint(new mxPoint(0.75, 0.5), false),
  5987. new mxConnectionConstraint(new mxPoint(1, 0), false),
  5988. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  5989. new mxConnectionConstraint(new mxPoint(1, 1), false)];
  5990. SingleArrowShape.prototype.getConstraints = function(style, w, h)
  5991. {
  5992. var constr = [];
  5993. var aw = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowWidth', this.arrowWidth))));
  5994. var as = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowSize', this.arrowSize))));
  5995. var at = (h - aw) / 2;
  5996. var ab = at + aw;
  5997. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  5998. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, at));
  5999. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - as) * 0.5, at));
  6000. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - as, 0));
  6001. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  6002. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - as, h));
  6003. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - as) * 0.5, h - at));
  6004. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - at));
  6005. return (constr);
  6006. };
  6007. DoubleArrowShape.prototype.getConstraints = function(style, w, h)
  6008. {
  6009. var constr = [];
  6010. var aw = h * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowWidth', SingleArrowShape.prototype.arrowWidth))));
  6011. var as = w * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arrowSize', SingleArrowShape.prototype.arrowSize))));
  6012. var at = (h - aw) / 2;
  6013. var ab = at + aw;
  6014. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  6015. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, as, 0));
  6016. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5, at));
  6017. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - as, 0));
  6018. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  6019. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - as, h));
  6020. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5, h - at));
  6021. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, as, h));
  6022. return (constr);
  6023. };
  6024. CrossShape.prototype.getConstraints = function(style, w, h)
  6025. {
  6026. var constr = [];
  6027. var m = Math.min(h, w);
  6028. var size = Math.max(0, Math.min(m, m * parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  6029. var t = (h - size) / 2;
  6030. var b = t + size;
  6031. var l = (w - size) / 2;
  6032. var r = l + size;
  6033. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l, t * 0.5));
  6034. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l, 0));
  6035. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  6036. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r, 0));
  6037. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r, t * 0.5));
  6038. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r, t));
  6039. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l, h - t * 0.5));
  6040. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l, h));
  6041. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  6042. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r, h));
  6043. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r, h - t * 0.5));
  6044. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r, b));
  6045. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + r) * 0.5, t));
  6046. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, t));
  6047. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  6048. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, b));
  6049. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + r) * 0.5, b));
  6050. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l, b));
  6051. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l * 0.5, t));
  6052. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, t));
  6053. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  6054. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, b));
  6055. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l * 0.5, b));
  6056. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, l, t));
  6057. return (constr);
  6058. };
  6059. UmlLifeline.prototype.constraints = null;
  6060. OrShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.25), false),
  6061. new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  6062. new mxConnectionConstraint(new mxPoint(0, 0.75), false),
  6063. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  6064. new mxConnectionConstraint(new mxPoint(0.7, 0.1), false),
  6065. new mxConnectionConstraint(new mxPoint(0.7, 0.9), false)];
  6066. XorShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.175, 0.25), false),
  6067. new mxConnectionConstraint(new mxPoint(0.25, 0.5), false),
  6068. new mxConnectionConstraint(new mxPoint(0.175, 0.75), false),
  6069. new mxConnectionConstraint(new mxPoint(1, 0.5), false),
  6070. new mxConnectionConstraint(new mxPoint(0.7, 0.1), false),
  6071. new mxConnectionConstraint(new mxPoint(0.7, 0.9), false)];
  6072. RequiredInterfaceShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  6073. new mxConnectionConstraint(new mxPoint(1, 0.5), false)];
  6074. ProvidedRequiredInterfaceShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0, 0.5), false),
  6075. new mxConnectionConstraint(new mxPoint(1, 0.5), false)];
  6076. })();