Shapes.js 230 KB

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