mxGmdl.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926
  1. /**
  2. * $Id: mxGmdl.js,v 1.0 2015/09/09 17:05:39 mate Exp $
  3. * Copyright (c) 2006-2015, JGraph Ltd
  4. */
  5. //**********************************************************************************************************************************************************
  6. //player
  7. //**********************************************************************************************************************************************************
  8. /**
  9. * Extends mxShape.
  10. */
  11. function mxShapeGmdlPlayer(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(mxShapeGmdlPlayer, mxShape);
  23. mxShapeGmdlPlayer.prototype.cst = {
  24. SHAPE_PLAYER : 'mxgraph.gmdl.player'
  25. };
  26. /**
  27. * Function: paintVertexShape
  28. *
  29. * Paints the vertex shape.
  30. */
  31. mxShapeGmdlPlayer.prototype.paintVertexShape = function(c, x, y, w, h)
  32. {
  33. c.translate(x, y);
  34. c.begin();
  35. c.rect(0, 0, w, h);
  36. c.fill();
  37. c.setShadow(false);
  38. this.foreground(c, x, y, w, h);
  39. };
  40. mxShapeGmdlPlayer.prototype.foreground = function(c, x, y, w, h)
  41. {
  42. if ( h >= 4)
  43. {
  44. c.setFillColor('#FFED00');
  45. c.begin();
  46. c.rect(0, 0, w * 0.8, 4);
  47. c.fill();
  48. }
  49. if ( h >= 14 && w >= 33)
  50. {
  51. c.setFillColor('#717171');
  52. c.begin();
  53. c.rect(w - 33, h * 0.5 - 7, 4, 14);
  54. c.fill();
  55. c.begin();
  56. c.rect(w - 25, h * 0.5 - 7, 4, 14);
  57. c.fill();
  58. }
  59. };
  60. mxCellRenderer.prototype.defaultShapes[mxShapeGmdlPlayer.prototype.cst.SHAPE_PLAYER] = mxShapeGmdlPlayer;
  61. //**********************************************************************************************************************************************************
  62. //switch
  63. //**********************************************************************************************************************************************************
  64. /**
  65. * Extends mxShape.
  66. */
  67. function mxShapeGmdlSwitch(bounds, fill, stroke, strokewidth)
  68. {
  69. mxShape.call(this);
  70. this.bounds = bounds;
  71. this.fill = fill;
  72. this.stroke = stroke;
  73. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  74. };
  75. /**
  76. * Extends mxShape.
  77. */
  78. mxUtils.extend(mxShapeGmdlSwitch, mxShape);
  79. mxShapeGmdlSwitch.prototype.cst = {
  80. SHAPE_SWITCH : 'mxgraph.gmdl.switch',
  81. STATE : 'switchState',
  82. STATE_ON : 'on',
  83. STATE_OFF : 'off'
  84. };
  85. /**
  86. * Function: paintVertexShape
  87. *
  88. * Paints the vertex shape.
  89. */
  90. mxShapeGmdlSwitch.prototype.paintVertexShape = function(c, x, y, w, h)
  91. {
  92. c.translate(x, y);
  93. var state = mxUtils.getValue(this.style, mxShapeGmdlSwitch.prototype.cst.STATE, mxShapeGmdlSwitch.prototype.cst.STATE_ON);
  94. this.background(c, x, y, w, h, state);
  95. c.setShadow(true);
  96. this.foreground(c, x, y, w, h, state);
  97. };
  98. mxShapeGmdlSwitch.prototype.background = function(c, x, y, w, h, state)
  99. {
  100. c.begin();
  101. if (state === mxShapeGmdlSwitch.prototype.cst.STATE_ON)
  102. {
  103. c.save();
  104. c.setAlpha('0.5');
  105. c.moveTo(w * 0.135, h * 0.8);
  106. c.arcTo(w * 0.135, h * 0.3, 0, 0, 1, w * 0.135, h * 0.2);
  107. c.lineTo(w * 0.675, h * 0.2);
  108. c.arcTo(w * 0.135, h * 0.3, 0, 0, 1, w * 0.675, h * 0.8);
  109. c.close();
  110. c.fillAndStroke();
  111. c.restore();
  112. }
  113. else
  114. {
  115. c.setFillColor('#BCBBBB');
  116. c.moveTo(w * 0.225, h * 0.8);
  117. c.arcTo(w * 0.135, h * 0.3, 0, 0, 1, w * 0.225, h * 0.2);
  118. c.lineTo(w * 0.865, h * 0.2);
  119. c.arcTo(w * 0.135, h * 0.3, 0, 0, 1, w * 0.865, h * 0.8);
  120. c.close();
  121. c.fillAndStroke();
  122. }
  123. };
  124. mxShapeGmdlSwitch.prototype.foreground = function(c, x, y, w, h, state)
  125. {
  126. c.begin();
  127. if (state === mxShapeGmdlSwitch.prototype.cst.STATE_ON)
  128. {
  129. c.ellipse(w * 0.36, 0, w * 0.64, h);
  130. }
  131. else
  132. {
  133. c.setFillColor('#F1F1F1');
  134. c.ellipse(0, 0, w * 0.64, h);
  135. }
  136. c.fillAndStroke();
  137. };
  138. mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSwitch.prototype.cst.SHAPE_SWITCH] = mxShapeGmdlSwitch;
  139. //**********************************************************************************************************************************************************
  140. //rect with margins
  141. //**********************************************************************************************************************************************************
  142. /**
  143. * Extends mxShape.
  144. */
  145. function mxShapeGmdlMarginRect(bounds, fill, stroke, strokewidth)
  146. {
  147. mxShape.call(this);
  148. this.bounds = bounds;
  149. this.fill = fill;
  150. this.stroke = stroke;
  151. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  152. };
  153. /**
  154. * Extends mxShape.
  155. */
  156. mxUtils.extend(mxShapeGmdlMarginRect, mxShape);
  157. mxShapeGmdlMarginRect.prototype.cst = {
  158. SHAPE_MARGIN_RECT : 'mxgraph.gmdl.marginRect',
  159. MARGIN : 'rectMargin',
  160. MARGIN_TOP : 'rectMarginTop',
  161. MARGIN_LEFT : 'rectMarginLeft',
  162. MARGIN_BOTTOM : 'rectMarginBottom',
  163. MARGIN_RIGHT : 'rectMarginRight'
  164. };
  165. /**
  166. * Function: paintVertexShape
  167. *
  168. * Paints the vertex shape.
  169. */
  170. mxShapeGmdlMarginRect.prototype.paintVertexShape = function(c, x, y, w, h)
  171. {
  172. c.translate(x, y);
  173. this.background(c, x, y, w, h);
  174. };
  175. mxShapeGmdlMarginRect.prototype.background = function(c, x, y, w, h, state)
  176. {
  177. var margin = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlMarginRect.prototype.cst.MARGIN, '0'));
  178. var marginTop = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlMarginRect.prototype.cst.MARGIN_TOP, '0'));
  179. var marginLeft = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlMarginRect.prototype.cst.MARGIN_LEFT, '0'));
  180. var marginBottom = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlMarginRect.prototype.cst.MARGIN_BOTTOM, '0'));
  181. var marginRight = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlMarginRect.prototype.cst.MARGIN_RIGHT, '0'));
  182. var x1 = margin + marginLeft;
  183. var y1 = margin + marginTop;
  184. var w1 = w - marginRight - x1 - margin;
  185. var h1 = h - marginBottom - y1 - margin;
  186. if (w1 >0 && h1 > 0)
  187. {
  188. c.begin();
  189. c.rect(x1, y1, w1, h1);
  190. c.fillAndStroke();
  191. }
  192. };
  193. mxCellRenderer.prototype.defaultShapes[mxShapeGmdlMarginRect.prototype.cst.SHAPE_MARGIN_RECT] = mxShapeGmdlMarginRect;
  194. //**********************************************************************************************************************************************************
  195. //slider normal
  196. //**********************************************************************************************************************************************************
  197. /**
  198. * Extends mxShape.
  199. */
  200. function mxShapeGmdlSliderNormal(bounds, fill, stroke, strokewidth)
  201. {
  202. mxShape.call(this);
  203. this.bounds = bounds;
  204. this.fill = fill;
  205. this.stroke = stroke;
  206. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  207. };
  208. /**
  209. * Extends mxShape.
  210. */
  211. mxUtils.extend(mxShapeGmdlSliderNormal, mxShape);
  212. mxShapeGmdlSliderNormal.prototype.cst = {
  213. SHAPE_SLIDER_NORMAL : 'mxgraph.gmdl.sliderNormal',
  214. HANDLE_SIZE : 'handleSize'
  215. };
  216. /**
  217. * Function: paintVertexShape
  218. *
  219. * Paints the vertex shape.
  220. */
  221. mxShapeGmdlSliderNormal.prototype.paintVertexShape = function(c, x, y, w, h)
  222. {
  223. c.translate(x, y);
  224. this.background(c, x, y, w, h);
  225. c.setShadow(true);
  226. };
  227. mxShapeGmdlSliderNormal.prototype.background = function(c, x, y, w, h)
  228. {
  229. var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderNormal.prototype.cst.HANDLE_SIZE, '10'));
  230. c.ellipse(0, h * 0.5 - hSize * 0.5, hSize, hSize);
  231. c.stroke();
  232. c.begin();
  233. c.moveTo(hSize, h * 0.5);
  234. c.lineTo(w, h * 0.5);
  235. c.fillAndStroke();
  236. };
  237. mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSliderNormal.prototype.cst.SHAPE_SLIDER_NORMAL] = mxShapeGmdlSliderNormal;
  238. //**********************************************************************************************************************************************************
  239. //slider normal v2
  240. //**********************************************************************************************************************************************************
  241. /**
  242. * Extends mxShape.
  243. */
  244. function mxShapeGmdlSlider2(bounds, fill, stroke, strokewidth)
  245. {
  246. mxShape.call(this);
  247. this.bounds = bounds;
  248. this.fill = fill;
  249. this.stroke = stroke;
  250. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  251. };
  252. /**
  253. * Extends mxShape.
  254. */
  255. mxUtils.extend(mxShapeGmdlSlider2, mxShape);
  256. mxShapeGmdlSlider2.prototype.cst = {
  257. SHAPE_SLIDER : 'mxgraph.gmdl.slider2',
  258. BAR_POS : 'barPos',
  259. HANDLE_SIZE : 'handleSize'
  260. };
  261. /**
  262. * Function: paintVertexShape
  263. *
  264. * Paints the vertex shape.
  265. */
  266. mxShapeGmdlSlider2.prototype.paintVertexShape = function(c, x, y, w, h)
  267. {
  268. c.translate(x, y);
  269. this.background(c, x, y, w, h);
  270. c.setShadow(true);
  271. };
  272. mxShapeGmdlSlider2.prototype.background = function(c, x, y, w, h)
  273. {
  274. var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSlider2.prototype.cst.HANDLE_SIZE, '10'));
  275. var barPos = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSlider2.prototype.cst.BAR_POS, '40')) / 100;
  276. barPos = Math.max(0, Math.min(1, barPos));
  277. c.save();
  278. c.setStrokeColor('#bbbbbb');
  279. c.begin();
  280. c.moveTo(0, h * 0.5);
  281. c.lineTo(w, h * 0.5);
  282. c.fillAndStroke();
  283. c.restore();
  284. c.begin();
  285. c.moveTo(0, h * 0.5);
  286. c.lineTo(barPos * w, h * 0.5);
  287. c.fillAndStroke();
  288. c.begin();
  289. c.ellipse(barPos * w - hSize * 0.5, h * 0.5 - hSize * 0.5, hSize, hSize);
  290. c.fillAndStroke();
  291. };
  292. mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSlider2.prototype.cst.SHAPE_SLIDER] = mxShapeGmdlSlider2;
  293. mxShapeGmdlSlider2.prototype.constraints = null;
  294. Graph.handleFactory[mxShapeGmdlSlider2.prototype.cst.SHAPE_SLIDER] = function(state)
  295. {
  296. var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
  297. {
  298. var barPos = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'barPos', 0.4))));
  299. return new mxPoint(bounds.x + barPos * bounds.width / 100, bounds.y + bounds.height / 2);
  300. }, function(bounds, pt)
  301. {
  302. this.state.style['barPos'] = Math.round(100 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 100;
  303. })];
  304. return handles;
  305. };
  306. //**********************************************************************************************************************************************************
  307. //slider focused v2
  308. //**********************************************************************************************************************************************************
  309. /**
  310. * Extends mxShape.
  311. */
  312. function mxShapeGmdlSliderFocused(bounds, fill, stroke, strokewidth)
  313. {
  314. mxShape.call(this);
  315. this.bounds = bounds;
  316. this.fill = fill;
  317. this.stroke = stroke;
  318. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  319. };
  320. /**
  321. * Extends mxShape.
  322. */
  323. mxUtils.extend(mxShapeGmdlSliderFocused, mxShape);
  324. mxShapeGmdlSliderFocused.prototype.cst = {
  325. SHAPE_SLIDER_FOCUSED : 'mxgraph.gmdl.sliderFocused',
  326. BAR_POS : 'barPos',
  327. HANDLE_SIZE : 'handleSize'
  328. };
  329. /**
  330. * Function: paintVertexShape
  331. *
  332. * Paints the vertex shape.
  333. */
  334. mxShapeGmdlSliderFocused.prototype.paintVertexShape = function(c, x, y, w, h)
  335. {
  336. c.translate(x, y);
  337. this.background(c, x, y, w, h);
  338. c.setShadow(true);
  339. };
  340. mxShapeGmdlSliderFocused.prototype.background = function(c, x, y, w, h)
  341. {
  342. var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderFocused.prototype.cst.HANDLE_SIZE, '10'));
  343. var barPos = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderFocused.prototype.cst.BAR_POS, '40')) / 100;
  344. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#ffffff');
  345. barPos = Math.max(0, Math.min(1, barPos));
  346. c.save();
  347. c.setStrokeColor('#bbbbbb');
  348. c.begin();
  349. c.moveTo(0, h * 0.5);
  350. c.lineTo(w, h * 0.5);
  351. c.fillAndStroke();
  352. c.restore();
  353. c.begin();
  354. c.moveTo(0, h * 0.5);
  355. c.lineTo(barPos * w, h * 0.5);
  356. c.fillAndStroke();
  357. c.begin();
  358. c.ellipse(barPos * w - hSize * 0.167, h * 0.5 - hSize * 0.167, hSize * 0.33, hSize * 0.33);
  359. c.fillAndStroke();
  360. c.setFillColor(strokeColor);
  361. c.setAlpha(0.15);
  362. c.begin();
  363. c.ellipse(barPos * w - hSize * 0.5, h * 0.5 - hSize * 0.5, hSize, hSize);
  364. c.fill();
  365. };
  366. mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSliderFocused.prototype.cst.SHAPE_SLIDER_FOCUSED] = mxShapeGmdlSliderFocused;
  367. mxShapeGmdlSliderFocused.prototype.constraints = null;
  368. Graph.handleFactory[mxShapeGmdlSliderFocused.prototype.cst.SHAPE_SLIDER_FOCUSED] = function(state)
  369. {
  370. var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
  371. {
  372. var barPos = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'barPos', 0.4))));
  373. return new mxPoint(bounds.x + barPos * bounds.width / 100, bounds.y + bounds.height / 2);
  374. }, function(bounds, pt)
  375. {
  376. this.state.style['barPos'] = Math.round(100 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 100;
  377. })];
  378. return handles;
  379. };
  380. //**********************************************************************************************************************************************************
  381. //slider disabled
  382. //**********************************************************************************************************************************************************
  383. /**
  384. * Extends mxShape.
  385. */
  386. function mxShapeGmdlSliderDisabled(bounds, fill, stroke, strokewidth)
  387. {
  388. mxShape.call(this);
  389. this.bounds = bounds;
  390. this.fill = fill;
  391. this.stroke = stroke;
  392. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  393. };
  394. /**
  395. * Extends mxShape.
  396. */
  397. mxUtils.extend(mxShapeGmdlSliderDisabled, mxShape);
  398. mxShapeGmdlSliderDisabled.prototype.cst = {
  399. SHAPE_SLIDER_DISABLED : 'mxgraph.gmdl.sliderDisabled',
  400. HANDLE_POSITION : 'hPos',
  401. HANDLE_SIZE : 'handleSize'
  402. };
  403. /**
  404. * Function: paintVertexShape
  405. *
  406. * Paints the vertex shape.
  407. */
  408. mxShapeGmdlSliderDisabled.prototype.paintVertexShape = function(c, x, y, w, h)
  409. {
  410. c.translate(x, y);
  411. this.background(c, x, y, w, h);
  412. c.setShadow(true);
  413. };
  414. mxShapeGmdlSliderDisabled.prototype.background = function(c, x, y, w, h)
  415. {
  416. var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDisabled.prototype.cst.HANDLE_SIZE, '10'));
  417. var hPos = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDisabled.prototype.cst.HANDLE_POSITION, '50')) / 100;
  418. hPos = Math.max(hPos, 0);
  419. hPos = Math.min(hPos, 1);
  420. c.ellipse(w * hPos - hSize * 0.5, (h - hSize) * 0.5, hSize, hSize);
  421. c.fillAndStroke();
  422. var endL = w * hPos - 7;
  423. var startR = w * hPos + 7;
  424. if (endL > 0)
  425. {
  426. c.begin();
  427. c.moveTo(0, h * 0.5);
  428. c.lineTo(endL, h * 0.5);
  429. c.stroke();
  430. }
  431. if (startR < w)
  432. {
  433. c.begin();
  434. c.moveTo(startR, h * 0.5);
  435. c.lineTo(w, h * 0.5);
  436. c.stroke();
  437. }
  438. };
  439. mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSliderDisabled.prototype.cst.SHAPE_SLIDER_DISABLED] = mxShapeGmdlSliderDisabled;
  440. //**********************************************************************************************************************************************************
  441. //slider disabled v2
  442. //**********************************************************************************************************************************************************
  443. /**
  444. * Extends mxShape.
  445. */
  446. function mxShapeGmdlSliderDisabled2(bounds, fill, stroke, strokewidth)
  447. {
  448. mxShape.call(this);
  449. this.bounds = bounds;
  450. this.fill = fill;
  451. this.stroke = stroke;
  452. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  453. };
  454. /**
  455. * Extends mxShape.
  456. */
  457. mxUtils.extend(mxShapeGmdlSliderDisabled2, mxShape);
  458. mxShapeGmdlSliderDisabled2.prototype.cst = {
  459. SHAPE_SLIDER_DISABLED : 'mxgraph.gmdl.sliderDisabled2',
  460. HANDLE_POSITION : 'hPos',
  461. HANDLE_SIZE : 'handleSize'
  462. };
  463. /**
  464. * Function: paintVertexShape
  465. *
  466. * Paints the vertex shape.
  467. */
  468. mxShapeGmdlSliderDisabled2.prototype.paintVertexShape = function(c, x, y, w, h)
  469. {
  470. c.translate(x, y);
  471. this.background(c, x, y, w, h);
  472. c.setShadow(true);
  473. };
  474. mxShapeGmdlSliderDisabled2.prototype.background = function(c, x, y, w, h)
  475. {
  476. var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDisabled2.prototype.cst.HANDLE_SIZE, '10'));
  477. var hPos = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDisabled2.prototype.cst.HANDLE_POSITION, '50')) / 100;
  478. hPos = Math.min(Math.max(hPos, 0), 1);
  479. c.ellipse(w * hPos - hSize * 0.5, (h - hSize) * 0.5, hSize, hSize);
  480. c.fillAndStroke();
  481. var endL = w * hPos - 7;
  482. var startR = w * hPos + 7;
  483. if (endL > 0)
  484. {
  485. c.begin();
  486. c.moveTo(0, h * 0.5);
  487. c.lineTo(endL, h * 0.5);
  488. c.stroke();
  489. }
  490. if (startR < w)
  491. {
  492. c.begin();
  493. c.moveTo(startR, h * 0.5);
  494. c.lineTo(w, h * 0.5);
  495. c.stroke();
  496. }
  497. };
  498. mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSliderDisabled2.prototype.cst.SHAPE_SLIDER_DISABLED] = mxShapeGmdlSliderDisabled2;
  499. mxShapeGmdlSlider2.prototype.constraints = null;
  500. Graph.handleFactory[mxShapeGmdlSliderDisabled2.prototype.cst.SHAPE_SLIDER_DISABLED] = function(state)
  501. {
  502. var handles = [Graph.createHandle(state, ['hPos'], function(bounds)
  503. {
  504. var hPos = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'hPos', 0.4))));
  505. return new mxPoint(bounds.x + hPos * bounds.width / 100, bounds.y + bounds.height / 2);
  506. }, function(bounds, pt)
  507. {
  508. this.state.style['hPos'] = Math.round(100 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 100;
  509. })];
  510. return handles;
  511. };
  512. //**********************************************************************************************************************************************************
  513. //slider discrete
  514. //**********************************************************************************************************************************************************
  515. /**
  516. * Extends mxShape.
  517. */
  518. function mxShapeGmdlSliderDiscrete(bounds, fill, stroke, strokewidth)
  519. {
  520. mxShape.call(this);
  521. this.bounds = bounds;
  522. this.fill = fill;
  523. this.stroke = stroke;
  524. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  525. };
  526. /**
  527. * Extends mxShape.
  528. */
  529. mxUtils.extend(mxShapeGmdlSliderDiscrete, mxShape);
  530. mxShapeGmdlSliderDiscrete.prototype.cst = {
  531. SHAPE_DISCRETE : 'mxgraph.gmdl.sliderDiscrete',
  532. BAR_POS : 'barPos',
  533. HANDLE_SIZE : 'handleSize'
  534. };
  535. /**
  536. * Function: paintVertexShape
  537. *
  538. * Paints the vertex shape.
  539. */
  540. mxShapeGmdlSliderDiscrete.prototype.paintVertexShape = function(c, x, y, w, h)
  541. {
  542. c.translate(x, y);
  543. this.background(c, x, y, w, h);
  544. c.setShadow(true);
  545. };
  546. mxShapeGmdlSliderDiscrete.prototype.background = function(c, x, y, w, h)
  547. {
  548. var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDiscrete.prototype.cst.HANDLE_SIZE, '10'));
  549. var barPos = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDiscrete.prototype.cst.BAR_POS, '40')) / 100;
  550. var fontSize = parseFloat(mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '12'));
  551. var fontColor = mxUtils.getValue(this.style, mxConstants.STYLE_FONTCOLOR, '#000000');
  552. barPos = Math.max(0, Math.min(1, barPos));
  553. c.save();
  554. c.setStrokeColor('#bbbbbb');
  555. c.begin();
  556. c.moveTo(0, h * 0.5 + 22.5);
  557. c.lineTo(w, h * 0.5 + 22.5);
  558. c.fillAndStroke();
  559. c.restore();
  560. c.begin();
  561. c.moveTo(0, h * 0.5 + 22.5);
  562. c.lineTo(barPos * w, h * 0.5 + 22.5);
  563. c.fillAndStroke();
  564. c.begin();
  565. c.moveTo(barPos * w, h * 0.5 + 15.5);
  566. c.lineTo(barPos * w - 10.5, h * 0.5 + 2.5);
  567. c.arcTo(15, 15, 0, 0, 1, barPos * w, h * 0.5 - 22.5);
  568. c.arcTo(15, 15, 0, 0, 1, barPos * w + 10.5, h * 0.5 + 2.5);
  569. c.close();
  570. c.fillAndStroke();
  571. c.setFontSize(fontSize);
  572. c.setFontColor(fontColor);
  573. var p = Math.round(barPos * 100);
  574. c.text(barPos * w, h * 0.5 - 9, 0, 0, p.toString() , mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  575. };
  576. mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSliderDiscrete.prototype.cst.SHAPE_DISCRETE] = mxShapeGmdlSliderDiscrete;
  577. mxShapeGmdlSliderDiscrete.prototype.constraints = null;
  578. Graph.handleFactory[mxShapeGmdlSliderDiscrete.prototype.cst.SHAPE_DISCRETE] = function(state)
  579. {
  580. var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
  581. {
  582. var barPos = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'barPos', 0.4))));
  583. return new mxPoint(bounds.x + barPos * bounds.width / 100, bounds.y + bounds.height / 2 + 22.5);
  584. }, function(bounds, pt)
  585. {
  586. this.state.style['barPos'] = Math.round(100 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 100;
  587. })];
  588. return handles;
  589. };
  590. //**********************************************************************************************************************************************************
  591. //slider discrete with dots
  592. //**********************************************************************************************************************************************************
  593. /**
  594. * Extends mxShape.
  595. */
  596. function mxShapeGmdlSliderDiscreteDots(bounds, fill, stroke, strokewidth)
  597. {
  598. mxShape.call(this);
  599. this.bounds = bounds;
  600. this.fill = fill;
  601. this.stroke = stroke;
  602. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  603. };
  604. /**
  605. * Extends mxShape.
  606. */
  607. mxUtils.extend(mxShapeGmdlSliderDiscreteDots, mxShape);
  608. mxShapeGmdlSliderDiscreteDots.prototype.cst = {
  609. SHAPE_DISCRETE_DOTS : 'mxgraph.gmdl.sliderDiscreteDots',
  610. BAR_POS : 'barPos',
  611. HANDLE_SIZE : 'handleSize'
  612. };
  613. /**
  614. * Function: paintVertexShape
  615. *
  616. * Paints the vertex shape.
  617. */
  618. mxShapeGmdlSliderDiscreteDots.prototype.paintVertexShape = function(c, x, y, w, h)
  619. {
  620. c.translate(x, y);
  621. this.background(c, x, y, w, h);
  622. c.setShadow(true);
  623. };
  624. mxShapeGmdlSliderDiscreteDots.prototype.background = function(c, x, y, w, h)
  625. {
  626. var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDiscreteDots.prototype.cst.HANDLE_SIZE, '10'));
  627. var barPos = parseFloat(mxUtils.getValue(this.style, mxShapeGmdlSliderDiscreteDots.prototype.cst.BAR_POS, '40')) / 100;
  628. var fontSize = parseFloat(mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '12'));
  629. var fontColor = mxUtils.getValue(this.style, mxConstants.STYLE_FONTCOLOR, '#000000');
  630. var bright = mxUtils.getValue(this.style, 'bright', '1');
  631. barPos = Math.max(0, Math.min(1, barPos));
  632. c.save();
  633. c.setStrokeColor('#bebebe');
  634. c.begin();
  635. c.moveTo(0, h * 0.5 + 22.5);
  636. c.lineTo(w, h * 0.5 + 22.5);
  637. c.fillAndStroke();
  638. c.restore();
  639. if (barPos <= 0.1)
  640. {
  641. c.setFillColor('#bebebe');
  642. }
  643. c.begin();
  644. c.moveTo(0, h * 0.5 + 22.5);
  645. c.lineTo(barPos * w, h * 0.5 + 22.5);
  646. c.fillAndStroke();
  647. c.begin();
  648. c.moveTo(barPos * w, h * 0.5 + 15.5);
  649. c.lineTo(barPos * w - 10.5, h * 0.5 + 2.5);
  650. c.arcTo(15, 15, 0, 0, 1, barPos * w, h * 0.5 - 22.5);
  651. c.arcTo(15, 15, 0, 0, 1, barPos * w + 10.5, h * 0.5 + 2.5);
  652. c.close();
  653. c.fill();
  654. if (bright == '1')
  655. {
  656. c.setFillColor('#000000');
  657. }
  658. else
  659. {
  660. c.setFillColor('#ffffff');
  661. }
  662. c.ellipse(-1.5, h * 0.5 + 21, 3, 3);
  663. c.fill();
  664. c.ellipse(w * 0.2 - 1.5, h * 0.5 + 21, 3, 3);
  665. c.fill();
  666. c.ellipse(w * 0.4 - 1.5, h * 0.5 + 21, 3, 3);
  667. c.fill();
  668. c.ellipse(w * 0.6 - 1.5, h * 0.5 + 21, 3, 3);
  669. c.fill();
  670. c.ellipse(w * 0.8 - 1.5, h * 0.5 + 21, 3, 3);
  671. c.fill();
  672. c.ellipse(w - 1.5, h * 0.5 + 21, 3, 3);
  673. c.fill();
  674. c.setFontSize(fontSize);
  675. c.setFontColor(fontColor);
  676. var p = Math.round(barPos * 100);
  677. c.text(barPos * w, h * 0.5 - 9, 0, 0, p.toString() , mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  678. };
  679. mxCellRenderer.prototype.defaultShapes[mxShapeGmdlSliderDiscreteDots.prototype.cst.SHAPE_DISCRETE_DOTS] = mxShapeGmdlSliderDiscreteDots;
  680. mxShapeGmdlSliderDiscreteDots.prototype.constraints = null;
  681. Graph.handleFactory[mxShapeGmdlSliderDiscreteDots.prototype.cst.SHAPE_DISCRETE_DOTS] = function(state)
  682. {
  683. var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
  684. {
  685. var barPos = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'barPos', 0.4))));
  686. return new mxPoint(bounds.x + barPos * bounds.width / 100, bounds.y + bounds.height / 2 + 22.5);
  687. }, function(bounds, pt)
  688. {
  689. this.state.style['barPos'] = Math.round(0.05 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 0.05;
  690. })];
  691. return handles;
  692. };
  693. //**********************************************************************************************************************************************************
  694. //Progress Bar
  695. //**********************************************************************************************************************************************************
  696. /**
  697. * Extends mxShape.
  698. */
  699. function mxShapeGmdlProgressBar(bounds, fill, stroke, strokewidth)
  700. {
  701. mxShape.call(this);
  702. this.bounds = bounds;
  703. this.fill = fill;
  704. this.stroke = stroke;
  705. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  706. this.dx1 = 0.8;
  707. };
  708. /**
  709. * Extends mxShape.
  710. */
  711. mxUtils.extend(mxShapeGmdlProgressBar, mxShape);
  712. mxShapeGmdlProgressBar.prototype.cst = {
  713. PROGRESS_BAR : 'mxgraph.gmdl.progressBar'
  714. };
  715. /**
  716. * Function: paintVertexShape
  717. *
  718. * Paints the vertex shape.
  719. */
  720. mxShapeGmdlProgressBar.prototype.paintVertexShape = function(c, x, y, w, h)
  721. {
  722. var dx1 = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx1', this.dx1))));
  723. c.translate(x, y);
  724. c.save();
  725. c.setStrokeColor('#aaaaaa');
  726. c.begin();
  727. c.moveTo(0, h * 0.5);
  728. c.lineTo(w , h * 0.5);
  729. c.stroke();
  730. c.restore();
  731. c.setShadow(false);
  732. c.begin();
  733. c.moveTo(0, h * 0.5);
  734. c.lineTo(dx1, h * 0.5);
  735. c.stroke();
  736. // c.setStrokeColor('#000000');
  737. // c.setAlpha('0.2');
  738. // c.begin();
  739. // c.moveTo(0, h * 0.5);
  740. // c.lineTo(dx1, h * 0.5);
  741. // c.stroke();
  742. };
  743. mxCellRenderer.registerShape(mxShapeGmdlProgressBar.prototype.cst.PROGRESS_BAR, mxShapeGmdlProgressBar);
  744. mxShapeGmdlProgressBar.prototype.constraints = null;
  745. Graph.handleFactory[mxShapeGmdlProgressBar.prototype.cst.PROGRESS_BAR] = function(state)
  746. {
  747. var handles = [Graph.createHandle(state, ['dx1'], function(bounds)
  748. {
  749. var dx1 = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx1', this.dx1))));
  750. return new mxPoint(bounds.x + dx1 * bounds.width, bounds.y + bounds.height / 2);
  751. }, function(bounds, pt)
  752. {
  753. this.state.style['dx1'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  754. })];
  755. var handle2 = Graph.createHandle(state, ['dx2'], function(bounds)
  756. {
  757. var dx2 = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx2', this.dx1))));
  758. return new mxPoint(bounds.x + dx2 * bounds.width, bounds.y + bounds.height / 2);
  759. }, function(bounds, pt)
  760. {
  761. this.state.style['dx2'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  762. });
  763. handles.push(handle2);
  764. return handles;
  765. };