mxBasic.js 120 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758
  1. /**
  2. * Copyright (c) 2006-2018, JGraph Holdings Ltd
  3. */
  4. //**********************************************************************************************************************************************************
  5. // Cross
  6. //**********************************************************************************************************************************************************
  7. /**
  8. * Extends mxShape.
  9. */
  10. function mxShapeBasicCross(bounds, fill, stroke, strokewidth)
  11. {
  12. mxShape.call(this);
  13. this.bounds = bounds;
  14. this.fill = fill;
  15. this.stroke = stroke;
  16. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  17. this.dx = 0.5;
  18. };
  19. /**
  20. * Extends mxShape.
  21. */
  22. mxUtils.extend(mxShapeBasicCross, mxActor);
  23. mxShapeBasicCross.prototype.cst = {CROSS : 'mxgraph.basic.cross2'};
  24. /**
  25. * Function: paintVertexShape
  26. *
  27. * Paints the vertex shape.
  28. */
  29. mxShapeBasicCross.prototype.paintVertexShape = function(c, x, y, w, h)
  30. {
  31. c.translate(x, y);
  32. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  33. c.begin();
  34. c.moveTo(w * 0.5 + dx, 0);
  35. c.lineTo(w * 0.5 + dx, h * 0.5 - dx);
  36. c.lineTo(w, h * 0.5 - dx);
  37. c.lineTo(w, h * 0.5 + dx);
  38. c.lineTo(w * 0.5 + dx, h * 0.5 + dx);
  39. c.lineTo(w * 0.5 + dx, h);
  40. c.lineTo(w * 0.5 - dx, h);
  41. c.lineTo(w * 0.5 - dx, h * 0.5 + dx);
  42. c.lineTo(0, h * 0.5 + dx);
  43. c.lineTo(0, h * 0.5 - dx);
  44. c.lineTo(w * 0.5 - dx, h * 0.5 - dx);
  45. c.lineTo(w * 0.5 - dx, 0);
  46. c.close();
  47. c.fillAndStroke();
  48. };
  49. mxCellRenderer.registerShape(mxShapeBasicCross.prototype.cst.CROSS, mxShapeBasicCross);
  50. mxShapeBasicCross.prototype.constraints = null;
  51. Graph.handleFactory[mxShapeBasicCross.prototype.cst.CROSS] = function(state)
  52. {
  53. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  54. {
  55. var dx = Math.max(0, Math.min(bounds.width / 2, bounds.width / 2, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  56. return new mxPoint(bounds.x + bounds.width / 2 + dx, bounds.y + bounds.height / 2 - dx);
  57. }, function(bounds, pt)
  58. {
  59. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, pt.x - bounds.x - bounds.width / 2))) / 100;
  60. })];
  61. return handles;
  62. };
  63. //**********************************************************************************************************************************************************
  64. // Rectangular Callout
  65. //**********************************************************************************************************************************************************
  66. /**
  67. * Extends mxShape.
  68. */
  69. function mxShapeBasicRectCallout(bounds, fill, stroke, strokewidth)
  70. {
  71. mxShape.call(this);
  72. this.bounds = bounds;
  73. this.fill = fill;
  74. this.stroke = stroke;
  75. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  76. this.dy = 0.5;
  77. this.dx = 0.5;
  78. };
  79. /**
  80. * Extends mxShape.
  81. */
  82. mxUtils.extend(mxShapeBasicRectCallout, mxActor);
  83. mxShapeBasicRectCallout.prototype.customProperties = [
  84. {name: 'dx', dispName: 'Callout Position', type: 'float', min:0, defVal:30},
  85. {name: 'dy', dispName: 'Callout Size', type: 'float', min:0, defVal:15}
  86. ];
  87. mxShapeBasicRectCallout.prototype.cst = {RECT_CALLOUT : 'mxgraph.basic.rectCallout'};
  88. /**
  89. * Function: paintVertexShape
  90. *
  91. * Paints the vertex shape.
  92. */
  93. mxShapeBasicRectCallout.prototype.paintVertexShape = function(c, x, y, w, h)
  94. {
  95. c.translate(x, y);
  96. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  97. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  98. c.begin();
  99. c.moveTo(dx - dy * 0.5, h - dy);
  100. c.lineTo(0, h - dy);
  101. c.lineTo(0, 0);
  102. c.lineTo(w, 0);
  103. c.lineTo(w, h - dy);
  104. c.lineTo(dx + dy * 0.5, h - dy);
  105. c.lineTo(dx - dy, h);
  106. c.close();
  107. c.fillAndStroke();
  108. };
  109. mxShapeBasicRectCallout.prototype.getLabelMargins = function()
  110. {
  111. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  112. {
  113. return new mxRectangle(0, 0, 0, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy)) * this.scale);
  114. }
  115. return null;
  116. };
  117. mxCellRenderer.registerShape(mxShapeBasicRectCallout.prototype.cst.RECT_CALLOUT, mxShapeBasicRectCallout);
  118. Graph.handleFactory[mxShapeBasicRectCallout.prototype.cst.RECT_CALLOUT] = function(state)
  119. {
  120. var handles = [Graph.createHandle(state, ['dx', 'dy'], function(bounds)
  121. {
  122. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  123. var dy = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  124. return new mxPoint(bounds.x + dx, bounds.y + bounds.height - dy);
  125. }, function(bounds, pt)
  126. {
  127. var y = parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy)) * 0.6;
  128. this.state.style['dx'] = Math.round(100 * Math.max(y, Math.min(bounds.width - y, pt.x - bounds.x))) / 100;
  129. this.state.style['dy'] = Math.round(Math.max(0, Math.min(bounds.height, bounds.y + bounds.height - pt.y)));
  130. })];
  131. return handles;
  132. };
  133. mxShapeBasicRectCallout.prototype.getConstraints = function(style, w, h)
  134. {
  135. var constr = [];
  136. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  137. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  138. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  139. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
  140. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  141. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
  142. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  143. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dy) * 0.5));
  144. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h - dy));
  145. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx - dy, h));
  146. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - dy));
  147. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dy) * 0.5));
  148. return (constr);
  149. }
  150. //**********************************************************************************************************************************************************
  151. // Rounded Rectangular Callout
  152. //**********************************************************************************************************************************************************
  153. /**
  154. * Extends mxShape.
  155. */
  156. function mxShapeBasicRoundRectCallout(bounds, fill, stroke, strokewidth)
  157. {
  158. mxShape.call(this);
  159. this.bounds = bounds;
  160. this.fill = fill;
  161. this.stroke = stroke;
  162. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  163. this.dy = 0.5;
  164. this.dx = 0.5;
  165. this.size = 10;
  166. };
  167. /**
  168. * Extends mxShape.
  169. */
  170. mxUtils.extend(mxShapeBasicRoundRectCallout, mxActor);
  171. mxShapeBasicRoundRectCallout.prototype.cst = {ROUND_RECT_CALLOUT : 'mxgraph.basic.roundRectCallout'};
  172. mxShapeBasicRoundRectCallout.prototype.getLabelMargins = mxShapeBasicRectCallout.prototype.getLabelMargins;
  173. mxShapeBasicRoundRectCallout.prototype.customProperties = [
  174. {name: 'size', dispName: 'Arc Size', type: 'float', min:0, defVal:5},
  175. {name: 'dx', dispName: 'Callout Position', type: 'float', min:0, defVal:30},
  176. {name: 'dy', dispName: 'Callout Size', type: 'float', min:0, defVal:15}
  177. ];
  178. /**
  179. * Function: paintVertexShape
  180. *
  181. * Paints the vertex shape.
  182. */
  183. mxShapeBasicRoundRectCallout.prototype.paintVertexShape = function(c, x, y, w, h)
  184. {
  185. c.translate(x, y);
  186. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  187. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  188. var r = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  189. r = Math.min((h - dy) / 2, w / 2, r);
  190. dx = Math.max(r + dy * 0.5, dx);
  191. dx = Math.min(w - r - dy * 0.5, dx);
  192. c.begin();
  193. c.moveTo(dx - dy * 0.5, h - dy);
  194. c.lineTo(r, h - dy);
  195. c.arcTo(r, r, 0, 0, 1, 0, h - dy - r);
  196. c.lineTo(0, r);
  197. c.arcTo(r, r, 0, 0, 1, r, 0);
  198. c.lineTo(w - r, 0);
  199. c.arcTo(r, r, 0, 0, 1, w, r);
  200. c.lineTo(w, h - dy - r);
  201. c.arcTo(r, r, 0, 0, 1, w - r, h - dy);
  202. c.lineTo(dx + dy * 0.5, h - dy);
  203. c.arcTo(1.9 * dy, 1.4 * dy, 0, 0, 1, dx - dy, h);
  204. c.arcTo(0.9 * dy, 1.4 * dy, 0, 0, 0, dx - dy * 0.5, h - dy);
  205. c.close();
  206. c.fillAndStroke();
  207. };
  208. mxCellRenderer.registerShape(mxShapeBasicRoundRectCallout.prototype.cst.ROUND_RECT_CALLOUT, mxShapeBasicRoundRectCallout);
  209. mxShapeBasicRoundRectCallout.prototype.constraints = null;
  210. Graph.handleFactory[mxShapeBasicRoundRectCallout.prototype.cst.ROUND_RECT_CALLOUT] = function(state)
  211. {
  212. return [Graph.createHandle(state, ['dx', 'dy'], function(bounds)
  213. {
  214. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  215. var dy = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  216. return new mxPoint(bounds.x + dx, bounds.y + bounds.height - dy);
  217. }, function(bounds, pt)
  218. {
  219. var y = parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy)) * 0.6;
  220. this.state.style['dx'] = Math.round(100 * Math.max(y, Math.min(bounds.width - y, pt.x - bounds.x))) / 100;
  221. this.state.style['dy'] = Math.round(Math.max(0, Math.min(bounds.height, bounds.y + bounds.height - pt.y)));
  222. }), Graph.createHandle(state, ['size'], function(bounds)
  223. {
  224. var size = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'size', this.size))));
  225. return new mxPoint(bounds.x + bounds.width - size, bounds.y + 10);
  226. }, function(bounds, pt)
  227. {
  228. var dy = parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy));
  229. this.state.style['size'] = Math.round(100 * Math.max(0, Math.min(bounds.width / 2, (bounds.height - dy) / 2, bounds.x + bounds.width - pt.x))) / 100;
  230. })];
  231. };
  232. mxShapeBasicRoundRectCallout.prototype.getConstraints = function(style, w, h)
  233. {
  234. var constr = [];
  235. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  236. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  237. var r = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  238. r = Math.min((h - dy) / 2, w / 2, r);
  239. dx = Math.max(r + dy * 0.5, dx);
  240. dx = Math.min(w - r - dy * 0.5, dx);
  241. if (r < w * 0.25)
  242. {
  243. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
  244. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
  245. }
  246. if (r < (h - dy) * 0.25)
  247. {
  248. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dy) * 0.25));
  249. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dy) * 0.75));
  250. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dy) * 0.25));
  251. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dy) * 0.75));
  252. }
  253. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r * 0.293, r * 0.293));
  254. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  255. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - r * 0.293, r * 0.293));
  256. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dy) * 0.5));
  257. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dy) * 0.5));
  258. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - r * 0.293, h - dy - r * 0.293));
  259. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, r * 0.293, h - dy - r * 0.293));
  260. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx - dy, h));
  261. return (constr);
  262. }
  263. //**********************************************************************************************************************************************************
  264. // Wave
  265. //**********************************************************************************************************************************************************
  266. /**
  267. * Extends mxShape.
  268. */
  269. function mxShapeBasicWave(bounds, fill, stroke, strokewidth)
  270. {
  271. mxShape.call(this);
  272. this.bounds = bounds;
  273. this.fill = fill;
  274. this.stroke = stroke;
  275. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  276. this.dy = 0.5;
  277. };
  278. /**
  279. * Extends mxShape.
  280. */
  281. mxUtils.extend(mxShapeBasicWave, mxActor);
  282. mxShapeBasicWave.prototype.customProperties = [
  283. {name: 'dy', dispName: 'Wave Size', type: 'float', min:0, max:1, defVal: 0.3}
  284. ];
  285. mxShapeBasicWave.prototype.cst = {WAVE : 'mxgraph.basic.wave2'};
  286. /**
  287. * Function: paintVertexShape
  288. *
  289. * Paints the vertex shape.
  290. */
  291. mxShapeBasicWave.prototype.paintVertexShape = function(c, x, y, w, h)
  292. {
  293. c.translate(x, y);
  294. var dy = h * Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  295. var fy = 1.4
  296. c.begin();
  297. c.moveTo(0, dy / 2);
  298. c.quadTo(w / 6, dy * (1 - fy), w / 3, dy / 2);
  299. c.quadTo(w / 2, dy * fy, w * 2 / 3, dy / 2);
  300. c.quadTo(w * 5 / 6, dy * (1 - fy), w, dy / 2);
  301. c.lineTo(w, h - dy / 2);
  302. c.quadTo(w * 5 / 6, h - dy * fy, w * 2 / 3, h - dy / 2);
  303. c.quadTo(w / 2, h - dy * (1 - fy), w / 3, h - dy / 2);
  304. c.quadTo(w / 6, h - dy * fy, 0, h - dy / 2);
  305. c.close();
  306. c.fillAndStroke();
  307. };
  308. mxCellRenderer.registerShape(mxShapeBasicWave.prototype.cst.WAVE, mxShapeBasicWave);
  309. mxShapeBasicWave.prototype.constraints = null;
  310. Graph.handleFactory[mxShapeBasicWave.prototype.cst.WAVE] = function(state)
  311. {
  312. var handles = [Graph.createHandle(state, ['dy'], function(bounds)
  313. {
  314. var dy = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  315. return new mxPoint(bounds.x + bounds.width / 2, bounds.y + dy * bounds.height);
  316. }, function(bounds, pt)
  317. {
  318. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(1, (pt.y - bounds.y) / bounds.height))) / 100;
  319. })];
  320. return handles;
  321. };
  322. mxShapeBasicWave.prototype.getConstraints = function(style, w, h)
  323. {
  324. var constr = [];
  325. var dy = h * Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  326. var fy = 1.4
  327. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy * 0.5));
  328. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w / 6, h * 0.015));
  329. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w / 3, dy * 0.5));
  330. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5, dy * 0.95));
  331. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.67, dy * 0.5));
  332. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.83, h * 0.015));
  333. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy * 0.5));
  334. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h * 0.5));
  335. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h - dy * 0.5));
  336. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.83, h - dy * 0.95));
  337. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.67, h - dy * 0.5));
  338. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5, h - dy * 0.04));
  339. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w / 3, h - dy * 0.5));
  340. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w / 6, h - dy * 0.95));
  341. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - dy * 0.5));
  342. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h * 0.5));
  343. return (constr);
  344. }
  345. //**********************************************************************************************************************************************************
  346. //Octagon
  347. //**********************************************************************************************************************************************************
  348. /**
  349. * Extends mxShape.
  350. */
  351. function mxShapeBasicOctagon(bounds, fill, stroke, strokewidth)
  352. {
  353. mxShape.call(this);
  354. this.bounds = bounds;
  355. this.fill = fill;
  356. this.stroke = stroke;
  357. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  358. this.dx = 0.5;
  359. };
  360. /**
  361. * Extends mxShape.
  362. */
  363. mxUtils.extend(mxShapeBasicOctagon, mxActor);
  364. mxShapeBasicOctagon.prototype.customProperties = [
  365. {name: 'dx', dispName: 'Cutoff Size', type: 'float', min:0, defVal:15}
  366. ];
  367. mxShapeBasicOctagon.prototype.cst = {OCTAGON : 'mxgraph.basic.octagon2'};
  368. /**
  369. * Function: paintVertexShape
  370. *
  371. * Paints the vertex shape.
  372. */
  373. mxShapeBasicOctagon.prototype.paintVertexShape = function(c, x, y, w, h)
  374. {
  375. c.translate(x, y);
  376. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx)))) * 2;
  377. dx = Math.min(w * 0.5, h * 0.5, dx);
  378. c.begin();
  379. c.moveTo(dx, 0);
  380. c.lineTo(w - dx, 0);
  381. c.lineTo(w, dx);
  382. c.lineTo(w, h - dx);
  383. c.lineTo(w - dx, h);
  384. c.lineTo(dx, h);
  385. c.lineTo(0, h - dx);
  386. c.lineTo(0, dx);
  387. c.close();
  388. c.fillAndStroke();
  389. };
  390. mxCellRenderer.registerShape(mxShapeBasicOctagon.prototype.cst.OCTAGON, mxShapeBasicOctagon);
  391. mxShapeBasicOctagon.prototype.constraints = null;
  392. Graph.handleFactory[mxShapeBasicOctagon.prototype.cst.OCTAGON] = function(state)
  393. {
  394. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  395. {
  396. var dx = Math.max(0, Math.min(bounds.width / 4, bounds.width / 4, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  397. return new mxPoint(bounds.x + dx, bounds.y + dx);
  398. }, function(bounds, pt)
  399. {
  400. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 4, bounds.width / 4, pt.x - bounds.x))) / 100;
  401. })];
  402. return handles;
  403. };
  404. mxShapeBasicOctagon.prototype.getConstraints = function(style, w, h)
  405. {
  406. var constr = [];
  407. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx)))) * 2;
  408. dx = Math.min(w * 0.5, h * 0.5, dx) * 0.5;
  409. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  410. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  411. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  412. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  413. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, dx));
  414. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, dx));
  415. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, h - dx));
  416. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, h - dx));
  417. return (constr);
  418. }
  419. //**********************************************************************************************************************************************************
  420. //Isometric Cube
  421. //**********************************************************************************************************************************************************
  422. /**
  423. * Extends mxShape.
  424. */
  425. function mxShapeBasicIsoCube(bounds, fill, stroke, strokewidth)
  426. {
  427. mxShape.call(this);
  428. this.bounds = bounds;
  429. this.fill = fill;
  430. this.stroke = stroke;
  431. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  432. this.isoAngle = 15;
  433. };
  434. /**
  435. * Extends mxShape.
  436. */
  437. mxUtils.extend(mxShapeBasicIsoCube, mxActor);
  438. mxShapeBasicIsoCube.prototype.customProperties = [
  439. {name: 'isoAngle', dispName: 'Perspective Angle', type: 'float', min:0, defVal:15}
  440. ];
  441. mxShapeBasicIsoCube.prototype.cst = {ISO_CUBE : 'mxgraph.basic.isocube'};
  442. /**
  443. * Function: paintVertexShape
  444. *
  445. * Paints the vertex shape.
  446. */
  447. mxShapeBasicIsoCube.prototype.paintVertexShape = function(c, x, y, w, h)
  448. {
  449. c.translate(x, y);
  450. var isoAngle = Math.max(0.01, Math.min(94, parseFloat(mxUtils.getValue(this.style, 'isoAngle', this.isoAngle)))) * Math.PI / 200 ;
  451. var isoH = Math.min(w * Math.tan(isoAngle), h * 0.5);
  452. c.begin();
  453. c.moveTo(w * 0.5, 0);
  454. c.lineTo(w, isoH);
  455. c.lineTo(w, h - isoH);
  456. c.lineTo(w * 0.5, h);
  457. c.lineTo(0, h - isoH);
  458. c.lineTo(0, isoH);
  459. c.close();
  460. c.fillAndStroke();
  461. c.setShadow(false);
  462. c.begin();
  463. c.moveTo(0, isoH);
  464. c.lineTo(w * 0.5, 2 * isoH);
  465. c.lineTo(w, isoH);
  466. c.moveTo(w * 0.5, 2 * isoH);
  467. c.lineTo(w * 0.5, h);
  468. c.stroke();
  469. };
  470. mxCellRenderer.registerShape(mxShapeBasicIsoCube.prototype.cst.ISO_CUBE, mxShapeBasicIsoCube);
  471. mxShapeBasicIsoCube.prototype.constraints = null;
  472. Graph.handleFactory[mxShapeBasicIsoCube.prototype.cst.ISO_CUBE] = function(state)
  473. {
  474. var handles = [Graph.createHandle(state, ['isoAngle'], function(bounds)
  475. {
  476. var isoAngle = Math.max(0.01, Math.min(94, parseFloat(mxUtils.getValue(this.state.style, 'isoAngle', this.isoAngle)))) * Math.PI / 200 ;
  477. var isoH = Math.min(bounds.width * Math.tan(isoAngle), bounds.height * 0.5);
  478. return new mxPoint(bounds.x, bounds.y + isoH);
  479. }, function(bounds, pt)
  480. {
  481. this.state.style['isoAngle'] = Math.round(100 * Math.max(0, Math.min(100, pt.y - bounds.y))) / 100;
  482. })];
  483. return handles;
  484. };
  485. mxShapeBasicIsoCube.prototype.getConstraints = function(style, w, h)
  486. {
  487. var constr = [];
  488. var isoAngle = Math.max(0.01, Math.min(94, parseFloat(mxUtils.getValue(this.style, 'isoAngle', this.isoAngle)))) * Math.PI / 200 ;
  489. var isoH = Math.min(w * Math.tan(isoAngle), h * 0.5);
  490. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  491. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, isoH));
  492. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  493. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h - isoH));
  494. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  495. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - isoH));
  496. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  497. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, isoH));
  498. return (constr);
  499. }
  500. //**********************************************************************************************************************************************************
  501. //Acute Triangle
  502. //**********************************************************************************************************************************************************
  503. /**
  504. * Extends mxShape.
  505. */
  506. function mxShapeBasicTriangleAcute(bounds, fill, stroke, strokewidth)
  507. {
  508. mxShape.call(this);
  509. this.bounds = bounds;
  510. this.fill = fill;
  511. this.stroke = stroke;
  512. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  513. this.dx = 0.5;
  514. };
  515. /**
  516. * Extends mxShape.
  517. */
  518. mxUtils.extend(mxShapeBasicTriangleAcute, mxActor);
  519. mxShapeBasicTriangleAcute.prototype.customProperties = [
  520. {name: 'dx', dispName: 'Top', type: 'float', min:0, max:1, defVal:0.5}
  521. ];
  522. mxShapeBasicTriangleAcute.prototype.cst = {ACUTE_TRIANGLE : 'mxgraph.basic.acute_triangle'};
  523. /**
  524. * Function: paintVertexShape
  525. *
  526. * Paints the vertex shape.
  527. */
  528. mxShapeBasicTriangleAcute.prototype.paintVertexShape = function(c, x, y, w, h)
  529. {
  530. c.translate(x, y);
  531. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  532. c.begin();
  533. c.moveTo(0, h);
  534. c.lineTo(dx, 0);
  535. c.lineTo(w, h);
  536. c.close();
  537. c.fillAndStroke();
  538. };
  539. mxCellRenderer.registerShape(mxShapeBasicTriangleAcute.prototype.cst.ACUTE_TRIANGLE, mxShapeBasicTriangleAcute);
  540. mxShapeBasicTriangleAcute.prototype.constraints = null;
  541. Graph.handleFactory[mxShapeBasicTriangleAcute.prototype.cst.ACUTE_TRIANGLE] = function(state)
  542. {
  543. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  544. {
  545. var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  546. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + 10);
  547. }, function(bounds, pt)
  548. {
  549. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  550. })];
  551. return handles;
  552. };
  553. mxShapeBasicTriangleAcute.prototype.getConstraints = function(style, w, h)
  554. {
  555. var constr = [];
  556. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  557. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  558. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  559. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  560. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, 0));
  561. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx * 0.5, h * 0.5));
  562. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - (w - dx) * 0.5, h * 0.5));
  563. return (constr);
  564. }
  565. //**********************************************************************************************************************************************************
  566. //Obtuse Triangle
  567. //**********************************************************************************************************************************************************
  568. /**
  569. * Extends mxShape.
  570. */
  571. function mxShapeBasicTriangleObtuse(bounds, fill, stroke, strokewidth)
  572. {
  573. mxShape.call(this);
  574. this.bounds = bounds;
  575. this.fill = fill;
  576. this.stroke = stroke;
  577. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  578. this.dx = 0.5;
  579. };
  580. /**
  581. * Extends mxShape.
  582. */
  583. mxUtils.extend(mxShapeBasicTriangleObtuse, mxActor);
  584. mxShapeBasicTriangleObtuse.prototype.customProperties = [
  585. {name: 'dx', dispName: 'Bottom', type: 'float', min:0, max:1, defVal:0.25}
  586. ];
  587. mxShapeBasicTriangleObtuse.prototype.cst = {OBTUSE_TRIANGLE : 'mxgraph.basic.obtuse_triangle'};
  588. /**
  589. * Function: paintVertexShape
  590. *
  591. * Paints the vertex shape.
  592. */
  593. mxShapeBasicTriangleObtuse.prototype.paintVertexShape = function(c, x, y, w, h)
  594. {
  595. c.translate(x, y);
  596. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  597. c.begin();
  598. c.moveTo(dx, h);
  599. c.lineTo(0, 0);
  600. c.lineTo(w, h);
  601. c.close();
  602. c.fillAndStroke();
  603. };
  604. mxCellRenderer.registerShape(mxShapeBasicTriangleObtuse.prototype.cst.OBTUSE_TRIANGLE, mxShapeBasicTriangleObtuse);
  605. mxShapeBasicTriangleObtuse.prototype.constraints = null;
  606. Graph.handleFactory[mxShapeBasicTriangleObtuse.prototype.cst.OBTUSE_TRIANGLE] = function(state)
  607. {
  608. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  609. {
  610. var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  611. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + bounds.height - 10);
  612. }, function(bounds, pt)
  613. {
  614. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  615. })];
  616. return handles;
  617. };
  618. mxShapeBasicTriangleObtuse.prototype.getConstraints = function(style, w, h)
  619. {
  620. var constr = [];
  621. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  622. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  623. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  624. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5, h * 0.5));
  625. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + dx) * 0.5, h));
  626. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, h));
  627. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx * 0.5, h * 0.5));
  628. return (constr);
  629. }
  630. //**********************************************************************************************************************************************************
  631. //Drop
  632. //**********************************************************************************************************************************************************
  633. /**
  634. * Extends mxShape.
  635. */
  636. function mxShapeBasicDrop(bounds, fill, stroke, strokewidth)
  637. {
  638. mxShape.call(this);
  639. this.bounds = bounds;
  640. this.fill = fill;
  641. this.stroke = stroke;
  642. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  643. };
  644. /**
  645. * Extends mxShape.
  646. */
  647. mxUtils.extend(mxShapeBasicDrop, mxActor);
  648. mxShapeBasicDrop.prototype.cst = {DROP : 'mxgraph.basic.drop'};
  649. /**
  650. * Function: paintVertexShape
  651. *
  652. * Paints the vertex shape.
  653. */
  654. mxShapeBasicDrop.prototype.paintVertexShape = function(c, x, y, w, h)
  655. {
  656. c.translate(x, y);
  657. var r = Math.min(h, w) * 0.5;
  658. var d = h - r;
  659. var a = Math.sqrt(d * d - r * r);
  660. var angle = Math.atan(a / r);
  661. var x1 = r * Math.sin(angle);
  662. var y1 = r * Math.cos(angle);
  663. c.begin();
  664. c.moveTo(w * 0.5, 0);
  665. c.lineTo(w * 0.5 + x1, h - r - y1);
  666. c.arcTo(r, r, 0, 0, 1, w * 0.5 + r, h - r);
  667. c.arcTo(r, r, 0, 0, 1, w * 0.5, h);
  668. c.arcTo(r, r, 0, 0, 1, w * 0.5 - r, h - r);
  669. c.arcTo(r, r, 0, 0, 1, w * 0.5 - x1, h - r - y1);
  670. c.close();
  671. c.fillAndStroke();
  672. };
  673. mxCellRenderer.registerShape(mxShapeBasicDrop.prototype.cst.DROP, mxShapeBasicDrop);
  674. mxShapeBasicDrop.prototype.constraints = null;
  675. //**********************************************************************************************************************************************************
  676. //Cone 2
  677. //**********************************************************************************************************************************************************
  678. /**
  679. * Extends mxShape.
  680. */
  681. function mxShapeBasicCone2(bounds, fill, stroke, strokewidth)
  682. {
  683. mxShape.call(this);
  684. this.bounds = bounds;
  685. this.fill = fill;
  686. this.stroke = stroke;
  687. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  688. this.dx = 0.5;
  689. this.dy = 0.9;
  690. };
  691. /**
  692. * Extends mxShape.
  693. */
  694. mxUtils.extend(mxShapeBasicCone2, mxActor);
  695. mxShapeBasicCone2.prototype.customProperties = [
  696. {name: 'dx', dispName: 'Top', type: 'float', min:0, max:1, defVal:0.5},
  697. {name: 'dy', dispName: 'Bottom', type: 'float', min:0, max:1, defVal:0.9}
  698. ];
  699. mxShapeBasicCone2.prototype.cst = {CONE2 : 'mxgraph.basic.cone2'};
  700. /**
  701. * Function: paintVertexShape
  702. *
  703. * Paints the vertex shape.
  704. */
  705. mxShapeBasicCone2.prototype.paintVertexShape = function(c, x, y, w, h)
  706. {
  707. c.translate(x, y);
  708. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  709. var dy = h * Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  710. var ry = h - dy;
  711. c.begin();
  712. c.moveTo(dx, 0);
  713. if (ry > 0)
  714. {
  715. c.lineTo(w, h - ry);
  716. c.arcTo(w * 0.5, ry, 0, 0, 1, w * 0.5, h);
  717. c.arcTo(w * 0.5, ry, 0, 0, 1, 0, h - ry);
  718. }
  719. else
  720. {
  721. c.lineTo(w, h);
  722. c.lineTo(0, h);
  723. }
  724. c.close();
  725. c.fillAndStroke();
  726. };
  727. mxCellRenderer.registerShape(mxShapeBasicCone2.prototype.cst.CONE2, mxShapeBasicCone2);
  728. mxShapeBasicCone2.prototype.constraints = null;
  729. Graph.handleFactory[mxShapeBasicCone2.prototype.cst.CONE2] = function(state)
  730. {
  731. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  732. {
  733. var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  734. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + 10);
  735. }, function(bounds, pt)
  736. {
  737. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  738. })];
  739. var handle2 = Graph.createHandle(state, ['dy'], function(bounds)
  740. {
  741. var dy = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  742. return new mxPoint(bounds.x + 10, bounds.y + dy * bounds.height);
  743. }, function(bounds, pt)
  744. {
  745. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(1, (pt.y - bounds.y) / bounds.height))) / 100;
  746. });
  747. handles.push(handle2);
  748. return handles;
  749. };
  750. mxShapeBasicCone2.prototype.getConstraints = function(style, w, h)
  751. {
  752. var constr = [];
  753. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  754. var dy = h * Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  755. var ry = h - dy;
  756. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, 0));
  757. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h - ry));
  758. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.5, h));
  759. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - ry));
  760. return (constr);
  761. }
  762. //**********************************************************************************************************************************************************
  763. //Pyramid
  764. //**********************************************************************************************************************************************************
  765. /**
  766. * Extends mxShape.
  767. */
  768. function mxShapeBasicPyramid(bounds, fill, stroke, strokewidth)
  769. {
  770. mxShape.call(this);
  771. this.bounds = bounds;
  772. this.fill = fill;
  773. this.stroke = stroke;
  774. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  775. this.dx1 = 0.5;
  776. this.dx2 = 0.6;
  777. this.dy1 = 0.9;
  778. this.dy2 = 0.8;
  779. };
  780. /**
  781. * Extends mxShape.
  782. */
  783. mxUtils.extend(mxShapeBasicPyramid, mxActor);
  784. mxShapeBasicPyramid.prototype.customProperties = [
  785. {name: 'dx1', dispName: 'Top', type: 'float', min:0, max:1, defVal:0.4},
  786. {name: 'dx2', dispName: 'Bottom', type: 'float', min:0, max:1, defVal:0.6},
  787. {name: 'dy1', dispName: 'Perspective Left', type: 'float', min:0, max:1, defVal:0.9},
  788. {name: 'dy2', dispName: 'Perspective Right', type: 'float', min:0, max:1, defVal:0.8}
  789. ];
  790. mxShapeBasicPyramid.prototype.cst = {PYRAMID : 'mxgraph.basic.pyramid'};
  791. /**
  792. * Function: paintVertexShape
  793. *
  794. * Paints the vertex shape.
  795. */
  796. mxShapeBasicPyramid.prototype.paintVertexShape = function(c, x, y, w, h)
  797. {
  798. c.translate(x, y);
  799. var dx1 = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx1', this.dx1))));
  800. var dx2 = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx2', this.dx2))));
  801. var dy1 = h * Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy1', this.dy1))));
  802. var dy2 = h * Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy2', this.dy2))));
  803. c.begin();
  804. c.moveTo(dx1, 0);
  805. c.lineTo(w, dy2);
  806. c.lineTo(dx2, h);
  807. c.lineTo(0, dy1);
  808. c.close();
  809. c.fillAndStroke();
  810. c.setShadow(false);
  811. c.begin();
  812. c.moveTo(dx1, 0);
  813. c.lineTo(dx2, h);
  814. c.stroke();
  815. };
  816. mxCellRenderer.registerShape(mxShapeBasicPyramid.prototype.cst.PYRAMID, mxShapeBasicPyramid);
  817. mxShapeBasicPyramid.prototype.constraints = null;
  818. Graph.handleFactory[mxShapeBasicPyramid.prototype.cst.PYRAMID] = function(state)
  819. {
  820. var handles = [Graph.createHandle(state, ['dx1'], function(bounds)
  821. {
  822. var dx1 = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx1', this.dx1))));
  823. return new mxPoint(bounds.x + dx1 * bounds.width, bounds.y + 10);
  824. }, function(bounds, pt)
  825. {
  826. this.state.style['dx1'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  827. })];
  828. var handle2 = Graph.createHandle(state, ['dx2'], function(bounds)
  829. {
  830. var dx2 = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx2', this.dx2))));
  831. return new mxPoint(bounds.x + dx2 * bounds.width, bounds.y + bounds.height - 10);
  832. }, function(bounds, pt)
  833. {
  834. this.state.style['dx2'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  835. });
  836. handles.push(handle2);
  837. var handle3 = Graph.createHandle(state, ['dy1'], function(bounds)
  838. {
  839. var dy1 = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dy1', this.dy1))));
  840. return new mxPoint(bounds.x + 10, bounds.y + dy1 * bounds.height);
  841. }, function(bounds, pt)
  842. {
  843. this.state.style['dy1'] = Math.round(100 * Math.max(0, Math.min(1, (pt.y - bounds.y) / bounds.height))) / 100;
  844. });
  845. handles.push(handle3);
  846. var handle4 = Graph.createHandle(state, ['dy2'], function(bounds)
  847. {
  848. var dy2 = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dy2', this.dy2))));
  849. return new mxPoint(bounds.x + bounds.width - 10, bounds.y + dy2 * bounds.height);
  850. }, function(bounds, pt)
  851. {
  852. this.state.style['dy2'] = Math.round(100 * Math.max(0, Math.min(1, (pt.y - bounds.y) / bounds.height))) / 100;
  853. });
  854. handles.push(handle4);
  855. return handles;
  856. };
  857. mxShapeBasicPyramid.prototype.getConstraints = function(style, w, h)
  858. {
  859. var constr = [];
  860. var dx1 = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx1', this.dx1))));
  861. var dx2 = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx2', this.dx2))));
  862. var dy1 = h * Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy1', this.dy1))));
  863. var dy2 = h * Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy2', this.dy2))));
  864. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx1, 0));
  865. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + dx1) * 0.5, dy2 * 0.5));
  866. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dy2));
  867. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + dx2) * 0.5, (h + dy2) * 0.5));
  868. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2, h));
  869. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx2 * 0.5, (h + dy1) * 0.5));
  870. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, dy1));
  871. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx1 * 0.5, dy1 * 0.5));
  872. return (constr);
  873. }
  874. //**********************************************************************************************************************************************************
  875. //4 Point Star 2
  876. //**********************************************************************************************************************************************************
  877. /**
  878. * Extends mxShape.
  879. */
  880. function mxShapeBasic4PointStar2(bounds, fill, stroke, strokewidth)
  881. {
  882. mxShape.call(this);
  883. this.bounds = bounds;
  884. this.fill = fill;
  885. this.stroke = stroke;
  886. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  887. this.dx = 0.8;
  888. };
  889. /**
  890. * Extends mxShape.
  891. */
  892. mxUtils.extend(mxShapeBasic4PointStar2, mxActor);
  893. mxShapeBasic4PointStar2.prototype.customProperties = [
  894. {name: 'dx', dispName: 'Thickness', type: 'float', min:0, max:1, defVal:0.8}
  895. ];
  896. mxShapeBasic4PointStar2.prototype.cst = {FOUR_POINT_STAR_2 : 'mxgraph.basic.4_point_star_2'};
  897. /**
  898. * Function: paintVertexShape
  899. *
  900. * Paints the vertex shape.
  901. */
  902. mxShapeBasic4PointStar2.prototype.paintVertexShape = function(c, x, y, w, h)
  903. {
  904. c.translate(x, y);
  905. var dx = 0.5 * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  906. c.begin();
  907. c.moveTo(0, h * 0.5);
  908. c.lineTo(dx * w, dx * h);
  909. c.lineTo(w * 0.5, 0);
  910. c.lineTo(w - dx * w, dx * h);
  911. c.lineTo(w, h * 0.5);
  912. c.lineTo(w - dx * w, h - dx * h);
  913. c.lineTo(w * 0.5, h);
  914. c.lineTo(dx * w, h - dx * h);
  915. c.close();
  916. c.fillAndStroke();
  917. };
  918. mxCellRenderer.registerShape(mxShapeBasic4PointStar2.prototype.cst.FOUR_POINT_STAR_2, mxShapeBasic4PointStar2);
  919. mxShapeBasic4PointStar2.prototype.constraints = null;
  920. Graph.handleFactory[mxShapeBasic4PointStar2.prototype.cst.FOUR_POINT_STAR_2] = function(state)
  921. {
  922. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  923. {
  924. var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  925. return new mxPoint(bounds.x + dx * bounds.width / 2, bounds.y + dx * bounds.height / 2);
  926. }, function(bounds, pt)
  927. {
  928. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, 2 * (pt.x - bounds.x) / bounds.width))) / 100;
  929. })];
  930. return handles;
  931. };
  932. mxShapeBasic4PointStar2.prototype.getConstraints = function(style, w, h)
  933. {
  934. var constr = [];
  935. var dx = 0.5 * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  936. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  937. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  938. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  939. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  940. constr.push(new mxConnectionConstraint(new mxPoint(dx, dx), false));
  941. constr.push(new mxConnectionConstraint(new mxPoint(1 - dx, dx), false));
  942. constr.push(new mxConnectionConstraint(new mxPoint(1 - dx, 1 - dx), false));
  943. constr.push(new mxConnectionConstraint(new mxPoint(dx, 1 - dx), false));
  944. return (constr);
  945. }
  946. //**********************************************************************************************************************************************************
  947. //Diagonal Snip Rectangle
  948. //**********************************************************************************************************************************************************
  949. /**
  950. * Extends mxShape.
  951. */
  952. function mxShapeBasicDiagSnipRect(bounds, fill, stroke, strokewidth)
  953. {
  954. mxShape.call(this);
  955. this.bounds = bounds;
  956. this.fill = fill;
  957. this.stroke = stroke;
  958. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  959. this.dx = 0.5;
  960. };
  961. /**
  962. * Extends mxShape.
  963. */
  964. mxUtils.extend(mxShapeBasicDiagSnipRect, mxActor);
  965. mxShapeBasicDiagSnipRect.prototype.customProperties = [
  966. {name: 'dx', dispName: 'Snip', type: 'float', min:0, deVal:6},
  967. ];
  968. mxShapeBasicDiagSnipRect.prototype.cst = {DIAG_SNIP_RECT : 'mxgraph.basic.diag_snip_rect'};
  969. /**
  970. * Function: paintVertexShape
  971. *
  972. * Paints the vertex shape.
  973. */
  974. mxShapeBasicDiagSnipRect.prototype.paintVertexShape = function(c, x, y, w, h)
  975. {
  976. c.translate(x, y);
  977. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx)))) * 2;
  978. dx = Math.min(w * 0.5, h * 0.5, dx);
  979. c.begin();
  980. c.moveTo(dx, 0);
  981. c.lineTo(w, 0);
  982. c.lineTo(w, h - dx);
  983. c.lineTo(w - dx, h);
  984. c.lineTo(0, h);
  985. c.lineTo(0, dx);
  986. c.close();
  987. c.fillAndStroke();
  988. };
  989. mxCellRenderer.registerShape(mxShapeBasicDiagSnipRect.prototype.cst.DIAG_SNIP_RECT, mxShapeBasicDiagSnipRect);
  990. mxShapeBasicDiagSnipRect.prototype.constraints = null;
  991. Graph.handleFactory[mxShapeBasicDiagSnipRect.prototype.cst.DIAG_SNIP_RECT] = function(state)
  992. {
  993. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  994. {
  995. var dx = Math.max(0, Math.min(bounds.width / 4, bounds.width / 4, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  996. return new mxPoint(bounds.x + dx, bounds.y + dx);
  997. }, function(bounds, pt)
  998. {
  999. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 4, bounds.width / 4, pt.x - bounds.x))) / 100;
  1000. })];
  1001. return handles;
  1002. };
  1003. mxShapeBasicDiagSnipRect.prototype.getConstraints = function(style, w, h)
  1004. {
  1005. var constr = [];
  1006. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx)))) * 2;
  1007. dx = Math.min(w * 0.5, h * 0.5, dx) * 0.5;
  1008. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, dx));
  1009. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1010. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  1011. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  1012. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, h - dx));
  1013. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  1014. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  1015. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  1016. return (constr);
  1017. }
  1018. //**********************************************************************************************************************************************************
  1019. //Diagonal Round Rectangle
  1020. //**********************************************************************************************************************************************************
  1021. /**
  1022. * Extends mxShape.
  1023. */
  1024. function mxShapeBasicDiagRoundRect(bounds, fill, stroke, strokewidth)
  1025. {
  1026. mxShape.call(this);
  1027. this.bounds = bounds;
  1028. this.fill = fill;
  1029. this.stroke = stroke;
  1030. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1031. this.dx = 0.5;
  1032. };
  1033. /**
  1034. * Extends mxShape.
  1035. */
  1036. mxUtils.extend(mxShapeBasicDiagRoundRect, mxActor);
  1037. mxShapeBasicDiagRoundRect.prototype.customProperties = [
  1038. {name: 'dx', dispName: 'Rounding Size', type: 'float', min:0, defVal:6},
  1039. ];
  1040. mxShapeBasicDiagRoundRect.prototype.cst = {DIAG_ROUND_RECT : 'mxgraph.basic.diag_round_rect'};
  1041. /**
  1042. * Function: paintVertexShape
  1043. *
  1044. * Paints the vertex shape.
  1045. */
  1046. mxShapeBasicDiagRoundRect.prototype.paintVertexShape = function(c, x, y, w, h)
  1047. {
  1048. c.translate(x, y);
  1049. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx)))) * 2;
  1050. dx = Math.min(w * 0.5, h * 0.5, dx);
  1051. c.begin();
  1052. c.moveTo(dx, 0);
  1053. c.lineTo(w, 0);
  1054. c.lineTo(w, h - dx);
  1055. c.arcTo(dx, dx, 0, 0, 1, w - dx, h);
  1056. c.lineTo(0, h);
  1057. c.lineTo(0, dx);
  1058. c.arcTo(dx, dx, 0, 0, 1, dx, 0);
  1059. c.close();
  1060. c.fillAndStroke();
  1061. };
  1062. mxCellRenderer.registerShape(mxShapeBasicDiagRoundRect.prototype.cst.DIAG_ROUND_RECT, mxShapeBasicDiagRoundRect);
  1063. mxShapeBasicDiagRoundRect.prototype.constraints = null;
  1064. Graph.handleFactory[mxShapeBasicDiagRoundRect.prototype.cst.DIAG_ROUND_RECT] = function(state)
  1065. {
  1066. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1067. {
  1068. var dx = Math.max(0, Math.min(bounds.width / 4, bounds.width / 4, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1069. return new mxPoint(bounds.x + dx, bounds.y + dx);
  1070. }, function(bounds, pt)
  1071. {
  1072. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 4, bounds.width / 4, pt.x - bounds.x))) / 100;
  1073. })];
  1074. return handles;
  1075. };
  1076. mxShapeBasicDiagRoundRect.prototype.getConstraints = function(style, w, h)
  1077. {
  1078. var constr = [];
  1079. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1080. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  1081. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  1082. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  1083. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  1084. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  1085. return (constr);
  1086. }
  1087. //**********************************************************************************************************************************************************
  1088. //Corner Round Rectangle
  1089. //**********************************************************************************************************************************************************
  1090. /**
  1091. * Extends mxShape.
  1092. */
  1093. function mxShapeBasicCornerRoundRect(bounds, fill, stroke, strokewidth)
  1094. {
  1095. mxShape.call(this);
  1096. this.bounds = bounds;
  1097. this.fill = fill;
  1098. this.stroke = stroke;
  1099. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1100. this.dx = 0.5;
  1101. };
  1102. /**
  1103. * Extends mxShape.
  1104. */
  1105. mxUtils.extend(mxShapeBasicCornerRoundRect, mxActor);
  1106. mxShapeBasicCornerRoundRect.prototype.customProperties = [
  1107. {name: 'dx', dispName: 'Rounding Size', type: 'float', min:0, defVal:6},
  1108. ];
  1109. mxShapeBasicCornerRoundRect.prototype.cst = {CORNER_ROUND_RECT : 'mxgraph.basic.corner_round_rect'};
  1110. /**
  1111. * Function: paintVertexShape
  1112. *
  1113. * Paints the vertex shape.
  1114. */
  1115. mxShapeBasicCornerRoundRect.prototype.paintVertexShape = function(c, x, y, w, h)
  1116. {
  1117. c.translate(x, y);
  1118. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx)))) * 2;
  1119. dx = Math.min(w * 0.5, h * 0.5, dx);
  1120. c.begin();
  1121. c.moveTo(dx, 0);
  1122. c.lineTo(w, 0);
  1123. c.lineTo(w, h);
  1124. c.lineTo(0, h);
  1125. c.lineTo(0, dx);
  1126. c.arcTo(dx, dx, 0, 0, 1, dx, 0);
  1127. c.close();
  1128. c.fillAndStroke();
  1129. };
  1130. mxCellRenderer.registerShape(mxShapeBasicCornerRoundRect.prototype.cst.CORNER_ROUND_RECT, mxShapeBasicCornerRoundRect);
  1131. mxShapeBasicCornerRoundRect.prototype.constraints = null;
  1132. Graph.handleFactory[mxShapeBasicCornerRoundRect.prototype.cst.CORNER_ROUND_RECT] = function(state)
  1133. {
  1134. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1135. {
  1136. var dx = Math.max(0, Math.min(bounds.width / 4, bounds.width / 4, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1137. return new mxPoint(bounds.x + dx, bounds.y + dx);
  1138. }, function(bounds, pt)
  1139. {
  1140. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 4, bounds.width / 4, pt.x - bounds.x))) / 100;
  1141. })];
  1142. return handles;
  1143. };
  1144. mxShapeBasicCornerRoundRect.prototype.getConstraints = function(style, w, h)
  1145. {
  1146. var constr = [];
  1147. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1148. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  1149. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  1150. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  1151. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  1152. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  1153. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  1154. return (constr);
  1155. }
  1156. //**********************************************************************************************************************************************************
  1157. //Plaque
  1158. //**********************************************************************************************************************************************************
  1159. /**
  1160. * Extends mxShape.
  1161. */
  1162. function mxShapeBasicPlaque(bounds, fill, stroke, strokewidth)
  1163. {
  1164. mxShape.call(this);
  1165. this.bounds = bounds;
  1166. this.fill = fill;
  1167. this.stroke = stroke;
  1168. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1169. this.dx = 0.5;
  1170. };
  1171. /**
  1172. * Extends mxShape.
  1173. */
  1174. mxUtils.extend(mxShapeBasicPlaque, mxActor);
  1175. mxShapeBasicPlaque.prototype.customProperties = [
  1176. {name: 'dx', dispName: 'Cutoff Size', type: 'float', min:0, defVal:6},
  1177. ];
  1178. mxShapeBasicPlaque.prototype.cst = {PLAQUE : 'mxgraph.basic.plaque'};
  1179. /**
  1180. * Function: paintVertexShape
  1181. *
  1182. * Paints the vertex shape.
  1183. */
  1184. mxShapeBasicPlaque.prototype.paintVertexShape = function(c, x, y, w, h)
  1185. {
  1186. c.translate(x, y);
  1187. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx)))) * 2;
  1188. dx = Math.min(w * 0.5, h * 0.5, dx);
  1189. c.begin();
  1190. c.moveTo(w - dx, 0);
  1191. c.arcTo(dx, dx, 0, 0, 0, w, dx);
  1192. c.lineTo(w, h - dx);
  1193. c.arcTo(dx, dx, 0, 0, 0, w - dx, h);
  1194. c.lineTo(dx, h);
  1195. c.arcTo(dx, dx, 0, 0, 0, 0, h - dx);
  1196. c.lineTo(0, dx);
  1197. c.arcTo(dx, dx, 0, 0, 0, dx, 0);
  1198. c.close();
  1199. c.fillAndStroke();
  1200. };
  1201. mxCellRenderer.registerShape(mxShapeBasicPlaque.prototype.cst.PLAQUE, mxShapeBasicPlaque);
  1202. mxShapeBasicPlaque.prototype.constraints = null;
  1203. Graph.handleFactory[mxShapeBasicPlaque.prototype.cst.PLAQUE] = function(state)
  1204. {
  1205. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1206. {
  1207. var dx = Math.max(0, Math.min(bounds.width / 4, bounds.width / 4, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1208. return new mxPoint(bounds.x + dx * 1.41, bounds.y + dx * 1.41);
  1209. }, function(bounds, pt)
  1210. {
  1211. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 4, bounds.width / 4, pt.x - bounds.x))) / 100;
  1212. })];
  1213. return handles;
  1214. };
  1215. mxShapeBasicPlaque.prototype.getConstraints = function(style, w, h)
  1216. {
  1217. var constr = [];
  1218. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1219. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  1220. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  1221. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  1222. return (constr);
  1223. }
  1224. //**********************************************************************************************************************************************************
  1225. //Frame
  1226. //**********************************************************************************************************************************************************
  1227. /**
  1228. * Extends mxShape.
  1229. */
  1230. function mxShapeBasicFrame(bounds, fill, stroke, strokewidth)
  1231. {
  1232. mxShape.call(this);
  1233. this.bounds = bounds;
  1234. this.fill = fill;
  1235. this.stroke = stroke;
  1236. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1237. this.dx = 0.5;
  1238. };
  1239. /**
  1240. * Extends mxShape.
  1241. */
  1242. mxUtils.extend(mxShapeBasicFrame, mxActor);
  1243. mxShapeBasicFrame.prototype.customProperties = [
  1244. {name: 'dx', dispName: 'Width', type: 'float', min:0, defVal:10},
  1245. ];
  1246. mxShapeBasicFrame.prototype.cst = {FRAME : 'mxgraph.basic.frame'};
  1247. /**
  1248. * Function: paintVertexShape
  1249. *
  1250. * Paints the vertex shape.
  1251. */
  1252. mxShapeBasicFrame.prototype.paintVertexShape = function(c, x, y, w, h)
  1253. {
  1254. c.translate(x, y);
  1255. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1256. dx = Math.min(w * 0.5, h * 0.5, dx);
  1257. c.begin();
  1258. c.moveTo(w, 0);
  1259. c.lineTo(w, h);
  1260. c.lineTo(0, h);
  1261. c.lineTo(0, 0);
  1262. c.close();
  1263. c.moveTo(dx, dx);
  1264. c.lineTo(dx, h - dx);
  1265. c.lineTo(w - dx, h - dx);
  1266. c.lineTo(w - dx, dx);
  1267. c.close();
  1268. c.fillAndStroke();
  1269. };
  1270. mxCellRenderer.registerShape(mxShapeBasicFrame.prototype.cst.FRAME, mxShapeBasicFrame);
  1271. mxShapeBasicFrame.prototype.constraints = null;
  1272. Graph.handleFactory[mxShapeBasicFrame.prototype.cst.FRAME] = function(state)
  1273. {
  1274. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1275. {
  1276. var dx = Math.max(0, Math.min(bounds.width / 2, bounds.width / 2, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1277. return new mxPoint(bounds.x + dx, bounds.y + dx);
  1278. }, function(bounds, pt)
  1279. {
  1280. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, pt.x - bounds.x))) / 100;
  1281. })];
  1282. return handles;
  1283. };
  1284. mxShapeBasicFrame.prototype.getConstraints = function(style, w, h)
  1285. {
  1286. var constr = [];
  1287. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1288. dx = Math.min(w * 0.5, h * 0.5, dx);
  1289. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  1290. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.25, 0));
  1291. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1292. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.75, 0));
  1293. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  1294. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h * 0.25));
  1295. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  1296. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h * 0.75));
  1297. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  1298. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.75, h));
  1299. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  1300. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w * 0.25, h));
  1301. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  1302. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h * 0.75));
  1303. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  1304. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h * 0.25));
  1305. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, dx));
  1306. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - 2 * dx)* 0.25 + dx, dx));
  1307. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false, null, 0, dx));
  1308. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w * 1.5 - dx) * 0.5, dx));
  1309. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, -dx, dx));
  1310. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, (h - 2 * dx)* 0.25 + dx));
  1311. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false, null, -dx, 0));
  1312. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, (h - 2 * dx) * 0.75 + dx));
  1313. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false, null, -dx, -dx));
  1314. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - 2 * dx) * 0.75 + dx, h - dx));
  1315. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false, null, 0, -dx));
  1316. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - 2 * dx) * 0.25 + dx, h - dx));
  1317. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false, null, dx, -dx));
  1318. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, (h - 2 * dx) * 0.75 + dx));
  1319. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false, null, dx, 0));
  1320. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, (h - 2 * dx) * 0.25 + dx));
  1321. return (constr);
  1322. }
  1323. //**********************************************************************************************************************************************************
  1324. //Plaque Frame
  1325. //**********************************************************************************************************************************************************
  1326. /**
  1327. * Extends mxShape.
  1328. */
  1329. function mxShapeBasicPlaqueFrame(bounds, fill, stroke, strokewidth)
  1330. {
  1331. mxShape.call(this);
  1332. this.bounds = bounds;
  1333. this.fill = fill;
  1334. this.stroke = stroke;
  1335. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1336. this.dx = 0.5;
  1337. };
  1338. /**
  1339. */
  1340. mxUtils.extend(mxShapeBasicPlaqueFrame, mxActor);
  1341. mxShapeBasicPlaqueFrame.prototype.customProperties = [
  1342. {name: 'dx', dispName: 'Width', type: 'float', mix:0, defVal:10},
  1343. ];
  1344. mxShapeBasicPlaqueFrame.prototype.cst = {PLAQUE_FRAME : 'mxgraph.basic.plaque_frame'};
  1345. /**
  1346. * Function: paintVertexShape
  1347. *
  1348. * Paints the vertex shape.
  1349. */
  1350. mxShapeBasicPlaqueFrame.prototype.paintVertexShape = function(c, x, y, w, h)
  1351. {
  1352. c.translate(x, y);
  1353. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1354. dx = Math.min(w * 0.25, h * 0.25, dx);
  1355. c.begin();
  1356. c.moveTo(w - dx, 0);
  1357. c.arcTo(dx, dx, 0, 0, 0, w, dx);
  1358. c.lineTo(w, h - dx);
  1359. c.arcTo(dx, dx, 0, 0, 0, w - dx, h);
  1360. c.lineTo(dx, h);
  1361. c.arcTo(dx, dx, 0, 0, 0, 0, h - dx);
  1362. c.lineTo(0, dx);
  1363. c.arcTo(dx, dx, 0, 0, 0, dx, 0);
  1364. c.close();
  1365. c.moveTo(dx * 2, dx);
  1366. c.arcTo(dx * 2, dx * 2, 0, 0, 1, dx, dx * 2);
  1367. c.lineTo(dx, h - 2 * dx);
  1368. c.arcTo(dx * 2, dx * 2, 0, 0, 1, dx * 2, h - dx);
  1369. c.lineTo(w - 2 * dx, h - dx);
  1370. c.arcTo(dx * 2, dx * 2, 0, 0, 1, w - dx, h - 2 * dx);
  1371. c.lineTo(w - dx, dx * 2);
  1372. c.arcTo(dx * 2, dx * 2, 0, 0, 1, w - 2 * dx, dx);
  1373. c.close();
  1374. c.fillAndStroke();
  1375. };
  1376. mxCellRenderer.registerShape(mxShapeBasicPlaqueFrame.prototype.cst.PLAQUE_FRAME, mxShapeBasicPlaqueFrame);
  1377. mxShapeBasicPlaqueFrame.prototype.constraints = null;
  1378. Graph.handleFactory[mxShapeBasicPlaqueFrame.prototype.cst.PLAQUE_FRAME] = function(state)
  1379. {
  1380. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1381. {
  1382. var dx = Math.max(0, Math.min(bounds.width / 4, bounds.width / 4, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1383. return new mxPoint(bounds.x + dx, bounds.y + dx);
  1384. }, function(bounds, pt)
  1385. {
  1386. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 4, bounds.width / 4, pt.x - bounds.x))) / 100;
  1387. })];
  1388. return handles;
  1389. };
  1390. mxShapeBasicPlaqueFrame.prototype.getConstraints = function(style, w, h)
  1391. {
  1392. var constr = [];
  1393. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1394. dx = Math.min(w * 0.5, h * 0.5, dx);
  1395. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1396. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  1397. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  1398. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  1399. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false, null, 0, dx));
  1400. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false, null, -dx, 0));
  1401. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false, null, 0, -dx));
  1402. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false, null, dx, 0));
  1403. return (constr);
  1404. }
  1405. //**********************************************************************************************************************************************************
  1406. //Rounded Frame
  1407. //**********************************************************************************************************************************************************
  1408. /**
  1409. * Extends mxShape.
  1410. */
  1411. function mxShapeBasicRoundedFrame(bounds, fill, stroke, strokewidth)
  1412. {
  1413. mxShape.call(this);
  1414. this.bounds = bounds;
  1415. this.fill = fill;
  1416. this.stroke = stroke;
  1417. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1418. this.dx = 0.5;
  1419. };
  1420. /**
  1421. * Extends mxShape.
  1422. */
  1423. mxUtils.extend(mxShapeBasicRoundedFrame, mxActor);
  1424. mxShapeBasicRoundedFrame.prototype.customProperties = [
  1425. {name: 'dx', dispName: 'Width', type: 'float', min:0, defVal:10},
  1426. ];
  1427. mxShapeBasicRoundedFrame.prototype.cst = {ROUNDED_FRAME : 'mxgraph.basic.rounded_frame'};
  1428. /**
  1429. * Function: paintVertexShape
  1430. *
  1431. * Paints the vertex shape.
  1432. */
  1433. mxShapeBasicRoundedFrame.prototype.paintVertexShape = function(c, x, y, w, h)
  1434. {
  1435. c.translate(x, y);
  1436. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1437. dx = Math.min(w * 0.25, h * 0.25, dx);
  1438. c.begin();
  1439. c.moveTo(w - 2 * dx, 0);
  1440. c.arcTo(dx * 2, dx * 2, 0, 0, 1, w, 2 * dx);
  1441. c.lineTo(w, h - 2 * dx);
  1442. c.arcTo(dx * 2, dx * 2, 0, 0, 1, w - 2 * dx, h);
  1443. c.lineTo(dx * 2, h);
  1444. c.arcTo(dx * 2, dx * 2, 0, 0, 1, 0, h - 2 * dx);
  1445. c.lineTo(0, 2 * dx);
  1446. c.arcTo(dx * 2, dx * 2, 0, 0, 1, 2 * dx, 0);
  1447. c.close();
  1448. c.moveTo(dx * 2, dx);
  1449. c.arcTo(dx, dx, 0, 0, 0, dx, dx * 2);
  1450. c.lineTo(dx, h - 2 * dx);
  1451. c.arcTo(dx, dx, 0, 0, 0, dx * 2, h - dx);
  1452. c.lineTo(w - 2 * dx, h - dx);
  1453. c.arcTo(dx, dx, 0, 0, 0, w - dx, h - 2 * dx);
  1454. c.lineTo(w - dx, dx * 2);
  1455. c.arcTo(dx, dx, 0, 0, 0, w - 2 * dx, dx);
  1456. c.close();
  1457. c.fillAndStroke();
  1458. };
  1459. mxCellRenderer.registerShape(mxShapeBasicRoundedFrame.prototype.cst.ROUNDED_FRAME, mxShapeBasicRoundedFrame);
  1460. mxShapeBasicRoundedFrame.prototype.constraints = null;
  1461. Graph.handleFactory[mxShapeBasicRoundedFrame.prototype.cst.ROUNDED_FRAME] = function(state)
  1462. {
  1463. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1464. {
  1465. var dx = Math.max(0, Math.min(bounds.width / 4, bounds.width / 4, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1466. return new mxPoint(bounds.x + dx, bounds.y + dx);
  1467. }, function(bounds, pt)
  1468. {
  1469. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 4, bounds.width / 4, pt.x - bounds.x))) / 100;
  1470. })];
  1471. return handles;
  1472. };
  1473. mxShapeBasicRoundedFrame.prototype.getConstraints = function(style, w, h)
  1474. {
  1475. var constr = [];
  1476. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1477. dx = Math.min(w * 0.5, h * 0.5, dx);
  1478. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1479. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  1480. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  1481. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  1482. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false, null, 0, dx));
  1483. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false, null, -dx, 0));
  1484. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false, null, 0, -dx));
  1485. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false, null, dx, 0));
  1486. return (constr);
  1487. }
  1488. //**********************************************************************************************************************************************************
  1489. //Frame Corner
  1490. //**********************************************************************************************************************************************************
  1491. /**
  1492. * Extends mxShape.
  1493. */
  1494. function mxShapeBasicFrameCorner(bounds, fill, stroke, strokewidth)
  1495. {
  1496. mxShape.call(this);
  1497. this.bounds = bounds;
  1498. this.fill = fill;
  1499. this.stroke = stroke;
  1500. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1501. this.dx = 0.5;
  1502. };
  1503. /**
  1504. * Extends mxShape.
  1505. */
  1506. mxUtils.extend(mxShapeBasicFrameCorner, mxActor);
  1507. mxShapeBasicFrameCorner.prototype.customProperties = [
  1508. {name: 'dx', dispName: 'Width', type: 'float', min:0, defVal:10},
  1509. ];
  1510. mxShapeBasicFrameCorner.prototype.cst = {FRAME_CORNER : 'mxgraph.basic.frame_corner'};
  1511. /**
  1512. * Function: paintVertexShape
  1513. *
  1514. * Paints the vertex shape.
  1515. */
  1516. mxShapeBasicFrameCorner.prototype.paintVertexShape = function(c, x, y, w, h)
  1517. {
  1518. c.translate(x, y);
  1519. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1520. dx = Math.min(w * 0.5, h * 0.5, dx);
  1521. c.begin();
  1522. c.moveTo(0, 0);
  1523. c.lineTo(w, 0);
  1524. c.lineTo(w - dx, dx);
  1525. c.lineTo(dx, dx);
  1526. c.lineTo(dx, h - dx);
  1527. c.lineTo(0, h);
  1528. c.close();
  1529. c.fillAndStroke();
  1530. };
  1531. mxCellRenderer.registerShape(mxShapeBasicFrameCorner.prototype.cst.FRAME_CORNER, mxShapeBasicFrameCorner);
  1532. mxShapeBasicFrameCorner.prototype.constraints = null;
  1533. Graph.handleFactory[mxShapeBasicFrameCorner.prototype.cst.FRAME_CORNER] = function(state)
  1534. {
  1535. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1536. {
  1537. var dx = Math.max(0, Math.min(bounds.width / 2, bounds.width / 2, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1538. return new mxPoint(bounds.x + dx, bounds.y + dx);
  1539. }, function(bounds, pt)
  1540. {
  1541. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, pt.x - bounds.x))) / 100;
  1542. })];
  1543. return handles;
  1544. };
  1545. mxShapeBasicFrameCorner.prototype.getConstraints = function(style, w, h)
  1546. {
  1547. var constr = [];
  1548. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1549. dx = Math.min(w * 0.5, h * 0.5, dx);
  1550. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  1551. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1552. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  1553. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false, null, -dx, dx));
  1554. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - 2 * dx) * 0.5 + dx, dx));
  1555. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, dx));
  1556. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, (h - 2 * dx) * 0.5 + dx));
  1557. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false, null, dx, -dx));
  1558. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  1559. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  1560. return (constr);
  1561. }
  1562. //**********************************************************************************************************************************************************
  1563. //Diagonal Stripe
  1564. //**********************************************************************************************************************************************************
  1565. /**
  1566. * Extends mxShape.
  1567. */
  1568. function mxShapeBasicDiagStripe(bounds, fill, stroke, strokewidth)
  1569. {
  1570. mxShape.call(this);
  1571. this.bounds = bounds;
  1572. this.fill = fill;
  1573. this.stroke = stroke;
  1574. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1575. this.dx = 0.5;
  1576. };
  1577. /**
  1578. * Extends mxShape.
  1579. */
  1580. mxUtils.extend(mxShapeBasicDiagStripe, mxActor);
  1581. mxShapeBasicDiagStripe.prototype.customProperties = [
  1582. {name: 'dx', dispName: 'Width', type: 'float', mix:0, defVal:10},
  1583. ];
  1584. mxShapeBasicDiagStripe.prototype.cst = {DIAG_STRIPE : 'mxgraph.basic.diag_stripe'};
  1585. /**
  1586. * Function: paintVertexShape
  1587. *
  1588. * Paints the vertex shape.
  1589. */
  1590. mxShapeBasicDiagStripe.prototype.paintVertexShape = function(c, x, y, w, h)
  1591. {
  1592. c.translate(x, y);
  1593. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1594. dx = Math.min(w, h, dx);
  1595. c.begin();
  1596. c.moveTo(0, h);
  1597. c.lineTo(w, 0);
  1598. c.lineTo(w, Math.min(dx * 100 / w, h));
  1599. c.lineTo(Math.min(dx * 100 / h, w), h);
  1600. c.close();
  1601. c.fillAndStroke();
  1602. };
  1603. mxCellRenderer.registerShape(mxShapeBasicDiagStripe.prototype.cst.DIAG_STRIPE, mxShapeBasicDiagStripe);
  1604. mxShapeBasicDiagStripe.prototype.constraints = null;
  1605. Graph.handleFactory[mxShapeBasicDiagStripe.prototype.cst.DIAG_STRIPE] = function(state)
  1606. {
  1607. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1608. {
  1609. var dx = Math.max(0, Math.min(bounds.width / 2, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1610. return new mxPoint(bounds.x + dx, bounds.y + bounds.height);
  1611. }, function(bounds, pt)
  1612. {
  1613. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, pt.x - bounds.x))) / 100;
  1614. })];
  1615. return handles;
  1616. };
  1617. mxShapeBasicDiagStripe.prototype.getConstraints = function(style, w, h)
  1618. {
  1619. var constr = [];
  1620. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1621. dx = Math.min(w, h, dx);
  1622. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  1623. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0.5), false));
  1624. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  1625. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, Math.min(dx * 100 / w, h) * 0.5));
  1626. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, Math.min(dx * 100 / w, h)));
  1627. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w + Math.min(dx * 100 / h, w)) * 0.5, (Math.min(dx * 100 / w, h) + h) * 0.5));
  1628. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, Math.min(dx * 100 / h, w), h));
  1629. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, Math.min(dx * 100 / h, w) * 0.5, h));
  1630. return (constr);
  1631. }
  1632. //**********************************************************************************************************************************************************
  1633. //Donut
  1634. //**********************************************************************************************************************************************************
  1635. /**
  1636. * Extends mxShape.
  1637. */
  1638. function mxShapeBasicDonut(bounds, fill, stroke, strokewidth)
  1639. {
  1640. mxShape.call(this);
  1641. this.bounds = bounds;
  1642. this.fill = fill;
  1643. this.stroke = stroke;
  1644. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1645. this.dx = 0.5;
  1646. };
  1647. /**
  1648. * Extends mxShape.
  1649. */
  1650. mxUtils.extend(mxShapeBasicDonut, mxActor);
  1651. mxShapeBasicDonut.prototype.customProperties = [
  1652. {name: 'dx', dispName: 'Width', type: 'float', min:0, defVal:25}
  1653. ];
  1654. mxShapeBasicDonut.prototype.cst = {DONUT : 'mxgraph.basic.donut'};
  1655. /**
  1656. * Function: paintVertexShape
  1657. *
  1658. * Paints the vertex shape.
  1659. */
  1660. mxShapeBasicDonut.prototype.paintVertexShape = function(c, x, y, w, h)
  1661. {
  1662. c.translate(x, y);
  1663. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1664. dx = Math.min(w * 0.5, h * 0.5, dx);
  1665. c.begin();
  1666. c.moveTo(0, h * 0.5);
  1667. c.arcTo(w * 0.5, h * 0.5, 0, 0, 1, w * 0.5, 0);
  1668. c.arcTo(w * 0.5, h * 0.5, 0, 0, 1, w, h * 0.5);
  1669. c.arcTo(w * 0.5, h * 0.5, 0, 0, 1, w * 0.5, h);
  1670. c.arcTo(w * 0.5, h * 0.5, 0, 0, 1, 0, h * 0.5);
  1671. c.close();
  1672. c.moveTo(w * 0.5, dx);
  1673. c.arcTo(w * 0.5 - dx, h * 0.5 - dx, 0, 0, 0, dx, h * 0.5);
  1674. c.arcTo(w * 0.5 - dx, h * 0.5 - dx, 0, 0, 0, w * 0.5, h - dx);
  1675. c.arcTo(w * 0.5 - dx, h * 0.5 - dx, 0, 0, 0, w - dx, h * 0.5);
  1676. c.arcTo(w * 0.5 - dx, h * 0.5 - dx, 0, 0, 0, w * 0.5, dx);
  1677. c.close();
  1678. c.fillAndStroke();
  1679. };
  1680. mxCellRenderer.registerShape(mxShapeBasicDonut.prototype.cst.DONUT, mxShapeBasicDonut);
  1681. mxShapeBasicDonut.prototype.constraints = null;
  1682. Graph.handleFactory[mxShapeBasicDonut.prototype.cst.DONUT] = function(state)
  1683. {
  1684. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1685. {
  1686. var dx = Math.max(0, Math.min(bounds.width / 2, bounds.width / 2, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1687. return new mxPoint(bounds.x + dx, bounds.y + bounds.height / 2);
  1688. }, function(bounds, pt)
  1689. {
  1690. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, pt.x - bounds.x))) / 100;
  1691. })];
  1692. return handles;
  1693. };
  1694. //**********************************************************************************************************************************************************
  1695. //Layered Rect
  1696. //**********************************************************************************************************************************************************
  1697. /**
  1698. * Extends mxShape.
  1699. */
  1700. function mxShapeBasicLayeredRect(bounds, fill, stroke, strokewidth)
  1701. {
  1702. mxShape.call(this);
  1703. this.bounds = bounds;
  1704. this.fill = fill;
  1705. this.stroke = stroke;
  1706. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1707. this.dx = 0.5;
  1708. };
  1709. /**
  1710. * Extends mxShape.
  1711. */
  1712. mxUtils.extend(mxShapeBasicLayeredRect, mxActor);
  1713. mxShapeBasicLayeredRect.prototype.customProperties = [
  1714. {name: 'dx', dispName: 'Layer Distance', type: 'float', mix:0, defVal:10},
  1715. {name: 'boundedLbl', dispName: 'Bounded Label', type: 'bool', defVal: false}
  1716. ];
  1717. mxShapeBasicLayeredRect.prototype.cst = {LAYERED_RECT : 'mxgraph.basic.layered_rect'};
  1718. /**
  1719. * Function: getLabelMargins
  1720. *
  1721. * Confines the label to the front rectangle if boundedLbl=1. Flips are
  1722. * handled in mxShape.getLabelBounds via mxUtils.getDirectedBounds.
  1723. */
  1724. mxShapeBasicLayeredRect.prototype.getLabelMargins = function(rect)
  1725. {
  1726. if (mxUtils.getValue(this.style, 'boundedLbl', false))
  1727. {
  1728. var w = rect.width / this.scale;
  1729. var h = rect.height / this.scale;
  1730. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1731. dx = Math.min(w * 0.5, h * 0.5, dx) * this.scale;
  1732. return new mxRectangle(0, 0, dx, dx);
  1733. }
  1734. return null;
  1735. };
  1736. /**
  1737. * Function: paintVertexShape
  1738. *
  1739. * Paints the vertex shape.
  1740. */
  1741. mxShapeBasicLayeredRect.prototype.paintVertexShape = function(c, x, y, w, h)
  1742. {
  1743. c.translate(x, y);
  1744. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1745. dx = Math.min(w * 0.5, h * 0.5, dx);
  1746. c.begin();
  1747. c.moveTo(dx, dx);
  1748. c.lineTo(w, dx);
  1749. c.lineTo(w, h);
  1750. c.lineTo(dx, h);
  1751. c.close();
  1752. c.fillAndStroke();
  1753. c.begin();
  1754. c.moveTo(dx * 0.5, dx * 0.5);
  1755. c.lineTo(w - dx * 0.5, dx * 0.5);
  1756. c.lineTo(w - dx * 0.5, h - dx * 0.5);
  1757. c.lineTo(dx * 0.5, h - dx * 0.5);
  1758. c.close();
  1759. c.fillAndStroke();
  1760. c.begin();
  1761. c.moveTo(0, 0);
  1762. c.lineTo(w - dx, 0);
  1763. c.lineTo(w - dx, h - dx);
  1764. c.lineTo(0, h - dx);
  1765. c.close();
  1766. c.fillAndStroke();
  1767. };
  1768. mxCellRenderer.registerShape(mxShapeBasicLayeredRect.prototype.cst.LAYERED_RECT, mxShapeBasicLayeredRect);
  1769. mxShapeBasicLayeredRect.prototype.constraints = null;
  1770. Graph.handleFactory[mxShapeBasicLayeredRect.prototype.cst.LAYERED_RECT] = function(state)
  1771. {
  1772. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1773. {
  1774. var dx = Math.max(0, Math.min(bounds.width / 2, bounds.width / 2, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1775. return new mxPoint(bounds.x + bounds.width - dx, bounds.y + bounds.height - dx);
  1776. }, function(bounds, pt)
  1777. {
  1778. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, - pt.x + bounds.width + bounds.x))) / 100;
  1779. })];
  1780. return handles;
  1781. };
  1782. mxShapeBasicLayeredRect.prototype.getConstraints = function(style, w, h)
  1783. {
  1784. var constr = [];
  1785. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1786. dx = Math.min(w * 0.5, h * 0.5, dx);
  1787. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  1788. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - dx) * 0.25, 0));
  1789. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - dx) * 0.5, 0));
  1790. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - dx) * 0.75, 0));
  1791. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx, 0));
  1792. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w - dx * 0.5, dx * 0.5));
  1793. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, dx));
  1794. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dx) * 0.25 + dx));
  1795. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dx) * 0.5 + dx));
  1796. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dx) * 0.75 + dx));
  1797. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h));
  1798. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - dx) * 0.75 + dx, h));
  1799. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - dx) * 0.5 + dx, h));
  1800. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, (w - dx) * 0.25 + dx, h));
  1801. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, h));
  1802. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx * 0.5, h - dx * 0.5));
  1803. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - dx));
  1804. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dx) * 0.75));
  1805. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dx) * 0.5));
  1806. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, (h - dx) * 0.25));
  1807. return (constr);
  1808. }
  1809. //**********************************************************************************************************************************************************
  1810. //Button
  1811. //**********************************************************************************************************************************************************
  1812. /**
  1813. * Extends mxShape.
  1814. */
  1815. function mxShapeBasicButton(bounds, fill, stroke, strokewidth)
  1816. {
  1817. mxShape.call(this);
  1818. this.bounds = bounds;
  1819. this.fill = fill;
  1820. this.stroke = stroke;
  1821. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1822. this.dx = 0.5;
  1823. };
  1824. /**
  1825. * Extends mxShape.
  1826. */
  1827. mxUtils.extend(mxShapeBasicButton, mxActor);
  1828. mxShapeBasicButton.prototype.customProperties = [
  1829. {name: 'dx', dispName: 'Button Height', type: 'float', min:0, defVal:10}
  1830. ];
  1831. mxShapeBasicButton.prototype.cst = {BUTTON : 'mxgraph.basic.button'};
  1832. /**
  1833. * Function: paintVertexShape
  1834. *
  1835. * Paints the vertex shape.
  1836. */
  1837. mxShapeBasicButton.prototype.paintVertexShape = function(c, x, y, w, h)
  1838. {
  1839. c.translate(x, y);
  1840. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1841. dx = Math.min(w * 0.5, h * 0.5, dx);
  1842. c.begin();
  1843. c.moveTo(0, 0);
  1844. c.lineTo(w, 0);
  1845. c.lineTo(w, h);
  1846. c.lineTo(0, h);
  1847. c.close();
  1848. c.fillAndStroke();
  1849. c.setShadow(false);
  1850. c.setLineJoin('round');
  1851. c.begin();
  1852. c.moveTo(0, h);
  1853. c.lineTo(0, 0);
  1854. c.lineTo(dx, dx);
  1855. c.lineTo(dx, h - dx);
  1856. c.close();
  1857. c.fillAndStroke();
  1858. c.begin();
  1859. c.moveTo(0, 0);
  1860. c.lineTo(w, 0);
  1861. c.lineTo(w - dx, dx);
  1862. c.lineTo(dx, dx);
  1863. c.close();
  1864. c.fillAndStroke();
  1865. c.begin();
  1866. c.moveTo(w, 0);
  1867. c.lineTo(w, h);
  1868. c.lineTo(w - dx, h - dx);
  1869. c.lineTo(w - dx, dx);
  1870. c.close();
  1871. c.fillAndStroke();
  1872. c.begin();
  1873. c.moveTo(0, h);
  1874. c.lineTo(dx, h - dx);
  1875. c.lineTo(w - dx, h - dx);
  1876. c.lineTo(w, h);
  1877. c.close();
  1878. c.fillAndStroke();
  1879. c.begin();
  1880. c.moveTo(0, h);
  1881. c.lineTo(0, 0);
  1882. c.lineTo(dx, dx);
  1883. c.lineTo(dx, h - dx);
  1884. c.close();
  1885. c.fillAndStroke();
  1886. };
  1887. mxCellRenderer.registerShape(mxShapeBasicButton.prototype.cst.BUTTON, mxShapeBasicButton);
  1888. mxShapeBasicButton.prototype.constraints = null;
  1889. Graph.handleFactory[mxShapeBasicButton.prototype.cst.BUTTON] = function(state)
  1890. {
  1891. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1892. {
  1893. var dx = Math.max(0, Math.min(bounds.width / 2, bounds.width / 2, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1894. return new mxPoint(bounds.x + dx, bounds.y + dx);
  1895. }, function(bounds, pt)
  1896. {
  1897. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, pt.x - bounds.x))) / 100;
  1898. })];
  1899. return handles;
  1900. };
  1901. //**********************************************************************************************************************************************************
  1902. //Shaded Button
  1903. //**********************************************************************************************************************************************************
  1904. /**
  1905. * Extends mxShape.
  1906. */
  1907. function mxShapeBasicShadedButton(bounds, fill, stroke, strokewidth)
  1908. {
  1909. mxShape.call(this);
  1910. this.bounds = bounds;
  1911. this.fill = fill;
  1912. this.stroke = stroke;
  1913. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1914. this.dx = 0.5;
  1915. };
  1916. /**
  1917. * Extends mxShape.
  1918. */
  1919. mxUtils.extend(mxShapeBasicShadedButton, mxActor);
  1920. mxShapeBasicShadedButton.prototype.customProperties = [
  1921. {name: 'dx', dispName: 'Button Height', type: 'float', min:0, defVal:10}
  1922. ];
  1923. mxShapeBasicShadedButton.prototype.cst = {SHADED_BUTTON : 'mxgraph.basic.shaded_button'};
  1924. /**
  1925. * Function: paintVertexShape
  1926. *
  1927. * Paints the vertex shape.
  1928. */
  1929. mxShapeBasicShadedButton.prototype.paintVertexShape = function(c, x, y, w, h)
  1930. {
  1931. c.translate(x, y);
  1932. c.setShadow(false);
  1933. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1934. dx = Math.min(w * 0.5, h * 0.5, dx);
  1935. c.begin();
  1936. c.moveTo(0, 0);
  1937. c.lineTo(w, 0);
  1938. c.lineTo(w, h);
  1939. c.lineTo(0, h);
  1940. c.close();
  1941. c.fill();
  1942. c.setFillColor('#ffffff');
  1943. c.setAlpha(0.25);
  1944. c.begin();
  1945. c.moveTo(0, h);
  1946. c.lineTo(0, 0);
  1947. c.lineTo(dx, dx);
  1948. c.lineTo(dx, h - dx);
  1949. c.close();
  1950. c.fill();
  1951. c.setAlpha(0.5);
  1952. c.begin();
  1953. c.moveTo(0, 0);
  1954. c.lineTo(w, 0);
  1955. c.lineTo(w - dx, dx);
  1956. c.lineTo(dx, dx);
  1957. c.close();
  1958. c.fill();
  1959. c.setFillColor('#000000');
  1960. c.setAlpha(0.25);
  1961. c.begin();
  1962. c.moveTo(w, 0);
  1963. c.lineTo(w, h);
  1964. c.lineTo(w - dx, h - dx);
  1965. c.lineTo(w - dx, dx);
  1966. c.close();
  1967. c.fill();
  1968. c.setAlpha(0.5);
  1969. c.begin();
  1970. c.moveTo(0, h);
  1971. c.lineTo(dx, h - dx);
  1972. c.lineTo(w - dx, h - dx);
  1973. c.lineTo(w, h);
  1974. c.close();
  1975. c.fill();
  1976. };
  1977. mxCellRenderer.registerShape(mxShapeBasicShadedButton.prototype.cst.SHADED_BUTTON, mxShapeBasicShadedButton);
  1978. mxShapeBasicShadedButton.prototype.constraints = null;
  1979. Graph.handleFactory[mxShapeBasicShadedButton.prototype.cst.SHADED_BUTTON] = function(state)
  1980. {
  1981. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1982. {
  1983. var dx = Math.max(0, Math.min(bounds.width / 2, bounds.width / 2, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1984. return new mxPoint(bounds.x + dx, bounds.y + dx);
  1985. }, function(bounds, pt)
  1986. {
  1987. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, pt.x - bounds.x))) / 100;
  1988. })];
  1989. return handles;
  1990. };
  1991. //**********************************************************************************************************************************************************
  1992. //Pie
  1993. //**********************************************************************************************************************************************************
  1994. /**
  1995. * Extends mxShape.
  1996. */
  1997. function mxShapeBasicPie(bounds, fill, stroke, strokewidth)
  1998. {
  1999. mxShape.call(this);
  2000. this.bounds = bounds;
  2001. this.fill = fill;
  2002. this.stroke = stroke;
  2003. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2004. this.startAngle = 0.25;
  2005. this.endAngle = 0.75;
  2006. };
  2007. /**
  2008. * Extends mxShape.
  2009. */
  2010. mxUtils.extend(mxShapeBasicPie, mxActor);
  2011. mxShapeBasicPie.prototype.customProperties = [
  2012. {name: 'startAngle', dispName: 'Start Angle', type: 'float', min:0, max:1, defVal: 0.2},
  2013. {name: 'endAngle', dispName: 'End Angle', type: 'float', min:0, max:1, defVal: 0.9}
  2014. ];
  2015. mxShapeBasicPie.prototype.cst = {PIE : 'mxgraph.basic.pie'};
  2016. /**
  2017. * Function: paintVertexShape
  2018. *
  2019. * Paints the vertex shape.
  2020. */
  2021. mxShapeBasicPie.prototype.paintVertexShape = function(c, x, y, w, h)
  2022. {
  2023. c.translate(x, y);
  2024. var startAngleSource = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'startAngle', this.startAngle))));
  2025. var endAngleSource = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'endAngle', this.endAngle))));
  2026. var startAngle = 2 * Math.PI * startAngleSource;
  2027. var endAngle = 2 * Math.PI * endAngleSource;
  2028. var rx = w * 0.5;
  2029. var ry = h * 0.5;
  2030. var startX = rx + Math.sin(startAngle) * rx;
  2031. var startY = ry - Math.cos(startAngle) * ry;
  2032. var endX = rx + Math.sin(endAngle) * rx;
  2033. var endY = ry - Math.cos(endAngle) * ry;
  2034. var angDiff = endAngle - startAngle;
  2035. if (angDiff < 0)
  2036. {
  2037. angDiff = angDiff + Math.PI * 2;
  2038. }
  2039. var bigArc = 0;
  2040. if (angDiff >= Math.PI)
  2041. {
  2042. bigArc = 1;
  2043. }
  2044. c.begin();
  2045. var startAngleDiff = startAngleSource % 1;
  2046. var endAngleDiff = endAngleSource % 1;
  2047. if (startAngleDiff == 0 && endAngleDiff == 0.5)
  2048. {
  2049. c.moveTo(rx, ry);
  2050. c.lineTo(startX, startY);
  2051. c.arcTo(rx, ry, 0, 0, 1, w, h * 0.5);
  2052. c.arcTo(rx, ry, 0, 0, 1, w * 0.5, h);
  2053. }
  2054. else if (startAngleDiff == 0.5 && endAngleDiff == 0)
  2055. {
  2056. c.moveTo(rx, ry);
  2057. c.lineTo(startX, startY);
  2058. c.arcTo(rx, ry, 0, 0, 1, 0, h * 0.5);
  2059. c.arcTo(rx, ry, 0, 0, 1, w * 0.5, 0);
  2060. }
  2061. else
  2062. {
  2063. c.moveTo(rx, ry);
  2064. c.lineTo(startX, startY);
  2065. c.arcTo(rx, ry, 0, bigArc, 1, endX, endY);
  2066. }
  2067. c.close();
  2068. c.fillAndStroke();
  2069. };
  2070. mxCellRenderer.registerShape(mxShapeBasicPie.prototype.cst.PIE, mxShapeBasicPie);
  2071. mxShapeBasicPie.prototype.constraints = null;
  2072. Graph.handleFactory[mxShapeBasicPie.prototype.cst.PIE] = function(state)
  2073. {
  2074. var handles = [Graph.createHandle(state, ['startAngle'], function(bounds)
  2075. {
  2076. var startAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'startAngle', this.startAngle))));
  2077. return new mxPoint(bounds.x + bounds.width * 0.5 + Math.sin(startAngle) * bounds.width * 0.5, bounds.y + bounds.height * 0.5 - Math.cos(startAngle) * bounds.height * 0.5);
  2078. }, function(bounds, pt)
  2079. {
  2080. var handleX = Math.round(100 * Math.max(-1, Math.min(1, (pt.x - bounds.x - bounds.width * 0.5) / (bounds.width * 0.5)))) / 100;
  2081. var handleY = -Math.round(100 * Math.max(-1, Math.min(1, (pt.y - bounds.y - bounds.height * 0.5) / (bounds.height * 0.5)))) / 100;
  2082. var res = 0.5 * Math.atan2(handleX, handleY) / Math.PI;
  2083. if (res < 0)
  2084. {
  2085. res = 1 + res;
  2086. }
  2087. this.state.style['startAngle'] = res;
  2088. })];
  2089. var handle2 = Graph.createHandle(state, ['endAngle'], function(bounds)
  2090. {
  2091. var endAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'endAngle', this.endAngle))));
  2092. return new mxPoint(bounds.x + bounds.width * 0.5 + Math.sin(endAngle) * bounds.width * 0.5, bounds.y + bounds.height * 0.5 - Math.cos(endAngle) * bounds.height * 0.5);
  2093. }, function(bounds, pt)
  2094. {
  2095. var handleX = Math.round(100 * Math.max(-1, Math.min(1, (pt.x - bounds.x - bounds.width * 0.5) / (bounds.width * 0.5)))) / 100;
  2096. var handleY = -Math.round(100 * Math.max(-1, Math.min(1, (pt.y - bounds.y - bounds.height * 0.5) / (bounds.height * 0.5)))) / 100;
  2097. var res = 0.5 * Math.atan2(handleX, handleY) / Math.PI;
  2098. if (res < 0)
  2099. {
  2100. res = 1 + res;
  2101. }
  2102. this.state.style['endAngle'] = res;
  2103. });
  2104. handles.push(handle2);
  2105. return handles;
  2106. };
  2107. //**********************************************************************************************************************************************************
  2108. //Arc
  2109. //**********************************************************************************************************************************************************
  2110. /**
  2111. * Extends mxShape.
  2112. */
  2113. function mxShapeBasicArc(bounds, fill, stroke, strokewidth)
  2114. {
  2115. mxShape.call(this);
  2116. this.bounds = bounds;
  2117. this.fill = fill;
  2118. this.stroke = stroke;
  2119. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2120. this.startAngle = 0.25;
  2121. this.endAngle = 0.75;
  2122. };
  2123. /**
  2124. * Extends mxShape.
  2125. */
  2126. mxUtils.extend(mxShapeBasicArc, mxActor);
  2127. mxShapeBasicArc.prototype.customProperties = [
  2128. {name: 'startAngle', dispName: 'Start Angle', type: 'float', min:0, max:1, defVal: 0.3},
  2129. {name: 'endAngle', dispName: 'End Angle', type: 'float', min:0, max:1, defVal:0.1},
  2130. {name: 'startArrow', dispName: 'Start Arrow', type: 'enum', defVal: 'none',
  2131. enumList: [{val: 'none', dispName: 'None'}, {val: 'classic', dispName: 'Classic'},
  2132. {val: 'classicThin', dispName: 'Classic Thin'}, {val: 'open', dispName: 'Open'},
  2133. {val: 'openThin', dispName: 'Open Thin'}, {val: 'block', dispName: 'Block'},
  2134. {val: 'blockThin', dispName: 'Block Thin'}, {val: 'oval', dispName: 'Oval'},
  2135. {val: 'diamond', dispName: 'Diamond'}, {val: 'diamondThin', dispName: 'Diamond Thin'}]},
  2136. {name: 'endArrow', dispName: 'End Arrow', type: 'enum', defVal: 'none',
  2137. enumList: [{val: 'none', dispName: 'None'}, {val: 'classic', dispName: 'Classic'},
  2138. {val: 'classicThin', dispName: 'Classic Thin'}, {val: 'open', dispName: 'Open'},
  2139. {val: 'openThin', dispName: 'Open Thin'}, {val: 'block', dispName: 'Block'},
  2140. {val: 'blockThin', dispName: 'Block Thin'}, {val: 'oval', dispName: 'Oval'},
  2141. {val: 'diamond', dispName: 'Diamond'}, {val: 'diamondThin', dispName: 'Diamond Thin'}]},
  2142. {name: 'startFill', dispName: 'Start Fill', type: 'bool', defVal: true},
  2143. {name: 'endFill', dispName: 'End Fill', type: 'bool', defVal: true},
  2144. {name: 'startSize', dispName: 'Start Size', type: 'float', min: 1, defVal: 6},
  2145. {name: 'endSize', dispName: 'End Size', type: 'float', min: 1, defVal: 6}
  2146. ];
  2147. mxShapeBasicArc.prototype.cst = {ARC : 'mxgraph.basic.arc'};
  2148. /**
  2149. * Function: paintVertexShape
  2150. *
  2151. * Paints the vertex shape.
  2152. */
  2153. mxShapeBasicArc.prototype.paintVertexShape = function(c, x, y, w, h)
  2154. {
  2155. c.translate(x, y);
  2156. var startAngleSource = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'startAngle', this.startAngle))));
  2157. var endAngleSource = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'endAngle', this.endAngle))));
  2158. var startAngle = 2 * Math.PI * startAngleSource;
  2159. var endAngle = 2 * Math.PI * endAngleSource;
  2160. // Arrow markers
  2161. var startArrow = mxUtils.getValue(this.style, mxConstants.STYLE_STARTARROW, mxConstants.NONE);
  2162. var endArrow = mxUtils.getValue(this.style, mxConstants.STYLE_ENDARROW, mxConstants.NONE);
  2163. var startSize = mxUtils.getNumber(this.style, mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_MARKERSIZE);
  2164. var endSize = mxUtils.getNumber(this.style, mxConstants.STYLE_ENDSIZE, mxConstants.DEFAULT_MARKERSIZE);
  2165. // Inset ellipse to keep markers within shape bounds
  2166. var markerPadding = 0;
  2167. if (startArrow != null && startArrow != mxConstants.NONE)
  2168. {
  2169. markerPadding = Math.max(markerPadding, startSize);
  2170. }
  2171. if (endArrow != null && endArrow != mxConstants.NONE)
  2172. {
  2173. markerPadding = Math.max(markerPadding, endSize);
  2174. }
  2175. if (markerPadding > 0)
  2176. {
  2177. markerPadding = (markerPadding + this.strokewidth) / 2;
  2178. }
  2179. var cx = w * 0.5;
  2180. var cy = h * 0.5;
  2181. var rx = Math.max(0, w * 0.5 - markerPadding);
  2182. var ry = Math.max(0, h * 0.5 - markerPadding);
  2183. var startX = cx + Math.sin(startAngle) * rx;
  2184. var startY = cy - Math.cos(startAngle) * ry;
  2185. var endX = cx + Math.sin(endAngle) * rx;
  2186. var endY = cy - Math.cos(endAngle) * ry;
  2187. var startMarker = null;
  2188. var endMarker = null;
  2189. if (startArrow != null && startArrow != mxConstants.NONE)
  2190. {
  2191. var startFilled = this.style[mxConstants.STYLE_STARTFILL] != 0;
  2192. // Direction pointing into the start (opposite of clockwise tangent)
  2193. var dx = -rx * Math.cos(startAngle);
  2194. var dy = -ry * Math.sin(startAngle);
  2195. var dist = Math.sqrt(dx * dx + dy * dy);
  2196. if (dist > 0)
  2197. {
  2198. var pe = new mxPoint(startX, startY);
  2199. startMarker = mxMarker.createMarker(c, this, startArrow, pe,
  2200. dx / dist, dy / dist, startSize, true, this.strokewidth, startFilled);
  2201. startX = pe.x;
  2202. startY = pe.y;
  2203. }
  2204. }
  2205. if (endArrow != null && endArrow != mxConstants.NONE)
  2206. {
  2207. var endFilled = this.style[mxConstants.STYLE_ENDFILL] != 0;
  2208. // Direction along the clockwise tangent at end
  2209. var dx = rx * Math.cos(endAngle);
  2210. var dy = ry * Math.sin(endAngle);
  2211. var dist = Math.sqrt(dx * dx + dy * dy);
  2212. if (dist > 0)
  2213. {
  2214. var pe = new mxPoint(endX, endY);
  2215. endMarker = mxMarker.createMarker(c, this, endArrow, pe,
  2216. dx / dist, dy / dist, endSize, false, this.strokewidth, endFilled);
  2217. endX = pe.x;
  2218. endY = pe.y;
  2219. }
  2220. }
  2221. // Draw arc
  2222. var angDiff = endAngle - startAngle;
  2223. if (angDiff < 0)
  2224. {
  2225. angDiff = angDiff + Math.PI * 2;
  2226. }
  2227. var bigArc = 0;
  2228. if (angDiff > Math.PI)
  2229. {
  2230. bigArc = 1;
  2231. }
  2232. c.begin();
  2233. var startAngleDiff = startAngleSource % 1;
  2234. var endAngleDiff = endAngleSource % 1;
  2235. if (startMarker == null && endMarker == null &&
  2236. startAngleDiff == 0 && endAngleDiff == 0.5)
  2237. {
  2238. c.moveTo(startX, startY);
  2239. c.arcTo(rx, ry, 0, 0, 1, cx + rx, cy);
  2240. c.arcTo(rx, ry, 0, 0, 1, cx, cy + ry);
  2241. }
  2242. else if (startMarker == null && endMarker == null &&
  2243. startAngleDiff == 0.5 && endAngleDiff == 0)
  2244. {
  2245. c.moveTo(startX, startY);
  2246. c.arcTo(rx, ry, 0, 0, 1, cx - rx, cy);
  2247. c.arcTo(rx, ry, 0, 0, 1, cx, cy - ry);
  2248. }
  2249. else
  2250. {
  2251. c.moveTo(startX, startY);
  2252. c.arcTo(rx, ry, 0, bigArc, 1, endX, endY);
  2253. }
  2254. c.stroke();
  2255. // Paint markers
  2256. c.setShadow(false);
  2257. c.setDashed(false);
  2258. if (startMarker != null)
  2259. {
  2260. c.setFillColor(mxUtils.getValue(this.style,
  2261. mxConstants.STYLE_STARTFILLCOLOR, this.stroke));
  2262. startMarker();
  2263. }
  2264. if (endMarker != null)
  2265. {
  2266. c.setFillColor(mxUtils.getValue(this.style,
  2267. mxConstants.STYLE_ENDFILLCOLOR, this.stroke));
  2268. endMarker();
  2269. }
  2270. };
  2271. mxCellRenderer.registerShape(mxShapeBasicArc.prototype.cst.ARC, mxShapeBasicArc);
  2272. mxShapeBasicArc.prototype.constraints = null;
  2273. Graph.handleFactory[mxShapeBasicArc.prototype.cst.ARC] = function(state)
  2274. {
  2275. var handles = [Graph.createHandle(state, ['startAngle'], function(bounds)
  2276. {
  2277. var startAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'startAngle', this.startAngle))));
  2278. return new mxPoint(bounds.x + bounds.width * 0.5 + Math.sin(startAngle) * bounds.width * 0.5, bounds.y + bounds.height * 0.5 - Math.cos(startAngle) * bounds.height * 0.5);
  2279. }, function(bounds, pt)
  2280. {
  2281. var handleX = Math.round(100 * Math.max(-1, Math.min(1, (pt.x - bounds.x - bounds.width * 0.5) / (bounds.width * 0.5)))) / 100;
  2282. var handleY = -Math.round(100 * Math.max(-1, Math.min(1, (pt.y - bounds.y - bounds.height * 0.5) / (bounds.height * 0.5)))) / 100;
  2283. var res = 0.5 * Math.atan2(handleX, handleY) / Math.PI;
  2284. if (res < 0)
  2285. {
  2286. res = 1 + res;
  2287. }
  2288. this.state.style['startAngle'] = res;
  2289. })];
  2290. var handle2 = Graph.createHandle(state, ['endAngle'], function(bounds)
  2291. {
  2292. var endAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'endAngle', this.endAngle))));
  2293. return new mxPoint(bounds.x + bounds.width * 0.5 + Math.sin(endAngle) * bounds.width * 0.5, bounds.y + bounds.height * 0.5 - Math.cos(endAngle) * bounds.height * 0.5);
  2294. }, function(bounds, pt)
  2295. {
  2296. var handleX = Math.round(100 * Math.max(-1, Math.min(1, (pt.x - bounds.x - bounds.width * 0.5) / (bounds.width * 0.5)))) / 100;
  2297. var handleY = -Math.round(100 * Math.max(-1, Math.min(1, (pt.y - bounds.y - bounds.height * 0.5) / (bounds.height * 0.5)))) / 100;
  2298. var res = 0.5 * Math.atan2(handleX, handleY) / Math.PI;
  2299. if (res < 0)
  2300. {
  2301. res = 1 + res;
  2302. }
  2303. this.state.style['endAngle'] = res;
  2304. });
  2305. handles.push(handle2);
  2306. return handles;
  2307. };
  2308. //**********************************************************************************************************************************************************
  2309. //Partial Concentric Ellipse
  2310. //**********************************************************************************************************************************************************
  2311. /**
  2312. * Extends mxShape.
  2313. */
  2314. function mxShapeBasicPartConcEllipse(bounds, fill, stroke, strokewidth)
  2315. {
  2316. mxShape.call(this);
  2317. this.bounds = bounds;
  2318. this.fill = fill;
  2319. this.stroke = stroke;
  2320. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2321. this.startAngle = 0.25;
  2322. this.endAngle = 0.75;
  2323. this.arcWidth = 0.5;
  2324. };
  2325. /**
  2326. * Extends mxShape.
  2327. */
  2328. mxUtils.extend(mxShapeBasicPartConcEllipse, mxActor);
  2329. mxShapeBasicPartConcEllipse.prototype.customProperties = [
  2330. {name: 'startAngle', dispName: 'Start Angle', type: 'float', min:0, max:1, defVal:0.25},
  2331. {name: 'endAngle', dispName: 'End Angle', type: 'float', min:0, max:1, defVal:0.1},
  2332. {name: 'arcWidth', dispName: 'Arc Width', type: 'float', min:0, max:1, defVal:0.5}
  2333. ];
  2334. mxShapeBasicPartConcEllipse.prototype.cst = {PART_CONC_ELLIPSE : 'mxgraph.basic.partConcEllipse'};
  2335. /**
  2336. * Function: paintVertexShape
  2337. *
  2338. * Paints the vertex shape.
  2339. */
  2340. mxShapeBasicPartConcEllipse.prototype.paintVertexShape = function(c, x, y, w, h)
  2341. {
  2342. c.translate(x, y);
  2343. var startAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'startAngle', this.startAngle))));
  2344. var endAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'endAngle', this.endAngle))));
  2345. var arcWidth = 1 - Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arcWidth', this.arcWidth))));
  2346. var rx = w * 0.5;
  2347. var ry = h * 0.5;
  2348. var rx2 = rx * arcWidth;
  2349. var ry2 = ry * arcWidth;
  2350. var angDiff = endAngle - startAngle;
  2351. if (angDiff < 0)
  2352. {
  2353. angDiff = angDiff + Math.PI * 2;
  2354. }
  2355. else if (angDiff == Math.PI)
  2356. {
  2357. endAngle = endAngle + 0.00001;
  2358. }
  2359. var startX = rx + Math.sin(startAngle) * rx;
  2360. var startY = ry - Math.cos(startAngle) * ry;
  2361. var innerStartX = rx + Math.sin(startAngle) * rx2;
  2362. var innerStartY = ry - Math.cos(startAngle) * ry2;
  2363. var endX = rx + Math.sin(endAngle) * rx;
  2364. var endY = ry - Math.cos(endAngle) * ry;
  2365. var innerEndX = rx + Math.sin(endAngle) * rx2;
  2366. var innerEndY = ry - Math.cos(endAngle) * ry2;
  2367. var bigArc = 0;
  2368. if (angDiff >= Math.PI)
  2369. {
  2370. bigArc = 1;
  2371. }
  2372. c.begin();
  2373. c.moveTo(startX, startY);
  2374. c.arcTo(rx, ry, 0, bigArc, 1, endX, endY);
  2375. c.lineTo(innerEndX, innerEndY);
  2376. c.arcTo(rx2, ry2, 0, bigArc, 0, innerStartX, innerStartY);
  2377. c.close();
  2378. c.fillAndStroke();
  2379. };
  2380. mxCellRenderer.registerShape(mxShapeBasicPartConcEllipse.prototype.cst.PART_CONC_ELLIPSE, mxShapeBasicPartConcEllipse);
  2381. mxShapeBasicPartConcEllipse.prototype.constraints = null;
  2382. Graph.handleFactory[mxShapeBasicPartConcEllipse.prototype.cst.PART_CONC_ELLIPSE] = function(state)
  2383. {
  2384. var handles = [Graph.createHandle(state, ['startAngle'], function(bounds)
  2385. {
  2386. var startAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'startAngle', this.startAngle))));
  2387. return new mxPoint(bounds.x + bounds.width * 0.5 + Math.sin(startAngle) * bounds.width * 0.5, bounds.y + bounds.height * 0.5 - Math.cos(startAngle) * bounds.height * 0.5);
  2388. }, function(bounds, pt)
  2389. {
  2390. var handleX = Math.round(100 * Math.max(-1, Math.min(1, (pt.x - bounds.x - bounds.width * 0.5) / (bounds.width * 0.5)))) / 100;
  2391. var handleY = -Math.round(100 * Math.max(-1, Math.min(1, (pt.y - bounds.y - bounds.height * 0.5) / (bounds.height * 0.5)))) / 100;
  2392. var res = 0.5 * Math.atan2(handleX, handleY) / Math.PI;
  2393. if (res < 0)
  2394. {
  2395. res = 1 + res;
  2396. }
  2397. this.state.style['startAngle'] = res;
  2398. })];
  2399. var handle2 = Graph.createHandle(state, ['endAngle'], function(bounds)
  2400. {
  2401. var endAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'endAngle', this.endAngle))));
  2402. return new mxPoint(bounds.x + bounds.width * 0.5 + Math.sin(endAngle) * bounds.width * 0.5, bounds.y + bounds.height * 0.5 - Math.cos(endAngle) * bounds.height * 0.5);
  2403. }, function(bounds, pt)
  2404. {
  2405. var handleX = Math.round(100 * Math.max(-1, Math.min(1, (pt.x - bounds.x - bounds.width * 0.5) / (bounds.width * 0.5)))) / 100;
  2406. var handleY = -Math.round(100 * Math.max(-1, Math.min(1, (pt.y - bounds.y - bounds.height * 0.5) / (bounds.height * 0.5)))) / 100;
  2407. var res = 0.5 * Math.atan2(handleX, handleY) / Math.PI;
  2408. if (res < 0)
  2409. {
  2410. res = 1 + res;
  2411. }
  2412. this.state.style['endAngle'] = res;
  2413. });
  2414. handles.push(handle2);
  2415. var handle3 = Graph.createHandle(state, ['arcWidth'], function(bounds)
  2416. {
  2417. var arcWidth = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'arcWidth', this.arcWidth))));
  2418. return new mxPoint(bounds.x + bounds.width / 2, bounds.y + arcWidth * bounds.height * 0.5);
  2419. }, function(bounds, pt)
  2420. {
  2421. this.state.style['arcWidth'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, (pt.y - bounds.y) / (bounds.height * 0.5)))) / 100;
  2422. });
  2423. handles.push(handle3);
  2424. return handles;
  2425. };
  2426. //**********************************************************************************************************************************************************
  2427. //Numbered entry (vertical)
  2428. //**********************************************************************************************************************************************************
  2429. /**
  2430. * Extends mxShape.
  2431. */
  2432. function mxShapeBasicNumEntryVert(bounds, fill, stroke, strokewidth)
  2433. {
  2434. mxShape.call(this);
  2435. this.bounds = bounds;
  2436. this.fill = fill;
  2437. this.stroke = stroke;
  2438. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2439. this.dy = 0.5;
  2440. };
  2441. /**
  2442. * Extends mxShape.
  2443. */
  2444. mxUtils.extend(mxShapeBasicNumEntryVert, mxActor);
  2445. mxShapeBasicNumEntryVert.prototype.cst = {NUM_ENTRY_VERT : 'mxgraph.basic.numberedEntryVert'};
  2446. /**
  2447. * Function: paintVertexShape
  2448. *
  2449. * Paints the vertex shape.
  2450. */
  2451. mxShapeBasicNumEntryVert.prototype.paintVertexShape = function(c, x, y, w, h)
  2452. {
  2453. c.translate(x, y);
  2454. var dy = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  2455. var inset = 5;
  2456. var d = Math.min(dy, w - 2 * inset, h - inset);
  2457. c.ellipse(w * 0.5 - d * 0.5, 0, d, d);
  2458. c.fillAndStroke();
  2459. c.begin();
  2460. c.moveTo(0, d * 0.5);
  2461. c.lineTo(w * 0.5 - d * 0.5 - inset, d * 0.5);
  2462. c.arcTo(d * 0.5 + inset, d * 0.5 + inset, 0, 0, 0, w * 0.5 + d * 0.5 + inset, d * 0.5);
  2463. c.lineTo(w, d * 0.5);
  2464. c.lineTo(w, h);
  2465. c.lineTo(0, h);
  2466. c.close();
  2467. c.fillAndStroke();
  2468. };
  2469. mxCellRenderer.registerShape(mxShapeBasicNumEntryVert.prototype.cst.NUM_ENTRY_VERT, mxShapeBasicNumEntryVert);
  2470. mxShapeBasicNumEntryVert.prototype.constraints = null;
  2471. Graph.handleFactory[mxShapeBasicNumEntryVert.prototype.cst.NUM_ENTRY_VERT] = function(state)
  2472. {
  2473. var handles = [Graph.createHandle(state, ['dy'], function(bounds)
  2474. {
  2475. var dy = Math.max(0, Math.min(bounds.width, bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  2476. return new mxPoint(bounds.x + bounds.width / 2, bounds.y + dy);
  2477. }, function(bounds, pt)
  2478. {
  2479. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height, bounds.width, pt.y - bounds.y))) / 100;
  2480. })];
  2481. return handles;
  2482. };
  2483. //**********************************************************************************************************************************************************
  2484. //Bending Arch
  2485. //**********************************************************************************************************************************************************
  2486. /**
  2487. * Extends mxShape.
  2488. */
  2489. function mxShapeBasicBendingArch(bounds, fill, stroke, strokewidth)
  2490. {
  2491. mxShape.call(this);
  2492. this.bounds = bounds;
  2493. this.fill = fill;
  2494. this.stroke = stroke;
  2495. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2496. this.startAngle = 0.25;
  2497. this.endAngle = 0.75;
  2498. this.arcWidth = 0.5;
  2499. };
  2500. /**
  2501. * Extends mxShape.
  2502. */
  2503. mxUtils.extend(mxShapeBasicBendingArch, mxActor);
  2504. mxShapeBasicBendingArch.prototype.cst = {BENDING_ARCH : 'mxgraph.basic.bendingArch'};
  2505. /**
  2506. * Function: paintVertexShape
  2507. *
  2508. * Paints the vertex shape.
  2509. */
  2510. mxShapeBasicBendingArch.prototype.paintVertexShape = function(c, x, y, w, h)
  2511. {
  2512. c.translate(x, y);
  2513. var startAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'startAngle', this.startAngle))));
  2514. var endAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'endAngle', this.endAngle))));
  2515. var arcWidth = 1 - Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.style, 'arcWidth', this.arcWidth))));
  2516. var rx = w * 0.5;
  2517. var ry = h * 0.5;
  2518. var rx2 = rx * arcWidth;
  2519. var ry2 = ry * arcWidth;
  2520. var startX = rx + Math.sin(startAngle) * rx;
  2521. var startY = ry - Math.cos(startAngle) * ry;
  2522. var innerStartX = rx + Math.sin(startAngle) * rx2;
  2523. var innerStartY = ry - Math.cos(startAngle) * ry2;
  2524. var endX = rx + Math.sin(endAngle) * rx;
  2525. var endY = ry - Math.cos(endAngle) * ry;
  2526. var innerEndX = rx + Math.sin(endAngle) * rx2;
  2527. var innerEndY = ry - Math.cos(endAngle) * ry2;
  2528. var angDiff = endAngle - startAngle;
  2529. if (angDiff < 0)
  2530. {
  2531. angDiff = angDiff + Math.PI * 2;
  2532. }
  2533. var bigArc = 0;
  2534. if (angDiff > Math.PI)
  2535. {
  2536. bigArc = 1;
  2537. }
  2538. var rx3 = rx2 - 5;
  2539. var ry3 = ry2 - 5;
  2540. c.ellipse(w * 0.5 - rx3, h * 0.5 - ry3, 2 * rx3, 2 * ry3);
  2541. c.fillAndStroke();
  2542. c.begin();
  2543. c.moveTo(startX, startY);
  2544. c.arcTo(rx, ry, 0, bigArc, 1, endX, endY);
  2545. c.lineTo(innerEndX, innerEndY);
  2546. c.arcTo(rx2, ry2, 0, bigArc, 0, innerStartX, innerStartY);
  2547. c.close();
  2548. c.fillAndStroke();
  2549. };
  2550. mxCellRenderer.registerShape(mxShapeBasicBendingArch.prototype.cst.BENDING_ARCH, mxShapeBasicBendingArch);
  2551. mxShapeBasicBendingArch.prototype.constraints = null;
  2552. Graph.handleFactory[mxShapeBasicBendingArch.prototype.cst.BENDING_ARCH] = function(state)
  2553. {
  2554. var handles = [Graph.createHandle(state, ['startAngle'], function(bounds)
  2555. {
  2556. var startAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'startAngle', this.startAngle))));
  2557. return new mxPoint(bounds.x + bounds.width * 0.5 + Math.sin(startAngle) * bounds.width * 0.5, bounds.y + bounds.height * 0.5 - Math.cos(startAngle) * bounds.height * 0.5);
  2558. }, function(bounds, pt)
  2559. {
  2560. var handleX = Math.round(100 * Math.max(-1, Math.min(1, (pt.x - bounds.x - bounds.width * 0.5) / (bounds.width * 0.5)))) / 100;
  2561. var handleY = -Math.round(100 * Math.max(-1, Math.min(1, (pt.y - bounds.y - bounds.height * 0.5) / (bounds.height * 0.5)))) / 100;
  2562. var res = 0.5 * Math.atan2(handleX, handleY) / Math.PI;
  2563. if (res < 0)
  2564. {
  2565. res = 1 + res;
  2566. }
  2567. this.state.style['startAngle'] = res;
  2568. })];
  2569. var handle2 = Graph.createHandle(state, ['endAngle'], function(bounds)
  2570. {
  2571. var endAngle = 2 * Math.PI * Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'endAngle', this.endAngle))));
  2572. return new mxPoint(bounds.x + bounds.width * 0.5 + Math.sin(endAngle) * bounds.width * 0.5, bounds.y + bounds.height * 0.5 - Math.cos(endAngle) * bounds.height * 0.5);
  2573. }, function(bounds, pt)
  2574. {
  2575. var handleX = Math.round(100 * Math.max(-1, Math.min(1, (pt.x - bounds.x - bounds.width * 0.5) / (bounds.width * 0.5)))) / 100;
  2576. var handleY = -Math.round(100 * Math.max(-1, Math.min(1, (pt.y - bounds.y - bounds.height * 0.5) / (bounds.height * 0.5)))) / 100;
  2577. var res = 0.5 * Math.atan2(handleX, handleY) / Math.PI;
  2578. if (res < 0)
  2579. {
  2580. res = 1 + res;
  2581. }
  2582. this.state.style['endAngle'] = res;
  2583. });
  2584. handles.push(handle2);
  2585. var handle3 = Graph.createHandle(state, ['arcWidth'], function(bounds)
  2586. {
  2587. var arcWidth = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'arcWidth', this.arcWidth))));
  2588. return new mxPoint(bounds.x + bounds.width / 2, bounds.y + arcWidth * bounds.height * 0.5);
  2589. }, function(bounds, pt)
  2590. {
  2591. this.state.style['arcWidth'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 2, bounds.width / 2, (pt.y - bounds.y) / (bounds.height * 0.5)))) / 100;
  2592. });
  2593. handles.push(handle3);
  2594. return handles;
  2595. };
  2596. //**********************************************************************************************************************************************************
  2597. //Three Corner Round Rectangle
  2598. //**********************************************************************************************************************************************************
  2599. /**
  2600. * Extends mxShape.
  2601. */
  2602. function mxShapeBasicThreeCornerRoundRect(bounds, fill, stroke, strokewidth)
  2603. {
  2604. mxShape.call(this);
  2605. this.bounds = bounds;
  2606. this.fill = fill;
  2607. this.stroke = stroke;
  2608. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2609. this.dx = 0.5;
  2610. };
  2611. /**
  2612. * Extends mxShape.
  2613. */
  2614. mxUtils.extend(mxShapeBasicThreeCornerRoundRect, mxActor);
  2615. mxShapeBasicThreeCornerRoundRect.prototype.customProperties = [
  2616. {name: 'dx', dispName: 'Rounding Size', type: 'float', min:0, defVal:6}
  2617. ];
  2618. mxShapeBasicThreeCornerRoundRect.prototype.cst = {THREE_CORNER_ROUND_RECT : 'mxgraph.basic.three_corner_round_rect'};
  2619. /**
  2620. * Function: paintVertexShape
  2621. *
  2622. * Paints the vertex shape.
  2623. */
  2624. mxShapeBasicThreeCornerRoundRect.prototype.paintVertexShape = function(c, x, y, w, h)
  2625. {
  2626. c.translate(x, y);
  2627. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx)))) * 2;
  2628. dx = Math.min(w * 0.5, h * 0.5, dx);
  2629. c.begin();
  2630. c.moveTo(dx, 0);
  2631. c.lineTo(w - dx, 0);
  2632. c.arcTo(dx, dx, 0, 0, 1, w, dx);
  2633. c.lineTo(w, h - dx);
  2634. c.arcTo(dx, dx, 0, 0, 1, w - dx, h);
  2635. c.lineTo(0, h);
  2636. c.lineTo(0, dx);
  2637. c.arcTo(dx, dx, 0, 0, 1, dx, 0);
  2638. c.close();
  2639. c.fillAndStroke();
  2640. };
  2641. mxCellRenderer.registerShape(mxShapeBasicThreeCornerRoundRect.prototype.cst.THREE_CORNER_ROUND_RECT, mxShapeBasicThreeCornerRoundRect);
  2642. mxShapeBasicThreeCornerRoundRect.prototype.constraints = null;
  2643. Graph.handleFactory[mxShapeBasicThreeCornerRoundRect.prototype.cst.THREE_CORNER_ROUND_RECT] = function(state)
  2644. {
  2645. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  2646. {
  2647. var dx = Math.max(0, Math.min(bounds.width / 4, bounds.width / 4, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  2648. return new mxPoint(bounds.x + dx, bounds.y + dx);
  2649. }, function(bounds, pt)
  2650. {
  2651. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.height / 4, bounds.width / 4, pt.x - bounds.x))) / 100;
  2652. })];
  2653. return handles;
  2654. };
  2655. mxShapeBasicThreeCornerRoundRect.prototype.getConstraints = function(style, w, h)
  2656. {
  2657. var constr = [];
  2658. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  2659. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  2660. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  2661. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  2662. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  2663. return (constr);
  2664. }
  2665. //**********************************************************************************************************************************************************
  2666. //Polygon
  2667. //**********************************************************************************************************************************************************
  2668. /**
  2669. * Extends mxShape.
  2670. */
  2671. function mxShapeBasicPolygon(bounds, fill, stroke, strokewidth)
  2672. {
  2673. mxShape.call(this);
  2674. this.bounds = bounds;
  2675. this.fill = fill;
  2676. this.stroke = stroke;
  2677. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2678. this.dx = 0.5;
  2679. this.dy = 0.5;
  2680. };
  2681. /**
  2682. * Extends mxShape.
  2683. */
  2684. mxUtils.extend(mxShapeBasicPolygon, mxActor);
  2685. mxShapeBasicPolygon.prototype.customProperties = [
  2686. {name: 'polyline', dispName: 'Polyline', type: 'bool', defVal:false},
  2687. {name: 'polyCurves', dispName: 'Curves', type: 'string', defVal: '[]'}
  2688. ];
  2689. mxShapeBasicPolygon.prototype.cst = {POLYGON : 'mxgraph.basic.polygon'};
  2690. /**
  2691. * Function: paintVertexShape
  2692. *
  2693. * Paints the vertex shape.
  2694. */
  2695. mxShapeBasicPolygon.prototype.paintVertexShape = function(c, x, y, w, h)
  2696. {
  2697. try
  2698. {
  2699. c.translate(x, y);
  2700. var coords = JSON.parse(mxUtils.getValue(this.state.style, 'polyCoords', '[]'));
  2701. var curves = JSON.parse(mxUtils.getValue(this.state.style, 'polyCurves', '[]'));
  2702. var polyline = mxUtils.getValue(this.style, 'polyline', false);
  2703. if (coords.length > 0)
  2704. {
  2705. c.begin();
  2706. c.moveTo(coords[0][0] * w, coords[0][1] * h);
  2707. for (var i = 1; i < coords.length; i++)
  2708. {
  2709. var ci = (curves.length > i - 1) ? curves[i - 1] : null;
  2710. if (ci != null && ci.length >= 3 && ci[0] === 'Q')
  2711. {
  2712. c.quadTo(ci[1] * w, ci[2] * h, coords[i][0] * w, coords[i][1] * h);
  2713. }
  2714. else
  2715. {
  2716. c.lineTo(coords[i][0] * w, coords[i][1] * h);
  2717. }
  2718. }
  2719. if (polyline == false)
  2720. {
  2721. var closeCurve = (curves.length >= coords.length) ? curves[coords.length - 1] : null;
  2722. if (closeCurve != null && closeCurve.length >= 3 && closeCurve[0] === 'Q')
  2723. {
  2724. c.quadTo(closeCurve[1] * w, closeCurve[2] * h, coords[0][0] * w, coords[0][1] * h);
  2725. }
  2726. c.close();
  2727. }
  2728. c.end();
  2729. c.fillAndStroke();
  2730. }
  2731. }
  2732. catch (e)
  2733. {
  2734. // ignore
  2735. }
  2736. };
  2737. mxCellRenderer.registerShape(mxShapeBasicPolygon.prototype.cst.POLYGON, mxShapeBasicPolygon);
  2738. mxShapeBasicPolygon.prototype.constraints = null;
  2739. (function()
  2740. {
  2741. function createPolygonHandles(state)
  2742. {
  2743. var handles = [];
  2744. try
  2745. {
  2746. var coords = JSON.parse(mxUtils.getValue(state.style, 'polyCoords', '[]'));
  2747. var curves = JSON.parse(mxUtils.getValue(state.style, 'polyCurves', '[]'));
  2748. var polyline = mxUtils.getValue(state.style, 'polyline', 0);
  2749. var isPolyline = polyline == 1 || polyline === true || polyline === 'true' || polyline === '1';
  2750. var minPoints = isPolyline ? 2 : 3;
  2751. // Ensure curves array matches coords length
  2752. while (curves.length < coords.length)
  2753. {
  2754. curves.push([]);
  2755. }
  2756. // Helper to refresh handler after structural changes
  2757. function refreshHandler()
  2758. {
  2759. var handler = state.view.graph.selectionCellsHandler.getHandler(state.cell);
  2760. if (handler != null)
  2761. {
  2762. handler.refresh(state);
  2763. }
  2764. }
  2765. // Vertex handles (move existing points)
  2766. for (var i = 0; i < coords.length; i++)
  2767. {
  2768. (function(index)
  2769. {
  2770. var handle = Graph.createHandle(state, ['polyCoords', 'polyCurves'], function(bounds)
  2771. {
  2772. return new mxPoint(bounds.x + coords[index][0] * bounds.width,
  2773. bounds.y + coords[index][1] * bounds.height);
  2774. }, function(bounds, pt)
  2775. {
  2776. var x = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  2777. var y = Math.round(100 * Math.max(0, Math.min(1, (pt.y - bounds.y) / bounds.height))) / 100;
  2778. coords[index] = [x, y];
  2779. state.style['polyCoords'] = JSON.stringify(coords);
  2780. state.style['polyCurves'] = JSON.stringify(curves);
  2781. }, false);
  2782. // Collinear removal on mouse up only (not during drag)
  2783. var vertexOrigExecute = handle.execute;
  2784. handle.execute = function(me)
  2785. {
  2786. if (coords.length > minPoints)
  2787. {
  2788. var n = coords.length;
  2789. var prevIdx = (index - 1 + n) % n;
  2790. var nextIdx = (index + 1) % n;
  2791. var canRemove = !isPolyline || (index > 0 && index < n - 1);
  2792. if (canRemove)
  2793. {
  2794. var bounds = this.state.getPaintBounds();
  2795. var px = coords[prevIdx][0] * bounds.width;
  2796. var py = coords[prevIdx][1] * bounds.height;
  2797. var nx = coords[nextIdx][0] * bounds.width;
  2798. var ny = coords[nextIdx][1] * bounds.height;
  2799. var cx = coords[index][0] * bounds.width;
  2800. var cy = coords[index][1] * bounds.height;
  2801. if (mxUtils.ptSegDistSq(px, py, nx, ny, cx, cy) < 4)
  2802. {
  2803. coords.splice(index, 1);
  2804. curves.splice(index, 1);
  2805. state.style['polyCoords'] = JSON.stringify(coords);
  2806. state.style['polyCurves'] = JSON.stringify(curves);
  2807. vertexOrigExecute.apply(this, arguments);
  2808. refreshHandler();
  2809. return;
  2810. }
  2811. }
  2812. }
  2813. vertexOrigExecute.apply(this, arguments);
  2814. };
  2815. handles.push(handle);
  2816. })(i);
  2817. }
  2818. // Control point handles (adjust bezier control points)
  2819. for (var i = 0; i < curves.length && i < coords.length; i++)
  2820. {
  2821. (function(segIndex)
  2822. {
  2823. if (curves[segIndex] != null && curves[segIndex].length >= 3 && curves[segIndex][0] === 'Q')
  2824. {
  2825. var cpHandle = Graph.createHandle(state, ['polyCurves'], function(bounds)
  2826. {
  2827. return new mxPoint(bounds.x + curves[segIndex][1] * bounds.width,
  2828. bounds.y + curves[segIndex][2] * bounds.height);
  2829. }, function(bounds, pt)
  2830. {
  2831. var x = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  2832. var y = Math.round(100 * Math.max(0, Math.min(1, (pt.y - bounds.y) / bounds.height))) / 100;
  2833. curves[segIndex] = ['Q', x, y];
  2834. state.style['polyCurves'] = JSON.stringify(curves);
  2835. }, false);
  2836. // Visually distinct: override shape color
  2837. var cpOrigRedraw = cpHandle.redraw;
  2838. cpHandle.redraw = function()
  2839. {
  2840. cpOrigRedraw.apply(this, arguments);
  2841. if (this.shape != null && this.shape.node != null)
  2842. {
  2843. this.shape.node.setAttribute('fill', '#fca000');
  2844. if (this.shape.node.firstChild != null)
  2845. {
  2846. this.shape.node.firstChild.setAttribute('fill', '#fca000');
  2847. }
  2848. }
  2849. };
  2850. handles.push(cpHandle);
  2851. }
  2852. })(i);
  2853. }
  2854. }
  2855. catch (e)
  2856. {
  2857. // ignore
  2858. }
  2859. return handles;
  2860. }
  2861. Graph.handleFactory[mxShapeBasicPolygon.prototype.cst.POLYGON] = createPolygonHandles;
  2862. })();
  2863. //**********************************************************************************************************************************************************
  2864. //Rectangle with pattern fill
  2865. //**********************************************************************************************************************************************************
  2866. /**
  2867. * Extends mxShape.
  2868. */
  2869. function mxShapeBasicPatternFillRect(bounds, fill, stroke, strokewidth)
  2870. {
  2871. mxShape.call(this);
  2872. this.bounds = bounds;
  2873. this.fill = fill;
  2874. this.stroke = stroke;
  2875. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2876. this.dx = 0.5;
  2877. };
  2878. /**
  2879. * Extends mxShape.
  2880. */
  2881. mxUtils.extend(mxShapeBasicPatternFillRect, mxActor);
  2882. mxShapeBasicPatternFillRect.prototype.cst = {PATTERN_FILL_RECT : 'mxgraph.basic.patternFillRect'};
  2883. mxShapeBasicPatternFillRect.prototype.customProperties = [
  2884. {name: 'step', dispName: 'Fill Step', type: 'float', min:0, defVal:5},
  2885. {name: 'fillStyle', dispName: 'Fill Style', type: 'enum', defVal:'none',
  2886. enumList:[
  2887. {val: 'none', dispName: 'None'},
  2888. {val: 'diag', dispName: 'Diagonal'},
  2889. {val: 'diagRev', dispName: 'Diagonal Reverse'},
  2890. {val: 'vert', dispName: 'Vertical'},
  2891. {val: 'hor', dispName: 'Horizontal'},
  2892. {val: 'grid', dispName: 'Grid'},
  2893. {val: 'diagGrid', dispName: 'Diagonal Grid'}
  2894. ]},
  2895. {name: 'fillStrokeWidth', dispName: 'Fill Stroke Width', type: 'float', min:0, defVal:1},
  2896. {name: 'fillStrokeColor', dispName: 'Fill Stroke Color', type: 'color', defVal:'#cccccc'},
  2897. {name: 'top', dispName: 'Top Line', type: 'bool', defVal:true},
  2898. {name: 'right', dispName: 'Right Line', type: 'bool', defVal:true},
  2899. {name: 'bottom', dispName: 'Bottom Line', type: 'bool', defVal:true},
  2900. {name: 'left', dispName: 'Left Line', type: 'bool', defVal:true}
  2901. ];
  2902. /**
  2903. * Function: paintVertexShape
  2904. *
  2905. * Paints the vertex shape.
  2906. */
  2907. mxShapeBasicPatternFillRect.prototype.paintVertexShape = function(c, x, y, w, h)
  2908. {
  2909. c.translate(x, y);
  2910. var strokeColor = mxUtils.getValue(this.style, 'strokeColor', '#000000');
  2911. var strokeWidth = mxUtils.getValue(this.style, 'strokeWidth', '1');
  2912. c.rect(0, 0, w, h);
  2913. c.fill();
  2914. var fillStrokeColor = mxUtils.getValue(this.style, 'fillStrokeColor', '#cccccc');
  2915. var fillStrokeWidth = parseFloat(mxUtils.getValue(this.style, 'fillStrokeWidth', 1));
  2916. c.setStrokeColor(fillStrokeColor);
  2917. c.setStrokeWidth(fillStrokeWidth);
  2918. var step = parseFloat(mxUtils.getValue(this.style, 'step', 5));
  2919. var fillStyle = mxUtils.getValue(this.style, 'fillStyle', 'none');
  2920. if (fillStyle == 'diag' || fillStyle == 'diagGrid')
  2921. {
  2922. step = step * 1.41;
  2923. var i = 0;
  2924. c.begin();
  2925. while (i < (h + w))
  2926. {
  2927. var cx = 0;
  2928. var cy = 0;
  2929. if (i <= h)
  2930. {
  2931. c.moveTo(0, i);
  2932. if(i <= w)
  2933. {
  2934. c.lineTo(i, 0);
  2935. }
  2936. else
  2937. {
  2938. c.lineTo(w, i - w);
  2939. }
  2940. }
  2941. else
  2942. {
  2943. c.moveTo(i - h, h);
  2944. if(i <= w)
  2945. {
  2946. c.lineTo(i, 0);
  2947. }
  2948. else
  2949. {
  2950. c.lineTo(w, i - w);
  2951. }
  2952. }
  2953. i = i + step;
  2954. }
  2955. c.stroke();
  2956. }
  2957. else if (fillStyle == 'vert' || fillStyle == 'grid')
  2958. {
  2959. c.begin();
  2960. var i = 0;
  2961. while (i <= w)
  2962. {
  2963. var cx = 0;
  2964. var cy = 0;
  2965. c.moveTo(i, 0);
  2966. c.lineTo(i, h);
  2967. i = i + step;
  2968. }
  2969. c.stroke();
  2970. }
  2971. if (fillStyle == 'diagRev' || fillStyle == 'diagGrid')
  2972. {
  2973. if (fillStyle == 'diagRev')
  2974. {
  2975. step = step * 1.41;
  2976. }
  2977. var i = 0;
  2978. c.begin();
  2979. while (i < (h + w))
  2980. {
  2981. var cx = 0;
  2982. var cy = 0;
  2983. if (i <= h)
  2984. {
  2985. c.moveTo(w, i);
  2986. if(i <= w)
  2987. {
  2988. c.lineTo(w - i, 0);
  2989. }
  2990. else
  2991. {
  2992. c.lineTo(w - w, i - w);
  2993. }
  2994. }
  2995. else
  2996. {
  2997. c.moveTo(w - i + h, h);
  2998. if(i <= w)
  2999. {
  3000. c.lineTo(w - i, 0);
  3001. }
  3002. else
  3003. {
  3004. c.lineTo(0, i - w);
  3005. }
  3006. }
  3007. i = i + step;
  3008. }
  3009. c.stroke();
  3010. }
  3011. else if (fillStyle == 'hor' || fillStyle == 'grid')
  3012. {
  3013. c.begin();
  3014. var i = 0;
  3015. while (i <= h)
  3016. {
  3017. var cx = 0;
  3018. var cy = 0;
  3019. c.moveTo(0, i);
  3020. c.lineTo(w, i);
  3021. i = i + step;
  3022. }
  3023. c.stroke();
  3024. }
  3025. c.setStrokeColor(strokeColor);
  3026. c.setStrokeWidth(strokeWidth);
  3027. c.begin();
  3028. c.moveTo(0, 0);
  3029. if (mxUtils.getValue(this.style, 'top', '1') == '1')
  3030. {
  3031. c.lineTo(w, 0);
  3032. }
  3033. else
  3034. {
  3035. c.moveTo(w, 0);
  3036. }
  3037. if (mxUtils.getValue(this.style, 'right', '1') == '1')
  3038. {
  3039. c.lineTo(w, h);
  3040. }
  3041. else
  3042. {
  3043. c.moveTo(w, h);
  3044. }
  3045. if (mxUtils.getValue(this.style, 'bottom', '1') == '1')
  3046. {
  3047. c.lineTo(0, h);
  3048. }
  3049. else
  3050. {
  3051. c.moveTo(0, h);
  3052. }
  3053. if (mxUtils.getValue(this.style, 'left', '1') == '1')
  3054. {
  3055. c.lineTo(0, 0);
  3056. }
  3057. c.end();
  3058. c.stroke();
  3059. };
  3060. mxCellRenderer.registerShape(mxShapeBasicPatternFillRect.prototype.cst.PATTERN_FILL_RECT, mxShapeBasicPatternFillRect);
  3061. mxShapeBasicPatternFillRect.prototype.getConstraints = function(style, w, h)
  3062. {
  3063. var constr = [];
  3064. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  3065. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
  3066. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  3067. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
  3068. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  3069. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.25), false));
  3070. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.5), false));
  3071. constr.push(new mxConnectionConstraint(new mxPoint(1, 0.75), false));
  3072. constr.push(new mxConnectionConstraint(new mxPoint(1, 1), false));
  3073. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));
  3074. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 1), false));
  3075. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 1), false));
  3076. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 1), false));
  3077. constr.push(new mxConnectionConstraint(new mxPoint(0, 1), false));
  3078. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.75), false));
  3079. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.5), false));
  3080. constr.push(new mxConnectionConstraint(new mxPoint(0, 0.25), false));
  3081. return (constr);
  3082. }