mxGmdl.js 27 KB

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