mxBootstrap.js 42 KB

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