mxMockupContainers.js 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119
  1. /**
  2. * $Id: mxMockupContainers.js,v 1.10 2013/07/09 11:19:51 mate Exp $
  3. * Copyright (c) 2006-2010, JGraph Ltd
  4. */
  5. //**********************************************************************************************************************************************************
  6. //Video Player
  7. //**********************************************************************************************************************************************************
  8. /**
  9. * Extends mxShape.
  10. */
  11. function mxShapeMockupVideoPlayer(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. this.barPos = 20;
  19. this.barHeight = 30;
  20. };
  21. /**
  22. * Extends mxShape.
  23. */
  24. mxUtils.extend(mxShapeMockupVideoPlayer, mxShape);
  25. mxShapeMockupVideoPlayer.prototype.cst = {
  26. FILL_COLOR2 : 'fillColor2',
  27. TEXT_COLOR : 'textColor',
  28. STROKE_COLOR2 : 'strokeColor2',
  29. STROKE_COLOR3 : 'strokeColor3',
  30. SHAPE_VIDEO_PLAYER : 'mxgraph.mockup.containers.videoPlayer',
  31. BAR_POS : 'barPos',
  32. BAR_HEIGHT : 'barHeight'
  33. };
  34. mxShapeMockupVideoPlayer.prototype.customProperties = [
  35. {name: 'fillColor2', dispName: 'Fill2 Color', type: 'color'},
  36. {name: 'textColor', dispName: 'Text Color', type: 'color'},
  37. {name: 'strokeColor2', dispName: 'Stroke2 Color', type: 'color'},
  38. {name: 'strokeColor3', dispName: 'Stroke3 Color', type: 'color'},
  39. {name: 'barPos', dispName: 'Handle Position', type: 'float', min:0, max:100, defVal:20},
  40. {name: 'barHeight', dispName: 'Video Bar Height', type: 'float', min:0, defVal:30}
  41. ];
  42. /**
  43. * Function: paintVertexShape
  44. *
  45. * Paints the vertex shape.
  46. */
  47. mxShapeMockupVideoPlayer.prototype.paintVertexShape = function(c, x, y, w, h)
  48. {
  49. var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  50. var buttonColor = mxUtils.getValue(this.style, mxShapeMockupVideoPlayer.prototype.cst.FILL_COLOR2, '#c4c4c4');
  51. var frameColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#666666');
  52. var filledColor = mxUtils.getValue(this.style, mxShapeMockupVideoPlayer.prototype.cst.STROKE_COLOR2, '#008cff');
  53. var emptyColor = mxUtils.getValue(this.style, mxShapeMockupVideoPlayer.prototype.cst.STROKE_COLOR3, '#c4c4c4');
  54. var barHeight = mxUtils.getValue(this.style, mxShapeMockupVideoPlayer.prototype.cst.BAR_HEIGHT, '30');
  55. w = Math.max(w, 5 * barHeight);
  56. h = Math.max(h, barHeight + 10);
  57. c.translate(x, y);
  58. this.background(c, x, y, w, h, bgColor, frameColor);
  59. c.setShadow(false);
  60. this.otherShapes(c, x, y, w, h, buttonColor, frameColor, filledColor, emptyColor, barHeight);
  61. };
  62. mxShapeMockupVideoPlayer.prototype.background = function(c, x, y, w, h, bgColor, frameColor)
  63. {
  64. c.setFillColor(bgColor);
  65. c.setStrokeColor(frameColor);
  66. c.begin();
  67. c.moveTo(0, 0);
  68. c.lineTo(w, 0);
  69. c.lineTo(w, h);
  70. c.lineTo(0, h);
  71. c.close();
  72. c.fillAndStroke();
  73. };
  74. mxShapeMockupVideoPlayer.prototype.otherShapes = function(c, x, y, w, h, buttonColor, frameColor, filledColor, emptyColor, barHeight)
  75. {
  76. var barPos = mxUtils.getValue(this.style, mxShapeMockupVideoPlayer.prototype.cst.BAR_POS, '20');
  77. barPos = Math.max(0, barPos);
  78. barPos = Math.min(100, barPos);
  79. var strokeWidth = mxUtils.getValue(this.style, mxConstants.STYLE_STROKEWIDTH, '1');
  80. var buttonR = 8;
  81. var barY = h - barHeight;
  82. var barMin = buttonR;
  83. var barMax = w - buttonR;
  84. var barRange = barMax - barMin;
  85. var realBarPos = barRange * barPos / 100;
  86. var barEnd = barMin + realBarPos;
  87. //progress bar
  88. c.setStrokeColor(filledColor);
  89. c.begin();
  90. c.moveTo(0, barY);
  91. c.lineTo(barEnd, barY);
  92. c.stroke();
  93. c.setStrokeColor(emptyColor);
  94. c.begin();
  95. c.moveTo(barEnd, barY);
  96. c.lineTo(w, barY);
  97. c.stroke();
  98. //progress bar button
  99. c.setStrokeColor(frameColor);
  100. c.begin();
  101. c.ellipse(barEnd - buttonR, barY - buttonR, 2 * buttonR, 2 * buttonR);
  102. c.fillAndStroke();
  103. c.begin();
  104. c.setStrokeWidth(strokeWidth / 2);
  105. c.ellipse(barEnd - buttonR * 0.5, barY - buttonR * 0.5, buttonR, buttonR);
  106. c.fillAndStroke();
  107. c.setStrokeWidth(strokeWidth);
  108. var iconSize = barHeight * 0.3;
  109. var iconY = h - (barHeight + iconSize) * 0.5;
  110. var iconX = barHeight * 0.3;
  111. c.setFillColor(buttonColor);
  112. c.setStrokeColor(buttonColor);
  113. //play icon
  114. c.begin();
  115. c.moveTo(iconX, iconY);
  116. c.lineTo(iconX + iconSize, iconY + iconSize * 0.5);
  117. c.lineTo(iconX, iconY + iconSize);
  118. c.close();
  119. c.fillAndStroke();
  120. //volume icon
  121. var speakerX = barHeight;
  122. var speakerY = h - barHeight;
  123. c.moveTo(speakerX + barHeight * 0.05, speakerY + barHeight * 0.4);
  124. c.lineTo(speakerX + barHeight * 0.15, speakerY + barHeight * 0.4);
  125. c.lineTo(speakerX + barHeight * 0.3, speakerY + barHeight * 0.25);
  126. c.lineTo(speakerX + barHeight * 0.3, speakerY + barHeight * 0.75);
  127. c.lineTo(speakerX + barHeight * 0.15, speakerY + barHeight * 0.6);
  128. c.lineTo(speakerX + barHeight * 0.05, speakerY + barHeight * 0.6);
  129. c.close();
  130. c.fillAndStroke();
  131. c.begin();
  132. c.moveTo(speakerX + barHeight * 0.4, speakerY + barHeight * 0.35);
  133. c.arcTo(barHeight * 0.2, barHeight * 0.3, 0, 0, 1, speakerX + barHeight * 0.4, speakerY + barHeight * 0.65);
  134. c.moveTo(speakerX + barHeight * 0.425, speakerY + barHeight * 0.25);
  135. c.arcTo(barHeight * 0.225, barHeight * 0.35, 0, 0, 1, speakerX + barHeight * 0.425, speakerY + barHeight * 0.75);
  136. c.stroke();
  137. //fullscreen button
  138. var screenX = w - barHeight * 1.3;
  139. c.begin();
  140. c.moveTo(screenX + barHeight * 0.1, speakerY + barHeight * 0.4);
  141. c.lineTo(screenX + barHeight * 0.1, speakerY + barHeight * 0.3);
  142. c.lineTo(screenX + barHeight * 0.25, speakerY + barHeight * 0.3);
  143. c.moveTo(screenX + barHeight * 0.1, speakerY + barHeight * 0.6);
  144. c.lineTo(screenX + barHeight * 0.1, speakerY + barHeight * 0.7);
  145. c.lineTo(screenX + barHeight * 0.25, speakerY + barHeight * 0.7);
  146. c.moveTo(screenX + barHeight * 0.9, speakerY + barHeight * 0.4);
  147. c.lineTo(screenX + barHeight * 0.9, speakerY + barHeight * 0.3);
  148. c.lineTo(screenX + barHeight * 0.75, speakerY + barHeight * 0.3);
  149. c.moveTo(screenX + barHeight * 0.9, speakerY + barHeight * 0.6);
  150. c.lineTo(screenX + barHeight * 0.9, speakerY + barHeight * 0.7);
  151. c.lineTo(screenX + barHeight * 0.75, speakerY + barHeight * 0.7);
  152. c.stroke();
  153. var textColor = mxUtils.getValue(this.style, mxShapeMockupVideoPlayer.prototype.cst.TEXT_COLOR, '#666666');
  154. c.begin();
  155. c.setFontSize(barHeight * 0.5);
  156. c.setFontColor(textColor);
  157. c.text(barHeight * 1.9, h - barHeight * 0.45, 0, 0, '0:00/3:53', mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  158. };
  159. mxCellRenderer.registerShape(mxShapeMockupVideoPlayer.prototype.cst.SHAPE_VIDEO_PLAYER, mxShapeMockupVideoPlayer);
  160. Graph.handleFactory[mxShapeMockupVideoPlayer.prototype.cst.SHAPE_VIDEO_PLAYER] = function(state)
  161. {
  162. var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
  163. {
  164. var barPos = Math.max(0, Math.min(100, parseFloat(mxUtils.getValue(this.state.style, 'barPos', this.barPos))));
  165. var barH = parseFloat(mxUtils.getValue(this.state.style, 'barHeight', this.barHeight));
  166. return new mxPoint(bounds.x + ((bounds.width - 16) * barPos / bounds.width) / 100 * bounds.width + 8, bounds.y + bounds.height - barH - 20);
  167. }, function(bounds, pt)
  168. {
  169. this.state.style['barPos'] = Math.round(1000 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 1000;
  170. })];
  171. var handle2 = Graph.createHandle(state, ['barHeight'], function(bounds)
  172. {
  173. var barHeight = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'barHeight', this.barHeight))));
  174. return new mxPoint(bounds.x + bounds.width - 20, bounds.y + bounds.height - barHeight);
  175. }, function(bounds, pt)
  176. {
  177. this.state.style['barHeight'] = Math.round(1000 * Math.max(0, Math.min(bounds.height, bounds.y + bounds.height - pt.y))) / 1000;
  178. });
  179. handles.push(handle2);
  180. return handles;
  181. }
  182. //**********************************************************************************************************************************************************
  183. //Accordion (LEGACY)
  184. //**********************************************************************************************************************************************************
  185. /**
  186. * Extends mxShape.
  187. */
  188. function mxShapeMockupAccordion(bounds, fill, stroke, strokewidth)
  189. {
  190. mxShape.call(this);
  191. this.bounds = bounds;
  192. this.fill = fill;
  193. this.stroke = stroke;
  194. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  195. };
  196. /**
  197. * Extends mxShape.
  198. */
  199. mxUtils.extend(mxShapeMockupAccordion, mxShape);
  200. mxShapeMockupAccordion.prototype.cst = {
  201. TEXT_COLOR : 'textColor',
  202. TEXT_COLOR2 : 'textColor2',
  203. TEXT_SIZE : 'textSize',
  204. SHAPE_ACCORDION : 'mxgraph.mockup.containers.accordion',
  205. STROKE_COLOR2 : 'strokeColor2',
  206. FILL_COLOR2 : 'fillColor2',
  207. SELECTED : '+', // must be 1 char
  208. MAIN_TEXT : 'mainText'
  209. };
  210. /**
  211. * Function: paintVertexShape
  212. *
  213. * Paints the vertex shape.
  214. */
  215. mxShapeMockupAccordion.prototype.paintVertexShape = function(c, x, y, w, h)
  216. {
  217. var textStrings = mxUtils.getValue(this.style, mxShapeMockupAccordion.prototype.cst.MAIN_TEXT, '+Group 1, Group 2, Group 3').toString().split(',');
  218. var fontColor = mxUtils.getValue(this.style, mxShapeMockupAccordion.prototype.cst.TEXT_COLOR, '#666666');
  219. var selectedFontColor = mxUtils.getValue(this.style, mxShapeMockupAccordion.prototype.cst.TEXT_COLOR2, '#ffffff');
  220. var fontSize = mxUtils.getValue(this.style, mxShapeMockupAccordion.prototype.cst.TEXT_SIZE, '17').toString();
  221. var frameColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#666666');
  222. var separatorColor = mxUtils.getValue(this.style, mxShapeMockupAccordion.prototype.cst.STROKE_COLOR2, '#c4c4c4');
  223. var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  224. var selectedFillColor = mxUtils.getValue(this.style, mxShapeMockupAccordion.prototype.cst.FILL_COLOR2, '#008cff');
  225. var buttonNum = textStrings.length;
  226. var maxButtonWidth = 0;
  227. var selectedButton = -1;
  228. var rSize = 10; //rounding size
  229. var labelOffset = 5;
  230. for (var i = 0; i < buttonNum; i++)
  231. {
  232. var buttonText = textStrings[i];
  233. if(buttonText.charAt(0) === mxShapeMockupAccordion.prototype.cst.SELECTED)
  234. {
  235. buttonText = textStrings[i].substring(1);
  236. selectedButton = i;
  237. }
  238. var currWidth = mxUtils.getSizeForString(buttonText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  239. if (currWidth > maxButtonWidth)
  240. {
  241. maxButtonWidth = currWidth;
  242. }
  243. }
  244. var minButtonHeight = fontSize * 1.5;
  245. var minH = buttonNum * minButtonHeight;
  246. var trueH = Math.max(h, minH);
  247. var minW = 2 * labelOffset + maxButtonWidth;
  248. var trueW = Math.max(w, minW);
  249. c.translate(x, y);
  250. this.background(c, trueW, trueH, rSize, buttonNum, labelOffset, buttonNum * minButtonHeight, frameColor, separatorColor, bgColor, selectedFillColor, selectedButton, minButtonHeight);
  251. c.setShadow(false);
  252. var currWidth = 0;
  253. for (var i = 0; i < buttonNum; i++)
  254. {
  255. if (i === selectedButton)
  256. {
  257. c.setFontColor(selectedFontColor);
  258. }
  259. else
  260. {
  261. c.setFontColor(fontColor);
  262. }
  263. currWidth = currWidth + labelOffset;
  264. var currHeight = 0;
  265. if (selectedButton === -1 || i <= selectedButton)
  266. {
  267. currHeight = (i * minButtonHeight + minButtonHeight * 0.5);
  268. }
  269. else
  270. {
  271. currHeight = trueH - (buttonNum - i - 0.5) * minButtonHeight;
  272. }
  273. this.buttonText(c, trueW, currHeight, textStrings[i], fontSize);
  274. }
  275. };
  276. mxShapeMockupAccordion.prototype.background = function(c, w, h, rSize, buttonNum, labelOffset, minH, frameColor, separatorColor, bgColor, selectedFillColor, selectedButton, minButtonHeight)
  277. {
  278. c.begin();
  279. //draw the frame
  280. c.setStrokeColor(frameColor);
  281. c.setFillColor(bgColor);
  282. c.moveTo(0, 0);
  283. c.lineTo(w, 0);
  284. c.lineTo(w, h);
  285. c.lineTo(0, h);
  286. c.close();
  287. c.fillAndStroke();
  288. //draw the button separators
  289. c.setStrokeColor(separatorColor);
  290. c.begin();
  291. for (var i = 1; i < buttonNum; i++)
  292. {
  293. if (i !== selectedButton)
  294. {
  295. if (selectedButton === -1 || i < selectedButton)
  296. {
  297. var currHeight = i * minButtonHeight;
  298. c.moveTo(0, currHeight);
  299. c.lineTo(w, currHeight);
  300. }
  301. else
  302. {
  303. var currHeight = h - (buttonNum - i) * minButtonHeight;
  304. c.moveTo(0, currHeight);
  305. c.lineTo(w, currHeight);
  306. }
  307. }
  308. }
  309. c.stroke();
  310. //draw the selected button
  311. c.setStrokeColor(mxConstants.NONE);
  312. c.setFillColor(selectedFillColor);
  313. if (selectedButton !== -1)
  314. {
  315. c.begin();
  316. var buttonTop = minButtonHeight * selectedButton;
  317. var buttonBottom = minButtonHeight * (selectedButton + 1);
  318. c.moveTo(0, buttonTop);
  319. c.lineTo(w, buttonTop);
  320. c.lineTo(w, buttonBottom);
  321. c.lineTo(0, buttonBottom);
  322. c.close();
  323. c.fill();
  324. }
  325. // //draw the frame again, to achieve a nicer effect
  326. c.begin();
  327. c.setStrokeColor(frameColor);
  328. c.setFillColor(bgColor);
  329. c.moveTo(0, 0);
  330. c.lineTo(w, 0);
  331. c.lineTo(w, h);
  332. c.lineTo(0, h);
  333. c.close();
  334. c.stroke();
  335. };
  336. mxShapeMockupAccordion.prototype.buttonText = function(c, w, h, textString, fontSize)
  337. {
  338. if(textString.charAt(0) === mxShapeMockupAccordion.prototype.cst.SELECTED)
  339. {
  340. textString = textString.substring(1);
  341. }
  342. c.begin();
  343. c.setFontSize(fontSize);
  344. c.text((w * 0.5), h, 0, 0, textString, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  345. };
  346. mxCellRenderer.registerShape(mxShapeMockupAccordion.prototype.cst.SHAPE_ACCORDION, mxShapeMockupAccordion);
  347. //**********************************************************************************************************************************************************
  348. //Browser Window
  349. //**********************************************************************************************************************************************************
  350. /**
  351. * Extends mxShape.
  352. */
  353. function mxShapeMockupBrowserWindow(bounds, fill, stroke, strokewidth)
  354. {
  355. mxShape.call(this);
  356. this.bounds = bounds;
  357. this.fill = fill;
  358. this.stroke = stroke;
  359. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  360. };
  361. /**
  362. * Extends mxShape.
  363. */
  364. mxUtils.extend(mxShapeMockupBrowserWindow, mxShape);
  365. mxShapeMockupBrowserWindow.prototype.cst = {
  366. STROKE_COLOR2 : 'strokeColor2',
  367. STROKE_COLOR3 : 'strokeColor3',
  368. MAIN_TEXT : 'mainText',
  369. SHAPE_BROWSER_WINDOW : 'mxgraph.mockup.containers.browserWindow'
  370. };
  371. mxShapeMockupBrowserWindow.prototype.customProperties = [
  372. {name: 'strokeColor2', dispName: 'Stroke2 Color', type: 'color'},
  373. {name: 'strokeColor3', dispName: 'Stroke3 Color', type: 'color'}
  374. ];
  375. /**
  376. * Function: paintVertexShape
  377. *
  378. * Paints the vertex shape.
  379. */
  380. mxShapeMockupBrowserWindow.prototype.paintVertexShape = function(c, x, y, w, h)
  381. {
  382. var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  383. var frameColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#666666');
  384. var closeColor = mxUtils.getValue(this.style, mxShapeMockupBrowserWindow.prototype.cst.STROKE_COLOR2, '#008cff');
  385. var insideColor = mxUtils.getValue(this.style, mxShapeMockupBrowserWindow.prototype.cst.STROKE_COLOR3, '#c4c4c4');
  386. w = Math.max(w, 260);
  387. h = Math.max(h, 110);
  388. c.translate(x, y);
  389. this.background(c, x, y, w, h, bgColor, frameColor);
  390. c.setShadow(false);
  391. this.otherShapes(c, x, y, w, h, frameColor, insideColor, closeColor);
  392. };
  393. mxShapeMockupBrowserWindow.prototype.background = function(c, x, y, w, h, bgColor, frameColor)
  394. {
  395. c.setFillColor(bgColor);
  396. c.setStrokeColor(frameColor);
  397. c.begin();
  398. c.moveTo(0, 0);
  399. c.lineTo(w, 0);
  400. c.lineTo(w, h);
  401. c.lineTo(0, h);
  402. c.close();
  403. c.fillAndStroke();
  404. };
  405. mxShapeMockupBrowserWindow.prototype.otherShapes = function(c, x, y, w, h, frameColor, insideColor, closeColor)
  406. {
  407. var strokeWidth = mxUtils.getValue(this.style, mxConstants.STYLE_STROKEWIDTH, '1');
  408. var mainText = mxUtils.getValue(this.style, mxShapeMockupBrowserWindow.prototype.cst.MAIN_TEXT, 'http://www.draw.io,Page 1').toString().split(',');
  409. //window buttons
  410. c.setStrokeColor(frameColor);
  411. c.ellipse(w - 75, 5, 20, 20);
  412. c.stroke();
  413. c.ellipse(w - 50, 5, 20, 20);
  414. c.stroke();
  415. c.setStrokeColor(closeColor);
  416. c.ellipse(w - 25, 5, 20, 20);
  417. c.stroke();
  418. c.setStrokeColor(insideColor);
  419. //lines
  420. c.begin();
  421. c.moveTo(0, 40);
  422. c.lineTo(30, 40);
  423. c.lineTo(30, 15);
  424. c.arcTo(5, 5, 0, 0, 1, 35, 10);
  425. c.lineTo(170, 10);
  426. c.arcTo(5, 5, 0, 0, 1, 175, 15);
  427. c.lineTo(175, 40);
  428. c.lineTo(w, 40);
  429. c.stroke();
  430. c.begin();
  431. c.moveTo(0, 110);
  432. c.lineTo(w, 110);
  433. c.stroke();
  434. //address field
  435. c.begin();
  436. c.moveTo(100, 60);
  437. c.arcTo(5, 5, 0, 0, 1, 105, 55);
  438. c.lineTo(w - 15, 55);
  439. c.arcTo(5, 5, 0, 0, 1, w - 10, 60);
  440. c.lineTo(w - 10, 85);
  441. c.arcTo(5, 5, 0, 0, 1, w - 15, 90);
  442. c.lineTo(105, 90);
  443. c.arcTo(5, 5, 0, 0, 1, 100, 85);
  444. c.close();
  445. c.stroke();
  446. //text
  447. var textColor = mxUtils.getValue(this.style, mxShapeMockupBrowserWindow.prototype.cst.TEXT_COLOR, '#666666');
  448. c.setFontColor(textColor);
  449. c.setFontSize(17);
  450. c.text(65, 25, 0, 0, mainText[1], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  451. c.text(130, 73, 0, 0, mainText[0], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  452. c.stroke();
  453. //icon on tab
  454. c.translate(37, 17);
  455. c.begin();
  456. c.moveTo(0, 0);
  457. c.lineTo(11, 0);
  458. c.lineTo(15, 4);
  459. c.lineTo(15, 18);
  460. c.lineTo(0, 18);
  461. c.close();
  462. c.stroke();
  463. c.setStrokeWidth(strokeWidth * 0.5); //maybe because of this (read later)
  464. c.begin();
  465. c.moveTo(11, 0);
  466. c.lineTo(11, 4);
  467. c.lineTo(15, 5);
  468. c.stroke();
  469. //icon in address bar
  470. c.setStrokeWidth(strokeWidth * 2); // i'm not sure why i have to multiply here
  471. c.translate(70, 47);
  472. c.begin();
  473. c.moveTo(0, 0);
  474. c.lineTo(11, 0);
  475. c.lineTo(15, 4);
  476. c.lineTo(15, 18);
  477. c.lineTo(0, 18);
  478. c.close();
  479. c.stroke();
  480. c.setStrokeWidth(strokeWidth * 0.5);
  481. c.begin();
  482. c.moveTo(11, 0);
  483. c.lineTo(11, 4);
  484. c.lineTo(15, 5);
  485. c.stroke();
  486. //back
  487. var iSi = 20; //icon size
  488. c.setFillColor(insideColor);
  489. c.begin();
  490. c.setStrokeWidth(strokeWidth * 2); // i'm not sure why i have to multiply here
  491. c.translate(-95, 0);
  492. c.moveTo(0, iSi * 0.5);
  493. c.lineTo(iSi * 0.5, 0);
  494. c.lineTo(iSi * 0.5, iSi * 0.3);
  495. c.lineTo(iSi, iSi * 0.3);
  496. c.lineTo(iSi, iSi * 0.7);
  497. c.lineTo(iSi * 0.5, iSi * 0.7);
  498. c.lineTo(iSi * 0.5, iSi);
  499. c.close();
  500. c.fillAndStroke();
  501. //forward
  502. c.begin();
  503. c.translate(30, 0);
  504. c.moveTo(iSi, iSi * 0.5);
  505. c.lineTo(iSi * 0.5, 0);
  506. c.lineTo(iSi * 0.5, iSi * 0.3);
  507. c.lineTo(0, iSi * 0.3);
  508. c.lineTo(0, iSi * 0.7);
  509. c.lineTo(iSi * 0.5, iSi * 0.7);
  510. c.lineTo(iSi * 0.5, iSi);
  511. c.close();
  512. c.fillAndStroke();
  513. //refresh
  514. c.begin();
  515. c.translate(30, 0);
  516. c.moveTo(iSi * 0.78, iSi * 0.665);
  517. c.arcTo(iSi * 0.3, iSi * 0.3, 0, 1, 1, iSi * 0.675, iSi * 0.252);
  518. c.lineTo(iSi * 0.595, iSi * 0.325);
  519. c.lineTo(iSi * 0.99, iSi * 0.415);
  520. c.lineTo(iSi * 0.9, iSi * 0.04);
  521. c.lineTo(iSi * 0.815, iSi * 0.12);
  522. c.arcTo(iSi * 0.49, iSi * 0.49, 0, 1, 0, iSi * 0.92, iSi * 0.8);
  523. c.close();
  524. c.fillAndStroke();
  525. };
  526. mxCellRenderer.registerShape(mxShapeMockupBrowserWindow.prototype.cst.SHAPE_BROWSER_WINDOW, mxShapeMockupBrowserWindow);
  527. //**********************************************************************************************************************************************************
  528. //User, Male
  529. //**********************************************************************************************************************************************************
  530. /**
  531. * Extends mxShape.
  532. */
  533. function mxShapeMockupUserMale(bounds, fill, stroke, strokewidth)
  534. {
  535. mxShape.call(this);
  536. this.bounds = bounds;
  537. this.fill = fill;
  538. this.stroke = stroke;
  539. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  540. };
  541. /**
  542. * Extends mxShape.
  543. */
  544. mxUtils.extend(mxShapeMockupUserMale, mxShape);
  545. mxShapeMockupUserMale.prototype.cst = {
  546. STROKE_COLOR2 : 'strokeColor2',
  547. SHAPE_MALE_USER : 'mxgraph.mockup.containers.userMale'
  548. };
  549. mxShapeMockupUserMale.prototype.customProperties = [
  550. {name: 'strokeColor2', dispName: 'Stroke2 Color', type: 'color'}
  551. ];
  552. /**
  553. * Function: paintVertexShape
  554. *
  555. * Paints the vertex shape.
  556. */
  557. mxShapeMockupUserMale.prototype.paintVertexShape = function(c, x, y, w, h)
  558. {
  559. var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  560. var frameColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#666666');
  561. var insideColor = mxUtils.getValue(this.style, mxShapeMockupUserMale.prototype.cst.STROKE_COLOR2, '#008cff');
  562. c.translate(x, y);
  563. this.background(c, x, y, w, h, bgColor, frameColor);
  564. c.setShadow(false);
  565. this.otherShapes(c, x, y, w, h, insideColor, frameColor);
  566. };
  567. mxShapeMockupUserMale.prototype.background = function(c, x, y, w, h, bgColor, frameColor)
  568. {
  569. c.setFillColor(bgColor);
  570. c.setStrokeColor(frameColor);
  571. c.begin();
  572. c.moveTo(0, 0);
  573. c.lineTo(w, 0);
  574. c.lineTo(w, h);
  575. c.lineTo(0, h);
  576. c.close();
  577. c.fillAndStroke();
  578. };
  579. mxShapeMockupUserMale.prototype.otherShapes = function(c, x, y, w, h, insideColor, frameColor)
  580. {
  581. //head left
  582. c.setStrokeColor(insideColor);
  583. c.setLineCap('round');
  584. c.setLineJoin('round');
  585. c.begin();
  586. c.moveTo(w * 0.5, h * 0.6721);
  587. c.curveTo(w * 0.3891, h * 0.6721, w * 0.31, h * 0.5648, w * 0.31, h * 0.3962);
  588. c.curveTo(w * 0.31, h * 0.3656, w * 0.3012, h * 0.3473, w * 0.3051, h * 0.3227);
  589. c.curveTo(w * 0.3126, h * 0.2762, w * 0.3124, h * 0.2212, w * 0.332, h * 0.1939);
  590. c.curveTo(w * 0.354, h * 0.1633, w * 0.4382, h * 0.12, w * 0.5, h * 0.12);
  591. c.stroke();
  592. //left ear
  593. c.begin();
  594. c.moveTo(w * 0.3046, h * 0.3716);
  595. c.curveTo(w * 0.3046, h * 0.3716, w * 0.3046, h * 0.341, w * 0.2826, h * 0.3594);
  596. c.curveTo(w * 0.2606, h * 0.3778, w * 0.2661, h * 0.4452, w * 0.266, h * 0.4452);
  597. c.quadTo(w * 0.2715, h * 0.4942, w * 0.277, h * 0.5065);
  598. c.curveTo(w * 0.2825, h * 0.5187, w * 0.277, h * 0.5187, w * 0.2935, h * 0.5371);
  599. c.curveTo(w * 0.31, h * 0.5554, w * 0.3375, h * 0.5615, w * 0.3375, h * 0.5616);
  600. c.stroke();
  601. // left shoulder
  602. c.begin();
  603. c.moveTo(w * 0.3829, h * 0.6213);
  604. c.curveTo(w * 0.3829, h * 0.6213, w * 0.405, h * 0.7704, w * 0.2921, h * 0.7888);
  605. c.curveTo(w * 0.2536, h * 0.795, w * 0.1328, h * 0.85, w * 0.1052, h * 0.8745);
  606. c.curveTo(w * 0.0776, h * 0.899, w * 0.0641, h * 0.9316, w * 0.0571, h * 0.9622);
  607. c.quadTo(w * 0.05, h, w * 0.05, h);
  608. c.stroke();
  609. // left hairline
  610. c.begin();
  611. c.moveTo(w * 0.3427, h * 0.4185);
  612. c.curveTo(w * 0.3427, h * 0.4185, w * 0.3427, h * 0.3839, w * 0.3427, h * 0.3593);
  613. c.curveTo(w * 0.3427, h * 0.3348, w * 0.3663, h * 0.3103, w * 0.3718, h * 0.3041);
  614. c.curveTo(w * 0.3773, h * 0.298, w * 0.3822, h * 0.2673, w * 0.3877, h * 0.2551);
  615. c.curveTo(w * 0.3932, h * 0.2429, w * 0.4095, h * 0.2429, w * 0.4259, h * 0.2367);
  616. c.curveTo(w * 0.4424, h * 0.2306, w * 0.4984, h * 0.2357, w * 0.4984, h * 0.2357);
  617. c.stroke();
  618. //shirt
  619. c.begin();
  620. c.moveTo(w * 0.365, h * 0.7427);
  621. c.curveTo(w * 0.365, h * 0.7427, w * 0.3772, h * 0.8076, w * 0.4286, h * 0.8224);
  622. c.curveTo(w * 0.4816, h * 0.8377, w * 0.5028, h * 0.8347, w * 0.5028, h * 0.8347);
  623. c.stroke();
  624. c.begin();
  625. c.moveTo(w * 0.3322, h * 0.7764);
  626. c.curveTo(w * 0.3322, h * 0.7764, w * 0.3556, h * 0.8386, w * 0.4038, h * 0.8684);
  627. c.curveTo(w * 0.4533, h * 0.8991, w * 0.5029, h * 0.8929, w * 0.5029, h * 0.8929);
  628. c.stroke();
  629. c.begin();
  630. c.moveTo(w * 0.2717, h * 0.9);
  631. c.lineTo(w * 0.2717, h);
  632. c.stroke();
  633. c.begin();
  634. c.moveTo(w * 0.1671, h * 0.8991);
  635. c.curveTo(w * 0.1671, h * 0.8991, w * 0.1726, h * 0.9114, w * 0.1836, h * 0.9481);
  636. c.curveTo(w * 0.1946, h * 0.9849, w * 0.2, h, w * 0.2, h);
  637. c.stroke();
  638. //head right
  639. c.begin();
  640. c.moveTo(w * 0.5, h * 0.6721);
  641. c.curveTo(w * 0.6109, h * 0.6721, w * 0.69, h * 0.5648, w * 0.69, h * 0.3962);
  642. c.curveTo(w * 0.69, h * 0.3656, w * 0.6988, h * 0.3473, w * 0.6949, h * 0.3227);
  643. c.curveTo(w * 0.6847, h * 0.2762, w * 0.6876, h * 0.2212, w * 0.668, h * 0.1939);
  644. c.curveTo(w * 0.646, h * 0.1633, w * 0.5618, h * 0.12, w * 0.5, h * 0.12);
  645. c.stroke();
  646. //right ear
  647. c.begin();
  648. c.moveTo(w * 0.6954, h * 0.3716);
  649. c.curveTo(w * 0.6954, h * 0.3716, w * 0.6954, h * 0.341, w * 0.7174, h * 0.3594);
  650. c.curveTo(w * 0.7394, h * 0.3778, w * 0.7339, h * 0.4452, w * 0.734, h * 0.4452);
  651. c.quadTo(w * 0.7285, h * 0.4942, w * 0.723, h * 0.5065);
  652. c.curveTo(w * 0.7175, h * 0.5187, w * 0.723, h * 0.5187, w * 0.7065, h * 0.5371);
  653. c.curveTo(w * 0.69, h * 0.5554, w * 0.6625, h * 0.5615, w * 0.6625, h * 0.5616);
  654. c.stroke();
  655. // right shoulder
  656. c.begin();
  657. c.moveTo(w * 0.6171, h * 0.6213);
  658. c.curveTo(w * 0.6171, h * 0.6213, w * 0.595, h * 0.7704, w * 0.7079, h * 0.7888);
  659. c.curveTo(w * 0.7464, h * 0.795, w * 0.8672, h * 0.85, w * 0.8948, h * 0.8745);
  660. c.curveTo(w * 0.9224, h * 0.899, w * 0.9359, h * 0.9316, w * 0.9429, h * 0.9622);
  661. c.quadTo(w * 0.95, h, w * 0.95, h);
  662. c.stroke();
  663. // right hairline
  664. c.begin();
  665. c.moveTo(w * 0.6573, h * 0.4185);
  666. c.curveTo(w * 0.6573, h * 0.4185, w * 0.6573, h * 0.3839, w * 0.6573, h * 0.3593);
  667. c.curveTo(w * 0.6573, h * 0.3348, w * 0.6337, h * 0.3103, w * 0.6282, h * 0.3041);
  668. c.curveTo(w * 0.6227, h * 0.298, w * 0.6178, h * 0.2673, w * 0.6123, h * 0.2551);
  669. c.curveTo(w * 0.6068, h * 0.2429, w * 0.5905, h * 0.2429, w * 0.5741, h * 0.2367);
  670. c.curveTo(w * 0.5576, h * 0.2306, w * 0.5016, h * 0.2357, w * 0.5016, h * 0.2357);
  671. c.stroke();
  672. //shirt, right
  673. c.begin();
  674. c.moveTo(w * 0.635, h * 0.7427);
  675. c.curveTo(w * 0.635, h * 0.7427, w * 0.6228, h * 0.8076, w * 0.5714, h * 0.8224);
  676. c.curveTo(w * 0.5184, h * 0.8377, w * 0.4972, h * 0.8347, w * 0.4972, h * 0.8347);
  677. c.stroke();
  678. c.begin();
  679. c.moveTo(w * 0.6678, h * 0.7764);
  680. c.curveTo(w * 0.6678, h * 0.7764, w * 0.6444, h * 0.8386, w * 0.5962, h * 0.8684);
  681. c.curveTo(w * 0.5467, h * 0.8991, w * 0.4971, h * 0.8929, w * 0.4971, h * 0.8929);
  682. c.stroke();
  683. c.begin();
  684. c.moveTo(w * 0.7283, h * 0.9);
  685. c.lineTo(w * 0.7283, h);
  686. c.stroke();
  687. c.begin();
  688. c.moveTo(w * 0.8329, h * 0.8991);
  689. c.curveTo(w * 0.8329, h * 0.8991, w * 0.8274, h * 0.9114, w * 0.8164, h * 0.9481);
  690. c.curveTo(w * 0.8054, h * 0.9849, w * 0.8, h, w * 0.8, h);
  691. c.stroke();
  692. c.setStrokeColor(frameColor);
  693. c.begin();
  694. c.moveTo(0, 0);
  695. c.lineTo(w, 0);
  696. c.lineTo(w, h);
  697. c.lineTo(0, h);
  698. c.close();
  699. c.stroke();
  700. };
  701. mxCellRenderer.registerShape(mxShapeMockupUserMale.prototype.cst.SHAPE_MALE_USER, mxShapeMockupUserMale);
  702. //**********************************************************************************************************************************************************
  703. //User, Female
  704. //**********************************************************************************************************************************************************
  705. /**
  706. * Extends mxShape.
  707. */
  708. function mxShapeMockupUserFemale(bounds, fill, stroke, strokewidth)
  709. {
  710. mxShape.call(this);
  711. this.bounds = bounds;
  712. this.fill = fill;
  713. this.stroke = stroke;
  714. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  715. };
  716. /**
  717. * Extends mxShape.
  718. */
  719. mxUtils.extend(mxShapeMockupUserFemale, mxShape);
  720. mxShapeMockupUserFemale.prototype.cst = {
  721. STROKE_COLOR2 : 'strokeColor2',
  722. SHAPE_FEMALE_USER : 'mxgraph.mockup.containers.userFemale'
  723. };
  724. mxShapeMockupUserFemale.prototype.customProperties = [
  725. {name: 'strokeColor2', dispName: 'Stroke2 Color', type: 'color'}
  726. ];
  727. /**
  728. * Function: paintVertexShape
  729. *
  730. * Paints the vertex shape.
  731. */
  732. mxShapeMockupUserFemale.prototype.paintVertexShape = function(c, x, y, w, h)
  733. {
  734. var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  735. var frameColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#666666');
  736. var insideColor = mxUtils.getValue(this.style, mxShapeMockupUserFemale.prototype.cst.STROKE_COLOR2, '#008cff');
  737. c.translate(x, y);
  738. this.background(c, x, y, w, h, bgColor, frameColor);
  739. c.setShadow(false);
  740. this.otherShapes(c, x, y, w, h, insideColor, frameColor);
  741. };
  742. mxShapeMockupUserFemale.prototype.background = function(c, x, y, w, h, bgColor, frameColor)
  743. {
  744. c.setFillColor(bgColor);
  745. c.setStrokeColor(frameColor);
  746. c.begin();
  747. c.moveTo(0, 0);
  748. c.lineTo(w, 0);
  749. c.lineTo(w, h);
  750. c.lineTo(0, h);
  751. c.close();
  752. c.fillAndStroke();
  753. };
  754. mxShapeMockupUserFemale.prototype.otherShapes = function(c, x, y, w, h, insideColor, frameColor)
  755. {
  756. //head left
  757. c.setStrokeColor(insideColor);
  758. c.setLineCap('round');
  759. c.setLineJoin('round');
  760. c.begin();
  761. c.moveTo(w * 0.3148, h * 0.468);
  762. c.curveTo(w * 0.3045, h * 0.3195, w * 0.3176, h * 0.2383, w * 0.3302, h * 0.2069);
  763. c.curveTo(w * 0.3508, h * 0.1557, w * 0.44, h * 0.1156, w * 0.5026, h * 0.1156);
  764. c.stroke();
  765. c.begin();
  766. c.moveTo(w * 0.5029, h * 0.6728);
  767. c.curveTo(w * 0.4616, h * 0.6728, w * 0.4018, h * 0.6177, w * 0.3663, h * 0.5653);
  768. c.stroke();
  769. c.begin();
  770. c.moveTo(w * 0.3108, h * 0.4021);
  771. c.curveTo(w * 0.3108, h * 0.4021, w * 0.3091, h * 0.3765, w * 0.2891, h * 0.3933);
  772. c.curveTo(w * 0.2691, h * 0.4101, w * 0.2782, h * 0.4661, w * 0.2782, h * 0.4661);
  773. c.quadTo(w * 0.2862, h * 0.5067, w * 0.2922, h * 0.5166);
  774. c.curveTo(w * 0.2982, h * 0.5265, w * 0.2929, h * 0.5268, w * 0.3097, h * 0.5412);
  775. c.stroke();
  776. c.begin();
  777. c.moveTo(w * 0.4038, h * 0.6176);
  778. c.curveTo(w * 0.4038, h * 0.6176, w * 0.4324, h * 0.7778, w * 0.3375, h * 0.7963);
  779. c.curveTo(w * 0.3054, h * 0.8026, w * 0.1753, h * 0.8578, w * 0.15, h * 0.8826);
  780. c.curveTo(w * 0.1247, h * 0.9074, w * 0.1126, h * 0.9412, w * 0.1063, h * 0.9722);
  781. c.curveTo(w * 0.10, h * 1.0032, w * 0.1, h, w * 0.1, h);
  782. c.stroke();
  783. c.begin();
  784. c.moveTo(w * 0.6377, h * 0.3365);
  785. c.curveTo(w * 0.5927, h * 0.2634, w * 0.5206, h * 0.2634, w * 0.5206, h * 0.2634);
  786. c.quadTo(w * 0.3769, h * 0.2591, w * 0.3713, h * 0.2659);
  787. c.curveTo(w * 0.3657, h * 0.2727, w * 0.3405, h * 0.3674, w * 0.3405, h * 0.3946);
  788. c.curveTo(w * 0.3405, h * 0.4218, w * 0.3405, h * 0.4602, w * 0.3405, h * 0.4602);
  789. c.quadTo(w * 0.3546, h * 0.6401, w * 0.3546, h * 0.6626);
  790. c.stroke();
  791. c.begin();
  792. c.moveTo(w * 0.2931, h * 0.818);
  793. c.curveTo(w * 0.2931, h * 0.818, w * 0.3224, h * 0.9159, w * 0.3826, h * 0.9677);
  794. c.curveTo(w * 0.4446, h * 1.01, w * 0.5065, h, w * 0.5065, h);
  795. c.stroke();
  796. c.begin();
  797. c.moveTo(w * 0.2995, h * 0.9106);
  798. c.lineTo(w * 0.2995, h);
  799. c.stroke();
  800. c.begin();
  801. c.moveTo(w * 0.2081, h * 0.907);
  802. c.curveTo(w * 0.2081, h * 0.907, w * 0.2131, h * 0.9194, w * 0.2232, h * 0.9565);
  803. c.curveTo(w * 0.2333, h * 0.9936, w * 0.24, h, w * 0.24, h);
  804. c.stroke();
  805. c.begin();
  806. c.moveTo(w * 0.6951, h * 0.4988);
  807. c.curveTo(w * 0.6951, h * 0.4662, w * 0.7042, h * 0.3453, w * 0.7, h * 0.32);
  808. c.curveTo(w * 0.6923, h * 0.273, w * 0.6926, h * 0.2175, w * 0.6727, h * 0.19);
  809. c.curveTo(w * 0.6504, h * 0.159, w * 0.5651, h * 0.1157, w * 0.5025, h * 0.1157);
  810. c.stroke();
  811. c.begin();
  812. c.moveTo(w * 0.5029, h * 0.6728);
  813. c.curveTo(w * 0.5546, h * 0.6728, w * 0.6107, h * 0.6316, w * 0.6461, h * 0.5602);
  814. c.stroke();
  815. c.begin();
  816. c.moveTo(w * 0.696, h * 0.4022);
  817. c.curveTo(w * 0.696, h * 0.4022, w * 0.6983, h * 0.3766, w * 0.7179, h * 0.4106);
  818. c.curveTo(w * 0.7375, h * 0.4278, w * 0.7273, h * 0.4836, w * 0.7273, h * 0.4836);
  819. c.quadTo(w * 0.7184, h * 0.5241, w * 0.7123, h * 0.5338);
  820. c.curveTo(w * 0.7062, h * 0.5436, w * 0.7114, h * 0.544, w * 0.6943, h * 0.558);
  821. c.stroke();
  822. c.begin();
  823. c.moveTo(w * 0.5995, h * 0.6278);
  824. c.curveTo(w * 0.5995, h * 0.6278, w * 0.5724, h * 0.7777, w * 0.6663, h * 0.7963);
  825. c.curveTo(w * 0.6984, h * 0.8026, w * 0.8386, h * 0.8578, w * 0.8638, h * 0.8826);
  826. c.curveTo(w * 0.8891, h * 0.9074, w * 0.9016, h * 0.9412, w * 0.9079, h * 0.9722);
  827. c.curveTo(w * 0.9142, h * 1.0032, w * 0.91, h, w * 0.91, h);
  828. c.stroke();
  829. c.begin();
  830. c.moveTo(w * 0.6545, h * 0.6802);
  831. c.lineTo(w * 0.6545, h * 0.3986);
  832. c.stroke();
  833. c.begin();
  834. c.moveTo(w * 0.7132, h * 0.8078);
  835. c.curveTo(w * 0.7132, h * 0.8078, w * 0.6839, h * 0.916, w * 0.6237, h * 0.9678);
  836. c.curveTo(w * 0.5617, h * 1.01, w * 0.4998, h, w * 0.4998, h);
  837. c.stroke();
  838. c.begin();
  839. c.moveTo(w * 0.7111, h * 0.9106);
  840. c.lineTo(w * 0.7111, h);
  841. c.stroke();
  842. c.begin();
  843. c.moveTo(w * 0.8075, h * 0.907);
  844. c.curveTo(w * 0.8075, h * 0.907, w * 0.8025, h * 0.9194, w * 0.7924, h * 0.9565);
  845. c.curveTo(w * 0.7823, h * 0.9936, w * 0.775, h, w * 0.775, h);
  846. c.stroke();
  847. c.begin();
  848. c.moveTo(w * 0.3148, h * 0.5448);
  849. c.curveTo(w * 0.3148, h * 0.5448, w * 0.32, h * 0.6216, w * 0.3148, h * 0.6677);
  850. c.quadTo(w * 0.2891, h * 0.7343, w * 0.2891, h * 0.7343);
  851. c.lineTo(w * 0.3303, h * 0.7625);
  852. c.lineTo(w * 0.39, h * 0.7625);
  853. c.stroke();
  854. c.begin();
  855. c.moveTo(w * 0.6852, h * 0.5448);
  856. c.curveTo(w * 0.6852, h * 0.5448, w * 0.68, h * 0.6216, w * 0.6852, h * 0.6677);
  857. c.quadTo(w * 0.7109, h * 0.7343, w * 0.7109, h * 0.7343);
  858. c.lineTo(w * 0.6697, h * 0.7625);
  859. c.lineTo(w * 0.62, h * 0.7625);
  860. c.stroke();
  861. c.setStrokeColor(frameColor);
  862. c.begin();
  863. c.moveTo(0, 0);
  864. c.lineTo(w, 0);
  865. c.lineTo(w, h);
  866. c.lineTo(0, h);
  867. c.close();
  868. c.stroke();
  869. };
  870. mxCellRenderer.registerShape(mxShapeMockupUserFemale.prototype.cst.SHAPE_FEMALE_USER, mxShapeMockupUserFemale);
  871. //**********************************************************************************************************************************************************
  872. //Group
  873. //**********************************************************************************************************************************************************
  874. /**
  875. * Extends mxShape.
  876. */
  877. function mxShapeMockupGroup(bounds, fill, stroke, strokewidth)
  878. {
  879. mxShape.call(this);
  880. this.bounds = bounds;
  881. this.fill = fill;
  882. this.stroke = stroke;
  883. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  884. };
  885. /**
  886. * Extends mxShape.
  887. */
  888. mxUtils.extend(mxShapeMockupGroup, mxShape);
  889. mxShapeMockupGroup.prototype.cst = {
  890. MAIN_TEXT : 'mainText',
  891. TEXT_SIZE : 'textSize',
  892. TEXT_COLOR : 'textColor',
  893. FILL_COLOR2 : 'fillColor2',
  894. SHAPE_GROUP : 'mxgraph.mockup.containers.group'
  895. };
  896. /**
  897. * Function: paintVertexShape
  898. *
  899. * Paints the vertex shape.
  900. */
  901. mxShapeMockupGroup.prototype.paintVertexShape = function(c, x, y, w, h)
  902. {
  903. var groupString = mxUtils.getValue(this.style, mxShapeMockupGroup.prototype.cst.MAIN_TEXT, 'Group').toString();
  904. var fontSize = mxUtils.getValue(this.style, mxShapeMockupGroup.prototype.cst.TEXT_SIZE, '17');
  905. var textWidth = mxUtils.getSizeForString(groupString, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  906. if (textWidth === 0)
  907. {
  908. textWidth = Math.max(80, textWidth);
  909. }
  910. c.translate(x, y);
  911. w = Math.max(w, textWidth + 15);
  912. h = Math.max(h, fontSize + 10);
  913. this.background(c, w, h, textWidth, fontSize);
  914. c.setShadow(false);
  915. this.foreground(c, w, h, textWidth, fontSize);
  916. this.buttonText(c, w, h, groupString, fontSize);
  917. };
  918. mxShapeMockupGroup.prototype.background = function(c, w, h, textWidth, fontSize)
  919. {
  920. c.roundrect(0, fontSize * 0.5, w, h - fontSize * 0.5, 5, 5);
  921. c.fillAndStroke();
  922. };
  923. mxShapeMockupGroup.prototype.foreground = function(c, w, h, textWidth, fontSize)
  924. {
  925. var fillColor = mxUtils.getValue(this.style, mxShapeMockupGroup.prototype.cst.FILL_COLOR2, '#000000');
  926. c.setFillColor(fillColor);
  927. c.roundrect(3, 0, textWidth + 6, fontSize * 1.5, fontSize * 0.25, fontSize * 0.25);
  928. c.fill();
  929. };
  930. mxShapeMockupGroup.prototype.buttonText = function(c, w, h, textString, fontSize)
  931. {
  932. var fontColor = mxUtils.getValue(this.style, mxShapeMockupGroup.prototype.cst.TEXT_COLOR, '#ffffff');
  933. c.setFontColor(fontColor);
  934. c.setFontSize(fontSize);
  935. c.text(6, 0, 0, 0, textString, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_TOP, 0, null, 0, 0, 0);
  936. };
  937. mxCellRenderer.registerShape(mxShapeMockupGroup.prototype.cst.SHAPE_GROUP, mxShapeMockupGroup);
  938. //**********************************************************************************************************************************************************
  939. //Window
  940. //**********************************************************************************************************************************************************
  941. /**
  942. * Extends mxShape.
  943. */
  944. function mxShapeMockupWindow(bounds, fill, stroke, strokewidth)
  945. {
  946. mxShape.call(this);
  947. this.bounds = bounds;
  948. this.fill = fill;
  949. this.stroke = stroke;
  950. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  951. };
  952. /**
  953. * Extends mxShape.
  954. */
  955. mxUtils.extend(mxShapeMockupWindow, mxShape);
  956. mxShapeMockupWindow.prototype.cst = {
  957. MAIN_TEXT : 'mainText',
  958. TEXT_SIZE : 'textSize',
  959. TEXT_COLOR : 'textColor',
  960. STROKE_COLOR2 : 'strokeColor2',
  961. STROKE_COLOR3 : 'strokeColor3',
  962. SHAPE_WINDOW : 'mxgraph.mockup.containers.window'
  963. };
  964. mxShapeMockupWindow.prototype.customProperties = [
  965. {name: 'strokeColor2', dispName: 'Stroke2 Color', type: 'color'},
  966. {name: 'strokeColor3', dispName: 'Stroke3 Color', type: 'color'}
  967. ];
  968. /**
  969. * Function: paintVertexShape
  970. *
  971. * Paints the vertex shape.
  972. */
  973. mxShapeMockupWindow.prototype.paintVertexShape = function(c, x, y, w, h)
  974. {
  975. var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  976. var frameColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#666666');
  977. var closeColor = mxUtils.getValue(this.style, mxShapeMockupWindow.prototype.cst.STROKE_COLOR2, '#008cff');
  978. var insideColor = mxUtils.getValue(this.style, mxShapeMockupWindow.prototype.cst.STROKE_COLOR3, '#c4c4c4');
  979. c.translate(x, y);
  980. h = Math.max(h, 30);
  981. w = Math.max(w, 90);
  982. this.background(c, x, y, w, h, bgColor, frameColor);
  983. c.setShadow(false);
  984. this.otherShapes(c, x, y, w, h, frameColor, insideColor, closeColor);
  985. };
  986. mxShapeMockupWindow.prototype.background = function(c, x, y, w, h, bgColor, frameColor)
  987. {
  988. c.setFillColor(bgColor);
  989. c.setStrokeColor(frameColor);
  990. c.rect(0, 0, w, h);
  991. c.fillAndStroke();
  992. };
  993. mxShapeMockupWindow.prototype.otherShapes = function(c, x, y, w, h, frameColor, insideColor, closeColor)
  994. {
  995. var strokeWidth = mxUtils.getValue(this.style, mxConstants.STYLE_STROKEWIDTH, '1');
  996. //window buttons
  997. c.setStrokeColor(frameColor);
  998. c.ellipse(w - 75, 5, 20, 20);
  999. c.stroke();
  1000. c.ellipse(w - 50, 5, 20, 20);
  1001. c.stroke();
  1002. c.setStrokeColor(closeColor);
  1003. c.ellipse(w - 25, 5, 20, 20);
  1004. c.stroke();
  1005. c.setStrokeColor(insideColor);
  1006. //lines
  1007. c.begin();
  1008. c.moveTo(0, 30);
  1009. c.lineTo(w, 30);
  1010. c.stroke();
  1011. //text
  1012. var windowTitle = mxUtils.getValue(this.style, mxShapeMockupWindow.prototype.cst.MAIN_TEXT, 'Window Title');
  1013. var fontColor = mxUtils.getValue(this.style, mxShapeMockupWindow.prototype.cst.TEXT_COLOR, '#666666');
  1014. var fontSize = mxUtils.getValue(this.style, mxShapeMockupWindow.prototype.cst.TEXT_SIZE, '17').toString();
  1015. c.setFontColor(fontColor);
  1016. c.setFontSize(fontSize);
  1017. c.text(10, 15, 0, 0, windowTitle, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1018. c.stroke();
  1019. };
  1020. mxCellRenderer.registerShape(mxShapeMockupWindow.prototype.cst.SHAPE_WINDOW, mxShapeMockupWindow);
  1021. //**********************************************************************************************************************************************************
  1022. //Horizontal Tab Bar (LEGACY)
  1023. //**********************************************************************************************************************************************************
  1024. /**
  1025. * Extends mxShape.
  1026. */
  1027. function mxShapeMockupHorTabBar(bounds, fill, stroke, strokewidth)
  1028. {
  1029. mxShape.call(this);
  1030. this.bounds = bounds;
  1031. this.fill = fill;
  1032. this.stroke = stroke;
  1033. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1034. };
  1035. /**
  1036. * Extends mxShape.
  1037. */
  1038. mxUtils.extend(mxShapeMockupHorTabBar, mxShape);
  1039. mxShapeMockupHorTabBar.prototype.cst = {
  1040. BLOCK : 'block',
  1041. CONE : 'cone',
  1042. HALF_CONE : 'halfCone',
  1043. ROUND : 'round',
  1044. TEXT_SIZE : 'textSize',
  1045. TAB_NAMES : 'tabs',
  1046. TAB_STYLE : 'tabStyle',
  1047. STYLE_FILLCOLOR2 : 'fillColor2',
  1048. TEXT_COLOR : 'textColor',
  1049. SEL_TEXT_COLOR : 'textColor2',
  1050. SHAPE_HOR_TAB_BAR : 'mxgraph.mockup.containers.horTabBar'
  1051. };
  1052. /**
  1053. * Function: paintVertexShape
  1054. *
  1055. * Paints the vertex shape.
  1056. */
  1057. //TODO tab widths are fixed, so tab text length is a bit of an issue. Cannot be fixed while we use labels for tab names
  1058. mxShapeMockupHorTabBar.prototype.paintVertexShape = function(c, x, y, w, h)
  1059. {
  1060. var fontSize = mxUtils.getValue(this.style, mxShapeMockupHorTabBar.prototype.cst.TEXT_SIZE, '17').toString();
  1061. var tabNames = mxUtils.getValue(this.style, mxShapeMockupHorTabBar.prototype.cst.TAB_NAMES, 'Tab 1,+Tab 2,Tab 3').toString().split(',');
  1062. var tabH = fontSize * 1.5;
  1063. var startOffset = 10;
  1064. var tabOffset = 5;
  1065. var labelOffset = 10;
  1066. var tabCount = tabNames.length;
  1067. var minW = 2 * startOffset + (tabCount - 1) * tabOffset + tabCount * 2 * labelOffset;
  1068. var rSize = 5;
  1069. var labelWidths = new Array();
  1070. var selectedTab = -1;
  1071. for (var i = 0; i < tabCount; i++)
  1072. {
  1073. var currLabel = tabNames[i];
  1074. if(currLabel.charAt(0) === '+')
  1075. {
  1076. currLabel = currLabel.substring(1);
  1077. selectedTab = i;
  1078. }
  1079. currW = mxUtils.getSizeForString(currLabel, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  1080. if (currW === 0)
  1081. {
  1082. labelWidths[i] = 40;
  1083. }
  1084. else
  1085. {
  1086. labelWidths[i] = currW;
  1087. };
  1088. minW = minW + labelWidths[i];
  1089. }
  1090. w = Math.max(w, minW);
  1091. h = Math.max(h, tabH + rSize);
  1092. c.translate(x, y);
  1093. this.background(c, w, h, rSize, tabH);
  1094. c.setShadow(false);
  1095. this.backTabs(c, w, h, rSize, tabH, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab);
  1096. this.focusTab(c, w, h, rSize, tabH, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab);
  1097. this.tabText(c, w, h, rSize, tabH, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab, tabNames);
  1098. };
  1099. mxShapeMockupHorTabBar.prototype.background = function(c, w, h, rSize, tabH)
  1100. {
  1101. c.begin();
  1102. c.moveTo(0, tabH + rSize);
  1103. c.arcTo(rSize, rSize, 0, 0, 1, rSize, tabH);
  1104. c.lineTo(w - rSize, tabH);
  1105. c.arcTo(rSize, rSize, 0, 0, 1, w, tabH + rSize);
  1106. c.lineTo(w, h);
  1107. c.lineTo(0, h);
  1108. c.close();
  1109. c.fillAndStroke();
  1110. };
  1111. mxShapeMockupHorTabBar.prototype.backTabs = function(c, w, h, rSize, tabH, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab)
  1112. {
  1113. var tabStyle = mxUtils.getValue(this.style, mxShapeMockupHorTabBar.prototype.cst.TAB_STYLE, mxShapeMockupHorTabBar.prototype.cst.BLOCK);
  1114. var currW = startOffset;
  1115. for (var i=0; i < tabCount; i++)
  1116. {
  1117. var tabW = labelWidths[i] + 2 * labelOffset;
  1118. if (selectedTab !== i)
  1119. {
  1120. if (tabStyle === mxShapeMockupHorTabBar.prototype.cst.BLOCK)
  1121. {
  1122. c.rect(currW, 0, tabW, tabH);
  1123. }
  1124. else if (tabStyle === mxShapeMockupHorTabBar.prototype.cst.CONE)
  1125. {
  1126. c.begin();
  1127. c.moveTo(currW, tabH);
  1128. c.lineTo(currW + labelOffset * 0.5, 0);
  1129. c.lineTo(currW + tabW - labelOffset * 0.5, 0);
  1130. c.lineTo(currW + tabW, tabH);
  1131. }
  1132. else if (tabStyle === mxShapeMockupHorTabBar.prototype.cst.HALF_CONE)
  1133. {
  1134. c.begin();
  1135. c.moveTo(currW, tabH);
  1136. c.lineTo(currW + labelOffset * 0.5, 0);
  1137. c.lineTo(currW + tabW, 0);
  1138. c.lineTo(currW + tabW, tabH);
  1139. }
  1140. else if (tabStyle === mxShapeMockupHorTabBar.prototype.cst.ROUND)
  1141. {
  1142. c.begin();
  1143. c.moveTo(currW - rSize, tabH);
  1144. c.arcTo(rSize, rSize, 0, 0, 0, currW, tabH - rSize);
  1145. c.lineTo(currW, rSize);
  1146. c.arcTo(rSize, rSize, 0, 0, 1, currW + rSize, 0);
  1147. c.lineTo(currW + tabW - rSize, 0);
  1148. c.arcTo(rSize, rSize, 0, 0, 1, currW + tabW, rSize);
  1149. c.lineTo(currW + tabW, tabH - rSize);
  1150. c.arcTo(rSize, rSize, 0, 0, 0, currW + tabW + rSize, tabH);
  1151. }
  1152. c.fillAndStroke();
  1153. }
  1154. currW = currW + tabW + tabOffset;
  1155. }
  1156. };
  1157. mxShapeMockupHorTabBar.prototype.focusTab = function(c, w, h, rSize, tabH, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab)
  1158. {
  1159. var tabStyle = mxUtils.getValue(this.style, mxShapeMockupHorTabBar.prototype.cst.TAB_STYLE, mxShapeMockupHorTabBar.prototype.cst.BLOCK);
  1160. var selectedFill = mxUtils.getValue(this.style, mxShapeMockupHorTabBar.prototype.cst.STYLE_FILLCOLOR2, '#008cff');
  1161. var currW = startOffset;
  1162. c.setStrokeColor(selectedFill);
  1163. c.setFillColor(selectedFill);
  1164. for (var i=0; i <= selectedTab; i++)
  1165. {
  1166. var tabW = labelWidths[i] + 2 * labelOffset;
  1167. if (selectedTab === i)
  1168. {
  1169. if (tabStyle === mxShapeMockupHorTabBar.prototype.cst.BLOCK)
  1170. {
  1171. c.begin();
  1172. c.moveTo(0, tabH + rSize);
  1173. c.arcTo(rSize, rSize, 0, 0, 1, rSize, tabH);
  1174. c.lineTo(currW, tabH);
  1175. c.lineTo(currW, 0);
  1176. c.lineTo(currW + tabW, 0);
  1177. c.lineTo(currW + tabW, tabH);
  1178. c.lineTo(w - rSize, tabH);
  1179. c.arcTo(rSize, rSize, 0, 0, 1, w, tabH + rSize);
  1180. c.close();
  1181. }
  1182. else if (tabStyle === mxShapeMockupHorTabBar.prototype.cst.CONE)
  1183. {
  1184. c.begin();
  1185. c.moveTo(0, tabH + rSize);
  1186. c.arcTo(rSize, rSize, 0, 0, 1, rSize, tabH);
  1187. c.lineTo(currW, tabH);
  1188. c.lineTo(currW + labelOffset * 0.5, 0);
  1189. c.lineTo(currW + tabW - labelOffset * 0.5, 0);
  1190. c.lineTo(currW + tabW, tabH);
  1191. c.lineTo(w - rSize, tabH);
  1192. c.arcTo(rSize, rSize, 0, 0, 1, w, tabH + rSize);
  1193. c.close();
  1194. }
  1195. else if (tabStyle === mxShapeMockupHorTabBar.prototype.cst.HALF_CONE)
  1196. {
  1197. c.begin();
  1198. c.moveTo(0, tabH + rSize);
  1199. c.arcTo(rSize, rSize, 0, 0, 1, rSize, tabH);
  1200. c.lineTo(currW, tabH);
  1201. c.lineTo(currW + labelOffset * 0.5, 0);
  1202. c.lineTo(currW + tabW, 0);
  1203. c.lineTo(currW + tabW, tabH);
  1204. c.lineTo(w - rSize, tabH);
  1205. c.arcTo(rSize, rSize, 0, 0, 1, w, tabH + rSize);
  1206. c.close();
  1207. }
  1208. else if (tabStyle === mxShapeMockupHorTabBar.prototype.cst.ROUND)
  1209. {
  1210. c.begin();
  1211. c.moveTo(0, tabH + rSize);
  1212. c.arcTo(rSize, rSize, 0, 0, 1, rSize, tabH);
  1213. c.lineTo(currW - rSize, tabH);
  1214. c.arcTo(rSize, rSize, 0, 0, 0, currW, tabH - rSize);
  1215. c.lineTo(currW, rSize);
  1216. c.arcTo(rSize, rSize, 0, 0, 1, currW + rSize, 0);
  1217. c.lineTo(currW + tabW - rSize, 0);
  1218. c.arcTo(rSize, rSize, 0, 0, 1, currW + tabW, rSize);
  1219. c.lineTo(currW + tabW, tabH - rSize);
  1220. c.arcTo(rSize, rSize, 0, 0, 0, currW + tabW + rSize, tabH);
  1221. c.lineTo(w - rSize, tabH);
  1222. c.arcTo(rSize, rSize, 0, 0, 1, w, tabH + rSize);
  1223. c.close();
  1224. }
  1225. c.fillAndStroke();
  1226. }
  1227. currW = currW + tabW + tabOffset;
  1228. }
  1229. };
  1230. mxShapeMockupHorTabBar.prototype.tabText = function(c, w, h, rSize, tabH, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab, tabNames)
  1231. {
  1232. var fontColor = mxUtils.getValue(this.style, mxShapeMockupHorTabBar.prototype.cst.TEXT_COLOR, '#666666');
  1233. var selFontColor = mxUtils.getValue(this.style, mxShapeMockupHorTabBar.prototype.cst.SEL_TEXT_COLOR, '#ffffff');
  1234. var fontSize = mxUtils.getValue(this.style, mxShapeMockupHorTabBar.prototype.cst.TEXT_SIZE, '17').toString();
  1235. c.setFontColor(fontColor);
  1236. c.setFontSize(fontSize);
  1237. var currW = startOffset;
  1238. for (var i=0; i < tabCount; i++)
  1239. {
  1240. var currLabel = tabNames[i];
  1241. if (i === selectedTab)
  1242. {
  1243. c.setFontColor(selFontColor);
  1244. }
  1245. if (currLabel.charAt(0) === '+')
  1246. {
  1247. currLabel = currLabel.substring(1);
  1248. }
  1249. var tabW = labelWidths[i] + 2 * labelOffset;
  1250. c.text(currW + labelOffset, tabH * 0.5, 0, 0, currLabel, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1251. currW = currW + tabW + tabOffset;
  1252. if (i === selectedTab)
  1253. {
  1254. c.setFontColor(fontColor);
  1255. }
  1256. }
  1257. };
  1258. mxCellRenderer.registerShape(mxShapeMockupHorTabBar.prototype.cst.SHAPE_HOR_TAB_BAR, mxShapeMockupHorTabBar);
  1259. //**********************************************************************************************************************************************************
  1260. //Vertical Tab Bar (LEGACY)
  1261. //**********************************************************************************************************************************************************
  1262. /**
  1263. * Extends mxShape.
  1264. */
  1265. //TODO tab widths are fixed, so tab text length is a bit of an issue. Cannot be fixed while we use labels for tab names
  1266. function mxShapeMockupVerTabBar(bounds, fill, stroke, strokewidth)
  1267. {
  1268. mxShape.call(this);
  1269. this.bounds = bounds;
  1270. this.fill = fill;
  1271. this.stroke = stroke;
  1272. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1273. };
  1274. /**
  1275. * Extends mxShape.
  1276. */
  1277. mxUtils.extend(mxShapeMockupVerTabBar, mxShape);
  1278. mxShapeMockupVerTabBar.prototype.cst = {
  1279. BLOCK : 'block',
  1280. ROUND : 'round',
  1281. TEXT_SIZE : 'textSize',
  1282. TAB_NAMES : 'tabs',
  1283. TAB_STYLE : 'tabStyle',
  1284. STYLE_FILLCOLOR2 : 'fillColor2',
  1285. TEXT_COLOR : 'textColor',
  1286. SEL_TEXT_COLOR : 'textColor2',
  1287. SHAPE_VER_TAB_BAR : 'mxgraph.mockup.containers.verTabBar'
  1288. };
  1289. /**
  1290. * Function: paintVertexShape
  1291. *
  1292. * Paints the vertex shape.
  1293. */
  1294. mxShapeMockupVerTabBar.prototype.paintVertexShape = function(c, x, y, w, h)
  1295. {
  1296. var fontSize = mxUtils.getValue(this.style, mxShapeMockupVerTabBar.prototype.cst.TEXT_SIZE, '17').toString();
  1297. var tabNames = mxUtils.getValue(this.style, mxShapeMockupVerTabBar.prototype.cst.TAB_NAMES, 'Tab 1,+Tab 2,Tab 3').toString().split(',');
  1298. var tabH = fontSize * 1.5;
  1299. var startOffset = 10;
  1300. var tabOffset = 5;
  1301. var labelOffset = 10;
  1302. var tabCount = tabNames.length;
  1303. var rSize = 5;
  1304. var labelWidths = new Array();
  1305. var selectedTab = -1;
  1306. for (var i = 0; i < tabCount; i++)
  1307. {
  1308. var currLabel = tabNames[i];
  1309. if(currLabel.charAt(0) === '+')
  1310. {
  1311. currLabel = currLabel.substring(1);
  1312. selectedTab = i;
  1313. }
  1314. var currW = mxUtils.getSizeForString(currLabel, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  1315. if (currW === 0)
  1316. {
  1317. labelWidths[i] = 42;
  1318. }
  1319. else
  1320. {
  1321. labelWidths[i] = currW;
  1322. }
  1323. }
  1324. var tabW = 2 * labelOffset + Math.max.apply(Math, labelWidths);
  1325. var minW = tabW + rSize;
  1326. w = Math.max(w, minW);
  1327. h = Math.max(h, 2 * startOffset + tabCount * tabH + (tabCount - 1) * tabOffset);
  1328. c.translate(x, y);
  1329. this.background(c, w, h, rSize, tabW);
  1330. c.setShadow(false);
  1331. this.backTabs(c, w, h, rSize, tabH, tabW, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab);
  1332. this.focusTab(c, w, h, rSize, tabH, tabW, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab);
  1333. this.tabText(c, w, h, rSize, tabH, tabW, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab, tabNames);
  1334. };
  1335. mxShapeMockupVerTabBar.prototype.background = function(c, w, h, rSize, tabW)
  1336. {
  1337. c.begin();
  1338. c.moveTo(tabW + rSize, h);
  1339. c.arcTo(rSize, rSize, 0, 0, 1, tabW, h - rSize);
  1340. c.lineTo(tabW, rSize);
  1341. c.arcTo(rSize, rSize, 0, 0, 1, tabW + rSize, 0);
  1342. c.lineTo(w, 0);
  1343. c.lineTo(w, h);
  1344. c.close();
  1345. c.fillAndStroke();
  1346. };
  1347. mxShapeMockupVerTabBar.prototype.backTabs = function(c, w, h, rSize, tabH, tabW, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab)
  1348. {
  1349. var tabStyle = mxUtils.getValue(this.style, mxShapeMockupVerTabBar.prototype.cst.TAB_STYLE, mxShapeMockupVerTabBar.prototype.cst.BLOCK);
  1350. var currH = startOffset;
  1351. for (var i=0; i < tabCount; i++)
  1352. {
  1353. if (selectedTab !== i)
  1354. {
  1355. if (tabStyle === mxShapeMockupVerTabBar.prototype.cst.BLOCK)
  1356. {
  1357. c.rect(0, currH, tabW, tabH);
  1358. }
  1359. else if (tabStyle === mxShapeMockupVerTabBar.prototype.cst.ROUND)
  1360. {
  1361. c.begin();
  1362. c.moveTo(tabW, currH + tabH + rSize);
  1363. c.arcTo(rSize, rSize, 0, 0, 0, tabW - rSize, currH + tabH);
  1364. c.lineTo(rSize, currH + tabH);
  1365. c.arcTo(rSize, rSize, 0, 0, 1, 0, currH + tabH - rSize);
  1366. c.lineTo(0, currH + rSize);
  1367. c.arcTo(rSize, rSize, 0, 0, 1, rSize, currH);
  1368. c.lineTo(tabW - rSize, currH);
  1369. c.arcTo(rSize, rSize, 0, 0, 0, tabW, currH - rSize);
  1370. }
  1371. c.fillAndStroke();
  1372. }
  1373. currH = currH + tabH + tabOffset;
  1374. }
  1375. };
  1376. mxShapeMockupVerTabBar.prototype.focusTab = function(c, w, h, rSize, tabH, tabW, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab)
  1377. {
  1378. var tabStyle = mxUtils.getValue(this.style, mxShapeMockupVerTabBar.prototype.cst.TAB_STYLE, mxShapeMockupVerTabBar.prototype.cst.BLOCK);
  1379. var selectedFill = mxUtils.getValue(this.style, mxShapeMockupVerTabBar.prototype.cst.STYLE_FILLCOLOR2, '#008cff');
  1380. if (selectedTab !== -1)
  1381. {
  1382. var currH = startOffset + (tabH + tabOffset) * selectedTab;
  1383. c.setStrokeColor(selectedFill);
  1384. c.setFillColor(selectedFill);
  1385. if (tabStyle === mxShapeMockupVerTabBar.prototype.cst.BLOCK)
  1386. {
  1387. c.begin();
  1388. c.moveTo(tabW + rSize, h);
  1389. c.arcTo(rSize, rSize, 0, 0, 1, tabW, h - rSize);
  1390. c.lineTo(tabW, currH + tabH);
  1391. c.lineTo(0, currH + tabH);
  1392. c.lineTo(0, currH);
  1393. c.lineTo(tabW, currH);
  1394. c.lineTo(tabW, rSize);
  1395. c.arcTo(rSize, rSize, 0, 0, 1, tabW + rSize, 0);
  1396. c.close();
  1397. }
  1398. else if (tabStyle === mxShapeMockupVerTabBar.prototype.cst.ROUND)
  1399. {
  1400. c.begin();
  1401. c.moveTo(tabW + rSize, h);
  1402. c.arcTo(rSize, rSize, 0, 0, 1, tabW, h - rSize);
  1403. c.lineTo(tabW, currH + tabH + rSize);
  1404. c.arcTo(rSize, rSize, 0, 0, 0, tabW - rSize, currH + tabH);
  1405. c.lineTo(rSize, currH + tabH);
  1406. c.arcTo(rSize, rSize, 0, 0, 1, 0, currH + tabH - rSize);
  1407. c.lineTo(0, currH + rSize);
  1408. c.arcTo(rSize, rSize, 0, 0, 1, rSize, currH);
  1409. c.lineTo(tabW - rSize, currH);
  1410. c.arcTo(rSize, rSize, 0, 0, 0, tabW, currH - rSize);
  1411. c.lineTo(tabW, rSize);
  1412. c.arcTo(rSize, rSize, 0, 0, 1, tabW + rSize, 0);
  1413. c.close();
  1414. }
  1415. c.fillAndStroke();
  1416. }
  1417. };
  1418. mxShapeMockupVerTabBar.prototype.tabText = function(c, w, h, rSize, tabH, tabW, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab, tabNames)
  1419. {
  1420. var fontColor = mxUtils.getValue(this.style, mxShapeMockupVerTabBar.prototype.cst.TEXT_COLOR, '#666666');
  1421. var selFontColor = mxUtils.getValue(this.style, mxShapeMockupVerTabBar.prototype.cst.SEL_TEXT_COLOR, '#ffffff');
  1422. var fontSize = mxUtils.getValue(this.style, mxShapeMockupVerTabBar.prototype.cst.TEXT_SIZE, '17').toString();
  1423. c.setFontColor(fontColor);
  1424. c.setFontSize(fontSize);
  1425. var currH = startOffset;
  1426. for (var i=0; i < tabCount; i++)
  1427. {
  1428. var currLabel = tabNames[i];
  1429. if (i === selectedTab)
  1430. {
  1431. c.setFontColor(selFontColor);
  1432. }
  1433. if (currLabel.charAt(0) === '+')
  1434. {
  1435. currLabel = currLabel.substring(1);
  1436. }
  1437. c.text(tabW * 0.5, currH + tabH * 0.5, 0, 0, currLabel, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1438. currH = currH + tabH + tabOffset;
  1439. if (i === selectedTab)
  1440. {
  1441. c.setFontColor(fontColor);
  1442. }
  1443. }
  1444. };
  1445. mxCellRenderer.registerShape(mxShapeMockupVerTabBar.prototype.cst.SHAPE_VER_TAB_BAR, mxShapeMockupVerTabBar);
  1446. //**********************************************************************************************************************************************************
  1447. //Alert Box (LEGACY)
  1448. //**********************************************************************************************************************************************************
  1449. /**
  1450. * Extends mxShape.
  1451. */
  1452. function mxShapeMockupAlertBox(bounds, fill, stroke, strokewidth)
  1453. {
  1454. mxShape.call(this);
  1455. this.bounds = bounds;
  1456. this.fill = fill;
  1457. this.stroke = stroke;
  1458. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1459. };
  1460. /**
  1461. * Extends mxShape.
  1462. */
  1463. mxUtils.extend(mxShapeMockupAlertBox, mxShape);
  1464. mxShapeMockupAlertBox.prototype.cst = {
  1465. MAIN_TEXT : 'mainText',
  1466. SUB_TEXT : 'subText',
  1467. BUTTON_TEXT : 'buttonText',
  1468. TEXT_SIZE : 'textSize',
  1469. TEXT_COLOR : 'textColor',
  1470. STROKE_COLOR2 : 'strokeColor2',
  1471. STROKE_COLOR3 : 'strokeColor3',
  1472. SHAPE_ALERT_BOX : 'mxgraph.mockup.containers.alertBox'
  1473. };
  1474. /**
  1475. * Function: paintVertexShape
  1476. *
  1477. * Paints the vertex shape.
  1478. */
  1479. mxShapeMockupAlertBox.prototype.paintVertexShape = function(c, x, y, w, h)
  1480. {
  1481. var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  1482. var frameColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#666666');
  1483. var closeColor = mxUtils.getValue(this.style, mxShapeMockupAlertBox.prototype.cst.STROKE_COLOR2, '#008cff');
  1484. var insideColor = mxUtils.getValue(this.style, mxShapeMockupAlertBox.prototype.cst.STROKE_COLOR3, '#c4c4c4');
  1485. c.translate(x, y);
  1486. h = Math.max(h, 75);
  1487. w = Math.max(w, 90);
  1488. this.background(c, x, y, w, h, bgColor, frameColor);
  1489. c.setShadow(false);
  1490. this.foreground(c, x, y, w, h, frameColor, insideColor, closeColor);
  1491. };
  1492. mxShapeMockupAlertBox.prototype.background = function(c, x, y, w, h, bgColor, frameColor)
  1493. {
  1494. c.setFillColor(bgColor);
  1495. c.setStrokeColor(frameColor);
  1496. c.rect(0, 0, w, h);
  1497. c.fillAndStroke();
  1498. };
  1499. mxShapeMockupAlertBox.prototype.foreground = function(c, x, y, w, h, frameColor, insideColor, closeColor)
  1500. {
  1501. var strokeWidth = mxUtils.getValue(this.style, mxConstants.STYLE_STROKEWIDTH, '1');
  1502. c.setStrokeColor(closeColor);
  1503. c.ellipse(w - 25, 5, 20, 20);
  1504. c.stroke();
  1505. c.setStrokeColor(insideColor);
  1506. c.begin();
  1507. c.moveTo(0, 30);
  1508. c.lineTo(w, 30);
  1509. c.stroke();
  1510. //buttons
  1511. var windowTitle = mxUtils.getValue(this.style, mxShapeMockupAlertBox.prototype.cst.MAIN_TEXT, 'Window Title').toString();
  1512. var subText = mxUtils.getValue(this.style, mxShapeMockupAlertBox.prototype.cst.SUB_TEXT, 'Sub Text').toString().split(',');
  1513. var buttonText = mxUtils.getValue(this.style, mxShapeMockupAlertBox.prototype.cst.BUTTON_TEXT, 'OK,Cancel').toString().split(',');
  1514. var fontColor = mxUtils.getValue(this.style, mxShapeMockupAlertBox.prototype.cst.TEXT_COLOR, '#666666');
  1515. var fontSize = mxUtils.getValue(this.style, mxShapeMockupAlertBox.prototype.cst.TEXT_SIZE, '17').toString();
  1516. var buttonCount = buttonText.length;
  1517. var buttonOffset = 10;
  1518. var buttonW = (w - buttonOffset * (buttonCount + 1)) / buttonCount;
  1519. c.setFontColor(fontColor);
  1520. c.setFontSize(fontSize);
  1521. c.text(10, 15, 0, 0, windowTitle, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1522. var currW = buttonOffset;
  1523. for (var i = 0; i < buttonText.length; i++)
  1524. {
  1525. if (buttonText[i] !== '')
  1526. {
  1527. c.rect(currW, h - 10 - fontSize * 1.5, buttonW, fontSize * 1.5);
  1528. c.stroke();
  1529. c.text(currW + buttonW * 0.5, h - 10 - fontSize * 0.75, 0, 0, buttonText[i], mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1530. }
  1531. currW = currW + buttonW + buttonOffset;
  1532. }
  1533. for (var i = 0; i < subText.length; i++)
  1534. {
  1535. c.text(w * 0.5, 30 + fontSize * (i * 1.5 + 0.75), 0, 0, subText[i], mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1536. }
  1537. c.stroke();
  1538. };
  1539. mxCellRenderer.registerShape(mxShapeMockupAlertBox.prototype.cst.SHAPE_ALERT_BOX, mxShapeMockupAlertBox);
  1540. //**********************************************************************************************************************************************************
  1541. //Rounded rectangle (adjustable rounding)
  1542. //**********************************************************************************************************************************************************
  1543. /**
  1544. * Extends mxShape.
  1545. */
  1546. function mxShapeMockupContainersRRect(bounds, fill, stroke, strokewidth)
  1547. {
  1548. mxShape.call(this);
  1549. this.bounds = bounds;
  1550. this.fill = fill;
  1551. this.stroke = stroke;
  1552. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1553. };
  1554. /**
  1555. * Extends mxShape.
  1556. */
  1557. mxUtils.extend(mxShapeMockupContainersRRect, mxShape);
  1558. mxShapeMockupContainersRRect.prototype.cst = {
  1559. RRECT : 'mxgraph.mockup.containers.rrect',
  1560. R_SIZE : 'rSize'
  1561. };
  1562. mxShapeMockupContainersRRect.prototype.customProperties = [
  1563. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10},
  1564. ];
  1565. /**
  1566. * Function: paintVertexShape
  1567. *
  1568. * Paints the vertex shape.
  1569. */
  1570. mxShapeMockupContainersRRect.prototype.paintVertexShape = function(c, x, y, w, h)
  1571. {
  1572. c.translate(x, y);
  1573. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeMockupContainersRRect.prototype.cst.R_SIZE, '10'));
  1574. c.roundrect(0, 0, w, h, rSize);
  1575. c.fillAndStroke();
  1576. };
  1577. mxCellRenderer.registerShape(mxShapeMockupContainersRRect.prototype.cst.RRECT, mxShapeMockupContainersRRect);
  1578. //**********************************************************************************************************************************************************
  1579. //Anchor (a dummy shape without visuals used for anchoring)
  1580. //**********************************************************************************************************************************************************
  1581. /**
  1582. * Extends mxShape.
  1583. */
  1584. function mxShapeMockupContainersAnchor(bounds, fill, stroke, strokewidth)
  1585. {
  1586. mxShape.call(this);
  1587. this.bounds = bounds;
  1588. };
  1589. /**
  1590. * Extends mxShape.
  1591. */
  1592. mxUtils.extend(mxShapeMockupContainersAnchor, mxShape);
  1593. mxShapeMockupContainersAnchor.prototype.cst = {
  1594. ANCHOR : 'mxgraph.mockup.containers.anchor'
  1595. };
  1596. /**
  1597. * Function: paintVertexShape
  1598. *
  1599. * Paints the vertex shape.
  1600. */
  1601. mxShapeMockupContainersAnchor.prototype.paintVertexShape = function(c, x, y, w, h)
  1602. {
  1603. };
  1604. mxCellRenderer.registerShape(mxShapeMockupContainersAnchor.prototype.cst.ANCHOR, mxShapeMockupContainersAnchor);
  1605. //**********************************************************************************************************************************************************
  1606. //Top Button
  1607. //**********************************************************************************************************************************************************
  1608. /**
  1609. * Extends mxShape.
  1610. */
  1611. function mxShapeMockupContrainersTopButton(bounds, fill, stroke, strokewidth)
  1612. {
  1613. mxShape.call(this);
  1614. this.bounds = bounds;
  1615. this.fill = fill;
  1616. this.stroke = stroke;
  1617. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1618. };
  1619. /**
  1620. * Extends mxShape.
  1621. */
  1622. mxUtils.extend(mxShapeMockupContrainersTopButton, mxShape);
  1623. mxShapeMockupContrainersTopButton.prototype.cst = {
  1624. TOP_BUTTON : 'mxgraph.mockup.containers.topButton',
  1625. R_SIZE : 'rSize'
  1626. };
  1627. mxShapeMockupContrainersTopButton.prototype.customProperties = [
  1628. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10},
  1629. ];
  1630. /**
  1631. * Function: paintVertexShape
  1632. *
  1633. * Paints the vertex shape.
  1634. */
  1635. mxShapeMockupContrainersTopButton.prototype.paintVertexShape = function(c, x, y, w, h)
  1636. {
  1637. c.translate(x, y);
  1638. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeMockupContrainersTopButton.prototype.cst.R_SIZE, '10'));
  1639. c.begin();
  1640. c.moveTo(0, rSize);
  1641. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  1642. c.lineTo(w - rSize, 0);
  1643. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  1644. c.lineTo(w, h);
  1645. c.lineTo(0, h);
  1646. c.close();
  1647. c.fillAndStroke();
  1648. };
  1649. mxCellRenderer.registerShape(mxShapeMockupContrainersTopButton.prototype.cst.TOP_BUTTON, mxShapeMockupContrainersTopButton);
  1650. //**********************************************************************************************************************************************************
  1651. //Left Button
  1652. //**********************************************************************************************************************************************************
  1653. /**
  1654. * Extends mxShape.
  1655. */
  1656. function mxShapeMockupContainersLeftButton(bounds, fill, stroke, strokewidth)
  1657. {
  1658. mxShape.call(this);
  1659. this.bounds = bounds;
  1660. this.fill = fill;
  1661. this.stroke = stroke;
  1662. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1663. };
  1664. /**
  1665. * Extends mxShape.
  1666. */
  1667. mxUtils.extend(mxShapeMockupContainersLeftButton, mxShape);
  1668. mxShapeMockupContainersLeftButton.prototype.cst = {
  1669. LEFT_BUTTON : 'mxgraph.mockup.containers.leftButton',
  1670. R_SIZE : 'rSize'
  1671. };
  1672. mxShapeMockupContainersLeftButton.prototype.customProperties = [
  1673. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10},
  1674. ];
  1675. /**
  1676. * Function: paintVertexShape
  1677. *
  1678. * Paints the vertex shape.
  1679. */
  1680. mxShapeMockupContainersLeftButton.prototype.paintVertexShape = function(c, x, y, w, h)
  1681. {
  1682. c.translate(x, y);
  1683. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeMockupContainersLeftButton.prototype.cst.R_SIZE, '10'));
  1684. c.begin();
  1685. c.moveTo(w, 0);
  1686. c.lineTo(w, h);
  1687. c.lineTo(rSize, h);
  1688. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  1689. c.lineTo(0, rSize);
  1690. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  1691. c.close();
  1692. c.fillAndStroke();
  1693. };
  1694. mxCellRenderer.registerShape(mxShapeMockupContainersLeftButton.prototype.cst.LEFT_BUTTON, mxShapeMockupContainersLeftButton);
  1695. //**********************************************************************************************************************************************************
  1696. //rect with margins
  1697. //**********************************************************************************************************************************************************
  1698. /**
  1699. * Extends mxShape.
  1700. */
  1701. function mxShapeMockupContainersMarginRect(bounds, fill, stroke, strokewidth)
  1702. {
  1703. mxShape.call(this);
  1704. this.bounds = bounds;
  1705. this.fill = fill;
  1706. this.stroke = stroke;
  1707. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1708. };
  1709. /**
  1710. * Extends mxShape.
  1711. */
  1712. mxUtils.extend(mxShapeMockupContainersMarginRect, mxShape);
  1713. mxShapeMockupContainersMarginRect.prototype.cst = {
  1714. SHAPE_MARGIN_RECT : 'mxgraph.mockup.containers.marginRect',
  1715. MARGIN : 'rectMargin',
  1716. MARGIN_TOP : 'rectMarginTop',
  1717. MARGIN_LEFT : 'rectMarginLeft',
  1718. MARGIN_BOTTOM : 'rectMarginBottom',
  1719. MARGIN_RIGHT : 'rectMarginRight'
  1720. };
  1721. mxShapeMockupContainersMarginRect.prototype.customProperties = [
  1722. {name: 'rectMargin', dispName: 'Global Margin', type: 'float', min:0, defVal:0},
  1723. {name: 'rectMarginTop', dispName: 'Top Margin', type: 'float', min:0, defVal:0},
  1724. {name: 'rectMarginLeft', dispName: 'Left Margin', type: 'float', min:0, defVal:0},
  1725. {name: 'rectMarginBottom', dispName: 'Bottom Margin', type: 'float', min:0, defVal:0},
  1726. {name: 'rectMarginRight', dispName: 'Right Margin', type: 'float', min:0, defVal:0}
  1727. ];
  1728. /**
  1729. * Function: paintVertexShape
  1730. *
  1731. * Paints the vertex shape.
  1732. */
  1733. mxShapeMockupContainersMarginRect.prototype.paintVertexShape = function(c, x, y, w, h)
  1734. {
  1735. c.translate(x, y);
  1736. this.background(c, x, y, w, h);
  1737. };
  1738. mxShapeMockupContainersMarginRect.prototype.background = function(c, x, y, w, h, state)
  1739. {
  1740. var margin = parseFloat(mxUtils.getValue(this.style, mxShapeMockupContainersMarginRect.prototype.cst.MARGIN, '0'));
  1741. var marginTop = parseFloat(mxUtils.getValue(this.style, mxShapeMockupContainersMarginRect.prototype.cst.MARGIN_TOP, '0'));
  1742. var marginLeft = parseFloat(mxUtils.getValue(this.style, mxShapeMockupContainersMarginRect.prototype.cst.MARGIN_LEFT, '0'));
  1743. var marginBottom = parseFloat(mxUtils.getValue(this.style, mxShapeMockupContainersMarginRect.prototype.cst.MARGIN_BOTTOM, '0'));
  1744. var marginRight = parseFloat(mxUtils.getValue(this.style, mxShapeMockupContainersMarginRect.prototype.cst.MARGIN_RIGHT, '0'));
  1745. var x1 = margin + marginLeft;
  1746. var y1 = margin + marginTop;
  1747. var w1 = w - marginRight - x1 - margin;
  1748. var h1 = h - marginBottom - y1 - margin;
  1749. if (w1 >0 && h1 > 0)
  1750. {
  1751. c.begin();
  1752. c.roundrect(x1, y1, w1, h1, 10, 10);
  1753. c.fillAndStroke();
  1754. }
  1755. };
  1756. mxCellRenderer.registerShape(mxShapeMockupContainersMarginRect.prototype.cst.SHAPE_MARGIN_RECT, mxShapeMockupContainersMarginRect);
  1757. //**********************************************************************************************************************************************************
  1758. //rect with margins (not rounded)
  1759. //**********************************************************************************************************************************************************
  1760. /**
  1761. * Extends mxShape.
  1762. */
  1763. function mxShapeMockupContainersMarginRect2(bounds, fill, stroke, strokewidth)
  1764. {
  1765. mxShape.call(this);
  1766. this.bounds = bounds;
  1767. this.fill = fill;
  1768. this.stroke = stroke;
  1769. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1770. };
  1771. /**
  1772. * Extends mxShape.
  1773. */
  1774. mxUtils.extend(mxShapeMockupContainersMarginRect2, mxShape);
  1775. mxShapeMockupContainersMarginRect2.prototype.cst = {
  1776. SHAPE_MARGIN_RECT : 'mxgraph.mockup.containers.marginRect2',
  1777. MARGIN : 'rectMargin',
  1778. MARGIN_TOP : 'rectMarginTop',
  1779. MARGIN_LEFT : 'rectMarginLeft',
  1780. MARGIN_BOTTOM : 'rectMarginBottom',
  1781. MARGIN_RIGHT : 'rectMarginRight'
  1782. };
  1783. mxShapeMockupContainersMarginRect2.prototype.customProperties = [
  1784. {name: 'rectMargin', dispName: 'Global Margin', type: 'float', min:0, defVal:0},
  1785. {name: 'rectMarginTop', dispName: 'Top Margin', type: 'float', min:0, defVal:0},
  1786. {name: 'rectMarginLeft', dispName: 'Left Margin', type: 'float', min:0, defVal:0},
  1787. {name: 'rectMarginBottom', dispName: 'Bottom Margin', type: 'float', min:0, defVal:0},
  1788. {name: 'rectMarginRight', dispName: 'Right Margin', type: 'float', min:0, defVal:0}
  1789. ];
  1790. /**
  1791. * Function: paintVertexShape
  1792. *
  1793. * Paints the vertex shape.
  1794. */
  1795. mxShapeMockupContainersMarginRect2.prototype.paintVertexShape = function(c, x, y, w, h)
  1796. {
  1797. c.translate(x, y);
  1798. this.background(c, x, y, w, h);
  1799. };
  1800. mxShapeMockupContainersMarginRect2.prototype.background = function(c, x, y, w, h, state)
  1801. {
  1802. var margin = parseFloat(mxUtils.getValue(this.style, mxShapeMockupContainersMarginRect2.prototype.cst.MARGIN, '0'));
  1803. var marginTop = parseFloat(mxUtils.getValue(this.style, mxShapeMockupContainersMarginRect2.prototype.cst.MARGIN_TOP, '0'));
  1804. var marginLeft = parseFloat(mxUtils.getValue(this.style, mxShapeMockupContainersMarginRect2.prototype.cst.MARGIN_LEFT, '0'));
  1805. var marginBottom = parseFloat(mxUtils.getValue(this.style, mxShapeMockupContainersMarginRect2.prototype.cst.MARGIN_BOTTOM, '0'));
  1806. var marginRight = parseFloat(mxUtils.getValue(this.style, mxShapeMockupContainersMarginRect2.prototype.cst.MARGIN_RIGHT, '0'));
  1807. var x1 = margin + marginLeft;
  1808. var y1 = margin + marginTop;
  1809. var w1 = w - marginRight - x1 - margin;
  1810. var h1 = h - marginBottom - y1 - margin;
  1811. if (w1 >0 && h1 > 0)
  1812. {
  1813. c.begin();
  1814. c.rect(x1, y1, w1, h1);
  1815. c.fillAndStroke();
  1816. }
  1817. };
  1818. mxCellRenderer.registerShape(mxShapeMockupContainersMarginRect2.prototype.cst.SHAPE_MARGIN_RECT, mxShapeMockupContainersMarginRect2);