mxGmdl.js 29 KB

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