mxIOS7Ui.js 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741
  1. /**
  2. * Copyright (c) 2006-2013, JGraph Holdings Ltd
  3. */
  4. var mxIOS7C =
  5. {
  6. MAIN_TEXT : 'mainText',
  7. SUB_TEXT : 'subText',
  8. TEXT_COLOR : 'textColor',
  9. TEXT_SIZE : 'textSize',
  10. BAR_POS : 'barPos',
  11. BUTTON_TEXT : 'buttonText',
  12. BUTTON_STATE : 'buttonState',
  13. SELECTED : '+', //has to be one character long
  14. STATE_ON : 'on',
  15. STATE_OFF : 'off',
  16. GRID_SIZE : 'gridSize',
  17. SHAPE_IOS7_APP_BAR : 'mxgraph.ios7ui.appBar',
  18. SHAPE_IOS7_ON_OFF_BUTTON : 'mxgraph.ios7ui.onOffButton',
  19. SHAPE_IOS7_SLIDER : 'mxgraph.ios7ui.slider',
  20. SHAPE_IOS7_DOWNLOAD_BAR : 'mxgraph.ios7ui.downloadBar',
  21. SHAPE_IOS7_ICON : 'mxgraph.ios7ui.icon',
  22. SHAPE_IOS7_HOR_BUTTON_BAR : 'mxgraph.ios7ui.horButtonBar',
  23. SHAPE_IOS7_PAGE_CONTROL : 'mxgraph.ios7ui.pageControl',
  24. SHAPE_IOS7_EXPAND : 'mxgraph.ios7ui.expand',
  25. SHAPE_IOS7_ICON_GRID : 'mxgraph.ios7ui.iconGrid',
  26. SHAPE_IOS7_PHONE : 'mxgraph.ios7ui.phone',
  27. SHAPE_IOS7_SEARCH_BOX : 'mxgraph.ios7ui.searchBox',
  28. SHAPE_IOS7_URL : 'mxgraph.ios7ui.url',
  29. SHAPE_IOS7_ACTION_DIALOG : 'mxgraph.ios7ui.actionDialog',
  30. STYLE_FILLCOLOR2 : 'fillColor2',
  31. STYLE_FILLCOLOR3 : 'fillColor3',
  32. STYLE_TEXTCOLOR : 'textColor',
  33. STYLE_TEXTCOLOR2 : 'textColor2',
  34. STYLE_STROKECOLOR2 : 'strokeColor2',
  35. STYLE_STROKECOLOR3 : 'strokeColor3',
  36. STYLE_TEXTSIZE : 'textSize'
  37. };
  38. //**********************************************************************************************************************************************************
  39. //iOS7 Application Bar
  40. //**********************************************************************************************************************************************************
  41. /**
  42. * Extends mxShape.
  43. */
  44. function mxShapeIOS7AppBar(bounds, fill, stroke, strokewidth)
  45. {
  46. mxShape.call(this);
  47. this.bounds = bounds;
  48. this.fill = fill;
  49. this.stroke = stroke;
  50. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  51. };
  52. /**
  53. * Extends mxShape.
  54. */
  55. mxUtils.extend(mxShapeIOS7AppBar, mxShape);
  56. mxShapeIOS7AppBar.prototype.customProperties = [
  57. {name: 'fillColor2', dispName: 'Fill Color 2', type: 'color', primary: true}
  58. ];
  59. /**
  60. * Function: paintVertexShape
  61. *
  62. * Paints the vertex shape.
  63. */
  64. mxShapeIOS7AppBar.prototype.paintVertexShape = function(c, x, y, w, h)
  65. {
  66. c.translate(x, y);
  67. this.background(c, x, y, w, h);
  68. c.setShadow(false);
  69. this.foreground(c, x, y, w, h);
  70. };
  71. mxShapeIOS7AppBar.prototype.background = function(c, x, y, w, h)
  72. {
  73. c.rect(0, 0, w, h);
  74. c.fill();
  75. };
  76. mxShapeIOS7AppBar.prototype.foreground = function(c, x, y, w, h)
  77. {
  78. c.setFillColor(mxUtils.getValue(this.style, mxIOS7C.STYLE_FILLCOLOR2, '#222222'));
  79. c.ellipse(5, h * 0.5 - 1.5, 3, 3);
  80. c.fill();
  81. c.ellipse(9, h * 0.5 - 1.5, 3, 3);
  82. c.fill();
  83. c.ellipse(13, h * 0.5 - 1.5, 3, 3);
  84. c.fill();
  85. c.ellipse(17, h * 0.5 - 1.5, 3, 3);
  86. c.fill();
  87. c.ellipse(21, h * 0.5 - 1.5, 3, 3);
  88. c.fill();
  89. c.ellipse(54, h * 0.5 + 2, 2, 2);
  90. c.fillAndStroke();
  91. c.setStrokeWidth(2);
  92. c.begin();
  93. c.moveTo(52, h * 0.5 + 1);
  94. c.arcTo(3.5, 3.5, 0, 0, 1, 58, h * 0.5 + 1);
  95. c.stroke();
  96. c.begin();
  97. c.moveTo(50, h * 0.5 - 1);
  98. c.arcTo(6, 6, 0, 0, 1, 60, h * 0.5 - 1);
  99. c.stroke();
  100. c.begin();
  101. c.moveTo(w - 19, h * 0.5 - 2);
  102. c.lineTo(w - 6, h * 0.5 - 2);
  103. c.lineTo(w - 6, h * 0.5 + 2);
  104. c.lineTo(w - 19, h * 0.5 + 2);
  105. c.close();
  106. c.fill();
  107. c.setStrokeWidth(1);
  108. c.begin();
  109. c.moveTo(w - 44, h * 0.5 - 2.5);
  110. c.lineTo(w - 36, h * 0.5 + 2.5);
  111. c.lineTo(w - 40, h * 0.5 + 5);
  112. c.lineTo(w - 40, h * 0.5 - 5);
  113. c.lineTo(w - 36, h * 0.5 - 2.5);
  114. c.lineTo(w - 44, h * 0.5 + 2.5);
  115. c.stroke();
  116. c.begin();
  117. c.moveTo(w - 20, h * 0.5 - 3);
  118. c.lineTo(w - 5, h * 0.5 - 3);
  119. c.lineTo(w - 5, h * 0.5 - 1);
  120. c.lineTo(w - 3.5, h * 0.5 - 1);
  121. c.lineTo(w - 3.5, h * 0.5 + 1);
  122. c.lineTo(w - 5, h * 0.5 + 1);
  123. c.lineTo(w - 5, h * 0.5 + 3);
  124. c.lineTo(w - 20, h * 0.5 + 3);
  125. c.close();
  126. c.stroke();
  127. };
  128. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_APP_BAR, mxShapeIOS7AppBar);
  129. //**********************************************************************************************************************************************************
  130. //On-Off Button
  131. //**********************************************************************************************************************************************************
  132. /**
  133. * Extends mxShape.
  134. */
  135. function mxShapeIOS7OnOffButton(bounds, fill, stroke, strokewidth)
  136. {
  137. mxShape.call(this);
  138. this.bounds = bounds;
  139. this.fill = fill;
  140. this.stroke = stroke;
  141. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  142. };
  143. /**
  144. * Extends mxShape.
  145. */
  146. mxUtils.extend(mxShapeIOS7OnOffButton, mxShape);
  147. mxShapeIOS7OnOffButton.prototype.customProperties = [
  148. {name: 'buttonState', dispName: 'Button State', type: 'enum',
  149. enumList: [{val: 'on', dispName: 'On'},
  150. {val: 'off', dispName: 'Off'}]
  151. },
  152. {name: 'strokeColor2', dispName: 'Stroke Color 2', type: 'color', primary:true},
  153. {name: 'fillColor2', dispName: 'Fill Color 2', type: 'color', primary:true},
  154. {name: 'handleColor', dispName: 'Handle Color', defVal: '#ffffff', type: 'color', primary:true}
  155. ];
  156. /**
  157. * Function: paintVertexShape
  158. *
  159. * Paints the vertex shape.
  160. */
  161. mxShapeIOS7OnOffButton.prototype.paintVertexShape = function(c, x, y, w, h)
  162. {
  163. c.translate(x, y);
  164. w = Math.max(w, 2 * h);
  165. var state = mxUtils.getValue(this.style, mxIOS7C.BUTTON_STATE, mxIOS7C.STATE_ON);
  166. this.background(c, x, y, w, h, state);
  167. c.setShadow(false);
  168. this.foreground(c, x, y, w, h, state);
  169. };
  170. mxShapeIOS7OnOffButton.prototype.background = function(c, x, y, w, h, state)
  171. {
  172. if (state === mxIOS7C.STATE_ON)
  173. {
  174. c.roundrect(0, 0, w, h, h * 0.5, h * 0.5);
  175. c.fillAndStroke();
  176. }
  177. else if (state === mxIOS7C.STATE_OFF)
  178. {
  179. c.setStrokeColor(mxUtils.getValue(this.style, mxIOS7C.STYLE_STROKECOLOR2, '#aaaaaa'));
  180. c.setFillColor(mxUtils.getValue(this.style, mxIOS7C.STYLE_FILLCOLOR2, '#ffffff'));
  181. c.roundrect(0, 0, w, h, h * 0.5, h * 0.5);
  182. c.fillAndStroke();
  183. }
  184. };
  185. mxShapeIOS7OnOffButton.prototype.foreground = function(c, x, y, w, h, state)
  186. {
  187. c.setFillColor(mxUtils.getValue(this.style, 'handleColor', '#ffffff'));
  188. if (state === mxIOS7C.STATE_ON)
  189. {
  190. c.ellipse(w - h + 1, 1, h - 2, h - 2);
  191. c.fill();
  192. }
  193. else
  194. {
  195. c.ellipse(0, 0, h, h);
  196. c.stroke();
  197. }
  198. };
  199. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_ON_OFF_BUTTON, mxShapeIOS7OnOffButton);
  200. //**********************************************************************************************************************************************************
  201. //Slider
  202. //**********************************************************************************************************************************************************
  203. /**
  204. * Extends mxShape.
  205. */
  206. function mxShapeIOS7Slider(bounds, fill, stroke, strokewidth)
  207. {
  208. mxShape.call(this);
  209. this.bounds = bounds;
  210. this.fill = fill;
  211. this.stroke = stroke;
  212. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  213. this.barPos = 80;
  214. };
  215. /**
  216. * Extends mxShape.
  217. */
  218. mxUtils.extend(mxShapeIOS7Slider, mxShape);
  219. /**
  220. * Function: paintVertexShape
  221. *
  222. * Paints the vertex shape.
  223. */
  224. mxShapeIOS7Slider.prototype.paintVertexShape = function(c, x, y, w, h)
  225. {
  226. c.translate(x, y);
  227. c.setShadow(false);
  228. this.foreground(c, w, h);
  229. };
  230. mxShapeIOS7Slider.prototype.foreground = function(c, w, h)
  231. {
  232. c.setStrokeWidth(2);
  233. c.begin();
  234. c.moveTo(0, h * 0.5);
  235. c.lineTo(w, h * 0.5);
  236. c.stroke();
  237. var barPos = mxUtils.getValue(this.style, mxIOS7C.BAR_POS, '80');
  238. barPos = Math.min(barPos, 100);
  239. barPos = Math.max(barPos, 0);
  240. var deadzone = 0;
  241. var virRange = w - 2 * deadzone;
  242. var truePos = deadzone + virRange * barPos / 100;
  243. c.setStrokeColor(mxUtils.getValue(this.style, mxIOS7C.STYLE_STROKECOLOR2, '#a0a0a0'));
  244. c.ellipse(truePos - 5, h * 0.5 - 5, 10, 10);
  245. c.fillAndStroke();
  246. };
  247. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_SLIDER, mxShapeIOS7Slider);
  248. Graph.handleFactory[mxIOS7C.SHAPE_IOS7_SLIDER] = function(state)
  249. {
  250. var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
  251. {
  252. var barPos = Math.max(0, Math.min(100, parseFloat(mxUtils.getValue(this.state.style, 'barPos', this.barPos))));
  253. return new mxPoint(bounds.x + barPos / 100 * bounds.width, bounds.y + bounds.height / 2);
  254. }, function(bounds, pt)
  255. {
  256. this.state.style['barPos'] = Math.round(1000 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 1000;
  257. })];
  258. return handles;
  259. }
  260. //**********************************************************************************************************************************************************
  261. //Download Bar
  262. //**********************************************************************************************************************************************************
  263. /**
  264. * Extends mxShape.
  265. */
  266. function mxShapeIOS7DownloadBar(bounds, fill, stroke, strokewidth)
  267. {
  268. mxShape.call(this);
  269. this.bounds = bounds;
  270. this.fill = fill;
  271. this.stroke = stroke;
  272. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  273. this.barPos = 80;
  274. };
  275. /**
  276. * Extends mxShape.
  277. */
  278. mxUtils.extend(mxShapeIOS7DownloadBar, mxShape);
  279. mxShapeIOS7DownloadBar.prototype.customProperties = [
  280. {name: 'barPos', dispName: 'Handle Position', type: 'float', min:0, max:1, defVal:30},
  281. {name: 'strokeColor2', dispName: 'Stroke Color 2', type: 'color'}
  282. ];
  283. /**
  284. * Function: paintVertexShape
  285. *
  286. * Paints the vertex shape.
  287. */
  288. mxShapeIOS7DownloadBar.prototype.paintVertexShape = function(c, x, y, w, h)
  289. {
  290. c.translate(x, y);
  291. this.foreground(c, w, h);
  292. };
  293. mxShapeIOS7DownloadBar.prototype.foreground = function(c, w, h)
  294. {
  295. var fieldText = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, '');
  296. c.setFontStyle(mxConstants.FONT_BOLD);
  297. c.text(w * 0.5, h * 0.2, 0, 0, fieldText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  298. var barPos = mxUtils.getValue(this.style, mxIOS7C.BAR_POS, '80');
  299. barPos = Math.min(barPos, 100);
  300. barPos = Math.max(barPos, 0);
  301. var truePos = w * barPos / 100;
  302. c.setStrokeWidth(2);
  303. c.setStrokeColor(mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, ''));
  304. c.begin();
  305. c.moveTo(0, h * 0.5);
  306. c.lineTo(w, h * 0.5);
  307. c.stroke();
  308. c.setStrokeColor(mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, ''));
  309. c.begin();
  310. c.moveTo(0, h * 0.5);
  311. c.lineTo(truePos, h * 0.5);
  312. c.stroke();
  313. };
  314. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_DOWNLOAD_BAR, mxShapeIOS7DownloadBar);
  315. Graph.handleFactory[mxIOS7C.SHAPE_IOS7_DOWNLOAD_BAR] = function(state)
  316. {
  317. var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
  318. {
  319. var barPos = Math.max(0, Math.min(100, parseFloat(mxUtils.getValue(this.state.style, 'barPos', this.barPos))));
  320. return new mxPoint(bounds.x + barPos / 100 * bounds.width, bounds.y + bounds.height / 2);
  321. }, function(bounds, pt)
  322. {
  323. this.state.style['barPos'] = Math.round(1000 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 1000;
  324. })];
  325. return handles;
  326. }
  327. //**********************************************************************************************************************************************************
  328. //Icon
  329. //**********************************************************************************************************************************************************
  330. /**
  331. * Extends mxShape.
  332. */
  333. function mxShapeIOS7Icon(bounds, fill, stroke, strokewidth)
  334. {
  335. mxShape.call(this);
  336. this.bounds = bounds;
  337. this.fill = fill;
  338. this.stroke = stroke;
  339. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  340. };
  341. /**
  342. * Extends mxShape.
  343. */
  344. mxUtils.extend(mxShapeIOS7Icon, mxShape);
  345. mxShapeIOS7Icon.prototype.customProperties = [
  346. {name: 'fillColor2', dispName: 'Icon Top', defVal: '#00D0F0', type: 'color', primary:true},
  347. {name: 'fillColor3', dispName: 'Icon Bottom', defVal: '#0080F0', type: 'color', primary:true}
  348. ];
  349. /**
  350. * Function: paintVertexShape
  351. *
  352. * Paints the vertex shape.
  353. */
  354. mxShapeIOS7Icon.prototype.paintVertexShape = function(c, x, y, w, h)
  355. {
  356. c.translate(x, y);
  357. this.foreground(c, w, h);
  358. };
  359. mxShapeIOS7Icon.prototype.foreground = function(c, w, h)
  360. {
  361. c.setGradient(mxUtils.getValue(this.style, 'fillColor2', '#00D0F0'), mxUtils.getValue(this.style, 'fillColor3', '#0080F0'), w * 0.325, 0, w * 0.675, h * 0.5, mxConstants.DIRECTION_SOUTH, 1, 1);
  362. c.roundrect(0, 0, w, h, w * 0.1, h * 0.1);
  363. c.fill();
  364. var fieldText = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, '');
  365. c.setFontColor('#ffffff');
  366. c.setFontStyle(mxConstants.FONT_BOLD);
  367. c.setFontSize(8);
  368. c.text(w * 0.5, h * 0.5, 0, 0, fieldText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  369. };
  370. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_ICON, mxShapeIOS7Icon);
  371. //**********************************************************************************************************************************************************
  372. //Horizontal Button Bar
  373. //**********************************************************************************************************************************************************
  374. /**
  375. * Extends mxShape.
  376. */
  377. function mxShapeIOS7horButtonBar(bounds, fill, stroke, strokewidth)
  378. {
  379. mxShape.call(this);
  380. this.bounds = bounds;
  381. this.fill = fill;
  382. this.stroke = stroke;
  383. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  384. };
  385. /**
  386. * Extends mxShape.
  387. */
  388. mxUtils.extend(mxShapeIOS7horButtonBar, mxShape);
  389. mxShapeIOS7horButtonBar.prototype.customProperties = [
  390. {name: 'accentColor', dispName: 'Selected Button', defVal: '#0080F0', type: 'color', primary:true}
  391. ];
  392. /**
  393. * Function: paintVertexShape
  394. *
  395. * Paints the vertex shape.
  396. */
  397. mxShapeIOS7horButtonBar.prototype.paintVertexShape = function(c, x, y, w, h)
  398. {
  399. var textStrings = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, '+Button 1, Button 2, Button 3').toString().split(',');
  400. var fontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR, '#666666');
  401. var selectedFontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR2, '#ffffff');
  402. var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '8.5').toString();
  403. var frameColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#666666');
  404. var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  405. var selectedFillColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_FILLCOLOR2, '#008cff');
  406. var buttonNum = textStrings.length;
  407. var buttonWidths = new Array(buttonNum);
  408. var buttonTotalWidth = 0;
  409. var selectedButton = -1;
  410. var rSize = 2.5; //rounding size
  411. var labelOffset = 2.5;
  412. for (var i = 0; i < buttonNum; i++)
  413. {
  414. var buttonText = textStrings[i];
  415. if(buttonText.charAt(0) === mxIOS7C.SELECTED)
  416. {
  417. buttonText = textStrings[i].substring(1);
  418. selectedButton = i;
  419. }
  420. buttonWidths[i] = mxUtils.getSizeForString(buttonText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  421. buttonTotalWidth += buttonWidths[i];
  422. }
  423. var trueH = Math.max(h, fontSize * 1.5, 10);
  424. var minW = 2 * labelOffset * buttonNum + buttonTotalWidth;
  425. var trueW = Math.max(w, minW);
  426. c.translate(x, y);
  427. this.background(c, trueW, trueH, rSize, buttonNum, buttonWidths, labelOffset, minW, frameColor, bgColor, selectedFillColor, selectedButton);
  428. c.setShadow(false);
  429. var currWidth = 0;
  430. for (var i = 0; i < buttonNum; i++)
  431. {
  432. if (i === selectedButton)
  433. {
  434. c.setFontColor(selectedFontColor);
  435. }
  436. else
  437. {
  438. c.setFontColor(fontColor);
  439. }
  440. currWidth = currWidth + labelOffset;
  441. this.buttonText(c, currWidth, trueH, textStrings[i], buttonWidths[i], fontSize, minW, trueW);
  442. currWidth = currWidth + buttonWidths[i] + labelOffset;
  443. }
  444. };
  445. mxShapeIOS7horButtonBar.prototype.background = function(c, w, h, rSize, buttonNum, buttonWidths, labelOffset, minW, frameColor, bgColor, selectedFillColor, selectedButton)
  446. {
  447. c.begin();
  448. //draw the frame
  449. c.setStrokeColor(frameColor);
  450. c.setFillColor(bgColor);
  451. c.moveTo(0, rSize);
  452. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  453. c.lineTo(w - rSize, 0);
  454. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  455. c.lineTo(w, h - rSize);
  456. c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
  457. c.lineTo(rSize, h);
  458. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  459. c.close();
  460. c.fillAndStroke();
  461. //draw the button separators
  462. c.setStrokeColor(frameColor);
  463. c.begin();
  464. for (var i = 1; i < buttonNum; i++)
  465. {
  466. if (i !== selectedButton && i !== (selectedButton + 1))
  467. {
  468. var currWidth = 0;
  469. for (var j = 0; j < i; j++)
  470. {
  471. currWidth += buttonWidths[j] + 2 * labelOffset;
  472. }
  473. currWidth = currWidth * w / minW;
  474. c.moveTo(currWidth, 0);
  475. c.lineTo(currWidth, h);
  476. }
  477. }
  478. c.stroke();
  479. //draw the selected button
  480. var buttonLeft = 0;
  481. c.setStrokeColor(mxConstants.NONE);
  482. for (var i = 0; i < selectedButton; i++)
  483. {
  484. buttonLeft += buttonWidths[i] + 2 * labelOffset;
  485. }
  486. buttonLeft = buttonLeft * w / minW;
  487. var buttonRight = (buttonWidths[selectedButton] + 2 * labelOffset) * w / minW;
  488. buttonRight += buttonLeft;
  489. c.setFillColor(mxUtils.getValue(this.style, 'accentColor', '#0080F0'));
  490. if (selectedButton === 0)
  491. {
  492. c.begin();
  493. // we draw a path for the first button
  494. c.moveTo(0, rSize);
  495. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  496. c.lineTo(buttonRight, 0);
  497. c.lineTo(buttonRight, h);
  498. c.lineTo(rSize, h);
  499. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  500. c.close();
  501. c.fill();
  502. }
  503. else if (selectedButton === buttonNum - 1)
  504. {
  505. c.begin();
  506. // we draw a path for the last button
  507. c.moveTo(buttonLeft, 0);
  508. c.lineTo(buttonRight - rSize, 0);
  509. c.arcTo(rSize, rSize, 0, 0, 1, buttonRight, rSize);
  510. c.lineTo(buttonRight, h - rSize);
  511. c.arcTo(rSize, rSize, 0, 0, 1, buttonRight - rSize, h);
  512. c.lineTo(buttonLeft, h);
  513. c.close();
  514. c.fill();
  515. }
  516. else if (selectedButton !== -1)
  517. {
  518. c.begin();
  519. // we draw a path rectangle for one of the buttons in the middle
  520. c.moveTo(buttonLeft, 0);
  521. c.lineTo(buttonRight, 0);
  522. c.lineTo(buttonRight, h);
  523. c.lineTo(buttonLeft, h);
  524. c.close();
  525. c.fill();
  526. }
  527. //draw the frame again, to achieve a nicer effect
  528. c.setStrokeColor(frameColor);
  529. c.setFillColor(bgColor);
  530. c.begin();
  531. c.moveTo(0, rSize);
  532. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  533. c.lineTo(w - rSize, 0);
  534. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  535. c.lineTo(w, h - rSize);
  536. c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
  537. c.lineTo(rSize, h);
  538. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  539. c.close();
  540. c.stroke();
  541. };
  542. mxShapeIOS7horButtonBar.prototype.buttonText = function(c, w, h, textString, buttonWidth, fontSize, minW, trueW)
  543. {
  544. if(textString.charAt(0) === mxIOS7C.SELECTED)
  545. {
  546. textString = textString.substring(1);
  547. }
  548. c.begin();
  549. c.setFontSize(fontSize);
  550. c.text((w + buttonWidth * 0.5) * trueW / minW, h * 0.5, 0, 0, textString, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  551. };
  552. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_HOR_BUTTON_BAR, mxShapeIOS7horButtonBar);
  553. //**********************************************************************************************************************************************************
  554. //Page Control
  555. //**********************************************************************************************************************************************************
  556. /**
  557. * Extends mxShape.
  558. */
  559. function mxShapeIOS7pageControl(bounds, fill, stroke, strokewidth)
  560. {
  561. mxShape.call(this);
  562. this.bounds = bounds;
  563. this.fill = fill;
  564. this.stroke = stroke;
  565. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  566. };
  567. /**
  568. * Extends mxShape.
  569. */
  570. mxUtils.extend(mxShapeIOS7pageControl, mxShape);
  571. /**
  572. * Function: paintVertexShape
  573. *
  574. * Paints the vertex shape.
  575. */
  576. mxShapeIOS7pageControl.prototype.paintVertexShape = function(c, x, y, w, h)
  577. {
  578. c.translate(x, y);
  579. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#000000');
  580. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  581. var rSize = Math.min(h * 0.5, w * 0.05);
  582. c.setFillColor(strokeColor);
  583. c.ellipse(0, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
  584. c.fill();
  585. c.ellipse(w * 0.25 - rSize * 0.5, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
  586. c.fill();
  587. c.ellipse(w * 0.5 - rSize, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
  588. c.fill();
  589. c.ellipse(w * 0.75 - rSize * 1.5, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
  590. c.fill();
  591. c.setFillColor(fillColor);
  592. c.ellipse(w - 2 * rSize, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
  593. c.fill();
  594. };
  595. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_PAGE_CONTROL, mxShapeIOS7pageControl);
  596. //**********************************************************************************************************************************************************
  597. //Icon Grid
  598. //**********************************************************************************************************************************************************
  599. /**
  600. * Extends mxShape.
  601. */
  602. function mxShapeIOS7iconGrid(bounds, fill, stroke, strokewidth)
  603. {
  604. mxShape.call(this);
  605. this.bounds = bounds;
  606. this.fill = fill;
  607. this.stroke = stroke;
  608. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  609. };
  610. /**
  611. * Extends mxShape.
  612. */
  613. mxUtils.extend(mxShapeIOS7iconGrid, mxShape);
  614. mxShapeIOS7iconGrid.prototype.customProperties = [
  615. {name: 'gridSize', dispName: 'Grid Size', type: 'string'},
  616. ];
  617. /**
  618. * Function: paintVertexShape
  619. *
  620. * Paints the vertex shape.
  621. */
  622. mxShapeIOS7iconGrid.prototype.paintVertexShape = function(c, x, y, w, h)
  623. {
  624. c.translate(x, y);
  625. var gridSize = decodeURIComponent(mxUtils.getValue(this.style, mxIOS7C.GRID_SIZE, '4,7').toString()).split(',');
  626. var boxSizeX = w / (parseInt(gridSize[0],10) + (gridSize[0]-1) * 0.1);
  627. var boxSizeY = h / (parseInt(gridSize[1],10) + (gridSize[1]-1) * 0.1);
  628. for (var i = 0; i < gridSize[0]; i++)
  629. {
  630. for (var j = 0; j < gridSize[1]; j++)
  631. {
  632. c.rect(boxSizeX * 1.1 * i, boxSizeY * 1.1 * j, boxSizeX, boxSizeY);
  633. c.fill();
  634. }
  635. }
  636. };
  637. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_ICON_GRID, mxShapeIOS7iconGrid);
  638. //**********************************************************************************************************************************************************
  639. //iPhone Vertical
  640. //**********************************************************************************************************************************************************
  641. /**
  642. * Extends mxShape.
  643. */
  644. function mxShapeIOS7phone(bounds, fill, stroke, strokewidth)
  645. {
  646. mxShape.call(this);
  647. this.bounds = bounds;
  648. this.fill = fill;
  649. this.stroke = stroke;
  650. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  651. };
  652. /**
  653. * Extends mxShape.
  654. */
  655. mxUtils.extend(mxShapeIOS7phone, mxShape);
  656. /**
  657. * Function: paintVertexShape
  658. *
  659. * Paints the vertex shape.
  660. */
  661. mxShapeIOS7phone.prototype.paintVertexShape = function(c, x, y, w, h)
  662. {
  663. c.translate(x, y);
  664. var rSize = 25;
  665. c.roundrect(0, 0, w, h, rSize, rSize);
  666. c.fillAndStroke();
  667. c.setShadow(false);
  668. this.foreground(c, x, y, w, h, rSize);
  669. };
  670. mxShapeIOS7phone.prototype.foreground = function(c, x, y, w, h, rSize)
  671. {
  672. c.rect(w * 0.0625, h * 0.15, w * 0.875, h * 0.7);
  673. c.stroke();
  674. c.ellipse(w * 0.4875, h * 0.04125, w * 0.025, h * 0.0125);
  675. c.stroke();
  676. c.roundrect(w * 0.375, h * 0.075, w * 0.25, h * 0.01875, w * 0.02, h * 0.01);
  677. c.stroke();
  678. c.ellipse(w * 0.4, h * 0.875, w * 0.2, h * 0.1);
  679. c.stroke();
  680. c.roundrect(w * 0.4575, h * 0.905, w * 0.085, h * 0.04375, h * 0.00625, h * 0.00625);
  681. c.stroke();
  682. };
  683. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_PHONE, mxShapeIOS7phone);
  684. //**********************************************************************************************************************************************************
  685. //Search Box
  686. //**********************************************************************************************************************************************************
  687. /**
  688. * Extends mxShape.
  689. */
  690. function mxShapeIOS7searchBox(bounds, fill, stroke, strokewidth)
  691. {
  692. mxShape.call(this);
  693. this.bounds = bounds;
  694. this.fill = fill;
  695. this.stroke = stroke;
  696. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  697. };
  698. /**
  699. * Extends mxShape.
  700. */
  701. mxUtils.extend(mxShapeIOS7searchBox, mxShape);
  702. mxShapeIOS7searchBox.prototype.customProperties = [
  703. {name: 'fieldColor', dispName: 'Field Color', defVal: '#ffffff', type: 'color', primary:true}
  704. ];
  705. /**
  706. * Function: paintVertexShape
  707. *
  708. * Paints the vertex shape.
  709. */
  710. mxShapeIOS7searchBox.prototype.paintVertexShape = function(c, x, y, w, h)
  711. {
  712. c.translate(x, y);
  713. this.background(c, w, h);
  714. c.setShadow(false);
  715. this.foreground(c, w, h);
  716. };
  717. mxShapeIOS7searchBox.prototype.background = function(c, w, h)
  718. {
  719. c.rect(0, 0, w, h);
  720. c.fill();
  721. };
  722. mxShapeIOS7searchBox.prototype.foreground = function(c, w, h)
  723. {
  724. var mainText = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, 'Search');
  725. var fontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR, '#666666');
  726. var strokeColor2 = mxUtils.getValue(this.style, mxIOS7C.STYLE_STROKECOLOR2, '#008cff');
  727. var fontSize = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTSIZE, '17');
  728. var rSize = Math.min(w, h) * 0.1;
  729. c.setFillColor(mxUtils.getValue(this.style, 'fieldColor', '#ffffff'));
  730. c.roundrect(w * 0.05, h * 0.15, w * 0.5, h * 0.7, rSize, rSize);
  731. c.fillAndStroke();
  732. c.setFontColor(fontColor);
  733. c.setFontSize(Math.min(h * 0.7, w * 0.1));
  734. c.text(5, h * 0.5, 0, 0, mainText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  735. c.setStrokeColor(strokeColor2);
  736. c.ellipse(w * 0.05 + 3, h * 0.5 - 3, 4, 4);
  737. c.stroke();
  738. c.begin();
  739. c.moveTo(w * 0.05 + 8, h * 0.5 + 3.5);
  740. c.lineTo(w * 0.05 + 6, h * 0.5 + 0.5);
  741. c.stroke();
  742. };
  743. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_SEARCH_BOX, mxShapeIOS7searchBox);
  744. //**********************************************************************************************************************************************************
  745. //URL
  746. //**********************************************************************************************************************************************************
  747. /**
  748. * Extends mxShape.
  749. */
  750. function mxShapeIOS7URL(bounds, fill, stroke, strokewidth)
  751. {
  752. mxShape.call(this);
  753. this.bounds = bounds;
  754. this.fill = fill;
  755. this.stroke = stroke;
  756. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  757. };
  758. /**
  759. * Extends mxShape.
  760. */
  761. mxUtils.extend(mxShapeIOS7URL, mxShape);
  762. mxShapeIOS7URL.prototype.customProperties = [
  763. {name: 'fieldColor', dispName: 'Field Color', defVal: '#d8d8d8', type: 'color', primary:true}
  764. ];
  765. /**
  766. * Function: paintVertexShape
  767. *
  768. * Paints the vertex shape.
  769. */
  770. mxShapeIOS7URL.prototype.paintVertexShape = function(c, x, y, w, h)
  771. {
  772. c.translate(x, y);
  773. this.background(c, w, h);
  774. c.setShadow(false);
  775. this.foreground(c, w, h);
  776. };
  777. mxShapeIOS7URL.prototype.background = function(c, w, h)
  778. {
  779. c.rect(0, 0, w, h);
  780. c.fill();
  781. };
  782. mxShapeIOS7URL.prototype.foreground = function(c, w, h)
  783. {
  784. var mainText = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, 'draw.io');
  785. var fontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR, '#666666');
  786. var strokeColor2 = mxUtils.getValue(this.style, mxIOS7C.STYLE_STROKECOLOR2, '#008cff');
  787. var fontSize = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTSIZE, '17');
  788. var rSize = Math.min(w, h) * 0.1;
  789. c.setFillColor(mxUtils.getValue(this.style, 'fieldColor', '#d8d8d8'));
  790. c.roundrect(w * 0.05, h * 0.15, w * 0.9, h * 0.7, rSize, rSize);
  791. c.fill();
  792. c.setFontColor(fontColor);
  793. c.setFontSize(Math.min(h * 0.7, w * 0.1));
  794. c.text(w * 0.5, h * 0.5, 0, 0, mainText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  795. c.setStrokeColor(strokeColor2);
  796. c.begin();
  797. c.moveTo(w * 0.95 - 5, h * 0.5);
  798. c.arcTo(3, 3, 0, 1, 1, w * 0.95 - 8, h * 0.5 - 3);
  799. c.stroke();
  800. c.setFillColor(strokeColor2);
  801. c.begin();
  802. c.moveTo(w * 0.95 - 8, h * 0.5 - 4);
  803. c.lineTo(w * 0.95 - 6, h * 0.5 - 3);
  804. c.lineTo(w * 0.95 - 8, h * 0.5 - 2);
  805. c.close();
  806. c.fillAndStroke();
  807. };
  808. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_URL, mxShapeIOS7URL);
  809. //**********************************************************************************************************************************************************
  810. //Action Dialog
  811. //**********************************************************************************************************************************************************
  812. /**
  813. * Extends mxShape.
  814. */
  815. function mxShapeIOS7Actiondialog(bounds, fill, stroke, strokewidth)
  816. {
  817. mxShape.call(this);
  818. this.bounds = bounds;
  819. this.fill = fill;
  820. this.stroke = stroke;
  821. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  822. };
  823. /**
  824. * Extends mxShape.
  825. */
  826. mxUtils.extend(mxShapeIOS7Actiondialog, mxShape);
  827. mxShapeIOS7Actiondialog.prototype.customProperties = [
  828. {name: 'buttonColor', dispName: 'Button Color', defVal: '#e0e0e0', type: 'color', primary:true}
  829. ];
  830. /**
  831. * Function: paintVertexShape
  832. *
  833. * Paints the vertex shape.
  834. */
  835. mxShapeIOS7Actiondialog.prototype.paintVertexShape = function(c, x, y, w, h)
  836. {
  837. var mainText = mxUtils.getValue(this.style, mxIOS7C.MAIN_TEXT, 'Main Text');
  838. var subText = mxUtils.getValue(this.style, mxIOS7C.SUB_TEXT, 'Sub Text');
  839. var fontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR, '#666666');
  840. var fontSize = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTSIZE, '17');
  841. c.translate(x, y);
  842. this.background(c, x, y, w, h);
  843. c.setShadow(false);
  844. c.setFillColor(mxUtils.getValue(this.style, 'buttonColor', '#e0e0e0'));
  845. c.roundrect(w * 0.05, h * 0.1, w * 0.9, h * 0.35, w * 0.025, h * 0.05);
  846. c.fill();
  847. c.roundrect(w * 0.05, h * 0.55, w * 0.9, h * 0.35, w * 0.025, h * 0.05);
  848. c.fill();
  849. c.setFontStyle(mxConstants.FONT_BOLD);
  850. this.mainText(c, x, y, w, h, mainText, fontSize, fontColor);
  851. this.subText(c, x, y, w, h, subText, fontSize / 1.4, fontColor);
  852. };
  853. mxShapeIOS7Actiondialog.prototype.background = function(c, x, y, w, h)
  854. {
  855. c.rect(0, 0, w, h);
  856. c.fill();
  857. };
  858. mxShapeIOS7Actiondialog.prototype.mainText = function(c, x, y, w, h, text, fontSize, fontColor)
  859. {
  860. c.begin();
  861. c.setFontSize(fontSize);
  862. c.setFontColor(fontColor);
  863. c.text(w * 0.5, h * 0.4, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  864. };
  865. mxShapeIOS7Actiondialog.prototype.subText = function(c, x, y, w, h, text, fontSize, fontColor)
  866. {
  867. c.begin();
  868. c.setFontSize(fontSize);
  869. c.text(w * 0.5, h * 0.7, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  870. };
  871. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_ACTION_DIALOG, mxShapeIOS7Actiondialog);
  872. //**********************************************************************************************************************************************************
  873. //Anchor (a dummy shape without visuals used for anchoring)
  874. //**********************************************************************************************************************************************************
  875. /**
  876. * Extends mxShape.
  877. */
  878. function mxShapeIOS7Anchor(bounds, fill, stroke, strokewidth)
  879. {
  880. mxShape.call(this);
  881. this.bounds = bounds;
  882. };
  883. /**
  884. * Extends mxShape.
  885. */
  886. mxUtils.extend(mxShapeIOS7Anchor, mxShape);
  887. mxShapeIOS7Anchor.prototype.cst = {
  888. ANCHOR : 'mxgraph.ios7ui.anchor'
  889. };
  890. /**
  891. * Function: paintVertexShape
  892. *
  893. * Paints the vertex shape.
  894. */
  895. mxShapeIOS7Anchor.prototype.paintVertexShape = function(c, x, y, w, h)
  896. {
  897. };
  898. mxCellRenderer.registerShape(mxShapeIOS7Anchor.prototype.cst.ANCHOR, mxShapeIOS7Anchor);
  899. //**********************************************************************************************************************************************************
  900. //Rounded rectangle (adjustable rounding)
  901. //**********************************************************************************************************************************************************
  902. /**
  903. * Extends mxShape.
  904. */
  905. function mxShapeIOS7RRect(bounds, fill, stroke, strokewidth)
  906. {
  907. mxShape.call(this);
  908. this.bounds = bounds;
  909. this.fill = fill;
  910. this.stroke = stroke;
  911. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  912. };
  913. /**
  914. * Extends mxShape.
  915. */
  916. mxUtils.extend(mxShapeIOS7RRect, mxShape);
  917. mxShapeIOS7RRect.prototype.cst = {
  918. RRECT : 'mxgraph.ios7ui.rrect',
  919. R_SIZE : 'rSize'
  920. };
  921. mxShapeIOS7RRect.prototype.customProperties = [
  922. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:3}
  923. ];
  924. /**
  925. * Function: paintVertexShape
  926. *
  927. * Paints the vertex shape.
  928. */
  929. mxShapeIOS7RRect.prototype.paintVertexShape = function(c, x, y, w, h)
  930. {
  931. c.translate(x, y);
  932. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7RRect.prototype.cst.R_SIZE, '10'));
  933. c.roundrect(0, 0, w, h, rSize);
  934. c.fillAndStroke();
  935. };
  936. mxCellRenderer.registerShape(mxShapeIOS7RRect.prototype.cst.RRECT, mxShapeIOS7RRect);
  937. //**********************************************************************************************************************************************************
  938. //Left Button
  939. //**********************************************************************************************************************************************************
  940. /**
  941. * Extends mxShape.
  942. */
  943. function mxShapeIOS7LeftButton(bounds, fill, stroke, strokewidth)
  944. {
  945. mxShape.call(this);
  946. this.bounds = bounds;
  947. this.fill = fill;
  948. this.stroke = stroke;
  949. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  950. };
  951. /**
  952. * Extends mxShape.
  953. */
  954. mxUtils.extend(mxShapeIOS7LeftButton, mxShape);
  955. mxShapeIOS7LeftButton.prototype.cst = {
  956. LEFT_BUTTON : 'mxgraph.ios7ui.leftButton',
  957. R_SIZE : 'rSize'
  958. };
  959. mxShapeIOS7LeftButton.prototype.customProperties = [
  960. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:3}
  961. ];
  962. /**
  963. * Function: paintVertexShape
  964. *
  965. * Paints the vertex shape.
  966. */
  967. mxShapeIOS7LeftButton.prototype.paintVertexShape = function(c, x, y, w, h)
  968. {
  969. c.translate(x, y);
  970. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7LeftButton.prototype.cst.R_SIZE, '10'));
  971. c.begin();
  972. c.moveTo(w, 0);
  973. c.lineTo(w, h);
  974. c.lineTo(rSize, h);
  975. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  976. c.lineTo(0, rSize);
  977. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  978. c.close();
  979. c.fillAndStroke();
  980. };
  981. mxCellRenderer.registerShape(mxShapeIOS7LeftButton.prototype.cst.LEFT_BUTTON, mxShapeIOS7LeftButton);
  982. //**********************************************************************************************************************************************************
  983. //Right Button
  984. //**********************************************************************************************************************************************************
  985. /**
  986. * Extends mxShape.
  987. */
  988. function mxShapeIOS7RightButton(bounds, fill, stroke, strokewidth)
  989. {
  990. mxShape.call(this);
  991. this.bounds = bounds;
  992. this.fill = fill;
  993. this.stroke = stroke;
  994. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  995. };
  996. /**
  997. * Extends mxShape.
  998. */
  999. mxUtils.extend(mxShapeIOS7RightButton, mxShape);
  1000. mxShapeIOS7RightButton.prototype.cst = {
  1001. RIGHT_BUTTON : 'mxgraph.ios7ui.rightButton',
  1002. R_SIZE : 'rSize'
  1003. };
  1004. mxShapeIOS7RightButton.prototype.customProperties = [
  1005. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:3}
  1006. ];
  1007. /**
  1008. * Function: paintVertexShape
  1009. *
  1010. * Paints the vertex shape.
  1011. */
  1012. mxShapeIOS7RightButton.prototype.paintVertexShape = function(c, x, y, w, h)
  1013. {
  1014. c.translate(x, y);
  1015. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7RightButton.prototype.cst.R_SIZE, '10'));
  1016. c.begin();
  1017. c.moveTo(0, 0);
  1018. c.lineTo(w - rSize, 0);
  1019. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  1020. c.lineTo(w, h - rSize);
  1021. c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
  1022. c.lineTo(0, h);
  1023. c.close();
  1024. c.fillAndStroke();
  1025. };
  1026. mxCellRenderer.registerShape(mxShapeIOS7RightButton.prototype.cst.RIGHT_BUTTON, mxShapeIOS7RightButton);
  1027. //**********************************************************************************************************************************************************
  1028. //Top Button
  1029. //**********************************************************************************************************************************************************
  1030. /**
  1031. * Extends mxShape.
  1032. */
  1033. function mxShapeIOS7TopButton(bounds, fill, stroke, strokewidth)
  1034. {
  1035. mxShape.call(this);
  1036. this.bounds = bounds;
  1037. this.fill = fill;
  1038. this.stroke = stroke;
  1039. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1040. };
  1041. /**
  1042. * Extends mxShape.
  1043. */
  1044. mxUtils.extend(mxShapeIOS7TopButton, mxShape);
  1045. mxShapeIOS7TopButton.prototype.cst = {
  1046. TOP_BUTTON : 'mxgraph.ios7ui.topButton',
  1047. R_SIZE : 'rSize'
  1048. };
  1049. mxShapeIOS7TopButton.prototype.customProperties = [
  1050. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:3}
  1051. ];
  1052. /**
  1053. * Function: paintVertexShape
  1054. *
  1055. * Paints the vertex shape.
  1056. */
  1057. mxShapeIOS7TopButton.prototype.paintVertexShape = function(c, x, y, w, h)
  1058. {
  1059. c.translate(x, y);
  1060. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7TopButton.prototype.cst.R_SIZE, '10'));
  1061. c.begin();
  1062. c.moveTo(w, h);
  1063. c.lineTo(0, h);
  1064. c.lineTo(0, rSize);
  1065. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  1066. c.lineTo(w - rSize, 0);
  1067. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  1068. c.close();
  1069. c.fillAndStroke();
  1070. };
  1071. mxCellRenderer.registerShape(mxShapeIOS7TopButton.prototype.cst.TOP_BUTTON, mxShapeIOS7TopButton);
  1072. //**********************************************************************************************************************************************************
  1073. //Bottom Button
  1074. //**********************************************************************************************************************************************************
  1075. /**
  1076. * Extends mxShape.
  1077. */
  1078. function mxShapeIOS7BottomButton(bounds, fill, stroke, strokewidth)
  1079. {
  1080. mxShape.call(this);
  1081. this.bounds = bounds;
  1082. this.fill = fill;
  1083. this.stroke = stroke;
  1084. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1085. };
  1086. /**
  1087. * Extends mxShape.
  1088. */
  1089. mxUtils.extend(mxShapeIOS7BottomButton, mxShape);
  1090. mxShapeIOS7BottomButton.prototype.cst = {
  1091. BOTTOM_BUTTON : 'mxgraph.ios7ui.bottomButton',
  1092. R_SIZE : 'rSize'
  1093. };
  1094. mxShapeIOS7BottomButton.prototype.customProperties = [
  1095. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:3},
  1096. ];
  1097. /**
  1098. * Function: paintVertexShape
  1099. *
  1100. * Paints the vertex shape.
  1101. */
  1102. mxShapeIOS7BottomButton.prototype.paintVertexShape = function(c, x, y, w, h)
  1103. {
  1104. c.translate(x, y);
  1105. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7BottomButton.prototype.cst.R_SIZE, '10'));
  1106. c.begin();
  1107. c.moveTo(w, 0);
  1108. c.lineTo(0, 0);
  1109. c.lineTo(0, h - rSize);
  1110. c.arcTo(rSize, rSize, 0, 0, 0, rSize, h);
  1111. c.lineTo(w - rSize, h);
  1112. c.arcTo(rSize, rSize, 0, 0, 0, w, h - rSize);
  1113. c.close();
  1114. c.fillAndStroke();
  1115. };
  1116. mxCellRenderer.registerShape(mxShapeIOS7BottomButton.prototype.cst.BOTTOM_BUTTON, mxShapeIOS7BottomButton);
  1117. //**********************************************************************************************************************************************************
  1118. //Horizontal Lines
  1119. //**********************************************************************************************************************************************************
  1120. /**
  1121. * Extends mxShape.
  1122. */
  1123. function mxShapeIOS7HorLines(bounds, fill, stroke, strokewidth)
  1124. {
  1125. mxShape.call(this);
  1126. this.bounds = bounds;
  1127. this.fill = fill;
  1128. this.stroke = stroke;
  1129. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1130. };
  1131. /**
  1132. * Extends mxShape.
  1133. */
  1134. mxUtils.extend(mxShapeIOS7HorLines, mxShape);
  1135. mxShapeIOS7HorLines.prototype.cst = {
  1136. HOR_LINES : 'mxgraph.ios7ui.horLines'
  1137. };
  1138. /**
  1139. * Function: paintVertexShape
  1140. *
  1141. * Paints the vertex shape.
  1142. */
  1143. mxShapeIOS7HorLines.prototype.paintVertexShape = function(c, x, y, w, h)
  1144. {
  1145. c.translate(x, y);
  1146. c.rect(0, 0, w, h);
  1147. c.fill();
  1148. c.begin();
  1149. c.moveTo(0, 0);
  1150. c.lineTo(w, 0);
  1151. c.moveTo(0, h);
  1152. c.lineTo(w, h);
  1153. c.stroke();
  1154. };
  1155. mxCellRenderer.registerShape(mxShapeIOS7HorLines.prototype.cst.HOR_LINES, mxShapeIOS7HorLines);
  1156. //**********************************************************************************************************************************************************
  1157. //rect with margins
  1158. //**********************************************************************************************************************************************************
  1159. /**
  1160. * Extends mxShape.
  1161. */
  1162. function mxShapeIOS7MarginRect(bounds, fill, stroke, strokewidth)
  1163. {
  1164. mxShape.call(this);
  1165. this.bounds = bounds;
  1166. this.fill = fill;
  1167. this.stroke = stroke;
  1168. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1169. };
  1170. /**
  1171. * Extends mxShape.
  1172. */
  1173. mxUtils.extend(mxShapeIOS7MarginRect, mxShape);
  1174. mxShapeIOS7MarginRect.prototype.customProperties = [
  1175. {name: 'rx', dispName: 'Hor. Rounding Size', type: 'float', min:0, defVal:3},
  1176. {name: 'ry', dispName: 'Ver. Rounding Size', type: 'float', min:0, defVal:3},
  1177. {name: 'rectMargin', dispName: 'Global Margin', type: 'float', min:0, defVal:5},
  1178. {name: 'rectMarginTop', dispName: 'Top Margin', type: 'float', min:0, defVal:0},
  1179. {name: 'rectMarginLeft', dispName: 'Left Margin', type: 'float', min:0, defVal:0},
  1180. {name: 'rectMarginBottom', dispName: 'Bottom Margin', type: 'float', min:0, defVal:0},
  1181. {name: 'rectMarginRight', dispName: 'Right Margin', type: 'float', min:0, defVal:0}
  1182. ];
  1183. mxShapeIOS7MarginRect.prototype.cst = {
  1184. SHAPE_MARGIN_RECT : 'mxgraph.ios7ui.marginRect',
  1185. MARGIN : 'rectMargin',
  1186. RX : 'rx',
  1187. RY : 'ry',
  1188. MARGIN_TOP : 'rectMarginTop',
  1189. MARGIN_LEFT : 'rectMarginLeft',
  1190. MARGIN_BOTTOM : 'rectMarginBottom',
  1191. MARGIN_RIGHT : 'rectMarginRight'
  1192. };
  1193. /**
  1194. * Function: paintVertexShape
  1195. *
  1196. * Paints the vertex shape.
  1197. */
  1198. mxShapeIOS7MarginRect.prototype.paintVertexShape = function(c, x, y, w, h)
  1199. {
  1200. c.translate(x, y);
  1201. this.background(c, x, y, w, h);
  1202. };
  1203. mxShapeIOS7MarginRect.prototype.background = function(c, x, y, w, h, state)
  1204. {
  1205. var margin = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN, '0'));
  1206. var marginTop = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN_TOP, '0'));
  1207. var marginLeft = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN_LEFT, '0'));
  1208. var marginBottom = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN_BOTTOM, '0'));
  1209. var marginRight = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN_RIGHT, '0'));
  1210. var rx = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.RX, '0'));
  1211. var ry = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.RY, '0'));
  1212. var x1 = margin + marginLeft;
  1213. var y1 = margin + marginTop;
  1214. var w1 = w - marginRight - x1 - margin;
  1215. var h1 = h - marginBottom - y1 - margin;
  1216. if (w1 >0 && h1 > 0)
  1217. {
  1218. c.begin();
  1219. c.roundrect(x1, y1, w1, h1, rx, ry);
  1220. c.fillAndStroke();
  1221. }
  1222. };
  1223. mxCellRenderer.registerShape(mxShapeIOS7MarginRect.prototype.cst.SHAPE_MARGIN_RECT, mxShapeIOS7MarginRect);
  1224. //**********************************************************************************************************************************************************
  1225. //Callout
  1226. //**********************************************************************************************************************************************************
  1227. /**
  1228. * Extends mxShape.
  1229. */
  1230. function mxShapeIOS7Callout(bounds, fill, stroke, strokewidth)
  1231. {
  1232. mxShape.call(this);
  1233. this.bounds = bounds;
  1234. this.fill = fill;
  1235. this.stroke = stroke;
  1236. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1237. };
  1238. /**
  1239. * Extends mxShape.
  1240. */
  1241. mxUtils.extend(mxShapeIOS7Callout, mxShape);
  1242. mxShapeIOS7Callout.prototype.cst = {
  1243. SHAPE_CALLOUT : 'mxgraph.ios7ui.callout'
  1244. };
  1245. /**
  1246. * Function: paintVertexShape
  1247. *
  1248. * Paints the vertex shape.
  1249. */
  1250. mxShapeIOS7Callout.prototype.paintVertexShape = function(c, x, y, w, h)
  1251. {
  1252. c.translate(x, y);
  1253. this.background(c, x, y, w, h);
  1254. };
  1255. mxShapeIOS7Callout.prototype.background = function(c, x, y, w, h, state)
  1256. {
  1257. var r = 10;
  1258. if (w >= 30 && h >= 20)
  1259. {
  1260. c.begin();
  1261. c.moveTo(15, h - r * 0.3);
  1262. c.arcTo(r * 2, r, 0, 0, 1, 0, h);
  1263. c.arcTo(r * 1.5, r * 1.5, 0, 0, 0, 10, h - r * 1);
  1264. c.lineTo(r, r);
  1265. c.arcTo(r, r, 0, 0, 1, r * 2, 0);
  1266. c.lineTo(w - r, 0);
  1267. c.arcTo(r, r, 0, 0, 1, w, r);
  1268. c.lineTo(w, h - r);
  1269. c.arcTo(r, r, 0, 0, 1, w - r, h);
  1270. c.lineTo(r * 2, h);
  1271. c.arcTo(r, r, 0, 0, 1, r * 1.5, h - r * 0.3);
  1272. c.close();
  1273. c.fillAndStroke();
  1274. }
  1275. };
  1276. mxCellRenderer.registerShape(mxShapeIOS7Callout.prototype.cst.SHAPE_CALLOUT, mxShapeIOS7Callout);
  1277. //**********************************************************************************************************************************************************
  1278. //Select Bar
  1279. //**********************************************************************************************************************************************************
  1280. /**
  1281. * Extends mxShape.
  1282. */
  1283. function mxShapeIOS7SelectBar(bounds, fill, stroke, strokewidth)
  1284. {
  1285. mxShape.call(this);
  1286. this.bounds = bounds;
  1287. this.fill = fill;
  1288. this.stroke = stroke;
  1289. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1290. this.dy = 0.5;
  1291. this.dx = 0.5;
  1292. this.dx2 = 70;
  1293. this.size = 10;
  1294. };
  1295. /**
  1296. * Extends mxShape.
  1297. */
  1298. mxUtils.extend(mxShapeIOS7SelectBar, mxActor);
  1299. mxShapeIOS7SelectBar.prototype.cst = {
  1300. SELECT_BAR : 'mxgraph.ios7ui.selectBar'
  1301. };
  1302. mxShapeIOS7SelectBar.prototype.customProperties = [
  1303. {name: 'dx', dispName: 'Callout Position', type: 'float', min:0, defVal:120},
  1304. {name: 'dx2', dispName: 'Field Size', type: 'float', min:0, defVal: 75},
  1305. {name: 'size', dispName: 'Rounding size', type: 'float', min:0, defVal:5},
  1306. {name: 'dy', dispName: 'Callout Size', type: 'float', min:0, defVal:5}
  1307. ];
  1308. /**
  1309. * Function: paintVertexShape
  1310. *
  1311. * Paints the vertex shape.
  1312. */
  1313. mxShapeIOS7SelectBar.prototype.paintVertexShape = function(c, x, y, w, h)
  1314. {
  1315. c.translate(x, y);
  1316. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1317. var dx2 = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx2', this.dx2))));
  1318. var r = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1319. var dy = Math.max(0, Math.min(h, (w - Math.max(20, r) - r) / 2, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  1320. r = Math.min(h / 2, w / 2, r);
  1321. dx = Math.max(r + dy, dx);
  1322. dx = Math.min(w - r - dy, w - 20 - dy, dx);
  1323. c.begin();
  1324. c.moveTo(dx - dy, h);
  1325. c.lineTo(r, h);
  1326. c.arcTo(r, r, 0, 0, 1, 0, h - r);
  1327. c.lineTo(0, r);
  1328. c.arcTo(r, r, 0, 0, 1, r, 0);
  1329. c.lineTo(w - r, 0);
  1330. c.arcTo(r, r, 0, 0, 1, w, r);
  1331. c.lineTo(w, h - r);
  1332. c.arcTo(r, r, 0, 0, 1, w - r, h);
  1333. c.lineTo(dx + dy, h);
  1334. c.lineTo(dx, h + dy);
  1335. c.close();
  1336. c.fillAndStroke();
  1337. c.setShadow(false);
  1338. c.begin();
  1339. c.moveTo(w - Math.max(20, r), 0);
  1340. c.lineTo(w - Math.max(20, r), h);
  1341. c.stroke();
  1342. var currDx = dx2;
  1343. c.begin();
  1344. while (currDx < (w - Math.max(20, r)))
  1345. {
  1346. c.moveTo(currDx, 0);
  1347. c.lineTo(currDx, h);
  1348. currDx = currDx + dx2;
  1349. }
  1350. c.stroke();
  1351. var w1 = Math.min(Math.max(20, r), h);
  1352. var x1 = w - w1 * 0.5;
  1353. var y1 = h * 0.5;
  1354. c.setFillColor(mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, ''));
  1355. c.begin();
  1356. c.moveTo(x1 - w1 * 0.15, y1 - w1 * 0.225);
  1357. c.lineTo(x1 + w1 * 0.25, y1);
  1358. c.lineTo(x1 - w1 * 0.15, y1 + w1 * 0.225);
  1359. c.close();
  1360. c.fill();
  1361. };
  1362. mxCellRenderer.registerShape(mxShapeIOS7SelectBar.prototype.cst.SELECT_BAR, mxShapeIOS7SelectBar);
  1363. mxShapeIOS7SelectBar.prototype.constraints = null;
  1364. Graph.handleFactory[mxShapeIOS7SelectBar.prototype.cst.SELECT_BAR] = function(state)
  1365. {
  1366. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1367. {
  1368. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1369. return new mxPoint(bounds.x + dx, bounds.y + bounds.height);
  1370. }, function(bounds, pt)
  1371. {
  1372. var y = parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy)) * 0.6;
  1373. this.state.style['dx'] = Math.round(100 * Math.max(y, Math.min(bounds.width - y, pt.x - bounds.x))) / 100;
  1374. })];
  1375. var handle2 = Graph.createHandle(state, ['dy'], function(bounds)
  1376. {
  1377. var dy = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  1378. return new mxPoint(bounds.x + parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx)), bounds.y + bounds.height + dy);
  1379. }, function(bounds, pt)
  1380. {
  1381. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height, pt.y - bounds.y - bounds.height))) / 100;
  1382. });
  1383. handles.push(handle2);
  1384. var handle3 = Graph.createHandle(state, ['size'], function(bounds)
  1385. {
  1386. var size = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'size', this.size))));
  1387. return new mxPoint(bounds.x + bounds.width - size, bounds.y + 10);
  1388. }, function(bounds, pt)
  1389. {
  1390. this.state.style['size'] = Math.round(100 * Math.max(0, Math.min(bounds.width / 2, bounds.height / 2, bounds.x + bounds.width - pt.x))) / 100;
  1391. });
  1392. handles.push(handle3);
  1393. var handle4 = Graph.createHandle(state, ['dx2'], function(bounds)
  1394. {
  1395. var dx2 = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx2', this.dx2))));
  1396. return new mxPoint(bounds.x + dx2, bounds.y + bounds.height / 2);
  1397. }, function(bounds, pt)
  1398. {
  1399. this.state.style['dx2'] = Math.round(100 * Math.max(0, Math.min(bounds.width, pt.x - bounds.x))) / 100;
  1400. });
  1401. handles.push(handle4);
  1402. return handles;
  1403. }
  1404. //**********************************************************************************************************************************************************
  1405. //slider
  1406. //**********************************************************************************************************************************************************
  1407. /**
  1408. * Extends mxShape.
  1409. */
  1410. //mxShapeIOS7SelectBar
  1411. function mxShapeIOS7Slider2(bounds, fill, stroke, strokewidth)
  1412. {
  1413. mxShape.call(this);
  1414. this.bounds = bounds;
  1415. this.fill = fill;
  1416. this.stroke = stroke;
  1417. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1418. };
  1419. /**
  1420. * Extends mxShape.
  1421. */
  1422. mxUtils.extend(mxShapeIOS7Slider2, mxShape);
  1423. mxShapeIOS7Slider2.prototype.cst = {
  1424. SHAPE_SLIDER : 'mxgraph.ios7ui.slider',
  1425. BAR_POS : 'barPos',
  1426. HANDLE_SIZE : 'handleSize'
  1427. };
  1428. mxShapeIOS7Slider2.prototype.customProperties = [
  1429. {name: 'barPos', dispName: 'Handle Position', type: 'float', min:0, max:1, defVal:20},
  1430. {name: 'handleSize', dispName: 'Handle Size', type: 'float', min:0, defVal:10},
  1431. {name: 'barColor', dispName: 'Bar Color', defVal: '#bbbbbb', type: 'color', primary:true}
  1432. ];
  1433. /**
  1434. * Function: paintVertexShape
  1435. *
  1436. * Paints the vertex shape.
  1437. */
  1438. mxShapeIOS7Slider2.prototype.paintVertexShape = function(c, x, y, w, h)
  1439. {
  1440. c.translate(x, y);
  1441. this.background(c, x, y, w, h);
  1442. c.setShadow(true);
  1443. };
  1444. mxShapeIOS7Slider2.prototype.background = function(c, x, y, w, h)
  1445. {
  1446. var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7Slider2.prototype.cst.HANDLE_SIZE, '10'));
  1447. var barPos = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7Slider2.prototype.cst.BAR_POS, '40')) / 100;
  1448. barPos = Math.max(0, Math.min(1, barPos));
  1449. c.save();
  1450. c.setStrokeColor(mxUtils.getValue(this.style, 'barColor', '#bbbbbb'));
  1451. c.begin();
  1452. c.moveTo(0, h * 0.5);
  1453. c.lineTo(w, h * 0.5);
  1454. c.fillAndStroke();
  1455. c.restore();
  1456. c.begin();
  1457. c.moveTo(0, h * 0.5);
  1458. c.lineTo(barPos * w, h * 0.5);
  1459. c.fillAndStroke();
  1460. c.setStrokeColor(mxUtils.getValue(this.style, 'barColor', '#bbbbbb'));
  1461. c.begin();
  1462. c.ellipse(barPos * w - hSize * 0.5, h * 0.5 - hSize * 0.5, hSize, hSize);
  1463. c.fillAndStroke();
  1464. };
  1465. mxCellRenderer.registerShape(mxShapeIOS7Slider2.prototype.cst.SHAPE_SLIDER, mxShapeIOS7Slider2);
  1466. mxShapeIOS7Slider2.prototype.constraints = null;
  1467. Graph.handleFactory[mxShapeIOS7Slider2.prototype.cst.SHAPE_SLIDER] = function(state)
  1468. {
  1469. var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
  1470. {
  1471. var barPos = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'barPos', 0.4))));
  1472. return new mxPoint(bounds.x + barPos * bounds.width / 100, bounds.y + bounds.height / 2);
  1473. }, function(bounds, pt)
  1474. {
  1475. this.state.style['barPos'] = Math.round(100 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 100;
  1476. })];
  1477. return handles;
  1478. };