mxAndroid.js 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486
  1. /**
  2. * $Id: mxAndroid.js,v 1.5 2014/01/21 12:32:06 mate Exp $
  3. * Copyright (c) 2006-2013, JGraph Ltd
  4. */
  5. //**********************************************************************************************************************************************************
  6. //Horizontal Tab Bar (LEGACY)
  7. //**********************************************************************************************************************************************************
  8. /**
  9. * Extends mxShape.
  10. */
  11. function mxShapeAndroidTabBar(bounds, fill, stroke, strokewidth)
  12. {
  13. mxShape.call(this);
  14. this.bounds = bounds;
  15. this.fill = fill;
  16. this.stroke = stroke;
  17. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  18. };
  19. /**
  20. * Extends mxShape.
  21. */
  22. mxUtils.extend(mxShapeAndroidTabBar, mxShape);
  23. mxShapeAndroidTabBar.prototype.cst = {
  24. MAIN_TEXT : 'mainText',
  25. SHAPE_TAB_BAR : 'mxgraph.android.tabBar',
  26. TEXT_COLOR : 'textColor',
  27. TEXT_COLOR2 : 'textColor2',
  28. STROKE_COLOR2 : 'strokeColor2',
  29. FILL_COLOR2 : 'fillColor2',
  30. SELECTED : '+', //must be 1 char
  31. TEXT_SIZE : 'textSize'
  32. };
  33. /**
  34. * Function: paintVertexShape
  35. *
  36. * Paints the vertex shape.
  37. */
  38. mxShapeAndroidTabBar.prototype.paintVertexShape = function(c, x, y, w, h)
  39. {
  40. var textStrings = mxUtils.getValue(this.style, mxShapeAndroidTabBar.prototype.cst.MAIN_TEXT, '+Tab 1, Tab 2, Tab 3').toString().split(',');
  41. var fontColor = mxUtils.getValue(this.style, mxShapeAndroidTabBar.prototype.cst.TEXT_COLOR, 'none');
  42. var selectedFontColor = mxUtils.getValue(this.style, mxShapeAndroidTabBar.prototype.cst.TEXT_COLOR2, 'none');
  43. var fontSize = mxUtils.getValue(this.style, mxShapeAndroidTabBar.prototype.cst.TEXT_SIZE, '17').toString();
  44. var frameColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, 'none');
  45. var separatorColor = mxUtils.getValue(this.style, mxShapeAndroidTabBar.prototype.cst.STROKE_COLOR2, 'none');
  46. var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, 'none');
  47. var selectedFillColor = mxUtils.getValue(this.style, mxShapeAndroidTabBar.prototype.cst.FILL_COLOR2, 'none');
  48. var buttonNum = textStrings.length;
  49. var buttonWidths = new Array(buttonNum);
  50. var buttonTotalWidth = 0;
  51. var selectedButton = -1;
  52. var labelOffset = 5;
  53. for (var i = 0; i < buttonNum; i++)
  54. {
  55. var buttonText = textStrings[i];
  56. if(buttonText.charAt(0) === mxShapeAndroidTabBar.prototype.cst.SELECTED)
  57. {
  58. buttonText = textStrings[i].substring(1);
  59. selectedButton = i;
  60. }
  61. buttonWidths[i] = mxUtils.getSizeForString(buttonText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  62. buttonTotalWidth += buttonWidths[i];
  63. }
  64. var trueH = Math.max(h, fontSize * 1.5, 7);
  65. var minW = 2 * labelOffset * buttonNum + buttonTotalWidth;
  66. var trueW = Math.max(w, minW);
  67. c.translate(x, y);
  68. this.background(c, trueW, trueH, buttonNum, buttonWidths, labelOffset, minW, frameColor, separatorColor, bgColor, selectedFillColor, selectedButton);
  69. c.setShadow(false);
  70. c.setFontStyle(mxConstants.FONT_BOLD);
  71. var currWidth = 0;
  72. for (var i = 0; i < buttonNum; i++)
  73. {
  74. if (i === selectedButton)
  75. {
  76. c.setFontColor(selectedFontColor);
  77. }
  78. else
  79. {
  80. c.setFontColor(fontColor);
  81. }
  82. currWidth = currWidth + labelOffset;
  83. this.buttonText(c, currWidth, trueH, textStrings[i], buttonWidths[i], fontSize, minW, trueW);
  84. currWidth = currWidth + buttonWidths[i] + labelOffset;
  85. }
  86. };
  87. mxShapeAndroidTabBar.prototype.background = function(c, w, h, buttonNum, buttonWidths, labelOffset, minW, frameColor, separatorColor, bgColor, selectedFillColor, selectedButton)
  88. {
  89. c.begin();
  90. //draw the frame
  91. c.setStrokeColor(frameColor);
  92. c.setFillColor(bgColor);
  93. c.rect(0, 0, w, h);
  94. c.fillAndStroke();
  95. //draw the button separators
  96. c.setStrokeColor(separatorColor);
  97. c.begin();
  98. for (var i = 1; i < buttonNum; i++)
  99. {
  100. if (i !== selectedButton && i !== (selectedButton + 1))
  101. {
  102. var currWidth = 0;
  103. for (var j = 0; j < i; j++)
  104. {
  105. currWidth += buttonWidths[j] + 2 * labelOffset;
  106. }
  107. currWidth = currWidth * w / minW;
  108. c.moveTo(currWidth, h * 0.2);
  109. c.lineTo(currWidth, h * 0.8);
  110. }
  111. }
  112. c.stroke();
  113. //draw the selected button
  114. var buttonLeft = 0;
  115. c.setFillColor(selectedFillColor);
  116. for (var i = 0; i < selectedButton; i++)
  117. {
  118. buttonLeft += buttonWidths[i] + 2 * labelOffset;
  119. }
  120. buttonLeft = buttonLeft * w / minW;
  121. var buttonRight = (buttonWidths[selectedButton] + 2 * labelOffset) * w / minW;
  122. buttonRight += buttonLeft;
  123. c.rect(buttonLeft, 0, buttonRight - buttonLeft, h);
  124. c.fill();
  125. c.setAlpha(1);
  126. c.setFillColor('#33b5e5');
  127. c.rect(buttonLeft, h * 0.9, buttonRight - buttonLeft, h * 0.1);
  128. c.fill();
  129. };
  130. mxShapeAndroidTabBar.prototype.buttonText = function(c, w, h, textString, buttonWidth, fontSize, minW, trueW)
  131. {
  132. if(textString.charAt(0) === mxShapeAndroidTabBar.prototype.cst.SELECTED)
  133. {
  134. textString = textString.substring(1);
  135. }
  136. c.begin();
  137. c.setFontSize(fontSize);
  138. 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);
  139. };
  140. mxCellRenderer.prototype.defaultShapes[mxShapeAndroidTabBar.prototype.cst.SHAPE_TAB_BAR] = mxShapeAndroidTabBar;
  141. //**********************************************************************************************************************************************************
  142. //Android Phone Vertical
  143. //**********************************************************************************************************************************************************
  144. /**
  145. * Extends mxShape.
  146. */
  147. function mxShapeAndroidPhone(bounds, fill, stroke, strokewidth)
  148. {
  149. mxShape.call(this);
  150. this.bounds = bounds;
  151. this.fill = fill;
  152. this.stroke = stroke;
  153. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  154. };
  155. /**
  156. * Extends mxShape.
  157. */
  158. mxUtils.extend(mxShapeAndroidPhone, mxShape);
  159. /**
  160. * Function: paintVertexShape
  161. *
  162. * Paints the vertex shape.
  163. */
  164. mxShapeAndroidPhone.prototype.paintVertexShape = function(c, x, y, w, h)
  165. {
  166. c.translate(x, y);
  167. var rSize = 25;
  168. c.roundrect(0, 0, w, h, rSize, rSize);
  169. c.fillAndStroke();
  170. c.setShadow(false);
  171. this.foreground(c, x, y, w, h, rSize);
  172. };
  173. mxShapeAndroidPhone.prototype.foreground = function(c, x, y, w, h, rSize)
  174. {
  175. c.rect(w * 0.0625, h * 0.15, w * 0.875, h * 0.7);
  176. c.stroke();
  177. c.ellipse(w * 0.4875, h * 0.04125, w * 0.025, h * 0.0125);
  178. c.stroke();
  179. c.roundrect(w * 0.375, h * 0.075, w * 0.25, h * 0.01875, w * 0.02, h * 0.01);
  180. c.stroke();
  181. c.ellipse(w * 0.4, h * 0.875, w * 0.2, h * 0.1);
  182. c.stroke();
  183. c.roundrect(w * 0.4575, h * 0.905, w * 0.085, h * 0.04375, h * 0.00625, h * 0.00625);
  184. c.stroke();
  185. };
  186. mxCellRenderer.prototype.defaultShapes['mxgraph.android.phone'] = mxShapeAndroidPhone;
  187. //**********************************************************************************************************************************************************
  188. //Android Status Bar
  189. //**********************************************************************************************************************************************************
  190. /**
  191. * Extends mxShape.
  192. */
  193. function mxShapeAndroidStatusBar(bounds, fill, stroke, strokewidth)
  194. {
  195. mxShape.call(this);
  196. this.bounds = bounds;
  197. this.fill = fill;
  198. this.stroke = stroke;
  199. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  200. };
  201. /**
  202. * Extends mxShape.
  203. */
  204. mxUtils.extend(mxShapeAndroidStatusBar, mxShape);
  205. /**
  206. * Function: paintVertexShape
  207. *
  208. * Paints the vertex shape.
  209. */
  210. mxShapeAndroidStatusBar.prototype.paintVertexShape = function(c, x, y, w, h)
  211. {
  212. c.translate(x, y);
  213. this.background(c, x, y, w, h);
  214. c.setShadow(false);
  215. this.foreground(c, x, y, w, h);
  216. };
  217. mxShapeAndroidStatusBar.prototype.background = function(c, x, y, w, h)
  218. {
  219. c.rect(0, 0, w, h);
  220. c.fill();
  221. };
  222. mxShapeAndroidStatusBar.prototype.foreground = function(c, x, y, w, h)
  223. {
  224. c.rect(0, 0, w, h);
  225. c.fill();
  226. c.setFontColor(mxUtils.getValue(this.style, mxConstants.STYLE_FONTCOLOR, '#222222'));
  227. c.setFontSize(mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '5'));
  228. c.text(w - 30, h * 0.5 + 1, 0, 0, '12:00', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  229. c.setFillColor('#444444');
  230. c.begin();
  231. c.moveTo(w - 37, h * 0.5 + 6);
  232. c.lineTo(w - 37, h * 0.5 - 5);
  233. c.lineTo(w - 36, h * 0.5 - 5);
  234. c.lineTo(w - 36, h * 0.5 - 6);
  235. c.lineTo(w - 32, h * 0.5 - 6);
  236. c.lineTo(w - 32, h * 0.5 - 5);
  237. c.lineTo(w - 31, h * 0.5 - 5);
  238. c.lineTo(w - 31, h * 0.5 + 6);
  239. c.close();
  240. c.fill();
  241. c.setFillColor(mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, 'none'));
  242. c.ellipse(w - 56, h * 0.5 + 2, 2, 2);
  243. c.fillAndStroke();
  244. c.setStrokeWidth(2);
  245. c.begin();
  246. c.moveTo(w - 52, h * 0.5 + 1);
  247. c.arcTo(3.5, 3.5, 0, 0, 0, w - 58, h * 0.5 + 1);
  248. c.stroke();
  249. c.begin();
  250. c.moveTo(w - 50, h * 0.5 - 1);
  251. c.arcTo(6, 6, 0, 0, 0, w - 60, h * 0.5 - 1);
  252. c.stroke();
  253. c.setStrokeWidth(1);
  254. c.rect(w - 51, h * 0.5 + 5, 2, 1);
  255. c.fill();
  256. c.rect(w - 48, h * 0.5 + 2, 2, 4);
  257. c.fill();
  258. c.rect(w - 45, h * 0.5 - 1, 2, 7);
  259. c.fill();
  260. c.rect(w - 42, h * 0.5 - 4, 2, 10);
  261. c.fill();
  262. c.rect(w - 37, h * 0.5 - 2, 6, 8);
  263. c.fill();
  264. };
  265. mxCellRenderer.prototype.defaultShapes['mxgraph.android.statusBar'] = mxShapeAndroidStatusBar;
  266. //**********************************************************************************************************************************************************
  267. //Checkbox Button Group
  268. //**********************************************************************************************************************************************************
  269. /**
  270. * Extends mxShape.
  271. */
  272. function mxShapeAndroidCheckboxGroup(bounds, fill, stroke, strokewidth)
  273. {
  274. mxShape.call(this);
  275. this.bounds = bounds;
  276. this.fill = fill;
  277. this.stroke = stroke;
  278. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  279. };
  280. /**
  281. * Extends mxShape.
  282. */
  283. mxUtils.extend(mxShapeAndroidCheckboxGroup, mxShape);
  284. mxShapeAndroidCheckboxGroup.prototype.cst = {
  285. STYLE_TEXTCOLOR2 : 'textColor2',
  286. STYLE_STROKECOLOR2 : 'strokeColor2',
  287. BUTTON_TEXT : 'buttonText',
  288. SELECTED : '+' //has to be one character long
  289. };
  290. /**
  291. * Function: paintVertexShape
  292. *
  293. * Paints the vertex shape.
  294. */
  295. mxShapeAndroidCheckboxGroup.prototype.paintVertexShape = function(c, x, y, w, h)
  296. {
  297. c.translate(x, y);
  298. var fontColor = mxUtils.getValue(this.style, mxConstants.STYLE_TEXTCOLOR, '#666666');
  299. var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '8').toString();
  300. var optionText = mxUtils.getValue(this.style, mxShapeAndroidCheckboxGroup.prototype.cst.BUTTON_TEXT, 'Option 1').toString().split(',');
  301. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, 'none');
  302. var strokeColor2 = mxUtils.getValue(this.style, mxShapeAndroidCheckboxGroup.prototype.cst.STYLE_STROKECOLOR2, 'none');
  303. c.setStrokeColor(strokeColor2);
  304. var optionNum = optionText.length;
  305. var buttonSize = 5;
  306. var lineH = Math.max(fontSize * 1.5, buttonSize);
  307. var maxTextWidth = 0;
  308. var selected = -1;
  309. var labelOffset = 2.5;
  310. var minH = optionNum * lineH;
  311. var trueH = Math.max(h, minH);
  312. //get min width and selected option
  313. for (var i = 0; i < optionNum; i++)
  314. {
  315. var currText = optionText[i];
  316. if(currText.charAt(0) === mxShapeAndroidCheckboxGroup.prototype.cst.SELECTED)
  317. {
  318. currText = optionText[i].substring(1);
  319. selected = i;
  320. }
  321. var currWidth = mxUtils.getSizeForString(currText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  322. if (currWidth > maxTextWidth)
  323. {
  324. maxTextWidth = currWidth;
  325. }
  326. }
  327. var minW = 2 * labelOffset + maxTextWidth + 2 * buttonSize;
  328. var trueW = Math.max(w, minW);
  329. //draw the background
  330. c.roundrect(0, 0, trueW, trueH, 2.5, 2.5);
  331. c.fillAndStroke();
  332. c.setShadow(false);
  333. c.setFontSize(fontSize);
  334. c.setFontColor(fontColor);
  335. c.setStrokeColor(strokeColor);
  336. for (var i = 0; i < optionNum; i++)
  337. {
  338. var currHeight = (i * lineH + lineH * 0.5) * trueH / minH;
  339. var currText = optionText[i];
  340. if(currText.charAt(0) === mxShapeAndroidCheckboxGroup.prototype.cst.SELECTED)
  341. {
  342. currText = optionText[i].substring(1);
  343. selected = i;
  344. }
  345. c.text(buttonSize * 2 + labelOffset, currHeight, 0, 0, currText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  346. var iconX = buttonSize * 0.5;
  347. var iconY = currHeight - buttonSize * 0.5;
  348. if (selected === i)
  349. {
  350. c.rect(iconX, iconY, buttonSize, buttonSize);
  351. c.fillAndStroke();
  352. c.begin();
  353. c.moveTo(iconX + buttonSize * 0.25, iconY + buttonSize * 0.5);
  354. c.lineTo(iconX + buttonSize * 0.5, iconY + buttonSize * 0.75);
  355. c.lineTo(iconX + buttonSize * 0.75, iconY + buttonSize * 0.25);
  356. c.stroke();
  357. }
  358. else
  359. {
  360. c.rect(iconX, iconY, buttonSize, buttonSize);
  361. c.fillAndStroke();
  362. }
  363. selected = -1;
  364. }
  365. };
  366. mxCellRenderer.prototype.defaultShapes['mxgraph.android.checkboxGroup'] = mxShapeAndroidCheckboxGroup;
  367. //**********************************************************************************************************************************************************
  368. //Radio Button Group
  369. //**********************************************************************************************************************************************************
  370. /**
  371. * Extends mxShape.
  372. */
  373. function mxShapeAndroidRadioGroup(bounds, fill, stroke, strokewidth)
  374. {
  375. mxShape.call(this);
  376. this.bounds = bounds;
  377. this.fill = fill;
  378. this.stroke = stroke;
  379. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  380. };
  381. /**
  382. * Extends mxShape.
  383. */
  384. mxUtils.extend(mxShapeAndroidRadioGroup, mxShape);
  385. mxShapeAndroidRadioGroup.prototype.cst = {
  386. STYLE_TEXTCOLOR2 : 'textColor2',
  387. STYLE_STROKECOLOR2 : 'strokeColor2',
  388. BUTTON_TEXT : 'buttonText',
  389. SELECTED : '+' //has to be one character long
  390. };
  391. /**
  392. * Function: paintVertexShape
  393. *
  394. * Paints the vertex shape.
  395. */
  396. mxShapeAndroidRadioGroup.prototype.paintVertexShape = function(c, x, y, w, h)
  397. {
  398. c.translate(x, y);
  399. var fontColor = mxUtils.getValue(this.style, mxConstants.STYLE_TEXTCOLOR, '#666666');
  400. var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '8').toString();
  401. var optionText = mxUtils.getValue(this.style, mxShapeAndroidRadioGroup.prototype.cst.BUTTON_TEXT, 'Option 1').toString().split(',');
  402. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, 'none');
  403. var strokeColor2 = mxUtils.getValue(this.style, mxShapeAndroidRadioGroup.prototype.cst.STYLE_STROKECOLOR2, 'none');
  404. c.setStrokeColor(strokeColor2);
  405. var optionNum = optionText.length;
  406. var buttonSize = 5;
  407. var lineH = Math.max(fontSize * 1.5, buttonSize);
  408. var maxTextWidth = 0;
  409. var selected = -1;
  410. var labelOffset = 2.5;
  411. var minH = optionNum * lineH;
  412. var trueH = Math.max(h, minH);
  413. //get min width and selected option
  414. for (var i = 0; i < optionNum; i++)
  415. {
  416. var currText = optionText[i];
  417. if(currText.charAt(0) === mxShapeAndroidRadioGroup.prototype.cst.SELECTED)
  418. {
  419. currText = optionText[i].substring(1);
  420. selected = i;
  421. }
  422. var currWidth = mxUtils.getSizeForString(currText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  423. if (currWidth > maxTextWidth)
  424. {
  425. maxTextWidth = currWidth;
  426. }
  427. }
  428. var minW = 2 * labelOffset + maxTextWidth + 2 * buttonSize;
  429. var trueW = Math.max(w, minW);
  430. //draw the background
  431. c.roundrect(0, 0, trueW, trueH, 2.5, 2.5);
  432. c.fillAndStroke();
  433. c.setShadow(false);
  434. c.setFontSize(fontSize);
  435. c.setFontColor(fontColor);
  436. c.setStrokeColor(strokeColor);
  437. c.setFillColor(strokeColor);
  438. for (var i = 0; i < optionNum; i++)
  439. {
  440. var currHeight = (i * lineH + lineH * 0.5) * trueH / minH;
  441. var currText = optionText[i];
  442. if(currText.charAt(0) === mxShapeAndroidRadioGroup.prototype.cst.SELECTED)
  443. {
  444. currText = optionText[i].substring(1);
  445. selected = i;
  446. }
  447. c.text(buttonSize * 2 + labelOffset, currHeight, 0, 0, currText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  448. var iconX = buttonSize * 0.5;
  449. var iconY = currHeight - buttonSize * 0.5;
  450. if (selected === i)
  451. {
  452. c.ellipse(iconX, iconY, buttonSize, buttonSize);
  453. c.stroke();
  454. c.ellipse(iconX + buttonSize * 0.25, iconY + buttonSize * 0.25, buttonSize * 0.5, buttonSize * 0.5);
  455. c.fillAndStroke();
  456. }
  457. else
  458. {
  459. c.ellipse(iconX, iconY, buttonSize, buttonSize);
  460. c.stroke();
  461. }
  462. }
  463. };
  464. mxCellRenderer.prototype.defaultShapes['mxgraph.android.radioGroup'] = mxShapeAndroidRadioGroup;
  465. //**********************************************************************************************************************************************************
  466. //Menu Bar (LEGACY)
  467. //**********************************************************************************************************************************************************
  468. /**
  469. * Extends mxShape.
  470. */
  471. function mxShapeAndroidMenuBar(bounds, fill, stroke, strokewidth)
  472. {
  473. mxShape.call(this);
  474. this.bounds = bounds;
  475. this.fill = fill;
  476. this.stroke = stroke;
  477. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  478. };
  479. /**
  480. * Extends mxShape.
  481. */
  482. mxUtils.extend(mxShapeAndroidMenuBar, mxShape);
  483. mxShapeAndroidMenuBar.prototype.cst = {
  484. MENU_TEXT : 'menuText'
  485. };
  486. /**
  487. * Function: paintVertexShape
  488. *
  489. * Paints the vertex shape.
  490. */
  491. mxShapeAndroidMenuBar.prototype.paintVertexShape = function(c, x, y, w, h)
  492. {
  493. var textStrings = mxUtils.getValue(this.style, mxShapeAndroidMenuBar.prototype.cst.MENU_TEXT, 'Item 1, Item 2, Item 3').toString().split(',');
  494. var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '12');
  495. var buttonNum = textStrings.length;
  496. var maxButtonWidth = 0;
  497. var labelOffset = 2.5;
  498. for (var i = 0; i < buttonNum; i++)
  499. {
  500. var buttonText = textStrings[i];
  501. var currWidth = mxUtils.getSizeForString(buttonText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  502. if (currWidth > maxButtonWidth)
  503. {
  504. maxButtonWidth = currWidth;
  505. }
  506. }
  507. var minButtonHeight = fontSize * 1.5;
  508. var minH = buttonNum * minButtonHeight;
  509. var trueH = Math.max(h, minH);
  510. var minW = 2 * labelOffset + maxButtonWidth;
  511. var trueW = Math.max(w, minW);
  512. c.translate(x, y);
  513. c.rect(0, 0, w, trueH);
  514. c.fillAndStroke();
  515. c.setShadow(false);
  516. //draw the button separators
  517. c.begin();
  518. for (var i = 1; i < buttonNum; i++)
  519. {
  520. var currHeight = i * minButtonHeight * trueH / minH;
  521. c.moveTo(0, currHeight);
  522. c.lineTo(w, currHeight);
  523. }
  524. c.stroke();
  525. for (var i = 0; i < buttonNum; i++)
  526. {
  527. currWidth = currWidth + labelOffset;
  528. var currHeight = (i * minButtonHeight + minButtonHeight * 0.5) * trueH / minH;
  529. c.text(10, currHeight, 0, 0, textStrings[i], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  530. }
  531. };
  532. mxCellRenderer.prototype.defaultShapes['mxgraph.android.menuBar'] = mxShapeAndroidMenuBar;
  533. //**********************************************************************************************************************************************************
  534. //Text Selection Handles
  535. //**********************************************************************************************************************************************************
  536. /**
  537. * Extends mxShape.
  538. */
  539. function mxShapeAndroidTextSelHandles(bounds, fill, stroke, strokewidth)
  540. {
  541. mxShape.call(this);
  542. this.bounds = bounds;
  543. this.fill = fill;
  544. this.stroke = stroke;
  545. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  546. };
  547. /**
  548. * Extends mxShape.
  549. */
  550. mxUtils.extend(mxShapeAndroidTextSelHandles, mxShape);
  551. /**
  552. * Function: paintVertexShape
  553. *
  554. * Paints the vertex shape.
  555. */
  556. mxShapeAndroidTextSelHandles.prototype.paintVertexShape = function(c, x, y, w, h)
  557. {
  558. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, 'none');
  559. c.translate(x, y);
  560. var handleSizeX = 15;
  561. var barH = Math.max(0, h - handleSizeX * 1.5);
  562. c.setAlpha(0.5);
  563. c.rect(handleSizeX, 0, w - 2 * handleSizeX, barH);
  564. c.fill();
  565. c.begin();
  566. c.moveTo(0, h - handleSizeX);
  567. c.lineTo(handleSizeX * 0.5, h - handleSizeX * 1.5);
  568. c.lineTo(handleSizeX, h - handleSizeX);
  569. c.close();
  570. c.moveTo(w - handleSizeX, h - handleSizeX);
  571. c.lineTo(w - handleSizeX * 0.5, h - handleSizeX * 1.5);
  572. c.lineTo(w, h - handleSizeX);
  573. c.close();
  574. c.fill();
  575. c.setFillColor(strokeColor);
  576. c.rect(0, h - handleSizeX, handleSizeX, handleSizeX);
  577. c.fill();
  578. c.rect(w - handleSizeX, h - handleSizeX, handleSizeX, handleSizeX);
  579. c.fill();
  580. };
  581. mxCellRenderer.prototype.defaultShapes['mxgraph.android.textSelHandles'] = mxShapeAndroidTextSelHandles;
  582. //**********************************************************************************************************************************************************
  583. //Android Indeterminate Spinner
  584. //**********************************************************************************************************************************************************
  585. /**
  586. * Extends mxShape.
  587. */
  588. function mxShapeAndroidIndeterminateSpinner(bounds, fill, stroke, strokewidth)
  589. {
  590. mxShape.call(this);
  591. this.bounds = bounds;
  592. this.fill = fill;
  593. this.stroke = stroke;
  594. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  595. };
  596. /**
  597. * Extends mxShape.
  598. */
  599. mxUtils.extend(mxShapeAndroidIndeterminateSpinner, mxShape);
  600. /**
  601. * Function: paintVertexShape
  602. *
  603. * Paints the vertex shape.
  604. */
  605. mxShapeAndroidIndeterminateSpinner.prototype.paintVertexShape = function(c, x, y, w, h)
  606. {
  607. c.translate(x, y);
  608. this.background(c, x, y, w, h);
  609. };
  610. mxShapeAndroidIndeterminateSpinner.prototype.background = function(c, x, y, w, h)
  611. {
  612. c.setGradient('#aaaaaa', '#dddddd', w * 0.325, 0, w * 0.675, h * 0.5, mxConstants.DIRECTION_SOUTH, 1, 1);
  613. c.begin();
  614. c.moveTo(w * 0.5, h * 0.1);
  615. c.arcTo(w * 0.4, h * 0.4, 0, 0, 0, w * 0.5, h * 0.9);
  616. c.lineTo(w * 0.5, h);
  617. c.arcTo(w * 0.5, h * 0.5, 0, 0, 1, w * 0.5, 0);
  618. c.close();
  619. c.fill();
  620. c.setGradient('#ffffff', '#dddddd', w * 0.325, 0, w * 0.675, h * 0.5, mxConstants.DIRECTION_SOUTH, 1, 1);
  621. c.begin();
  622. c.moveTo(w * 0.5, h * 0.1);
  623. c.arcTo(w * 0.4, h * 0.4, 0, 0, 1, w * 0.5, h * 0.9);
  624. c.lineTo(w * 0.5, h);
  625. c.arcTo(w * 0.5, h * 0.5, 0, 0, 0, w * 0.5, 0);
  626. c.close();
  627. c.fill();
  628. };
  629. mxCellRenderer.prototype.defaultShapes['mxgraph.android.indeterminateSpinner'] = mxShapeAndroidIndeterminateSpinner;
  630. //**********************************************************************************************************************************************************
  631. //Anchor (a dummy shape without visuals used for anchoring)
  632. //**********************************************************************************************************************************************************
  633. /**
  634. * Extends mxShape.
  635. */
  636. function mxShapeAndroidAnchor(bounds, fill, stroke, strokewidth)
  637. {
  638. mxShape.call(this);
  639. this.bounds = bounds;
  640. };
  641. /**
  642. * Extends mxShape.
  643. */
  644. mxUtils.extend(mxShapeAndroidAnchor, mxShape);
  645. mxShapeAndroidAnchor.prototype.cst = {
  646. ANCHOR : 'mxgraph.android.anchor'
  647. };
  648. /**
  649. * Function: paintVertexShape
  650. *
  651. * Paints the vertex shape.
  652. */
  653. mxShapeAndroidAnchor.prototype.paintVertexShape = function(c, x, y, w, h)
  654. {
  655. };
  656. mxCellRenderer.registerShape(mxShapeAndroidAnchor.prototype.cst.ANCHOR, mxShapeAndroidAnchor);
  657. //**********************************************************************************************************************************************************
  658. //Rounded rectangle (adjustable rounding)
  659. //**********************************************************************************************************************************************************
  660. /**
  661. * Extends mxShape.
  662. */
  663. function mxShapeAndroidRRect(bounds, fill, stroke, strokewidth)
  664. {
  665. mxShape.call(this);
  666. this.bounds = bounds;
  667. this.fill = fill;
  668. this.stroke = stroke;
  669. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  670. };
  671. /**
  672. * Extends mxShape.
  673. */
  674. mxUtils.extend(mxShapeAndroidRRect, mxShape);
  675. mxShapeAndroidRRect.prototype.cst = {
  676. RRECT : 'mxgraph.android.rrect',
  677. R_SIZE : 'rSize'
  678. };
  679. /**
  680. * Function: paintVertexShape
  681. *
  682. * Paints the vertex shape.
  683. */
  684. mxShapeAndroidRRect.prototype.paintVertexShape = function(c, x, y, w, h)
  685. {
  686. c.translate(x, y);
  687. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeAndroidRRect.prototype.cst.R_SIZE, '10'));
  688. c.roundrect(0, 0, w, h, rSize);
  689. c.fillAndStroke();
  690. };
  691. mxCellRenderer.registerShape(mxShapeAndroidRRect.prototype.cst.RRECT, mxShapeAndroidRRect);
  692. //**********************************************************************************************************************************************************
  693. //Checkbox
  694. //**********************************************************************************************************************************************************
  695. /**
  696. * Extends mxShape.
  697. */
  698. function mxShapeAndroidCheckbox(bounds, fill, stroke, strokewidth)
  699. {
  700. mxShape.call(this);
  701. this.bounds = bounds;
  702. this.fill = fill;
  703. this.stroke = stroke;
  704. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  705. };
  706. /**
  707. * Extends mxShape.
  708. */
  709. mxUtils.extend(mxShapeAndroidCheckbox, mxShape);
  710. mxShapeAndroidCheckbox.prototype.cst = {
  711. CHECKBOX : 'mxgraph.android.checkbox'
  712. };
  713. /**
  714. * Function: paintVertexShape
  715. *
  716. * Paints the vertex shape.
  717. */
  718. mxShapeAndroidCheckbox.prototype.paintVertexShape = function(c, x, y, w, h)
  719. {
  720. c.translate(x, y);
  721. c.rect(0, 0, w, h);
  722. c.fillAndStroke();
  723. c.begin();
  724. c.moveTo(w * 0.8, h * 0.2);
  725. c.lineTo(w * 0.4, h * 0.8);
  726. c.lineTo(w * 0.25, h * 0.6);
  727. c.stroke();
  728. };
  729. mxCellRenderer.registerShape(mxShapeAndroidCheckbox.prototype.cst.CHECKBOX, mxShapeAndroidCheckbox);
  730. //**********************************************************************************************************************************************************
  731. //Progress Bar
  732. //**********************************************************************************************************************************************************
  733. /**
  734. * Extends mxShape.
  735. */
  736. function mxShapeAndroidProgressBar(bounds, fill, stroke, strokewidth)
  737. {
  738. mxShape.call(this);
  739. this.bounds = bounds;
  740. this.fill = fill;
  741. this.stroke = stroke;
  742. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  743. this.dx1 = 0.8;
  744. this.dx2 = 0.6;
  745. };
  746. /**
  747. * Extends mxShape.
  748. */
  749. mxUtils.extend(mxShapeAndroidProgressBar, mxShape);
  750. mxShapeAndroidProgressBar.prototype.cst = {
  751. PROGRESS_BAR : 'mxgraph.android.progressBar'
  752. };
  753. /**
  754. * Function: paintVertexShape
  755. *
  756. * Paints the vertex shape.
  757. */
  758. mxShapeAndroidProgressBar.prototype.paintVertexShape = function(c, x, y, w, h)
  759. {
  760. var dx1 = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx1', this.dx1))));
  761. var dx2 = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx2', this.dx2))));
  762. c.translate(x, y);
  763. c.save();
  764. c.save();
  765. c.setStrokeColor('#444444');
  766. c.begin();
  767. c.moveTo(0, h * 0.5);
  768. c.lineTo(w , h * 0.5);
  769. c.stroke();
  770. c.restore();
  771. c.setShadow(false);
  772. c.begin();
  773. c.moveTo(0, h * 0.5);
  774. c.lineTo(dx1, h * 0.5);
  775. c.stroke();
  776. c.setStrokeColor('#000000');
  777. c.setAlpha('0.2');
  778. c.begin();
  779. c.moveTo(0, h * 0.5);
  780. c.lineTo(dx1, h * 0.5);
  781. c.stroke();
  782. c.restore();
  783. c.setShadow(false);
  784. c.begin();
  785. c.moveTo(0, h * 0.5);
  786. c.lineTo(dx2, h * 0.5);
  787. c.stroke();
  788. };
  789. mxCellRenderer.registerShape(mxShapeAndroidProgressBar.prototype.cst.PROGRESS_BAR, mxShapeAndroidProgressBar);
  790. mxShapeAndroidProgressBar.prototype.constraints = null;
  791. Graph.handleFactory[mxShapeAndroidProgressBar.prototype.cst.PROGRESS_BAR] = function(state)
  792. {
  793. var handles = [Graph.createHandle(state, ['dx1'], function(bounds)
  794. {
  795. var dx1 = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx1', this.dx1))));
  796. return new mxPoint(bounds.x + dx1 * bounds.width, bounds.y + bounds.height / 2);
  797. }, function(bounds, pt)
  798. {
  799. this.state.style['dx1'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  800. })];
  801. var handle2 = Graph.createHandle(state, ['dx2'], function(bounds)
  802. {
  803. var dx2 = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx2', this.dx1))));
  804. return new mxPoint(bounds.x + dx2 * bounds.width, bounds.y + bounds.height / 2);
  805. }, function(bounds, pt)
  806. {
  807. this.state.style['dx2'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  808. });
  809. handles.push(handle2);
  810. return handles;
  811. }
  812. //**********************************************************************************************************************************************************
  813. //Progress Scrubber Disabled
  814. //**********************************************************************************************************************************************************
  815. /**
  816. * Extends mxShape.
  817. */
  818. function mxShapeAndroidProgressScrubberDisabled(bounds, fill, stroke, strokewidth)
  819. {
  820. mxShape.call(this);
  821. this.bounds = bounds;
  822. this.fill = fill;
  823. this.stroke = stroke;
  824. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  825. this.dx = 0.3;
  826. };
  827. /**
  828. * Extends mxShape.
  829. */
  830. mxUtils.extend(mxShapeAndroidProgressScrubberDisabled, mxShape);
  831. mxShapeAndroidProgressScrubberDisabled.prototype.cst = {
  832. PROGRESS_SCRUBBER_DISABLED : 'mxgraph.android.progressScrubberDisabled'
  833. };
  834. /**
  835. * Function: paintVertexShape
  836. *
  837. * Paints the vertex shape.
  838. */
  839. mxShapeAndroidProgressScrubberDisabled.prototype.paintVertexShape = function(c, x, y, w, h)
  840. {
  841. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  842. c.translate(x, y);
  843. c.save();
  844. c.save();
  845. c.setStrokeColor('#444444');
  846. c.begin();
  847. c.moveTo(0, h * 0.5);
  848. c.lineTo(w, h * 0.5);
  849. c.stroke();
  850. c.restore();
  851. c.setShadow(false);
  852. c.setAlpha('0.5');
  853. c.setFillColor('#666666');
  854. c.begin();
  855. var r = Math.min(h, w * 0.1) / 2;
  856. c.ellipse(dx - r, h * 0.5 - r, 2 * r, 2 * r);
  857. c.fill();
  858. c.restore();
  859. c.setShadow(false);
  860. c.begin();
  861. var r = Math.min(h, w * 0.1) / 8;
  862. c.ellipse(dx - r, h * 0.5 - r, 2 * r, 2 * r);
  863. c.fill();
  864. };
  865. mxCellRenderer.registerShape(mxShapeAndroidProgressScrubberDisabled.prototype.cst.PROGRESS_SCRUBBER_DISABLED, mxShapeAndroidProgressScrubberDisabled);
  866. mxShapeAndroidProgressScrubberDisabled.prototype.constraints = null;
  867. Graph.handleFactory[mxShapeAndroidProgressScrubberDisabled.prototype.cst.PROGRESS_SCRUBBER_DISABLED] = function(state)
  868. {
  869. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  870. {
  871. var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  872. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + bounds.height / 2);
  873. }, function(bounds, pt)
  874. {
  875. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  876. })];
  877. return handles;
  878. }
  879. //**********************************************************************************************************************************************************
  880. //Progress Scrubber Focused
  881. //**********************************************************************************************************************************************************
  882. /**
  883. * Extends mxShape.
  884. */
  885. function mxShapeAndroidProgressScrubberFocused(bounds, fill, stroke, strokewidth)
  886. {
  887. mxShape.call(this);
  888. this.bounds = bounds;
  889. this.fill = fill;
  890. this.stroke = stroke;
  891. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  892. this.dx = 0.3;
  893. };
  894. /**
  895. * Extends mxShape.
  896. */
  897. mxUtils.extend(mxShapeAndroidProgressScrubberFocused, mxShape);
  898. mxShapeAndroidProgressScrubberFocused.prototype.cst = {
  899. PROGRESS_SCRUBBER_FOCUSED : 'mxgraph.android.progressScrubberFocused'
  900. };
  901. /**
  902. * Function: paintVertexShape
  903. *
  904. * Paints the vertex shape.
  905. */
  906. mxShapeAndroidProgressScrubberFocused.prototype.paintVertexShape = function(c, x, y, w, h)
  907. {
  908. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  909. var fillColor = mxUtils.getValue(this.style, 'fillColor', '#ffffff');
  910. c.translate(x, y);
  911. c.save();
  912. c.save();
  913. c.setStrokeColor('#444444');
  914. c.begin();
  915. c.moveTo(0, h * 0.5);
  916. c.lineTo(w, h * 0.5);
  917. c.stroke();
  918. c.restore();
  919. c.setShadow(false);
  920. c.setAlpha('0.75');
  921. c.begin();
  922. var r = Math.min(h, w * 0.1) / 2;
  923. c.ellipse(dx - r, h * 0.5 - r, 2 * r, 2 * r);
  924. c.fill();
  925. c.restore();
  926. c.setShadow(false);
  927. c.setStrokeColor(fillColor);
  928. c.begin();
  929. c.moveTo(0, h * 0.5);
  930. c.lineTo(dx, h * 0.5);
  931. c.stroke();
  932. c.begin();
  933. var r = Math.min(h, w * 0.1) / 8;
  934. c.ellipse(dx - r, h * 0.5 - r, 2 * r, 2 * r);
  935. c.fill();
  936. };
  937. mxCellRenderer.registerShape(mxShapeAndroidProgressScrubberFocused.prototype.cst.PROGRESS_SCRUBBER_FOCUSED, mxShapeAndroidProgressScrubberFocused);
  938. mxShapeAndroidProgressScrubberFocused.prototype.constraints = null;
  939. Graph.handleFactory[mxShapeAndroidProgressScrubberFocused.prototype.cst.PROGRESS_SCRUBBER_FOCUSED] = function(state)
  940. {
  941. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  942. {
  943. var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  944. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + bounds.height / 2);
  945. }, function(bounds, pt)
  946. {
  947. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  948. })];
  949. return handles;
  950. }
  951. //**********************************************************************************************************************************************************
  952. //Progress Scrubber Pressed
  953. //**********************************************************************************************************************************************************
  954. /**
  955. * Extends mxShape.
  956. */
  957. function mxShapeAndroidProgressScrubberPressed(bounds, fill, stroke, strokewidth)
  958. {
  959. mxShape.call(this);
  960. this.bounds = bounds;
  961. this.fill = fill;
  962. this.stroke = stroke;
  963. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  964. this.dx = 0.3;
  965. };
  966. /**
  967. * Extends mxShape.
  968. */
  969. mxUtils.extend(mxShapeAndroidProgressScrubberPressed, mxShape);
  970. mxShapeAndroidProgressScrubberPressed.prototype.cst = {
  971. PROGRESS_SCRUBBER_PRESSED : 'mxgraph.android.progressScrubberPressed'
  972. };
  973. /**
  974. * Function: paintVertexShape
  975. *
  976. * Paints the vertex shape.
  977. */
  978. mxShapeAndroidProgressScrubberPressed.prototype.paintVertexShape = function(c, x, y, w, h)
  979. {
  980. var dx = w * Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  981. var fillColor = mxUtils.getValue(this.style, 'fillColor', '#ffffff');
  982. c.translate(x, y);
  983. c.save();
  984. c.save();
  985. c.setStrokeColor('#444444');
  986. c.begin();
  987. c.moveTo(0, h * 0.5);
  988. c.lineTo(w, h * 0.5);
  989. c.stroke();
  990. c.restore();
  991. c.setShadow(false);
  992. c.setStrokeColor(fillColor);
  993. c.setAlpha('0.5');
  994. c.begin();
  995. var r = Math.min(h, w * 0.1) / 2;
  996. c.ellipse(dx - r, h * 0.5 - r, 2 * r, 2 * r);
  997. c.fillAndStroke();
  998. c.restore();
  999. c.setShadow(false);
  1000. c.setStrokeColor(fillColor);
  1001. c.begin();
  1002. c.moveTo(0, h * 0.5);
  1003. c.lineTo(dx, h * 0.5);
  1004. c.stroke();
  1005. c.begin();
  1006. var r = Math.min(h, w * 0.1) / 8;
  1007. c.ellipse(dx - r, h * 0.5 - r, 2 * r, 2 * r);
  1008. c.fill();
  1009. };
  1010. mxCellRenderer.registerShape(mxShapeAndroidProgressScrubberPressed.prototype.cst.PROGRESS_SCRUBBER_PRESSED, mxShapeAndroidProgressScrubberPressed);
  1011. mxShapeAndroidProgressScrubberPressed.prototype.constraints = null;
  1012. Graph.handleFactory[mxShapeAndroidProgressScrubberPressed.prototype.cst.PROGRESS_SCRUBBER_PRESSED] = function(state)
  1013. {
  1014. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1015. {
  1016. var dx = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1017. return new mxPoint(bounds.x + dx * bounds.width, bounds.y + bounds.height / 2);
  1018. }, function(bounds, pt)
  1019. {
  1020. this.state.style['dx'] = Math.round(100 * Math.max(0, Math.min(1, (pt.x - bounds.x) / bounds.width))) / 100;
  1021. })];
  1022. return handles;
  1023. }
  1024. //**********************************************************************************************************************************************************
  1025. //Quickscroll
  1026. //**********************************************************************************************************************************************************
  1027. /**
  1028. * Extends mxShape.
  1029. */
  1030. function mxShapeAndroidQuickscroll2(bounds, fill, stroke, strokewidth)
  1031. {
  1032. mxShape.call(this);
  1033. this.bounds = bounds;
  1034. this.fill = fill;
  1035. this.stroke = stroke;
  1036. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1037. this.dy = 0.5;
  1038. };
  1039. /**
  1040. * Extends mxShape.
  1041. */
  1042. mxUtils.extend(mxShapeAndroidQuickscroll2, mxShape);
  1043. mxShapeAndroidQuickscroll2.prototype.cst = {
  1044. QUICKSCROLL : 'mxgraph.android.quickscroll2'
  1045. };
  1046. /**
  1047. * Function: paintVertexShape
  1048. *
  1049. * Paints the vertex shape.
  1050. */
  1051. mxShapeAndroidQuickscroll2.prototype.paintVertexShape = function(c, x, y, w, h)
  1052. {
  1053. var dy = Math.min(h - 20, Math.max(20, h * Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))))));
  1054. var fillColor = mxUtils.getValue(this.style, 'fillColor', '#ffffff');
  1055. c.translate(x, y);
  1056. c.save();
  1057. c.save();
  1058. c.setStrokeColor('#cccccc');
  1059. c.begin();
  1060. c.moveTo(w - 3, 0);
  1061. c.lineTo(w - 3, h);
  1062. c.stroke();
  1063. c.restore();
  1064. c.begin();
  1065. c.roundrect(w - 6, dy - 10, 6, 20, 1, 1);
  1066. c.fillAndStroke();
  1067. c.setFillColor('#cccccc');
  1068. c.begin();
  1069. c.rect(0, dy - 20, w - 18, 40);
  1070. c.fill();
  1071. c.setFillColor('#666666');
  1072. c.begin();
  1073. c.moveTo(w - 18, dy - 20);
  1074. c.lineTo(w - 6, dy);
  1075. c.lineTo(w - 18, dy + 20);
  1076. c.close();
  1077. c.fill();
  1078. c.setFontSize('12');
  1079. c.text((w - 18) * 0.5, dy, 0, 00, 'Aa', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1080. };
  1081. mxCellRenderer.registerShape(mxShapeAndroidQuickscroll2.prototype.cst.QUICKSCROLL, mxShapeAndroidQuickscroll2);
  1082. mxShapeAndroidQuickscroll2.prototype.constraints = null;
  1083. Graph.handleFactory[mxShapeAndroidQuickscroll2.prototype.cst.QUICKSCROLL] = function(state)
  1084. {
  1085. var handles = [Graph.createHandle(state, ['dy'], function(bounds)
  1086. {
  1087. var dy = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  1088. return new mxPoint(bounds.x + bounds.width - 3, bounds.y + Math.min(bounds.height - 20, Math.max(20, dy * bounds.height)));
  1089. }, function(bounds, pt)
  1090. {
  1091. this.state.style['dy'] = Math.round(1000 * Math.max(0, Math.min(1, (pt.y - bounds.y) / bounds.height))) / 1000;
  1092. })];
  1093. return handles;
  1094. }
  1095. //**********************************************************************************************************************************************************
  1096. //Quickscroll2
  1097. //**********************************************************************************************************************************************************
  1098. /**
  1099. * Extends mxShape.
  1100. */
  1101. function mxShapeAndroidQuickscroll3(bounds, fill, stroke, strokewidth)
  1102. {
  1103. mxShape.call(this);
  1104. this.bounds = bounds;
  1105. this.fill = fill;
  1106. this.stroke = stroke;
  1107. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1108. this.dy = 0.5;
  1109. };
  1110. /**
  1111. * Extends mxShape.
  1112. */
  1113. mxUtils.extend(mxShapeAndroidQuickscroll3, mxShape);
  1114. mxShapeAndroidQuickscroll3.prototype.cst = {
  1115. QUICKSCROLL : 'mxgraph.android.quickscroll3'
  1116. };
  1117. /**
  1118. * Function: paintVertexShape
  1119. *
  1120. * Paints the vertex shape.
  1121. */
  1122. mxShapeAndroidQuickscroll3.prototype.paintVertexShape = function(c, x, y, w, h)
  1123. {
  1124. var dy = Math.min(h - 10, Math.max(10, h * Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))))));
  1125. var fillColor = mxUtils.getValue(this.style, 'fillColor', '#ffffff');
  1126. c.translate(x, y);
  1127. c.save();
  1128. c.setStrokeColor('#cccccc');
  1129. c.begin();
  1130. c.moveTo(w * 0.5, 0);
  1131. c.lineTo(w * 0.5, h);
  1132. c.stroke();
  1133. c.restore();
  1134. c.begin();
  1135. c.roundrect(w * 0.5 - 3, dy - 10, 6, 20, 1, 1);
  1136. c.fillAndStroke();
  1137. };
  1138. mxCellRenderer.registerShape(mxShapeAndroidQuickscroll3.prototype.cst.QUICKSCROLL, mxShapeAndroidQuickscroll3);
  1139. mxShapeAndroidQuickscroll3.prototype.constraints = null;
  1140. Graph.handleFactory[mxShapeAndroidQuickscroll3.prototype.cst.QUICKSCROLL] = function(state)
  1141. {
  1142. var handles = [Graph.createHandle(state, ['dy'], function(bounds)
  1143. {
  1144. var dy = Math.max(0, Math.min(1, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  1145. return new mxPoint(bounds.x + bounds.width * 0.5, bounds.y + Math.min(bounds.height - 10, Math.max(10, dy * bounds.height)));
  1146. }, function(bounds, pt)
  1147. {
  1148. this.state.style['dy'] = Math.round(1000 * Math.max(0, Math.min(1, (pt.y - bounds.y) / bounds.height))) / 1000;
  1149. })];
  1150. return handles;
  1151. }
  1152. //**********************************************************************************************************************************************************
  1153. //Scrollbars
  1154. //**********************************************************************************************************************************************************
  1155. /**
  1156. * Extends mxShape.
  1157. */
  1158. function mxShapeAndroidScrollbars2(bounds, fill, stroke, strokewidth)
  1159. {
  1160. mxShape.call(this);
  1161. this.bounds = bounds;
  1162. this.fill = fill;
  1163. this.stroke = stroke;
  1164. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1165. };
  1166. /**
  1167. * Extends mxShape.
  1168. */
  1169. mxUtils.extend(mxShapeAndroidScrollbars2, mxShape);
  1170. mxShapeAndroidScrollbars2.prototype.cst = {
  1171. SCROLLBARS : 'mxgraph.android.scrollbars2'
  1172. };
  1173. /**
  1174. * Function: paintVertexShape
  1175. *
  1176. * Paints the vertex shape.
  1177. */
  1178. mxShapeAndroidScrollbars2.prototype.paintVertexShape = function(c, x, y, w, h)
  1179. {
  1180. c.translate(x, y);
  1181. c.begin();
  1182. c.rect(w - 5, 0, 5, h - 7);
  1183. c.fillAndStroke();
  1184. c.begin();
  1185. c.rect(0, h - 5, w - 7, 5);
  1186. c.fillAndStroke();
  1187. };
  1188. mxCellRenderer.registerShape(mxShapeAndroidScrollbars2.prototype.cst.SCROLLBARS, mxShapeAndroidScrollbars2);
  1189. mxShapeAndroidScrollbars2.prototype.constraints = null;
  1190. //**********************************************************************************************************************************************************
  1191. //Spinner
  1192. //**********************************************************************************************************************************************************
  1193. /**
  1194. * Extends mxShape.
  1195. */
  1196. function mxShapeAndroidSpinner2(bounds, fill, stroke, strokewidth)
  1197. {
  1198. mxShape.call(this);
  1199. this.bounds = bounds;
  1200. this.fill = fill;
  1201. this.stroke = stroke;
  1202. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1203. };
  1204. /**
  1205. * Extends mxShape.
  1206. */
  1207. mxUtils.extend(mxShapeAndroidSpinner2, mxShape);
  1208. mxShapeAndroidSpinner2.prototype.cst = {
  1209. SPINNER : 'mxgraph.android.spinner2'
  1210. };
  1211. /**
  1212. * Function: paintVertexShape
  1213. *
  1214. * Paints the vertex shape.
  1215. */
  1216. mxShapeAndroidSpinner2.prototype.paintVertexShape = function(c, x, y, w, h)
  1217. {
  1218. c.translate(x, y);
  1219. c.begin();
  1220. c.moveTo(0, h);
  1221. c.lineTo(w, h);
  1222. c.stroke();
  1223. var s = Math.min(w / 10, h)
  1224. c.begin();
  1225. c.moveTo(w - s, h);
  1226. c.lineTo(w, h - s);
  1227. c.lineTo(w, h);
  1228. c.close();
  1229. c.fillAndStroke();
  1230. };
  1231. mxCellRenderer.registerShape(mxShapeAndroidSpinner2.prototype.cst.SPINNER, mxShapeAndroidSpinner2);
  1232. mxShapeAndroidSpinner2.prototype.constraints = null;