mxBootstrap.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  1. /**
  2. * $Id: mxBootstrap.js,v 1.0 2014/09/10 07:05:39 mate Exp $
  3. * Copyright (c) 2006-2014, JGraph Ltd
  4. */
  5. //**********************************************************************************************************************************************************
  6. //Rounded rectangle (adjustable rounding)
  7. //**********************************************************************************************************************************************************
  8. /**
  9. * Extends mxShape.
  10. */
  11. function mxShapeBootstrapRRect(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. };
  19. /**
  20. * Extends mxShape.
  21. */
  22. mxUtils.extend(mxShapeBootstrapRRect, mxShape);
  23. mxShapeBootstrapRRect.prototype.cst = {
  24. PACKAGE : 'mxgraph.bootstrap.rrect',
  25. R_SIZE : 'rSize'
  26. };
  27. /**
  28. * Function: paintVertexShape
  29. *
  30. * Paints the vertex shape.
  31. */
  32. mxShapeBootstrapRRect.prototype.paintVertexShape = function(c, x, y, w, h)
  33. {
  34. c.translate(x, y);
  35. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapRRect.prototype.cst.R_SIZE, '10'));
  36. c.roundrect(0, 0, w, h, rSize);
  37. c.fillAndStroke();
  38. };
  39. mxCellRenderer.registerShape(mxShapeBootstrapRRect.prototype.cst.PACKAGE, mxShapeBootstrapRRect);
  40. //**********************************************************************************************************************************************************
  41. //Top Button
  42. //**********************************************************************************************************************************************************
  43. /**
  44. * Extends mxShape.
  45. */
  46. function mxShapeBootstrapTopButton(bounds, fill, stroke, strokewidth)
  47. {
  48. mxShape.call(this);
  49. this.bounds = bounds;
  50. this.fill = fill;
  51. this.stroke = stroke;
  52. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  53. };
  54. /**
  55. * Extends mxShape.
  56. */
  57. mxUtils.extend(mxShapeBootstrapTopButton, mxShape);
  58. mxShapeBootstrapTopButton.prototype.cst = {
  59. TOP_BUTTON : 'mxgraph.bootstrap.topButton',
  60. R_SIZE : 'rSize'
  61. };
  62. /**
  63. * Function: paintVertexShape
  64. *
  65. * Paints the vertex shape.
  66. */
  67. mxShapeBootstrapTopButton.prototype.paintVertexShape = function(c, x, y, w, h)
  68. {
  69. c.translate(x, y);
  70. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapTopButton.prototype.cst.R_SIZE, '10'));
  71. c.begin();
  72. c.moveTo(0, rSize);
  73. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  74. c.lineTo(w - rSize, 0);
  75. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  76. c.lineTo(w, h);
  77. c.lineTo(0, h);
  78. c.close();
  79. c.fillAndStroke();
  80. };
  81. mxCellRenderer.registerShape(mxShapeBootstrapTopButton.prototype.cst.TOP_BUTTON, mxShapeBootstrapTopButton);
  82. //**********************************************************************************************************************************************************
  83. //Bottom Button
  84. //**********************************************************************************************************************************************************
  85. /**
  86. * Extends mxShape.
  87. */
  88. function mxShapeBootstrapBottomButton(bounds, fill, stroke, strokewidth)
  89. {
  90. mxShape.call(this);
  91. this.bounds = bounds;
  92. this.fill = fill;
  93. this.stroke = stroke;
  94. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  95. };
  96. /**
  97. * Extends mxShape.
  98. */
  99. mxUtils.extend(mxShapeBootstrapBottomButton, mxShape);
  100. mxShapeBootstrapBottomButton.prototype.cst = {
  101. BOTTOM_BUTTON : 'mxgraph.bootstrap.bottomButton',
  102. R_SIZE : 'rSize'
  103. };
  104. /**
  105. * Function: paintVertexShape
  106. *
  107. * Paints the vertex shape.
  108. */
  109. mxShapeBootstrapBottomButton.prototype.paintVertexShape = function(c, x, y, w, h)
  110. {
  111. c.translate(x, y);
  112. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapBottomButton.prototype.cst.R_SIZE, '10'));
  113. c.begin();
  114. c.moveTo(0, 0);
  115. c.lineTo(w, 0);
  116. c.lineTo(w, h - rSize);
  117. c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
  118. c.lineTo(rSize, h);
  119. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  120. c.close();
  121. c.fillAndStroke();
  122. };
  123. mxCellRenderer.registerShape(mxShapeBootstrapBottomButton.prototype.cst.BOTTOM_BUTTON, mxShapeBootstrapBottomButton);
  124. //**********************************************************************************************************************************************************
  125. //Right Button
  126. //**********************************************************************************************************************************************************
  127. /**
  128. * Extends mxShape.
  129. */
  130. function mxShapeBootstrapRightButton(bounds, fill, stroke, strokewidth)
  131. {
  132. mxShape.call(this);
  133. this.bounds = bounds;
  134. this.fill = fill;
  135. this.stroke = stroke;
  136. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  137. };
  138. /**
  139. * Extends mxShape.
  140. */
  141. mxUtils.extend(mxShapeBootstrapRightButton, mxShape);
  142. mxShapeBootstrapRightButton.prototype.cst = {
  143. RIGHT_BUTTON : 'mxgraph.bootstrap.rightButton',
  144. R_SIZE : 'rSize'
  145. };
  146. /**
  147. * Function: paintVertexShape
  148. *
  149. * Paints the vertex shape.
  150. */
  151. mxShapeBootstrapRightButton.prototype.paintVertexShape = function(c, x, y, w, h)
  152. {
  153. c.translate(x, y);
  154. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapRightButton.prototype.cst.R_SIZE, '10'));
  155. c.begin();
  156. c.moveTo(0, 0);
  157. c.lineTo(w - rSize, 0);
  158. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  159. c.lineTo(w, h - rSize);
  160. c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
  161. c.lineTo(0, h);
  162. c.close();
  163. c.fillAndStroke();
  164. };
  165. mxCellRenderer.registerShape(mxShapeBootstrapRightButton.prototype.cst.RIGHT_BUTTON, mxShapeBootstrapRightButton);
  166. //**********************************************************************************************************************************************************
  167. //Left Button
  168. //**********************************************************************************************************************************************************
  169. /**
  170. * Extends mxShape.
  171. */
  172. function mxShapeBootstrapLeftButton(bounds, fill, stroke, strokewidth)
  173. {
  174. mxShape.call(this);
  175. this.bounds = bounds;
  176. this.fill = fill;
  177. this.stroke = stroke;
  178. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  179. };
  180. /**
  181. * Extends mxShape.
  182. */
  183. mxUtils.extend(mxShapeBootstrapLeftButton, mxShape);
  184. mxShapeBootstrapLeftButton.prototype.cst = {
  185. LEFT_BUTTON : 'mxgraph.bootstrap.leftButton',
  186. R_SIZE : 'rSize'
  187. };
  188. /**
  189. * Function: paintVertexShape
  190. *
  191. * Paints the vertex shape.
  192. */
  193. mxShapeBootstrapLeftButton.prototype.paintVertexShape = function(c, x, y, w, h)
  194. {
  195. c.translate(x, y);
  196. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapLeftButton.prototype.cst.R_SIZE, '10'));
  197. c.begin();
  198. c.moveTo(w, 0);
  199. c.lineTo(w, h);
  200. c.lineTo(rSize, h);
  201. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  202. c.lineTo(0, rSize);
  203. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  204. c.close();
  205. c.fillAndStroke();
  206. };
  207. mxCellRenderer.registerShape(mxShapeBootstrapLeftButton.prototype.cst.LEFT_BUTTON, mxShapeBootstrapLeftButton);
  208. //**********************************************************************************************************************************************************
  209. //Left Button (Striped)
  210. //**********************************************************************************************************************************************************
  211. /**
  212. * Extends mxShape.
  213. */
  214. function mxShapeBootstrapLeftButtonStriped(bounds, fill, stroke, strokewidth)
  215. {
  216. mxShape.call(this);
  217. this.bounds = bounds;
  218. this.fill = fill;
  219. this.stroke = stroke;
  220. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  221. };
  222. /**
  223. * Extends mxShape.
  224. */
  225. mxUtils.extend(mxShapeBootstrapLeftButtonStriped, mxShape);
  226. mxShapeBootstrapLeftButtonStriped.prototype.cst = {
  227. LEFT_BUTTON_STRIPED : 'mxgraph.bootstrap.leftButtonStriped'
  228. // R_SIZE : 'rSize'
  229. };
  230. /**
  231. * Function: paintVertexShape
  232. *
  233. * Paints the vertex shape.
  234. */
  235. mxShapeBootstrapLeftButtonStriped.prototype.paintVertexShape = function(c, x, y, w, h)
  236. {
  237. c.translate(x, y);
  238. // var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapLeftButtonStriped.prototype.cst.R_SIZE, '10'));
  239. rSize = 5;
  240. c.begin();
  241. c.moveTo(w, 0);
  242. c.lineTo(w, h);
  243. c.lineTo(rSize, h);
  244. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  245. c.lineTo(0, rSize);
  246. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  247. c.close();
  248. c.fill();
  249. var fillColor = '#ffffff';
  250. c.setAlpha('0.2');
  251. var stripeW = h * 0.5;
  252. c.setFillColor(fillColor);
  253. c.begin();
  254. c.moveTo(0, h * 0.75);
  255. c.lineTo(0, h * 0.25);
  256. c.lineTo(h * 0.75, h);
  257. c.lineTo(h * 0.25, h);
  258. c.close();
  259. c.fill();
  260. var end = false;
  261. var startX = stripeW * 0.5;
  262. while (!end)
  263. {
  264. c.begin();
  265. c.moveTo(startX, 0);
  266. if (startX + stripeW >= w)
  267. {
  268. c.lineTo(w, 0);
  269. c.lineTo(w, w - startX);
  270. }
  271. else
  272. {
  273. c.lineTo(startX + stripeW, 0);
  274. if (startX + stripeW + h > w)
  275. {
  276. c.lineTo(w, w - startX - stripeW);
  277. if (w - startX > h)
  278. {
  279. c.lineTo(w, h);
  280. c.lineTo(startX + h, h);
  281. }
  282. else
  283. {
  284. c.lineTo(w, w - startX);
  285. }
  286. }
  287. else
  288. {
  289. c.lineTo(startX + stripeW + h, h);
  290. c.lineTo(startX + h, h);
  291. }
  292. }
  293. c.close();
  294. c.fill();
  295. startX = startX + 2 * stripeW;
  296. if (startX > w)
  297. {
  298. end = true;
  299. }
  300. }
  301. };
  302. mxCellRenderer.registerShape(mxShapeBootstrapLeftButtonStriped.prototype.cst.LEFT_BUTTON_STRIPED, mxShapeBootstrapLeftButtonStriped);
  303. //**********************************************************************************************************************************************************
  304. //Rounded Button
  305. //**********************************************************************************************************************************************************
  306. /**
  307. * Extends mxShape.
  308. */
  309. function mxShapeBootstrapRoundedButton(bounds, fill, stroke, strokewidth)
  310. {
  311. mxShape.call(this);
  312. this.bounds = bounds;
  313. this.fill = fill;
  314. this.stroke = stroke;
  315. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  316. };
  317. /**
  318. * Extends mxShape.
  319. */
  320. mxUtils.extend(mxShapeBootstrapRoundedButton, mxShape);
  321. mxShapeBootstrapRoundedButton.prototype.cst = {
  322. ROUNDED_BUTTON : 'mxgraph.bootstrap.roundedButton'
  323. };
  324. /**
  325. * Function: paintVertexShape
  326. *
  327. * Paints the vertex shape.
  328. */
  329. mxShapeBootstrapRoundedButton.prototype.paintVertexShape = function(c, x, y, w, h)
  330. {
  331. c.translate(x, y);
  332. if (w > h)
  333. {
  334. var r = h * 0.5;
  335. c.begin();
  336. c.moveTo(w - r, 0);
  337. c.arcTo(r, r, 0, 0, 1, w - r, h);
  338. c.lineTo(r, h);
  339. c.arcTo(r, r, 0, 0, 1, r, 0);
  340. c.close();
  341. c.fillAndStroke();
  342. }
  343. else
  344. {
  345. var r = w * 0.5;
  346. c.begin();
  347. c.moveTo(0, h - r);
  348. c.arcTo(r, r, 0, 0, 0, w, h - r);
  349. c.lineTo(w, r);
  350. c.arcTo(r, r, 0, 0, 0, 0, r);
  351. c.close();
  352. c.fillAndStroke();
  353. }
  354. };
  355. mxCellRenderer.registerShape(mxShapeBootstrapRoundedButton.prototype.cst.ROUNDED_BUTTON, mxShapeBootstrapRoundedButton);
  356. //**********************************************************************************************************************************************************
  357. //Arrow
  358. //**********************************************************************************************************************************************************
  359. /**
  360. * Extends mxShape.
  361. */
  362. function mxShapeBootstrapArrow(bounds, fill, stroke, strokewidth)
  363. {
  364. mxShape.call(this);
  365. this.bounds = bounds;
  366. this.fill = fill;
  367. this.stroke = stroke;
  368. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  369. };
  370. /**
  371. * Extends mxShape.
  372. */
  373. mxUtils.extend(mxShapeBootstrapArrow, mxShape);
  374. mxShapeBootstrapArrow.prototype.cst = {
  375. ARROW : 'mxgraph.bootstrap.arrow'
  376. };
  377. /**
  378. * Function: paintVertexShape
  379. *
  380. * Paints the vertex shape.
  381. */
  382. mxShapeBootstrapArrow.prototype.paintVertexShape = function(c, x, y, w, h)
  383. {
  384. c.translate(x, y);
  385. c.begin();
  386. c.moveTo(0, h * 0.5);
  387. c.lineTo(w, h * 0.5);
  388. c.moveTo(w * 0.9, 0);
  389. c.lineTo(w, h * 0.5);
  390. c.lineTo(w * 0.9, h);
  391. c.stroke();
  392. };
  393. mxCellRenderer.registerShape(mxShapeBootstrapArrow.prototype.cst.ARROW, mxShapeBootstrapArrow);
  394. //**********************************************************************************************************************************************************
  395. //Tab Top
  396. //**********************************************************************************************************************************************************
  397. /**
  398. * Extends mxShape.
  399. */
  400. function mxShapeBootstrapTabTop(bounds, fill, stroke, strokewidth)
  401. {
  402. mxShape.call(this);
  403. this.bounds = bounds;
  404. this.fill = fill;
  405. this.stroke = stroke;
  406. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  407. };
  408. /**
  409. * Extends mxShape.
  410. */
  411. mxUtils.extend(mxShapeBootstrapTabTop, mxShape);
  412. mxShapeBootstrapTabTop.prototype.cst = {
  413. TAB_TOP : 'mxgraph.bootstrap.tabTop',
  414. R_SIZE : 'rSize'
  415. };
  416. /**
  417. * Function: paintVertexShape
  418. *
  419. * Paints the vertex shape.
  420. */
  421. mxShapeBootstrapTabTop.prototype.paintVertexShape = function(c, x, y, w, h)
  422. {
  423. c.translate(x, y);
  424. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeBootstrapTopButton.prototype.cst.R_SIZE, '10'));
  425. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  426. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  427. c.setStrokeColor(fillColor);
  428. c.begin();
  429. c.moveTo(0, rSize);
  430. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  431. c.lineTo(w - rSize, 0);
  432. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  433. c.lineTo(w, h);
  434. c.lineTo(0, h);
  435. c.close();
  436. c.fillAndStroke();
  437. c.setStrokeColor(strokeColor);
  438. c.begin();
  439. c.moveTo(0, h);
  440. c.lineTo(0, rSize);
  441. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  442. c.lineTo(w - rSize, 0);
  443. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  444. c.lineTo(w, h);
  445. c.stroke();
  446. };
  447. mxCellRenderer.registerShape(mxShapeBootstrapTabTop.prototype.cst.TAB_TOP, mxShapeBootstrapTabTop);
  448. //**********************************************************************************************************************************************************
  449. //Image
  450. //**********************************************************************************************************************************************************
  451. /**
  452. * Extends mxShape.
  453. */
  454. function mxShapeBootstrapImage(bounds, fill, stroke, strokewidth)
  455. {
  456. mxShape.call(this);
  457. this.bounds = bounds;
  458. this.fill = fill;
  459. this.stroke = stroke;
  460. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  461. };
  462. /**
  463. * Extends mxShape.
  464. */
  465. mxUtils.extend(mxShapeBootstrapImage, mxShape);
  466. mxShapeBootstrapImage.prototype.cst = {
  467. IMAGE : 'mxgraph.bootstrap.image',
  468. R_SIZE : 'rSize'
  469. };
  470. /**
  471. * Function: paintVertexShape
  472. *
  473. * Paints the vertex shape.
  474. */
  475. mxShapeBootstrapImage.prototype.paintVertexShape = function(c, x, y, w, h)
  476. {
  477. c.translate(x, y);
  478. var rSize = Math.max(0, parseInt(mxUtils.getValue(this.style, mxShapeBootstrapTopButton.prototype.cst.R_SIZE, '10')));
  479. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  480. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  481. c.begin();
  482. c.moveTo(0, rSize);
  483. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  484. c.lineTo(w - rSize, 0);
  485. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  486. c.lineTo(w, h - rSize);
  487. c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
  488. c.lineTo(rSize, h);
  489. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  490. c.close();
  491. c.stroke();
  492. var rsHalf = rSize * 0.5;
  493. c.translate(rsHalf, rsHalf);
  494. w = Math.max(0, w - rSize);
  495. h = Math.max(0, h - rSize);
  496. c.begin();
  497. c.moveTo(0, rsHalf);
  498. c.arcTo(rsHalf, rsHalf, 0, 0, 1, rsHalf, 0);
  499. c.lineTo(w - rsHalf, 0);
  500. c.arcTo(rsHalf, rsHalf, 0, 0, 1, w, rsHalf);
  501. c.lineTo(w, h - rsHalf);
  502. c.arcTo(rsHalf, rsHalf, 0, 0, 1, w - rsHalf, h);
  503. c.lineTo(rsHalf, h);
  504. c.arcTo(rsHalf, rsHalf, 0, 0, 1, 0, h - rsHalf);
  505. c.close();
  506. c.fill();
  507. };
  508. mxCellRenderer.registerShape(mxShapeBootstrapImage.prototype.cst.IMAGE, mxShapeBootstrapImage);
  509. //**********************************************************************************************************************************************************
  510. //Checkbox
  511. //**********************************************************************************************************************************************************
  512. /**
  513. * Extends mxShape.
  514. */
  515. function mxShapeBootstrapCheckbox(bounds, fill, stroke, strokewidth)
  516. {
  517. mxShape.call(this);
  518. this.bounds = bounds;
  519. this.fill = fill;
  520. this.stroke = stroke;
  521. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  522. };
  523. /**
  524. * Extends mxShape.
  525. */
  526. mxUtils.extend(mxShapeBootstrapCheckbox, mxShape);
  527. mxShapeBootstrapCheckbox.prototype.cst = {
  528. CHECKBOX : 'mxgraph.bootstrap.checkbox'
  529. };
  530. /**
  531. * Function: paintVertexShape
  532. *
  533. * Paints the vertex shape.
  534. */
  535. mxShapeBootstrapCheckbox.prototype.paintVertexShape = function(c, x, y, w, h)
  536. {
  537. c.translate(x, y);
  538. var rSize = 3;
  539. c.roundrect(0, 0, w, h, rSize, rSize);
  540. c.stroke();
  541. c.setStrokeWidth('3');
  542. c.begin();
  543. c.moveTo(w * 0.8, h * 0.2);
  544. c.lineTo(w * 0.4, h * 0.8);
  545. c.lineTo(w * 0.25, h * 0.6);
  546. c.stroke();
  547. };
  548. mxCellRenderer.registerShape(mxShapeBootstrapCheckbox.prototype.cst.CHECKBOX, mxShapeBootstrapCheckbox);
  549. //**********************************************************************************************************************************************************
  550. //Radio Button
  551. //**********************************************************************************************************************************************************
  552. /**
  553. * Extends mxShape.
  554. */
  555. function mxShapeBootstrapRadioButton(bounds, fill, stroke, strokewidth)
  556. {
  557. mxShape.call(this);
  558. this.bounds = bounds;
  559. this.fill = fill;
  560. this.stroke = stroke;
  561. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  562. };
  563. /**
  564. * Extends mxShape.
  565. */
  566. mxUtils.extend(mxShapeBootstrapRadioButton, mxShape);
  567. mxShapeBootstrapRadioButton.prototype.cst = {
  568. RADIO_BUTTON : 'mxgraph.bootstrap.radioButton'
  569. };
  570. /**
  571. * Function: paintVertexShape
  572. *
  573. * Paints the vertex shape.
  574. */
  575. mxShapeBootstrapRadioButton.prototype.paintVertexShape = function(c, x, y, w, h)
  576. {
  577. c.translate(x, y);
  578. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  579. c.ellipse(0, 0, w, h);
  580. c.stroke();
  581. c.setFillColor(strokeColor);
  582. c.ellipse(w * 0.25, h * 0.25, w * 0.5, h * 0.5);
  583. c.fill();
  584. };
  585. mxCellRenderer.registerShape(mxShapeBootstrapRadioButton.prototype.cst.RADIO_BUTTON, mxShapeBootstrapRadioButton);
  586. //**********************************************************************************************************************************************************
  587. //Horizontal Lines
  588. //**********************************************************************************************************************************************************
  589. /**
  590. * Extends mxShape.
  591. */
  592. function mxShapeBootstrapHorLines(bounds, fill, stroke, strokewidth)
  593. {
  594. mxShape.call(this);
  595. this.bounds = bounds;
  596. this.fill = fill;
  597. this.stroke = stroke;
  598. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  599. };
  600. /**
  601. * Extends mxShape.
  602. */
  603. mxUtils.extend(mxShapeBootstrapHorLines, mxShape);
  604. mxShapeBootstrapHorLines.prototype.cst = {
  605. HOR_LINES : 'mxgraph.bootstrap.horLines'
  606. };
  607. /**
  608. * Function: paintVertexShape
  609. *
  610. * Paints the vertex shape.
  611. */
  612. mxShapeBootstrapHorLines.prototype.paintVertexShape = function(c, x, y, w, h)
  613. {
  614. c.translate(x, y);
  615. c.rect(0, 0, w, h);
  616. c.fill();
  617. c.begin();
  618. c.moveTo(0, 0);
  619. c.lineTo(w, 0);
  620. c.moveTo(0, h);
  621. c.lineTo(w, h);
  622. c.stroke();
  623. };
  624. mxCellRenderer.registerShape(mxShapeBootstrapHorLines.prototype.cst.HOR_LINES, mxShapeBootstrapHorLines);
  625. //**********************************************************************************************************************************************************
  626. //User 2
  627. //**********************************************************************************************************************************************************
  628. /**
  629. * Extends mxShape.
  630. */
  631. function mxShapeBootstrapUserTwo(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(mxShapeBootstrapUserTwo, mxShape);
  643. mxShapeBootstrapUserTwo.prototype.cst = {
  644. USER2 : 'mxgraph.bootstrap.user2'
  645. };
  646. /**
  647. * Function: paintVertexShape
  648. *
  649. * Paints the vertex shape.
  650. */
  651. mxShapeBootstrapUserTwo.prototype.paintVertexShape = function(c, x, y, w, h)
  652. {
  653. c.translate(x, y);
  654. c.begin();
  655. c.moveTo(0, h * 0.95);
  656. c.arcTo(w * 0.3, h * 0.3, 0, 0, 1, w * 0.02, h * 0.87);
  657. c.arcTo(w * 0.1, h * 0.1, 0, 0, 1, w * 0.08, h * 0.812);
  658. c.arcTo(w * 3, h * 3, 0, 0, 1, w * 0.29, h * 0.732);
  659. c.arcTo(w * 0.15, h * 0.15, 0, 0, 0, w * 0.385, h * 0.607);
  660. c.arcTo(w * 0.11, h * 0.11, 0, 0, 0, w * 0.355, h * 0.53);
  661. c.arcTo(w * 0.3, h * 0.3, 0, 0, 1, w * 0.305, h * 0.44);
  662. c.arcTo(w * 0.33, h * 0.38, 0, 0, 1, w * 0.312, h * 0.15);
  663. c.arcTo(w * 0.218, h * 0.218 , 0, 0, 1, w * 0.688, h * 0.15);
  664. c.arcTo(w * 0.33, h * 0.38, 0, 0, 1, w * 0.693, h * 0.44);
  665. c.arcTo(w * 0.25, h * 0.25, 0, 0, 1, w * 0.645, h * 0.53);
  666. c.arcTo(w * 0.1, h * 0.1, 0, 0, 0, w * 0.612, h * 0.6);
  667. c.arcTo(w * 0.15, h * 0.15, 0, 0, 0, w * 0.7, h * 0.726);
  668. c.arcTo(w * 3, h * 3, 0, 0, 1, w * 0.92, h * 0.812);
  669. c.arcTo(w * 0.1, h * 0.1, 0, 0, 1, w * 0.97, h * 0.865);
  670. c.arcTo(w * 0.2, h * 0.2, 0, 0, 1, w * 0.995, h * 0.952);
  671. c.close();
  672. c.fill();
  673. };
  674. mxCellRenderer.registerShape(mxShapeBootstrapUserTwo.prototype.cst.USER2, mxShapeBootstrapUserTwo);
  675. //**********************************************************************************************************************************************************
  676. //Rating
  677. //**********************************************************************************************************************************************************
  678. /**
  679. * Extends mxShape.
  680. */
  681. function mxShapeBootstrapRating(bounds, fill, stroke, strokewidth)
  682. {
  683. mxShape.call(this);
  684. this.bounds = bounds;
  685. this.fill = fill;
  686. this.stroke = stroke;
  687. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  688. };
  689. /**
  690. * Extends mxShape.
  691. */
  692. mxUtils.extend(mxShapeBootstrapRating, mxShape);
  693. mxShapeBootstrapRating.prototype.cst = {
  694. RATING : 'mxgraph.bootstrap.rating',
  695. RATING_STYLE : 'ratingStyle',
  696. RATING_SCALE : 'ratingScale',
  697. RATING_HEART : 'heart',
  698. RATING_STAR : 'star',
  699. EMPTY_FILL_COLOR : 'emptyFillColor',
  700. GRADE : 'grade'
  701. };
  702. /**
  703. * Function: paintVertexShape
  704. *
  705. * Paints the vertex shape.
  706. */
  707. mxShapeBootstrapRating.prototype.paintVertexShape = function(c, x, y, w, h)
  708. {
  709. var ratingStyle = mxUtils.getValue(this.style, mxShapeBootstrapRating.prototype.cst.RATING_STYLE, mxShapeBootstrapRating.prototype.cst.RATING_STAR);
  710. var grade = mxUtils.getValue(this.style, mxShapeBootstrapRating.prototype.cst.GRADE, '5');
  711. var ratingScale = mxUtils.getValue(this.style, mxShapeBootstrapRating.prototype.cst.RATING_SCALE, '10');
  712. c.translate(x, y);
  713. if (ratingStyle === mxShapeBootstrapRating.prototype.cst.RATING_STAR)
  714. {
  715. for (var i = 0; i < grade; i++)
  716. {
  717. c.begin();
  718. c.moveTo(i * h * 1.2, 0.33 * h);
  719. c.lineTo(i * h * 1.2 + 0.364 * h, 0.33 * h);
  720. c.lineTo(i * h * 1.2 + 0.475 * h, 0);
  721. c.lineTo(i * h * 1.2 + 0.586 * h, 0.33 * h);
  722. c.lineTo(i * h * 1.2 + 0.95 * h, 0.33 * h);
  723. c.lineTo(i * h * 1.2 + 0.66 * h, 0.551 * h);
  724. c.lineTo(i * h * 1.2 + 0.775 * h, 0.9 * h);
  725. c.lineTo(i * h * 1.2 + 0.475 * h, 0.684 * h);
  726. c.lineTo(i * h * 1.2 + 0.175 * h, 0.9 * h);
  727. c.lineTo(i * h * 1.2 + 0.29 * h, 0.551 * h);
  728. c.close();
  729. c.fillAndStroke();
  730. }
  731. }
  732. else if (ratingStyle === mxShapeBootstrapRating.prototype.cst.RATING_HEART)
  733. {
  734. for (var i = 0; i < grade; i++)
  735. {
  736. c.begin();
  737. c.moveTo(i * h * 1.2 + h * 0.519, h * 0.947);
  738. c.curveTo(i * h * 1.2 + h * 0.558, h * 0.908, i * h * 1.5 + h * 0.778, h * 0.682, i * h * 1.5 + h * 0.916, h * 0.54);
  739. c.curveTo(i * h * 1.2 + h * 1.039, h * 0.414, i * h * 1.5 + h * 1.036, h * 0.229, i * h * 1.5 + h * 0.924, h * 0.115);
  740. c.curveTo(i * h * 1.2 + h * 0.812, 0, i * h * 1.5 + h * 0.631, 0, i * h * 1.5 + h * 0.519, h * 0.115);
  741. c.curveTo(i * h * 1.2 + h * 0.408, 0, i * h * 1.5 + h * 0.227, 0, i * h * 1.5 + h * 0.115, h * 0.115);
  742. c.curveTo(i * h * 1.2 + h * 0.03, h * 0.229, i * h * 1.5, h * 0.414, i * h * 1.5 + h * 0.123, h * 0.54);
  743. c.close();
  744. c.fillAndStroke();
  745. }
  746. }
  747. var emptyFillColor = mxUtils.getValue(this.style, mxShapeBootstrapRating.prototype.cst.EMPTY_FILL_COLOR, '#ffffff');
  748. c.setFillColor(emptyFillColor);
  749. if (ratingStyle === mxShapeBootstrapRating.prototype.cst.RATING_STAR)
  750. {
  751. for (var i = grade; i < ratingScale; i++)
  752. {
  753. c.begin();
  754. c.moveTo(i * h * 1.2, 0.33 * h);
  755. c.lineTo(i * h * 1.2 + 0.364 * h, 0.33 * h);
  756. c.lineTo(i * h * 1.2 + 0.475 * h, 0);
  757. c.lineTo(i * h * 1.2 + 0.586 * h, 0.33 * h);
  758. c.lineTo(i * h * 1.2 + 0.95 * h, 0.33 * h);
  759. c.lineTo(i * h * 1.2 + 0.66 * h, 0.551 * h);
  760. c.lineTo(i * h * 1.2 + 0.775 * h, 0.9 * h);
  761. c.lineTo(i * h * 1.2 + 0.475 * h, 0.684 * h);
  762. c.lineTo(i * h * 1.2 + 0.175 * h, 0.9 * h);
  763. c.lineTo(i * h * 1.2 + 0.29 * h, 0.551 * h);
  764. c.close();
  765. c.fillAndStroke();
  766. }
  767. }
  768. else if (ratingStyle === mxShapeBootstrapRating.prototype.cst.RATING_HEART)
  769. {
  770. for (var i = grade; i < ratingScale; i++)
  771. {
  772. c.begin();
  773. c.moveTo(i * h * 1.2 + h * 0.519, h * 0.947);
  774. c.curveTo(i * h * 1.2 + h * 0.558, h * 0.908, i * h * 1.5 + h * 0.778, h * 0.682, i * h * 1.5 + h * 0.916, h * 0.54);
  775. c.curveTo(i * h * 1.2 + h * 1.039, h * 0.414, i * h * 1.5 + h * 1.036, h * 0.229, i * h * 1.5 + h * 0.924, h * 0.115);
  776. c.curveTo(i * h * 1.2 + h * 0.812, 0, i * h * 1.5 + h * 0.631, 0, i * h * 1.5 + h * 0.519, h * 0.115);
  777. c.curveTo(i * h * 1.2 + h * 0.408, 0, i * h * 1.5 + h * 0.227, 0, i * h * 1.5 + h * 0.115, h * 0.115);
  778. c.curveTo(i * h * 1.2 + h * 0.03, h * 0.229, i * h * 1.5, h * 0.414, i * h * 1.5 + h * 0.123, h * 0.54);
  779. c.close();
  780. c.fillAndStroke();
  781. }
  782. }
  783. };
  784. mxCellRenderer.prototype.defaultShapes[mxShapeBootstrapRating.prototype.cst.RATING] = mxShapeBootstrapRating;
  785. //**********************************************************************************************************************************************************
  786. //Anchor (a dummy shape without visuals used for anchoring)
  787. //**********************************************************************************************************************************************************
  788. /**
  789. * Extends mxShape.
  790. */
  791. function mxShapeBoostrapAnchor(bounds, fill, stroke, strokewidth)
  792. {
  793. mxShape.call(this);
  794. this.bounds = bounds;
  795. };
  796. /**
  797. * Extends mxShape.
  798. */
  799. mxUtils.extend(mxShapeBoostrapAnchor, mxShape);
  800. mxShapeBoostrapAnchor.prototype.cst = {
  801. ANCHOR : 'mxgraph.bootstrap.anchor'
  802. };
  803. /**
  804. * Function: paintVertexShape
  805. *
  806. * Paints the vertex shape.
  807. */
  808. mxShapeBoostrapAnchor.prototype.paintVertexShape = function(c, x, y, w, h)
  809. {
  810. };
  811. mxCellRenderer.registerShape(mxShapeBoostrapAnchor.prototype.cst.ANCHOR, mxShapeBoostrapAnchor);