mxBootstrap.js 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502
  1. /**
  2. * Copyright (c) 2006-2014, JGraph Holdings Ltd
  3. */
  4. //**********************************************************************************************************************************************************
  5. //Rounded rectangle (adjustable rounding)
  6. //**********************************************************************************************************************************************************
  7. /**
  8. * Extends mxShape.
  9. */
  10. function mxShapeBootstrapRRect(bounds, fill, stroke, strokewidth)
  11. {
  12. mxShape.call(this);
  13. this.bounds = bounds;
  14. this.fill = fill;
  15. this.stroke = stroke;
  16. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  17. };
  18. /**
  19. * Extends mxShape.
  20. */
  21. mxUtils.extend(mxShapeBootstrapRRect, mxShape);
  22. mxShapeBootstrapRRect.prototype.cst = {
  23. PACKAGE : 'mxgraph.bootstrap.rrect',
  24. R_SIZE : 'rSize'
  25. };
  26. mxShapeBootstrapRRect.prototype.customProperties = [
  27. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10}
  28. ];
  29. /**
  30. * Function: paintVertexShape
  31. *
  32. * Paints the vertex shape.
  33. */
  34. mxShapeBootstrapRRect.prototype.paintVertexShape = function(c, x, y, w, h)
  35. {
  36. c.translate(x, y);
  37. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapRRect.prototype.cst.R_SIZE, '10'));
  38. c.roundrect(0, 0, w, h, rSize);
  39. c.fillAndStroke();
  40. };
  41. mxCellRenderer.registerShape(mxShapeBootstrapRRect.prototype.cst.PACKAGE, mxShapeBootstrapRRect);
  42. //**********************************************************************************************************************************************************
  43. //Top Button
  44. //**********************************************************************************************************************************************************
  45. /**
  46. * Extends mxShape.
  47. */
  48. function mxShapeBootstrapTopButton(bounds, fill, stroke, strokewidth)
  49. {
  50. mxShape.call(this);
  51. this.bounds = bounds;
  52. this.fill = fill;
  53. this.stroke = stroke;
  54. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  55. };
  56. /**
  57. * Extends mxShape.
  58. */
  59. mxUtils.extend(mxShapeBootstrapTopButton, mxShape);
  60. mxShapeBootstrapTopButton.prototype.cst = {
  61. TOP_BUTTON : 'mxgraph.bootstrap.topButton',
  62. R_SIZE : 'rSize'
  63. };
  64. mxShapeBootstrapTopButton.prototype.customProperties = [
  65. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10}
  66. ];
  67. /**
  68. * Function: paintVertexShape
  69. *
  70. * Paints the vertex shape.
  71. */
  72. mxShapeBootstrapTopButton.prototype.paintVertexShape = function(c, x, y, w, h)
  73. {
  74. c.translate(x, y);
  75. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapTopButton.prototype.cst.R_SIZE, '10'));
  76. c.begin();
  77. c.moveTo(0, rSize);
  78. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  79. c.lineTo(w - rSize, 0);
  80. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  81. c.lineTo(w, h);
  82. c.lineTo(0, h);
  83. c.close();
  84. c.fillAndStroke();
  85. };
  86. mxCellRenderer.registerShape(mxShapeBootstrapTopButton.prototype.cst.TOP_BUTTON, mxShapeBootstrapTopButton);
  87. //**********************************************************************************************************************************************************
  88. //Bottom Button
  89. //**********************************************************************************************************************************************************
  90. /**
  91. * Extends mxShape.
  92. */
  93. function mxShapeBootstrapBottomButton(bounds, fill, stroke, strokewidth)
  94. {
  95. mxShape.call(this);
  96. this.bounds = bounds;
  97. this.fill = fill;
  98. this.stroke = stroke;
  99. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  100. };
  101. /**
  102. * Extends mxShape.
  103. */
  104. mxUtils.extend(mxShapeBootstrapBottomButton, mxShape);
  105. mxShapeBootstrapBottomButton.prototype.cst = {
  106. BOTTOM_BUTTON : 'mxgraph.bootstrap.bottomButton',
  107. R_SIZE : 'rSize'
  108. };
  109. mxShapeBootstrapBottomButton.prototype.customProperties = [
  110. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10}
  111. ];
  112. /**
  113. * Function: paintVertexShape
  114. *
  115. * Paints the vertex shape.
  116. */
  117. mxShapeBootstrapBottomButton.prototype.paintVertexShape = function(c, x, y, w, h)
  118. {
  119. c.translate(x, y);
  120. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapBottomButton.prototype.cst.R_SIZE, '10'));
  121. c.begin();
  122. c.moveTo(0, 0);
  123. c.lineTo(w, 0);
  124. c.lineTo(w, h - rSize);
  125. c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
  126. c.lineTo(rSize, h);
  127. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  128. c.close();
  129. c.fillAndStroke();
  130. };
  131. mxCellRenderer.registerShape(mxShapeBootstrapBottomButton.prototype.cst.BOTTOM_BUTTON, mxShapeBootstrapBottomButton);
  132. //**********************************************************************************************************************************************************
  133. //Right Button
  134. //**********************************************************************************************************************************************************
  135. /**
  136. * Extends mxShape.
  137. */
  138. function mxShapeBootstrapRightButton(bounds, fill, stroke, strokewidth)
  139. {
  140. mxShape.call(this);
  141. this.bounds = bounds;
  142. this.fill = fill;
  143. this.stroke = stroke;
  144. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  145. };
  146. /**
  147. * Extends mxShape.
  148. */
  149. mxUtils.extend(mxShapeBootstrapRightButton, mxShape);
  150. mxShapeBootstrapRightButton.prototype.cst = {
  151. RIGHT_BUTTON : 'mxgraph.bootstrap.rightButton',
  152. R_SIZE : 'rSize'
  153. };
  154. mxShapeBootstrapRightButton.prototype.customProperties = [
  155. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10}
  156. ];
  157. /**
  158. * Function: paintVertexShape
  159. *
  160. * Paints the vertex shape.
  161. */
  162. mxShapeBootstrapRightButton.prototype.paintVertexShape = function(c, x, y, w, h)
  163. {
  164. c.translate(x, y);
  165. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapRightButton.prototype.cst.R_SIZE, '10'));
  166. c.begin();
  167. c.moveTo(0, 0);
  168. c.lineTo(w - rSize, 0);
  169. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  170. c.lineTo(w, h - rSize);
  171. c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
  172. c.lineTo(0, h);
  173. c.close();
  174. c.fillAndStroke();
  175. };
  176. mxCellRenderer.registerShape(mxShapeBootstrapRightButton.prototype.cst.RIGHT_BUTTON, mxShapeBootstrapRightButton);
  177. //**********************************************************************************************************************************************************
  178. //Left Button
  179. //**********************************************************************************************************************************************************
  180. /**
  181. * Extends mxShape.
  182. */
  183. function mxShapeBootstrapLeftButton(bounds, fill, stroke, strokewidth)
  184. {
  185. mxShape.call(this);
  186. this.bounds = bounds;
  187. this.fill = fill;
  188. this.stroke = stroke;
  189. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  190. };
  191. /**
  192. * Extends mxShape.
  193. */
  194. mxUtils.extend(mxShapeBootstrapLeftButton, mxShape);
  195. mxShapeBootstrapLeftButton.prototype.cst = {
  196. LEFT_BUTTON : 'mxgraph.bootstrap.leftButton',
  197. R_SIZE : 'rSize'
  198. };
  199. mxShapeBootstrapLeftButton.prototype.customProperties = [
  200. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10}
  201. ];
  202. /**
  203. * Function: paintVertexShape
  204. *
  205. * Paints the vertex shape.
  206. */
  207. mxShapeBootstrapLeftButton.prototype.paintVertexShape = function(c, x, y, w, h)
  208. {
  209. c.translate(x, y);
  210. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapLeftButton.prototype.cst.R_SIZE, '10'));
  211. c.begin();
  212. c.moveTo(w, 0);
  213. c.lineTo(w, h);
  214. c.lineTo(rSize, h);
  215. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  216. c.lineTo(0, rSize);
  217. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  218. c.close();
  219. c.fillAndStroke();
  220. };
  221. mxCellRenderer.registerShape(mxShapeBootstrapLeftButton.prototype.cst.LEFT_BUTTON, mxShapeBootstrapLeftButton);
  222. //**********************************************************************************************************************************************************
  223. //Left Button (Striped)
  224. //**********************************************************************************************************************************************************
  225. /**
  226. * Extends mxShape.
  227. */
  228. function mxShapeBootstrapLeftButtonStriped(bounds, fill, stroke, strokewidth)
  229. {
  230. mxShape.call(this);
  231. this.bounds = bounds;
  232. this.fill = fill;
  233. this.stroke = stroke;
  234. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  235. };
  236. /**
  237. * Extends mxShape.
  238. */
  239. mxUtils.extend(mxShapeBootstrapLeftButtonStriped, mxShape);
  240. mxShapeBootstrapLeftButtonStriped.prototype.cst = {
  241. LEFT_BUTTON_STRIPED : 'mxgraph.bootstrap.leftButtonStriped'
  242. };
  243. /**
  244. * Function: paintVertexShape
  245. *
  246. * Paints the vertex shape.
  247. */
  248. mxShapeBootstrapLeftButtonStriped.prototype.paintVertexShape = function(c, x, y, w, h)
  249. {
  250. c.translate(x, y);
  251. rSize = 5;
  252. c.begin();
  253. c.moveTo(w, 0);
  254. c.lineTo(w, h);
  255. c.lineTo(rSize, h);
  256. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  257. c.lineTo(0, rSize);
  258. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  259. c.close();
  260. c.fill();
  261. var fillColor = '#ffffff';
  262. c.setAlpha('0.2');
  263. var stripeW = h * 0.5;
  264. c.setFillColor(fillColor);
  265. c.begin();
  266. c.moveTo(0, h * 0.75);
  267. c.lineTo(0, h * 0.25);
  268. c.lineTo(h * 0.75, h);
  269. c.lineTo(h * 0.25, h);
  270. c.close();
  271. c.fill();
  272. var end = false;
  273. var startX = stripeW * 0.5;
  274. while (!end)
  275. {
  276. c.begin();
  277. c.moveTo(startX, 0);
  278. if (startX + stripeW >= w)
  279. {
  280. c.lineTo(w, 0);
  281. c.lineTo(w, w - startX);
  282. }
  283. else
  284. {
  285. c.lineTo(startX + stripeW, 0);
  286. if (startX + stripeW + h > w)
  287. {
  288. c.lineTo(w, w - startX - stripeW);
  289. if (w - startX > h)
  290. {
  291. c.lineTo(w, h);
  292. c.lineTo(startX + h, h);
  293. }
  294. else
  295. {
  296. c.lineTo(w, w - startX);
  297. }
  298. }
  299. else
  300. {
  301. c.lineTo(startX + stripeW + h, h);
  302. c.lineTo(startX + h, h);
  303. }
  304. }
  305. c.close();
  306. c.fill();
  307. startX = startX + 2 * stripeW;
  308. if (startX > w)
  309. {
  310. end = true;
  311. }
  312. }
  313. };
  314. mxCellRenderer.registerShape(mxShapeBootstrapLeftButtonStriped.prototype.cst.LEFT_BUTTON_STRIPED, mxShapeBootstrapLeftButtonStriped);
  315. //**********************************************************************************************************************************************************
  316. //Rounded Button
  317. //**********************************************************************************************************************************************************
  318. /**
  319. * Extends mxShape.
  320. */
  321. function mxShapeBootstrapRoundedButton(bounds, fill, stroke, strokewidth)
  322. {
  323. mxShape.call(this);
  324. this.bounds = bounds;
  325. this.fill = fill;
  326. this.stroke = stroke;
  327. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  328. };
  329. /**
  330. * Extends mxShape.
  331. */
  332. mxUtils.extend(mxShapeBootstrapRoundedButton, mxShape);
  333. mxShapeBootstrapRoundedButton.prototype.cst = {
  334. ROUNDED_BUTTON : 'mxgraph.bootstrap.roundedButton'
  335. };
  336. /**
  337. * Function: paintVertexShape
  338. *
  339. * Paints the vertex shape.
  340. */
  341. mxShapeBootstrapRoundedButton.prototype.paintVertexShape = function(c, x, y, w, h)
  342. {
  343. c.translate(x, y);
  344. if (w > h)
  345. {
  346. var r = h * 0.5;
  347. c.begin();
  348. c.moveTo(w - r, 0);
  349. c.arcTo(r, r, 0, 0, 1, w - r, h);
  350. c.lineTo(r, h);
  351. c.arcTo(r, r, 0, 0, 1, r, 0);
  352. c.close();
  353. c.fillAndStroke();
  354. }
  355. else
  356. {
  357. var r = w * 0.5;
  358. c.begin();
  359. c.moveTo(0, h - r);
  360. c.arcTo(r, r, 0, 0, 0, w, h - r);
  361. c.lineTo(w, r);
  362. c.arcTo(r, r, 0, 0, 0, 0, r);
  363. c.close();
  364. c.fillAndStroke();
  365. }
  366. };
  367. mxCellRenderer.registerShape(mxShapeBootstrapRoundedButton.prototype.cst.ROUNDED_BUTTON, mxShapeBootstrapRoundedButton);
  368. //**********************************************************************************************************************************************************
  369. //Arrow
  370. //**********************************************************************************************************************************************************
  371. /**
  372. * Extends mxShape.
  373. */
  374. function mxShapeBootstrapArrow(bounds, fill, stroke, strokewidth)
  375. {
  376. mxShape.call(this);
  377. this.bounds = bounds;
  378. this.fill = fill;
  379. this.stroke = stroke;
  380. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  381. };
  382. /**
  383. * Extends mxShape.
  384. */
  385. mxUtils.extend(mxShapeBootstrapArrow, mxShape);
  386. mxShapeBootstrapArrow.prototype.cst = {
  387. ARROW : 'mxgraph.bootstrap.arrow'
  388. };
  389. /**
  390. * Function: paintVertexShape
  391. *
  392. * Paints the vertex shape.
  393. */
  394. mxShapeBootstrapArrow.prototype.paintVertexShape = function(c, x, y, w, h)
  395. {
  396. c.translate(x, y);
  397. c.begin();
  398. c.moveTo(0, h * 0.5);
  399. c.lineTo(w, h * 0.5);
  400. c.moveTo(w * 0.9, 0);
  401. c.lineTo(w, h * 0.5);
  402. c.lineTo(w * 0.9, h);
  403. c.stroke();
  404. };
  405. mxCellRenderer.registerShape(mxShapeBootstrapArrow.prototype.cst.ARROW, mxShapeBootstrapArrow);
  406. //**********************************************************************************************************************************************************
  407. //Tab Top
  408. //**********************************************************************************************************************************************************
  409. /**
  410. * Extends mxShape.
  411. */
  412. function mxShapeBootstrapTabTop(bounds, fill, stroke, strokewidth)
  413. {
  414. mxShape.call(this);
  415. this.bounds = bounds;
  416. this.fill = fill;
  417. this.stroke = stroke;
  418. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  419. };
  420. /**
  421. * Extends mxShape.
  422. */
  423. mxUtils.extend(mxShapeBootstrapTabTop, mxShape);
  424. mxShapeBootstrapTabTop.prototype.cst = {
  425. TAB_TOP : 'mxgraph.bootstrap.tabTop',
  426. R_SIZE : 'rSize'
  427. };
  428. mxShapeBootstrapTabTop.prototype.customProperties = [
  429. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:5}
  430. ];
  431. /**
  432. * Function: paintVertexShape
  433. *
  434. * Paints the vertex shape.
  435. */
  436. mxShapeBootstrapTabTop.prototype.paintVertexShape = function(c, x, y, w, h)
  437. {
  438. c.translate(x, y);
  439. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapTopButton.prototype.cst.R_SIZE, '10'));
  440. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  441. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  442. c.setStrokeColor(fillColor);
  443. c.begin();
  444. c.moveTo(0, rSize);
  445. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  446. c.lineTo(w - rSize, 0);
  447. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  448. c.lineTo(w, h);
  449. c.lineTo(0, h);
  450. c.close();
  451. c.fillAndStroke();
  452. c.setStrokeColor(strokeColor);
  453. c.begin();
  454. c.moveTo(0, h);
  455. c.lineTo(0, rSize);
  456. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  457. c.lineTo(w - rSize, 0);
  458. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  459. c.lineTo(w, h);
  460. c.stroke();
  461. };
  462. mxCellRenderer.registerShape(mxShapeBootstrapTabTop.prototype.cst.TAB_TOP, mxShapeBootstrapTabTop);
  463. //**********************************************************************************************************************************************************
  464. //Image
  465. //**********************************************************************************************************************************************************
  466. /**
  467. * Extends mxShape.
  468. */
  469. function mxShapeBootstrapImage(bounds, fill, stroke, strokewidth)
  470. {
  471. mxShape.call(this);
  472. this.bounds = bounds;
  473. this.fill = fill;
  474. this.stroke = stroke;
  475. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  476. };
  477. /**
  478. * Extends mxShape.
  479. */
  480. mxUtils.extend(mxShapeBootstrapImage, mxShape);
  481. mxShapeBootstrapImage.prototype.cst = {
  482. IMAGE : 'mxgraph.bootstrap.image',
  483. R_SIZE : 'rSize'
  484. };
  485. mxShapeBootstrapImage.prototype.customProperties = [
  486. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:5}
  487. ];
  488. /**
  489. * Function: paintVertexShape
  490. *
  491. * Paints the vertex shape.
  492. */
  493. mxShapeBootstrapImage.prototype.paintVertexShape = function(c, x, y, w, h)
  494. {
  495. c.translate(x, y);
  496. var rSize = Math.max(0, parseInt(mxUtils.getValue(this.style, mxShapeBootstrapTopButton.prototype.cst.R_SIZE, '10')));
  497. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  498. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  499. c.begin();
  500. c.moveTo(0, rSize);
  501. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  502. c.lineTo(w - rSize, 0);
  503. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  504. c.lineTo(w, h - rSize);
  505. c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
  506. c.lineTo(rSize, h);
  507. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  508. c.close();
  509. c.stroke();
  510. var rsHalf = rSize * 0.5;
  511. c.translate(rsHalf, rsHalf);
  512. w = Math.max(0, w - rSize);
  513. h = Math.max(0, h - rSize);
  514. c.begin();
  515. c.moveTo(0, rsHalf);
  516. c.arcTo(rsHalf, rsHalf, 0, 0, 1, rsHalf, 0);
  517. c.lineTo(w - rsHalf, 0);
  518. c.arcTo(rsHalf, rsHalf, 0, 0, 1, w, rsHalf);
  519. c.lineTo(w, h - rsHalf);
  520. c.arcTo(rsHalf, rsHalf, 0, 0, 1, w - rsHalf, h);
  521. c.lineTo(rsHalf, h);
  522. c.arcTo(rsHalf, rsHalf, 0, 0, 1, 0, h - rsHalf);
  523. c.close();
  524. c.fill();
  525. };
  526. mxCellRenderer.registerShape(mxShapeBootstrapImage.prototype.cst.IMAGE, mxShapeBootstrapImage);
  527. //**********************************************************************************************************************************************************
  528. //Checkbox
  529. //**********************************************************************************************************************************************************
  530. /**
  531. * Extends mxShape.
  532. */
  533. function mxShapeBootstrapCheckbox(bounds, fill, stroke, strokewidth)
  534. {
  535. mxShape.call(this);
  536. this.bounds = bounds;
  537. this.fill = fill;
  538. this.stroke = stroke;
  539. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  540. };
  541. /**
  542. * Extends mxShape.
  543. */
  544. mxUtils.extend(mxShapeBootstrapCheckbox, mxShape);
  545. mxShapeBootstrapCheckbox.prototype.cst = {
  546. CHECKBOX : 'mxgraph.bootstrap.checkbox'
  547. };
  548. /**
  549. * Function: paintVertexShape
  550. *
  551. * Paints the vertex shape.
  552. */
  553. mxShapeBootstrapCheckbox.prototype.paintVertexShape = function(c, x, y, w, h)
  554. {
  555. c.translate(x, y);
  556. var rSize = 3;
  557. c.roundrect(0, 0, w, h, rSize, rSize);
  558. c.fillAndStroke();
  559. c.setStrokeWidth('3');
  560. c.begin();
  561. c.moveTo(w * 0.8, h * 0.2);
  562. c.lineTo(w * 0.4, h * 0.8);
  563. c.lineTo(w * 0.25, h * 0.6);
  564. c.stroke();
  565. };
  566. mxCellRenderer.registerShape(mxShapeBootstrapCheckbox.prototype.cst.CHECKBOX, mxShapeBootstrapCheckbox);
  567. //**********************************************************************************************************************************************************
  568. //Checkbox v2
  569. //**********************************************************************************************************************************************************
  570. /**
  571. * Extends mxShape.
  572. */
  573. function mxShapeBootstrapCheckbox2(bounds, fill, stroke, strokewidth)
  574. {
  575. mxShape.call(this);
  576. this.bounds = bounds;
  577. this.fill = fill;
  578. this.stroke = stroke;
  579. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  580. };
  581. /**
  582. * Extends mxShape.
  583. */
  584. mxUtils.extend(mxShapeBootstrapCheckbox2, mxShape);
  585. mxShapeBootstrapCheckbox2.prototype.customProperties = [
  586. {name: 'checked', dispName: 'Checked', type: 'bool', defVal: false},
  587. {name: 'checkedFill', dispName: 'Checked Fill Color', type: 'color', defVal: '#ffffff'},
  588. {name: 'checkedStroke', dispName: 'Checked Stroke Color', type: 'color', defVal: '#000000'}
  589. ];
  590. mxShapeBootstrapCheckbox2.prototype.cst = {
  591. CHECKBOX2 : 'mxgraph.bootstrap.checkbox2'
  592. };
  593. /**
  594. * Function: paintVertexShape
  595. *
  596. * Paints the vertex shape.
  597. */
  598. mxShapeBootstrapCheckbox2.prototype.paintVertexShape = function(c, x, y, w, h)
  599. {
  600. var isChecked = mxUtils.getValue(this.style, 'checked', false);
  601. var checkedFill = mxUtils.getValue(this.style, 'checkedFill', '#ffffff');
  602. var checkedStroke = mxUtils.getValue(this.style, 'checkedStroke', '#000000');
  603. c.translate(x, y);
  604. var rSize = 2;
  605. if (isChecked)
  606. {
  607. c.setFillColor(checkedFill);
  608. c.setStrokeColor(checkedStroke);
  609. c.roundrect(0, 0, w, h, rSize, rSize);
  610. c.fill();
  611. c.setStrokeWidth('2');
  612. c.begin();
  613. c.moveTo(w * 0.8, h * 0.2);
  614. c.lineTo(w * 0.4, h * 0.75);
  615. c.lineTo(w * 0.25, h * 0.6);
  616. c.stroke();
  617. }
  618. else
  619. {
  620. c.roundrect(0, 0, w, h, rSize, rSize);
  621. c.fillAndStroke();
  622. }
  623. };
  624. mxCellRenderer.registerShape(mxShapeBootstrapCheckbox2.prototype.cst.CHECKBOX2, mxShapeBootstrapCheckbox2);
  625. //**********************************************************************************************************************************************************
  626. //Radio Button
  627. //**********************************************************************************************************************************************************
  628. /**
  629. * Extends mxShape.
  630. */
  631. function mxShapeBootstrapRadioButton(bounds, fill, stroke, strokewidth)
  632. {
  633. mxShape.call(this);
  634. this.bounds = bounds;
  635. this.fill = fill;
  636. this.stroke = stroke;
  637. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  638. };
  639. /**
  640. * Extends mxShape.
  641. */
  642. mxUtils.extend(mxShapeBootstrapRadioButton, mxShape);
  643. mxShapeBootstrapRadioButton.prototype.cst = {
  644. RADIO_BUTTON : 'mxgraph.bootstrap.radioButton'
  645. };
  646. /**
  647. * Function: paintVertexShape
  648. *
  649. * Paints the vertex shape.
  650. */
  651. mxShapeBootstrapRadioButton.prototype.paintVertexShape = function(c, x, y, w, h)
  652. {
  653. c.translate(x, y);
  654. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  655. c.ellipse(0, 0, w, h);
  656. c.fillAndStroke();
  657. c.setFillColor(strokeColor);
  658. c.ellipse(w * 0.25, h * 0.25, w * 0.5, h * 0.5);
  659. c.fill();
  660. };
  661. mxCellRenderer.registerShape(mxShapeBootstrapRadioButton.prototype.cst.RADIO_BUTTON, mxShapeBootstrapRadioButton);
  662. //**********************************************************************************************************************************************************
  663. //Radio Button v2
  664. //**********************************************************************************************************************************************************
  665. /**
  666. * Extends mxShape.
  667. */
  668. function mxShapeBootstrapRadioButton2(bounds, fill, stroke, strokewidth)
  669. {
  670. mxShape.call(this);
  671. this.bounds = bounds;
  672. this.fill = fill;
  673. this.stroke = stroke;
  674. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  675. };
  676. /**
  677. * Extends mxShape.
  678. */
  679. mxUtils.extend(mxShapeBootstrapRadioButton2, mxShape);
  680. mxShapeBootstrapRadioButton2.prototype.customProperties = [
  681. {name: 'checked', dispName: 'Checked', type: 'bool', defVal: false},
  682. {name: 'checkedFill', dispName: 'Checked Fill Color', type: 'color', defVal: '#ffffff'},
  683. {name: 'checkedStroke', dispName: 'Checked Stroke Color', type: 'color', defVal: '#000000'}
  684. ];
  685. mxShapeBootstrapRadioButton2.prototype.cst = {
  686. RADIO_BUTTON2 : 'mxgraph.bootstrap.radioButton2'
  687. };
  688. /**
  689. * Function: paintVertexShape
  690. *
  691. * Paints the vertex shape.
  692. */
  693. mxShapeBootstrapRadioButton2.prototype.paintVertexShape = function(c, x, y, w, h)
  694. {
  695. var isChecked = mxUtils.getValue(this.style, 'checked', false);
  696. var checkedFill = mxUtils.getValue(this.style, 'checkedFill', '#ffffff');
  697. var checkedStroke = mxUtils.getValue(this.style, 'checkedStroke', '#000000');
  698. c.translate(x, y);
  699. if (isChecked)
  700. {
  701. c.setFillColor(checkedFill);
  702. c.setStrokeColor(checkedFill);
  703. c.ellipse(0, 0, w, h);
  704. c.fillAndStroke();
  705. c.setFillColor(checkedStroke);
  706. c.ellipse(w * 0.2, h * 0.2, w * 0.6, h * 0.6);
  707. c.fill();
  708. }
  709. else
  710. {
  711. c.ellipse(0, 0, w, h);
  712. c.fillAndStroke();
  713. }
  714. };
  715. mxCellRenderer.registerShape(mxShapeBootstrapRadioButton2.prototype.cst.RADIO_BUTTON2, mxShapeBootstrapRadioButton2);
  716. //**********************************************************************************************************************************************************
  717. //Horizontal Lines
  718. //**********************************************************************************************************************************************************
  719. /**
  720. * Extends mxShape.
  721. */
  722. function mxShapeBootstrapHorLines(bounds, fill, stroke, strokewidth)
  723. {
  724. mxShape.call(this);
  725. this.bounds = bounds;
  726. this.fill = fill;
  727. this.stroke = stroke;
  728. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  729. };
  730. /**
  731. * Extends mxShape.
  732. */
  733. mxUtils.extend(mxShapeBootstrapHorLines, mxShape);
  734. mxShapeBootstrapHorLines.prototype.cst = {
  735. HOR_LINES : 'mxgraph.bootstrap.horLines'
  736. };
  737. /**
  738. * Function: paintVertexShape
  739. *
  740. * Paints the vertex shape.
  741. */
  742. mxShapeBootstrapHorLines.prototype.paintVertexShape = function(c, x, y, w, h)
  743. {
  744. c.translate(x, y);
  745. c.rect(0, 0, w, h);
  746. c.fill();
  747. c.begin();
  748. c.moveTo(0, 0);
  749. c.lineTo(w, 0);
  750. c.moveTo(0, h);
  751. c.lineTo(w, h);
  752. c.stroke();
  753. };
  754. mxCellRenderer.registerShape(mxShapeBootstrapHorLines.prototype.cst.HOR_LINES, mxShapeBootstrapHorLines);
  755. //**********************************************************************************************************************************************************
  756. //User 2
  757. //**********************************************************************************************************************************************************
  758. /**
  759. * Extends mxShape.
  760. */
  761. function mxShapeBootstrapUserTwo(bounds, fill, stroke, strokewidth)
  762. {
  763. mxShape.call(this);
  764. this.bounds = bounds;
  765. this.fill = fill;
  766. this.stroke = stroke;
  767. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  768. };
  769. /**
  770. * Extends mxShape.
  771. */
  772. mxUtils.extend(mxShapeBootstrapUserTwo, mxShape);
  773. mxShapeBootstrapUserTwo.prototype.cst = {
  774. USER2 : 'mxgraph.bootstrap.user2'
  775. };
  776. /**
  777. * Function: paintVertexShape
  778. *
  779. * Paints the vertex shape.
  780. */
  781. mxShapeBootstrapUserTwo.prototype.paintVertexShape = function(c, x, y, w, h)
  782. {
  783. c.translate(x, y);
  784. c.begin();
  785. c.moveTo(0, h * 0.95);
  786. c.arcTo(w * 0.3, h * 0.3, 0, 0, 1, w * 0.02, h * 0.87);
  787. c.arcTo(w * 0.1, h * 0.1, 0, 0, 1, w * 0.08, h * 0.812);
  788. c.arcTo(w * 3, h * 3, 0, 0, 1, w * 0.29, h * 0.732);
  789. c.arcTo(w * 0.15, h * 0.15, 0, 0, 0, w * 0.385, h * 0.607);
  790. c.arcTo(w * 0.11, h * 0.11, 0, 0, 0, w * 0.355, h * 0.53);
  791. c.arcTo(w * 0.3, h * 0.3, 0, 0, 1, w * 0.305, h * 0.44);
  792. c.arcTo(w * 0.33, h * 0.38, 0, 0, 1, w * 0.312, h * 0.15);
  793. c.arcTo(w * 0.218, h * 0.218 , 0, 0, 1, w * 0.688, h * 0.15);
  794. c.arcTo(w * 0.33, h * 0.38, 0, 0, 1, w * 0.693, h * 0.44);
  795. c.arcTo(w * 0.25, h * 0.25, 0, 0, 1, w * 0.645, h * 0.53);
  796. c.arcTo(w * 0.1, h * 0.1, 0, 0, 0, w * 0.612, h * 0.6);
  797. c.arcTo(w * 0.15, h * 0.15, 0, 0, 0, w * 0.7, h * 0.726);
  798. c.arcTo(w * 3, h * 3, 0, 0, 1, w * 0.92, h * 0.812);
  799. c.arcTo(w * 0.1, h * 0.1, 0, 0, 1, w * 0.97, h * 0.865);
  800. c.arcTo(w * 0.2, h * 0.2, 0, 0, 1, w * 0.995, h * 0.952);
  801. c.close();
  802. c.fill();
  803. };
  804. mxCellRenderer.registerShape(mxShapeBootstrapUserTwo.prototype.cst.USER2, mxShapeBootstrapUserTwo);
  805. //**********************************************************************************************************************************************************
  806. //Rating
  807. //**********************************************************************************************************************************************************
  808. /**
  809. * Extends mxShape.
  810. */
  811. function mxShapeBootstrapRating(bounds, fill, stroke, strokewidth)
  812. {
  813. mxShape.call(this);
  814. this.bounds = bounds;
  815. this.fill = fill;
  816. this.stroke = stroke;
  817. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  818. };
  819. /**
  820. * Extends mxShape.
  821. */
  822. mxUtils.extend(mxShapeBootstrapRating, mxShape);
  823. mxShapeBootstrapRating.prototype.cst = {
  824. RATING : 'mxgraph.bootstrap.rating',
  825. RATING_STYLE : 'ratingStyle',
  826. RATING_SCALE : 'ratingScale',
  827. RATING_HEART : 'heart',
  828. RATING_STAR : 'star',
  829. EMPTY_FILL_COLOR : 'emptyFillColor',
  830. GRADE : 'grade'
  831. };
  832. mxShapeBootstrapRating.prototype.customProperties = [
  833. {name: 'ratingStyle', dispName: 'Rating Style', type: 'enum',
  834. enumList: [{val: 'heart', dispName: 'Heart'},
  835. {val: 'star', dispName: 'Star'}]
  836. },
  837. {name: 'ratingScale', dispName: 'Rating Scale', type: 'int', min:1, defVal:5},
  838. {name: 'emptyFillColor', dispName: 'Inactive Color', type: 'color', defVal:'none'},
  839. {name: 'grade', dispName: 'Grade', type: 'int', min:1, defVal:3}
  840. ];
  841. /**
  842. * Function: paintVertexShape
  843. *
  844. * Paints the vertex shape.
  845. */
  846. mxShapeBootstrapRating.prototype.paintVertexShape = function(c, x, y, w, h)
  847. {
  848. var ratingStyle = mxUtils.getValue(this.style, mxShapeBootstrapRating.prototype.cst.RATING_STYLE, mxShapeBootstrapRating.prototype.cst.RATING_STAR);
  849. var grade = mxUtils.getValue(this.style, mxShapeBootstrapRating.prototype.cst.GRADE, '5');
  850. var ratingScale = mxUtils.getValue(this.style, mxShapeBootstrapRating.prototype.cst.RATING_SCALE, '10');
  851. c.translate(x, y);
  852. if (ratingStyle === mxShapeBootstrapRating.prototype.cst.RATING_STAR)
  853. {
  854. for (var i = 0; i < grade; i++)
  855. {
  856. c.begin();
  857. c.moveTo(i * h * 1.2, 0.33 * h);
  858. c.lineTo(i * h * 1.2 + 0.364 * h, 0.33 * h);
  859. c.lineTo(i * h * 1.2 + 0.475 * h, 0);
  860. c.lineTo(i * h * 1.2 + 0.586 * h, 0.33 * h);
  861. c.lineTo(i * h * 1.2 + 0.95 * h, 0.33 * h);
  862. c.lineTo(i * h * 1.2 + 0.66 * h, 0.551 * h);
  863. c.lineTo(i * h * 1.2 + 0.775 * h, 0.9 * h);
  864. c.lineTo(i * h * 1.2 + 0.475 * h, 0.684 * h);
  865. c.lineTo(i * h * 1.2 + 0.175 * h, 0.9 * h);
  866. c.lineTo(i * h * 1.2 + 0.29 * h, 0.551 * h);
  867. c.close();
  868. c.fillAndStroke();
  869. }
  870. }
  871. else if (ratingStyle === mxShapeBootstrapRating.prototype.cst.RATING_HEART)
  872. {
  873. for (var i = 0; i < grade; i++)
  874. {
  875. c.begin();
  876. c.moveTo(i * h * 1.2 + h * 0.519, h * 0.947);
  877. c.curveTo(i * h * 1.2 + h * 0.558, h * 0.908,
  878. i * h * 1.2 + h * 0.778, h * 0.682,
  879. i * h * 1.2 + h * 0.916, h * 0.54);
  880. c.curveTo(i * h * 1.2 + h * 1.039, h * 0.414,
  881. i * h * 1.2 + h * 1.036, h * 0.229,
  882. i * h * 1.2 + h * 0.924, h * 0.115);
  883. c.curveTo(i * h * 1.2 + h * 0.812, 0,
  884. i * h * 1.2 + h * 0.631, 0,
  885. i * h * 1.2 + h * 0.519, h * 0.115);
  886. c.curveTo(i * h * 1.2 + h * 0.408, 0,
  887. i * h * 1.2 + h * 0.227, 0,
  888. i * h * 1.2 + h * 0.115, h * 0.115);
  889. c.curveTo(i * h * 1.2 + h * 0.03, h * 0.229,
  890. i * h * 1.2, h * 0.414,
  891. i * h * 1.2 + h * 0.123, h * 0.54);
  892. c.close();
  893. c.fillAndStroke();
  894. }
  895. }
  896. var emptyFillColor = mxUtils.getValue(this.style, mxShapeBootstrapRating.prototype.cst.EMPTY_FILL_COLOR, '#ffffff');
  897. c.setFillColor(emptyFillColor);
  898. if (ratingStyle === mxShapeBootstrapRating.prototype.cst.RATING_STAR)
  899. {
  900. for (var i = grade; i < ratingScale; i++)
  901. {
  902. c.begin();
  903. c.moveTo(i * h * 1.2, 0.33 * h);
  904. c.lineTo(i * h * 1.2 + 0.364 * h, 0.33 * h);
  905. c.lineTo(i * h * 1.2 + 0.475 * h, 0);
  906. c.lineTo(i * h * 1.2 + 0.586 * h, 0.33 * h);
  907. c.lineTo(i * h * 1.2 + 0.95 * h, 0.33 * h);
  908. c.lineTo(i * h * 1.2 + 0.66 * h, 0.551 * h);
  909. c.lineTo(i * h * 1.2 + 0.775 * h, 0.9 * h);
  910. c.lineTo(i * h * 1.2 + 0.475 * h, 0.684 * h);
  911. c.lineTo(i * h * 1.2 + 0.175 * h, 0.9 * h);
  912. c.lineTo(i * h * 1.2 + 0.29 * h, 0.551 * h);
  913. c.close();
  914. c.fillAndStroke();
  915. }
  916. }
  917. else if (ratingStyle === mxShapeBootstrapRating.prototype.cst.RATING_HEART)
  918. {
  919. for (var i = grade; i < ratingScale; i++)
  920. {
  921. c.begin();
  922. c.moveTo(i * h * 1.2 + h * 0.519, h * 0.947);
  923. c.curveTo(i * h * 1.2 + h * 0.558, h * 0.908,
  924. i * h * 1.2 + h * 0.778, h * 0.682,
  925. i * h * 1.2 + h * 0.916, h * 0.54);
  926. c.curveTo(i * h * 1.2 + h * 1.039, h * 0.414,
  927. i * h * 1.2 + h * 1.036, h * 0.229,
  928. i * h * 1.2 + h * 0.924, h * 0.115);
  929. c.curveTo(i * h * 1.2 + h * 0.812, 0,
  930. i * h * 1.2 + h * 0.631, 0,
  931. i * h * 1.2 + h * 0.519, h * 0.115);
  932. c.curveTo(i * h * 1.2 + h * 0.408, 0,
  933. i * h * 1.2 + h * 0.227, 0,
  934. i * h * 1.2 + h * 0.115, h * 0.115);
  935. c.curveTo(i * h * 1.2 + h * 0.03, h * 0.229,
  936. i * h * 1.2, h * 0.414,
  937. i * h * 1.2 + h * 0.123, h * 0.54);
  938. c.close();
  939. c.fillAndStroke();
  940. }
  941. }
  942. };
  943. mxCellRenderer.registerShape(mxShapeBootstrapRating.prototype.cst.RATING, mxShapeBootstrapRating);
  944. //**********************************************************************************************************************************************************
  945. //Anchor (a dummy shape without visuals used for anchoring)
  946. //**********************************************************************************************************************************************************
  947. /**
  948. * Extends mxShape.
  949. */
  950. function mxShapeBoostrapAnchor(bounds, fill, stroke, strokewidth)
  951. {
  952. mxShape.call(this);
  953. this.bounds = bounds;
  954. };
  955. /**
  956. * Extends mxShape.
  957. */
  958. mxUtils.extend(mxShapeBoostrapAnchor, mxShape);
  959. mxShapeBoostrapAnchor.prototype.cst = {
  960. ANCHOR : 'mxgraph.bootstrap.anchor'
  961. };
  962. /**
  963. * Function: paintVertexShape
  964. *
  965. * Paints the vertex shape.
  966. */
  967. mxShapeBoostrapAnchor.prototype.paintVertexShape = function(c, x, y, w, h)
  968. {
  969. };
  970. mxCellRenderer.registerShape(mxShapeBoostrapAnchor.prototype.cst.ANCHOR, mxShapeBoostrapAnchor);
  971. //**********************************************************************************************************************************************************
  972. //Range input
  973. //**********************************************************************************************************************************************************
  974. /**
  975. * Extends mxShape.
  976. */
  977. function mxShapeBootstrapRangeInput(bounds, fill, stroke, strokewidth)
  978. {
  979. mxShape.call(this);
  980. this.bounds = bounds;
  981. this.fill = fill;
  982. this.stroke = stroke;
  983. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  984. this.dx = 0.3;
  985. };
  986. /**
  987. * Extends mxShape.
  988. */
  989. mxUtils.extend(mxShapeBootstrapRangeInput, mxShape);
  990. mxShapeBootstrapRangeInput.prototype.customProperties = [
  991. {name: 'dx', dispName: 'Handle Position', type: 'float', min:0, max:1, defVal:0.3},
  992. {name: 'rangeStyle', dispName: 'Range Style', type: 'enum',
  993. enumList: [{val: 'rect', dispName: 'Rectangle'},
  994. {val: 'rounded', dispName: 'Rounded'}]
  995. },
  996. {name: 'handleStyle', dispName: 'Handle Style', type: 'enum',
  997. enumList: [{val: 'rect', dispName: 'Rectangle'},
  998. {val: 'circle', dispName: 'Circle'}]
  999. }
  1000. ];
  1001. mxShapeBootstrapRangeInput.prototype.cst = {
  1002. RANGE_INPUT : 'mxgraph.bootstrap.rangeInput'
  1003. };
  1004. /**
  1005. * Function: paintVertexShape
  1006. *
  1007. * Paints the vertex shape.
  1008. */
  1009. mxShapeBootstrapRangeInput.prototype.paintVertexShape = function(c, x, y, w, h)
  1010. {
  1011. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1012. var gradientColor = mxUtils.getValue(this.style, 'gradientColor', 'none');
  1013. var fillColor = mxUtils.getValue(this.state.style, 'fillColor', '#ffffff');
  1014. var strokeColor = mxUtils.getValue(this.state.style, 'strokeColor', '#000000');
  1015. var gradientDir = mxUtils.getValue(this.state.style, 'gradientDirection', 'south');
  1016. var rangeStyle = mxUtils.getValue(this.state.style, 'rangeStyle', 'rounded');
  1017. var handleStyle = mxUtils.getValue(this.state.style, 'handleStyle', 'circle');
  1018. var barH = Math.min(h * 0.5, w * 0.5);
  1019. var r = barH * 0.5;
  1020. c.translate(x, y);
  1021. if (rangeStyle == 'rect')
  1022. {
  1023. var opacity = parseFloat(mxUtils.getValue(this.style, 'opacity', '100'));
  1024. var op1 = opacity;
  1025. var op2 = opacity;
  1026. if (fillColor == 'none')
  1027. {
  1028. op1 = 0;
  1029. }
  1030. if (gradientColor == 'none')
  1031. {
  1032. op2 = 0;
  1033. }
  1034. c.setGradient(fillColor, fillColor, 0, 0, w, h, gradientDir, op1, op2);
  1035. c.rect(0, h * 0.5 - 2, w, 4);
  1036. c.fill();
  1037. }
  1038. else if (rangeStyle == 'rounded')
  1039. {
  1040. c.begin();
  1041. c.moveTo(0, h * 0.5);
  1042. c.arcTo(r, r, 0, 0, 1, r, h * 0.5 - r);
  1043. c.lineTo(w - r, h * 0.5 - r);
  1044. c.arcTo(r, r, 0, 0, 1, w, h * 0.5);
  1045. c.arcTo(r, r, 0, 0, 1, w - r, h * 0.5 + r);
  1046. c.lineTo(r, h * 0.5 + r);
  1047. c.arcTo(r, r, 0, 0, 1, 0, h * 0.5);
  1048. c.close();
  1049. c.fill();
  1050. }
  1051. if (handleStyle == 'rect')
  1052. {
  1053. c.setGradient(fillColor, gradientColor, 0, 0, w, h, gradientDir, op1, op2);
  1054. var hw = h * 0.5;
  1055. c.rect(dx - hw * 0.5, 0, hw, h);
  1056. c.fillAndStroke();
  1057. c.begin();
  1058. c.moveTo(dx - hw * 0.25, h * 0.3);
  1059. c.lineTo(dx + hw * 0.25, h * 0.3);
  1060. c.moveTo(dx - hw * 0.25, h * 0.5);
  1061. c.lineTo(dx + hw * 0.25, h * 0.5);
  1062. c.moveTo(dx - hw * 0.25, h * 0.7);
  1063. c.lineTo(dx + hw * 0.25, h * 0.7);
  1064. c.stroke();
  1065. }
  1066. else if (handleStyle == 'circle')
  1067. {
  1068. c.setFillColor(strokeColor);
  1069. c.ellipse(dx - barH, 0, 2 * barH, 2 * barH);
  1070. c.fill();
  1071. }
  1072. };
  1073. mxCellRenderer.registerShape(mxShapeBootstrapRangeInput.prototype.cst.RANGE_INPUT, mxShapeBootstrapRangeInput);
  1074. mxShapeBootstrapRangeInput.prototype.constraints = null;
  1075. Graph.handleFactory[mxShapeBootstrapRangeInput.prototype.cst.RANGE_INPUT] = function(state)
  1076. {
  1077. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1078. {
  1079. var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1080. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + bounds.height / 2);
  1081. }, function(bounds, pt)
  1082. {
  1083. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  1084. })];
  1085. return handles;
  1086. }
  1087. //**********************************************************************************************************************************************************
  1088. //Switch
  1089. //**********************************************************************************************************************************************************
  1090. /**
  1091. * Extends mxShape.
  1092. */
  1093. function mxShapeBootstrapSwitch(bounds, fill, stroke, strokewidth)
  1094. {
  1095. mxShape.call(this);
  1096. this.bounds = bounds;
  1097. this.fill = fill;
  1098. this.stroke = stroke;
  1099. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1100. };
  1101. /**
  1102. * Extends mxShape.
  1103. */
  1104. mxUtils.extend(mxShapeBootstrapSwitch, mxShape);
  1105. mxShapeBootstrapSwitch.prototype.customProperties = [
  1106. {name: 'buttonState', dispName: 'Button State', type: 'bool', defVal : true},
  1107. {name: 'onStrokeColor', dispName: 'On Stroke Color', type: 'color'},
  1108. {name: 'onFillColor', dispName: 'On Fill Color', type: 'color'},
  1109. ];
  1110. mxShapeBootstrapSwitch.prototype.cst = {
  1111. SHAPE_SWITCH : 'mxgraph.bootstrap.switch'
  1112. };
  1113. /**
  1114. * Function: paintVertexShape
  1115. *
  1116. * Paints the vertex shape.
  1117. */
  1118. mxShapeBootstrapSwitch.prototype.paintVertexShape = function(c, x, y, w, h)
  1119. {
  1120. c.translate(x, y);
  1121. w = Math.max(w, 2 * h);
  1122. var state = mxUtils.getValue(this.style, 'buttonState', true);
  1123. this.background(c, x, y, w, h, state);
  1124. c.setShadow(false);
  1125. this.foreground(c, x, y, w, h, state);
  1126. };
  1127. mxShapeBootstrapSwitch.prototype.background = function(c, x, y, w, h, state)
  1128. {
  1129. if (state == true)
  1130. {
  1131. c.setStrokeColor(mxUtils.getValue(this.style, 'onStrokeColor', '#ffffff'));
  1132. c.setFillColor(mxUtils.getValue(this.style, 'onFillColor', '#0085FC'));
  1133. c.roundrect(0, 0, w, h, h * 0.5, h * 0.5);
  1134. c.fill();
  1135. }
  1136. else
  1137. {
  1138. c.roundrect(0, 0, w, h, h * 0.5, h * 0.5);
  1139. c.fillAndStroke();
  1140. }
  1141. };
  1142. mxShapeBootstrapSwitch.prototype.foreground = function(c, x, y, w, h, state)
  1143. {
  1144. var r = h * 0.8;
  1145. if (state == true)
  1146. {
  1147. c.setFillColor(mxUtils.getValue(this.style, 'onStrokeColor', '#ffffff'));
  1148. c.ellipse(w - h * 0.9, h * 0.1, r, r);
  1149. c.fill();
  1150. }
  1151. else
  1152. {
  1153. c.setFillColor(mxUtils.getValue(this.style, 'strokeColor', '#000000'));
  1154. c.ellipse(h * 0.1, h * 0.1, r, r);
  1155. c.fill();
  1156. }
  1157. };
  1158. mxCellRenderer.registerShape(mxShapeBootstrapSwitch.prototype.cst.SHAPE_SWITCH, mxShapeBootstrapSwitch);
  1159. //**********************************************************************************************************************************************************
  1160. //X
  1161. //**********************************************************************************************************************************************************
  1162. /**
  1163. * Extends mxShape.
  1164. */
  1165. function mxShapeBootstrapX(bounds, fill, stroke, strokewidth)
  1166. {
  1167. mxShape.call(this);
  1168. this.bounds = bounds;
  1169. this.fill = fill;
  1170. this.stroke = stroke;
  1171. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1172. };
  1173. /**
  1174. * Extends mxShape.
  1175. */
  1176. mxUtils.extend(mxShapeBootstrapX, mxShape);
  1177. mxShapeBootstrapX.prototype.cst = {
  1178. SHAPE_X : 'mxgraph.bootstrap.x'
  1179. };
  1180. /**
  1181. * Function: paintVertexShape
  1182. *
  1183. * Paints the vertex shape.
  1184. */
  1185. mxShapeBootstrapX.prototype.paintVertexShape = function(c, x, y, w, h)
  1186. {
  1187. c.translate(x, y);
  1188. c.begin();
  1189. c.moveTo(0, 0);
  1190. c.lineTo(w, h);
  1191. c.moveTo(w, 0);
  1192. c.lineTo(0, h);
  1193. c.stroke();
  1194. };
  1195. mxCellRenderer.registerShape(mxShapeBootstrapX.prototype.cst.SHAPE_X, mxShapeBootstrapX);
  1196. //**********************************************************************************************************************************************************
  1197. //Popover
  1198. //**********************************************************************************************************************************************************
  1199. /**
  1200. * Extends mxShape.
  1201. */
  1202. function mxShapeInfographicPopover(bounds, fill, stroke, strokewidth)
  1203. {
  1204. mxShape.call(this);
  1205. this.bounds = bounds;
  1206. this.fill = fill;
  1207. this.stroke = stroke;
  1208. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1209. this.dx = 0.5;
  1210. this.dy = 0.5;
  1211. };
  1212. /**
  1213. * Extends mxShape.
  1214. */
  1215. mxUtils.extend(mxShapeInfographicPopover, mxActor);
  1216. mxShapeInfographicPopover.prototype.cst = {SHAPE_POPOVER : 'mxgraph.bootstrap.popover'};
  1217. mxShapeInfographicPopover.prototype.customProperties = [
  1218. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10},
  1219. {name:'dx', dispName:'Callout Position', min:0, defVal: 100},
  1220. {name:'dy', dispName:'Callout Size', min:0, defVal: 30}
  1221. ];
  1222. /**
  1223. * Function: paintVertexShape
  1224. *
  1225. * Paints the vertex shape.
  1226. */
  1227. mxShapeInfographicPopover.prototype.paintVertexShape = function(c, x, y, w, h)
  1228. {
  1229. c.translate(x, y);
  1230. var r = parseInt(mxUtils.getValue(this.style, 'rSize', '10'));
  1231. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1232. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  1233. var x1 = Math.max(dx - dy, 0);
  1234. var x2 = Math.min(dx + dy, w);
  1235. c.begin();
  1236. c.moveTo(r, 0);
  1237. c.lineTo(w - r, 0);
  1238. c.arcTo(r, r, 0, 0, 1, w, r);
  1239. c.lineTo(w, h - dy - r);
  1240. c.arcTo(r, r, 0, 0, 1, w - r, h - dy);
  1241. c.lineTo(x2, h - dy);
  1242. c.lineTo(dx, h);
  1243. c.lineTo(x1, h - dy);
  1244. c.lineTo(r, h - dy);
  1245. c.arcTo(r, r, 0, 0, 1, 0, h - dy - r);
  1246. c.lineTo(0, r);
  1247. c.arcTo(r, r, 0, 0, 1, r, 0);
  1248. c.close();
  1249. c.fillAndStroke();
  1250. };
  1251. mxCellRenderer.registerShape(mxShapeInfographicPopover.prototype.cst.SHAPE_POPOVER, mxShapeInfographicPopover);
  1252. mxShapeInfographicPopover.prototype.constraints = null;
  1253. Graph.handleFactory[mxShapeInfographicPopover.prototype.cst.SHAPE_POPOVER] = function(state)
  1254. {
  1255. var handles = [Graph.createHandle(state, ['dx', 'dy'], function(bounds)
  1256. {
  1257. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1258. var dy = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  1259. return new mxPoint(bounds.x + dx, bounds.y + bounds.height - dy);
  1260. }, function(bounds, pt)
  1261. {
  1262. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(bounds.width, pt.x - bounds.x))) / 100;
  1263. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height, bounds.y + bounds.height - pt.y))) / 100;
  1264. })];
  1265. return handles;
  1266. };
  1267. mxShapeInfographicPopover.prototype.getConstraints = function(style, w, h)
  1268. {
  1269. var constr = [];
  1270. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1271. var dy = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  1272. var x1 = Math.max(dx - dy * 0.35, 0);
  1273. var x2 = Math.min(dx + dy * 0.35, w);
  1274. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false));
  1275. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false));
  1276. constr.push(new mxConnectionConstraint(new mxPoint(0.5, 0), false));
  1277. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false));
  1278. constr.push(new mxConnectionConstraint(new mxPoint(1, 0), false));
  1279. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, (h - dy) * 0.5));
  1280. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, w, h - dy));
  1281. constr.push(new mxConnectionConstraint(new mxPoint(0.75, 0), false, null, 0, h - dy));
  1282. constr.push(new mxConnectionConstraint(new mxPoint(0.25, 0), false, null, 0, h - dy));
  1283. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, dx, h));
  1284. constr.push(new mxConnectionConstraint(new mxPoint(0, 0), false, null, 0, h - dy));
  1285. return (constr);
  1286. };