mxBasic.js 110 KB

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