mxMockupNavigation.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  1. /**
  2. * $Id: mxMockupNavigation.js,v 1.5 2014/01/21 13:11:15 gaudenz Exp $
  3. * Copyright (c) 2006-2010, JGraph Ltd
  4. */
  5. //**********************************************************************************************************************************************************
  6. //Breadcrumb (LEGACY)
  7. //**********************************************************************************************************************************************************
  8. /**
  9. * Extends mxShape.
  10. */
  11. function mxShapeMockupBreadcrumb(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(mxShapeMockupBreadcrumb, mxShape);
  23. mxShapeMockupBreadcrumb.prototype.cst = {
  24. SHAPE_BREADCRUMB : 'mxgraph.mockup.navigation.breadcrumb',
  25. MAIN_TEXT : 'mainText',
  26. TEXT_SIZE : 'textSize',
  27. TEXT_COLOR : 'textColor',
  28. TEXT_COLOR2 : 'textColor2'
  29. };
  30. /**
  31. * Function: paintVertexShape
  32. *
  33. * Paints the vertex shape.
  34. */
  35. mxShapeMockupBreadcrumb.prototype.paintVertexShape = function(c, x, y, w, h)
  36. {
  37. var textStrings = decodeURIComponent(mxUtils.getValue(this.style, mxShapeMockupBreadcrumb.prototype.cst.MAIN_TEXT, 'Layer 1, Layer 2, Layer 3').toString()).split(',');
  38. var fontColor = mxUtils.getValue(this.style, mxShapeMockupBreadcrumb.prototype.cst.TEXT_COLOR, '#666666');
  39. var selectedFontColor = mxUtils.getValue(this.style, mxShapeMockupBreadcrumb.prototype.cst.TEXT_COLOR2, '#008cff');
  40. var fontSize = mxUtils.getValue(this.style, mxShapeMockupBreadcrumb.prototype.cst.TEXT_SIZE, '17').toString();
  41. var separatorColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#c4c4c4');
  42. var buttonNum = textStrings.length;
  43. var buttonWidths = new Array(buttonNum);
  44. var buttonTotalWidth = 0;
  45. var labelOffset = 10;
  46. for (var i = 0; i < buttonNum; i++)
  47. {
  48. buttonWidths[i] = mxUtils.getSizeForString(textStrings[i], fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  49. buttonTotalWidth += buttonWidths[i];
  50. }
  51. var trueH = Math.max(h, fontSize * 1.5, 20);
  52. var minW = 2 * labelOffset * buttonNum + buttonTotalWidth;
  53. var trueW = Math.max(w, minW);
  54. c.translate(x, y);
  55. c.setShadow(false);
  56. this.separators(c, trueW, trueH, buttonNum, buttonWidths, labelOffset, minW, separatorColor);
  57. var currWidth = 0;
  58. for (var i = 0; i < buttonNum; i++)
  59. {
  60. if (i + 1 === buttonNum)
  61. {
  62. c.setFontColor(selectedFontColor);
  63. }
  64. else
  65. {
  66. c.setFontColor(fontColor);
  67. }
  68. currWidth = currWidth + labelOffset;
  69. this.buttonText(c, currWidth, trueH, textStrings[i], buttonWidths[i], fontSize, minW, trueW);
  70. currWidth = currWidth + buttonWidths[i] + labelOffset;
  71. }
  72. };
  73. mxShapeMockupBreadcrumb.prototype.separators = function(c, w, h, buttonNum, buttonWidths, labelOffset, minW, separatorColor)
  74. {
  75. //draw the button separators
  76. c.setStrokeColor(separatorColor);
  77. var midY = h * 0.5;
  78. var size = 5;
  79. c.begin();
  80. for (var i = 1; i < buttonNum; i++)
  81. {
  82. var currWidth = 0;
  83. for (var j = 0; j < i; j++)
  84. {
  85. currWidth += buttonWidths[j] + 2 * labelOffset;
  86. }
  87. currWidth = currWidth * w / minW;
  88. c.moveTo(currWidth - size * 0.5, midY - size);
  89. c.lineTo(currWidth + size * 0.5, midY);
  90. c.lineTo(currWidth - size * 0.5, midY + size);
  91. }
  92. c.stroke();
  93. };
  94. mxShapeMockupBreadcrumb.prototype.buttonText = function(c, w, h, textString, buttonWidth, fontSize, minW, trueW)
  95. {
  96. c.begin();
  97. c.setFontSize(fontSize);
  98. 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);
  99. };
  100. mxCellRenderer.registerShape(mxShapeMockupBreadcrumb.prototype.cst.SHAPE_BREADCRUMB, mxShapeMockupBreadcrumb);
  101. //**********************************************************************************************************************************************************
  102. //Step Bar
  103. //**********************************************************************************************************************************************************
  104. /**
  105. * Extends mxShape.
  106. */
  107. function mxShapeMockupStepBar(bounds, fill, stroke, strokewidth)
  108. {
  109. mxShape.call(this);
  110. this.bounds = bounds;
  111. this.fill = fill;
  112. this.stroke = stroke;
  113. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  114. };
  115. /**
  116. * Extends mxShape.
  117. */
  118. mxUtils.extend(mxShapeMockupStepBar, mxShape);
  119. mxShapeMockupStepBar.prototype.cst = {
  120. SHAPE_STEP_BAR : 'mxgraph.mockup.navigation.stepBar',
  121. SELECTED : '+', //must be 1 char
  122. MAIN_TEXT : 'mainText',
  123. TEXT_SIZE : 'textSize',
  124. TEXT_COLOR : 'textColor',
  125. TEXT_COLOR2 : 'textColor2'
  126. };
  127. mxShapeMockupStepBar.prototype.customProperties = [
  128. {name: 'mainText', dispName: 'Text', type: 'string'},
  129. {name: 'textSize', dispName: 'Text Size', type: 'float'},
  130. {name: 'textColor', dispName: 'Text Color', type: 'color'},
  131. {name: 'textColor2', dispName: 'Text2 Color', type: 'color'}
  132. ];
  133. /**
  134. * Function: paintVertexShape
  135. *
  136. * Paints the vertex shape.
  137. */
  138. mxShapeMockupStepBar.prototype.paintVertexShape = function(c, x, y, w, h)
  139. {
  140. var textStrings = decodeURIComponent(mxUtils.getValue(this.style, mxShapeMockupStepBar.prototype.cst.MAIN_TEXT, 'Step 1, Step 2, Step 3').toString()).split(',');
  141. var fontColor = mxUtils.getValue(this.style, mxShapeMockupStepBar.prototype.cst.TEXT_COLOR, '#666666');
  142. var currColor = mxUtils.getValue(this.style, mxShapeMockupStepBar.prototype.cst.TEXT_COLOR2, '#008cff');
  143. var fontSize = mxUtils.getValue(this.style, mxShapeMockupStepBar.prototype.cst.TEXT_SIZE, '17').toString();
  144. var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#c4c4c4');
  145. var doneColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#666666');
  146. var buttonNum = textStrings.length;
  147. var buttonWidths = new Array(buttonNum);
  148. var buttonTotalWidth = 0;
  149. var labelOffset = 10;
  150. var selectedButton = -1;
  151. for (var i = 0; i < buttonNum; i++)
  152. {
  153. var buttonText = textStrings[i];
  154. if(buttonText.charAt(0) === mxShapeMockupStepBar.prototype.cst.SELECTED)
  155. {
  156. buttonText = textStrings[i].substring(1);
  157. selectedButton = i;
  158. }
  159. buttonWidths[i] = mxUtils.getSizeForString(buttonText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  160. buttonTotalWidth += buttonWidths[i];
  161. }
  162. var trueH = Math.max(h, fontSize * 1.5, 20);
  163. var minW = 2 * labelOffset * buttonNum + buttonTotalWidth;
  164. var trueW = Math.max(w, minW);
  165. c.translate(x, y);
  166. this.stepLineBg(c, trueW, trueH, buttonNum, buttonWidths, labelOffset, minW, bgColor, fontSize, trueW);
  167. c.setShadow(false);
  168. this.stepLineFg(c, trueW, trueH, buttonNum, buttonWidths, labelOffset, minW, bgColor, doneColor, currColor, fontSize, trueW, selectedButton);
  169. var currWidth = 0;
  170. for (var i = 0; i < buttonNum; i++)
  171. {
  172. if (i >= selectedButton)
  173. {
  174. c.setFontColor(currColor);
  175. }
  176. else
  177. {
  178. c.setFontColor(fontColor);
  179. }
  180. currWidth = currWidth + labelOffset;
  181. this.buttonText(c, currWidth, trueH, textStrings[i], buttonWidths[i], fontSize, minW, trueW);
  182. currWidth = currWidth + buttonWidths[i] + labelOffset;
  183. }
  184. };
  185. mxShapeMockupStepBar.prototype.stepLineBg = function(c, w, h, buttonNum, buttonWidths, labelOffset, minW, bgColor, fontSize, trueW)
  186. {
  187. //draw the button separators
  188. c.setStrokeColor(bgColor);
  189. c.setFillColor(bgColor);
  190. var midY = fontSize * 2;
  191. var size = 10;
  192. var startX = 0;
  193. var endX = 0;
  194. for (var i = 0; i < buttonNum; i++)
  195. {
  196. var currWidth = 0;
  197. for (var j = 0; j < i; j++)
  198. {
  199. currWidth += buttonWidths[j] + 2 * labelOffset;
  200. }
  201. currWidth += buttonWidths[i] * 0.5 + labelOffset;
  202. currWidth = currWidth * w / minW;
  203. if (i === 0)
  204. {
  205. startX = currWidth;
  206. }
  207. else if (i + 1 === buttonNum)
  208. {
  209. endX = currWidth;
  210. }
  211. c.begin();
  212. c.ellipse(currWidth - size, midY - size, 2 * size, 2 * size);
  213. c.fillAndStroke();
  214. }
  215. c.begin();
  216. c.rect(startX, midY - size * 0.2, endX - startX, size * 0.4);
  217. c.fillAndStroke();
  218. };
  219. mxShapeMockupStepBar.prototype.stepLineFg = function(c, w, h, buttonNum, buttonWidths, labelOffset, minW, bgColor, doneColor, currColor, fontSize, trueW, selectedButton)
  220. {
  221. //draw the button separators
  222. c.setStrokeColor(doneColor);
  223. var midY = fontSize * 2;
  224. var size = 10 * 0.75;
  225. var startX = 0;
  226. var endX = 0;
  227. var strokeWidth = mxUtils.getValue(this.style, mxConstants.STYLE_STROKEWIDTH, '1');
  228. for (var i = 0; i <= selectedButton; i++)
  229. {
  230. var currWidth = 0;
  231. for (var j = 0; j < i; j++)
  232. {
  233. currWidth += buttonWidths[j] + 2 * labelOffset;
  234. }
  235. currWidth += buttonWidths[i] * 0.5 + labelOffset;
  236. currWidth = currWidth * w / minW;
  237. if (i === 0)
  238. {
  239. startX = currWidth;
  240. }
  241. else if (i === selectedButton)
  242. {
  243. endX = currWidth;
  244. }
  245. }
  246. c.setFillColor(doneColor);
  247. c.begin();
  248. c.rect(startX, midY - size * 0.15, endX - startX, size * 0.3);
  249. c.fill();
  250. c.setFillColor(bgColor);
  251. for (var i = 0; i <= selectedButton; i++)
  252. {
  253. var currWidth = 0;
  254. for (var j = 0; j < i; j++)
  255. {
  256. currWidth += buttonWidths[j] + 2 * labelOffset;
  257. }
  258. currWidth += buttonWidths[i] * 0.5 + labelOffset;
  259. currWidth = currWidth * w / minW;
  260. if (i === 0)
  261. {
  262. startX = currWidth;
  263. }
  264. else if (i + 1 === selectedButton)
  265. {
  266. endX = currWidth;
  267. }
  268. if (i < selectedButton)
  269. {
  270. c.setStrokeWidth(strokeWidth);
  271. c.begin();
  272. c.ellipse(currWidth - size, midY - size, 2 * size, 2 * size);
  273. c.fillAndStroke();
  274. c.setStrokeWidth(strokeWidth * 0.5);
  275. c.begin();
  276. c.ellipse(currWidth - size * 0.6, midY - size * 0.6, 2 * size * 0.6, 2 * size * 0.6);
  277. c.fillAndStroke();
  278. }
  279. else
  280. {
  281. c.setStrokeWidth(strokeWidth);
  282. c.setFillColor(bgColor);
  283. c.setStrokeColor(bgColor);
  284. c.begin();
  285. c.ellipse(currWidth - size / 0.75, midY - size / 0.75, 2 * size / 0.75, 2 * size / 0.75);
  286. c.fillAndStroke();
  287. c.setStrokeWidth(strokeWidth);
  288. c.setFillColor('#ffffff');
  289. c.setStrokeColor('#ffffff');
  290. c.begin();
  291. c.ellipse(currWidth - size, midY - size, 2 * size, 2 * size);
  292. c.fillAndStroke();
  293. c.setFillColor(currColor);
  294. c.setStrokeColor(currColor);
  295. c.setStrokeWidth(strokeWidth * 0.5);
  296. c.begin();
  297. c.ellipse(currWidth - size * 0.7, midY - size * 0.7, 2 * size * 0.7, 2 * size * 0.7);
  298. c.fillAndStroke();
  299. }
  300. }
  301. };
  302. mxShapeMockupStepBar.prototype.buttonText = function(c, w, h, textString, buttonWidth, fontSize, minW, trueW)
  303. {
  304. if(textString.charAt(0) === mxShapeMockupStepBar.prototype.cst.SELECTED)
  305. {
  306. textString = textString.substring(1);
  307. }
  308. c.begin();
  309. c.setFontSize(fontSize);
  310. c.text((w + buttonWidth * 0.5) * trueW / minW, fontSize * 0.5, 0, 0, textString, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  311. };
  312. mxCellRenderer.registerShape(mxShapeMockupStepBar.prototype.cst.SHAPE_STEP_BAR, mxShapeMockupStepBar);
  313. //**********************************************************************************************************************************************************
  314. //Cover Flow
  315. //**********************************************************************************************************************************************************
  316. /**
  317. * Extends mxShape.
  318. */
  319. function mxShapeMockupCoverFlow(bounds, fill, stroke, strokewidth)
  320. {
  321. mxShape.call(this);
  322. this.bounds = bounds;
  323. this.fill = fill;
  324. this.stroke = stroke;
  325. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  326. };
  327. /**
  328. * Extends mxShape.
  329. */
  330. mxUtils.extend(mxShapeMockupCoverFlow, mxShape);
  331. mxShapeMockupCoverFlow.prototype.cst = {
  332. SHAPE_COVER_FLOW : 'mxgraph.mockup.navigation.coverFlow'
  333. };
  334. /**
  335. * Function: paintVertexShape
  336. *
  337. * Paints the vertex shape.
  338. */
  339. mxShapeMockupCoverFlow.prototype.paintVertexShape = function(c, x, y, w, h)
  340. {
  341. c.translate(x, y);
  342. c.begin();
  343. c.moveTo(w * 0.0924, h * 0.07);
  344. c.lineTo(w * 0.005, h * 0.01);
  345. c.lineTo(w * 0.005, h * 0.99);
  346. c.lineTo(w * 0.0924, h * 0.93);
  347. c.moveTo(w * 0.1774, h * 0.09);
  348. c.lineTo(w * 0.0924, h * 0.01);
  349. c.lineTo(w * 0.0924, h * 0.99);
  350. c.lineTo(w * 0.1774, h * 0.91);
  351. c.moveTo(w * 0.3373, h * 0.22);
  352. c.lineTo(w * 0.1774, h * 0.01);
  353. c.lineTo(w * 0.1774, h * 0.99);
  354. c.lineTo(w * 0.3373, h * 0.78);
  355. c.moveTo(w * 0.912, h * 0.07);
  356. c.lineTo(w * 0.998, h * 0.01);
  357. c.lineTo(w * 0.998, h * 0.99);
  358. c.lineTo(w * 0.912, h * 0.93);
  359. c.moveTo(w * 0.8271, h * 0.09);
  360. c.lineTo(w * 0.912, h * 0.01);
  361. c.lineTo(w * 0.912, h * 0.99);
  362. c.lineTo(w * 0.8271, h * 0.91);
  363. c.moveTo(w * 0.6672, h * 0.22);
  364. c.lineTo(w * 0.8271, h * 0.01);
  365. c.lineTo(w * 0.8271, h * 0.99);
  366. c.lineTo(w * 0.6672, h * 0.78);
  367. c.moveTo(w * 0.3373, h * 0.005);
  368. c.lineTo(w * 0.3373, h * 0.995);
  369. c.lineTo(w * 0.6672, h * 0.995);
  370. c.lineTo(w * 0.6672, h * 0.005);
  371. c.close();
  372. c.fillAndStroke();
  373. };
  374. mxCellRenderer.registerShape(mxShapeMockupCoverFlow.prototype.cst.SHAPE_COVER_FLOW, mxShapeMockupCoverFlow);
  375. //**********************************************************************************************************************************************************
  376. //Scroll Bar
  377. //**********************************************************************************************************************************************************
  378. /**
  379. * Extends mxShape.
  380. */
  381. function mxShapeMockupScrollBar(bounds, fill, stroke, strokewidth)
  382. {
  383. mxShape.call(this);
  384. this.bounds = bounds;
  385. this.fill = fill;
  386. this.stroke = stroke;
  387. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  388. };
  389. /**
  390. * Extends mxShape.
  391. */
  392. mxUtils.extend(mxShapeMockupScrollBar, mxShape);
  393. mxShapeMockupScrollBar.prototype.cst = {
  394. SHAPE_SCROLL_BAR : 'mxgraph.mockup.navigation.scrollBar',
  395. FILL_COLOR2 : 'fillColor2',
  396. STROKE_COLOR2 : 'strokeColor2',
  397. BAR_POS : 'barPos'
  398. };
  399. mxShapeMockupScrollBar.prototype.customProperties = [
  400. {name: 'barPos', dispName: 'Handle Position', type: 'float'},
  401. {name: 'fillColor2', dispName: 'Fill2 Color', type: 'color'},
  402. {name: 'strokeColor2', dispName: 'Stroke2 Color', type: 'color'}
  403. ];
  404. /**
  405. * Function: paintVertexShape
  406. *
  407. * Paints the vertex shape.
  408. */
  409. mxShapeMockupScrollBar.prototype.paintVertexShape = function(c, x, y, w, h)
  410. {
  411. h = 20;
  412. var buttonX = 20;
  413. w = Math.max(w, 2 * buttonX);
  414. c.translate(x, y);
  415. this.background(c, w, h, buttonX);
  416. c.setShadow(false);
  417. this.foreground(c, w, h, buttonX);
  418. this.barPos = 20;
  419. };
  420. mxShapeMockupScrollBar.prototype.background = function(c, w, h, buttonX)
  421. {
  422. c.rect(0, 0, w, h);
  423. c.fillAndStroke();
  424. c.begin();
  425. c.moveTo(buttonX, 0);
  426. c.lineTo(buttonX, h);
  427. c.moveTo(w - buttonX, 0);
  428. c.lineTo(w - buttonX, h);
  429. c.stroke();
  430. }
  431. mxShapeMockupScrollBar.prototype.foreground = function(c, w, h, buttonX)
  432. {
  433. var barPos = mxUtils.getValue(this.style, mxShapeMockupScrollBar.prototype.cst.BAR_POS, '20');
  434. var fillColor2 = mxUtils.getValue(this.style, mxShapeMockupScrollBar.prototype.cst.FILL_COLOR2, '#99ddff');
  435. var strokeColor2 = mxUtils.getValue(this.style, mxShapeMockupScrollBar.prototype.cst.STROKE_COLOR2, 'none');
  436. barPos = Math.max(0, barPos);
  437. barPos = Math.min(100, barPos);
  438. c.setStrokeColor(strokeColor2);
  439. c.setFillColor(fillColor2);
  440. c.begin();
  441. c.moveTo(buttonX * 0.2, h * 0.5);
  442. c.lineTo(buttonX * 0.8, h * 0.2);
  443. c.lineTo(buttonX * 0.8, h * 0.8);
  444. c.close();
  445. c.moveTo(w - buttonX * 0.2, h * 0.5);
  446. c.lineTo(w - buttonX * 0.8, h * 0.2);
  447. c.lineTo(w - buttonX * 0.8, h * 0.8);
  448. c.close();
  449. c.fillAndStroke();
  450. //draw the handle based on arg.barPos
  451. var barWidth = 60;
  452. var barMin = buttonX;
  453. var barMax = w - buttonX;
  454. barWidth = Math.min(barWidth, barMax - barMin);
  455. var barCenterMin = barMin + barWidth / 2;
  456. var barCenterMax = barMax - barWidth / 2;
  457. var barCenterRange = barCenterMax - barCenterMin;
  458. var barCenterPos = barCenterRange * barPos / 100;
  459. var barStart = barMin + barCenterPos;
  460. c.roundrect(barStart, h * 0.15, barWidth, h * 0.7, 5, 5);
  461. c.fillAndStroke();
  462. };
  463. mxCellRenderer.registerShape(mxShapeMockupScrollBar.prototype.cst.SHAPE_SCROLL_BAR, mxShapeMockupScrollBar);
  464. Graph.handleFactory[mxShapeMockupScrollBar.prototype.cst.SHAPE_SCROLL_BAR] = function(state)
  465. {
  466. var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
  467. {
  468. var barPos = Math.max(0, Math.min(100, parseFloat(mxUtils.getValue(this.state.style, 'barPos', this.barPos))));
  469. return new mxPoint(bounds.x + ((bounds.width - 100) * barPos / bounds.width) / 100 * bounds.width + 50, bounds.y + 10);
  470. }, function(bounds, pt)
  471. {
  472. this.state.style['barPos'] = Math.round(1000 * Math.max(0, Math.min(100, (pt.x - bounds.x - 50) * 100 / (bounds.width - 100)))) / 1000;
  473. })];
  474. return handles;
  475. }
  476. //**********************************************************************************************************************************************************
  477. //Pagination
  478. //**********************************************************************************************************************************************************
  479. /**
  480. * Extends mxShape.
  481. */
  482. function mxShapeMockupPagination(bounds, fill, stroke, strokewidth)
  483. {
  484. mxShape.call(this);
  485. this.bounds = bounds;
  486. this.fill = fill;
  487. this.stroke = stroke;
  488. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  489. };
  490. /**
  491. * Extends mxShape.
  492. */
  493. mxUtils.extend(mxShapeMockupPagination, mxShape);
  494. mxShapeMockupPagination.prototype.cst = {
  495. MAIN_TEXT : 'linkText',
  496. TEXT_SIZE : 'textSize',
  497. TEXT_COLOR : 'textColor',
  498. SHAPE_PAGINATION : 'mxgraph.mockup.navigation.pagination'
  499. };
  500. /**
  501. * Function: paintVertexShape
  502. *
  503. * Paints the vertex shape.
  504. */
  505. mxShapeMockupPagination.prototype.paintVertexShape = function(c, x, y, w, h)
  506. {
  507. var mainText = decodeURIComponent(mxUtils.getValue(this.style, mxShapeMockupPagination.prototype.cst.MAIN_TEXT, '0-9 A B C D E F G H I J K L M N O P Q R S T U V X Y Z'));
  508. var textSize = mxUtils.getValue(this.style, mxShapeMockupPagination.prototype.cst.TEXT_SIZE, '17');
  509. var textColor = mxUtils.getValue(this.style, mxShapeMockupPagination.prototype.cst.TEXT_COLOR, '#0000ff');
  510. c.translate(x, y);
  511. var width = mxUtils.getSizeForString(mainText, textSize, mxConstants.DEFAULT_FONTFAMILY).width;
  512. c.setStrokeColor(textColor);
  513. c.setFontSize(textSize);
  514. c.setFontColor(textColor);
  515. c.text(w * 0.5, h * 0.5, 0, 0, mainText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  516. c.begin();
  517. c.moveTo(w * 0.5 - width * 0.5, (h + parseInt(textSize, 10)) * 0.5);
  518. c.lineTo(w * 0.5 + width * 0.5, (h + parseInt(textSize, 10)) * 0.5);
  519. c.stroke();
  520. };
  521. mxCellRenderer.registerShape(mxShapeMockupPagination.prototype.cst.SHAPE_PAGINATION, mxShapeMockupPagination);
  522. //**********************************************************************************************************************************************************
  523. //Page Control
  524. //**********************************************************************************************************************************************************
  525. /**
  526. * Extends mxShape.
  527. */
  528. function mxShapeMockupPageControl(bounds, fill, stroke, strokewidth)
  529. {
  530. mxShape.call(this);
  531. this.bounds = bounds;
  532. this.fill = fill;
  533. this.stroke = stroke;
  534. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  535. };
  536. /**
  537. * Extends mxShape.
  538. */
  539. mxUtils.extend(mxShapeMockupPageControl, mxShape);
  540. mxShapeMockupPageControl.prototype.cst = {
  541. SHAPE_PAGE_CONTROL : 'mxgraph.mockup.navigation.pageControl'
  542. };
  543. /**
  544. * Function: paintVertexShape
  545. *
  546. * Paints the vertex shape.
  547. */
  548. mxShapeMockupPageControl.prototype.paintVertexShape = function(c, x, y, w, h)
  549. {
  550. c.translate(x, y);
  551. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#000000');
  552. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  553. var rSize = Math.min(h * 0.5, w * 0.05);
  554. c.setFillColor(strokeColor);
  555. c.ellipse(0, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
  556. c.fill();
  557. c.setFillColor(fillColor);
  558. c.ellipse(w * 0.35 - rSize, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
  559. c.fill();
  560. c.ellipse(w * 0.65 - rSize, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
  561. c.fill();
  562. c.ellipse(w - 2 * rSize, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
  563. c.fill();
  564. };
  565. mxCellRenderer.registerShape(mxShapeMockupPageControl.prototype.cst.SHAPE_PAGE_CONTROL, mxShapeMockupPageControl);
  566. //**********************************************************************************************************************************************************
  567. //Map Navigator
  568. //**********************************************************************************************************************************************************
  569. /**
  570. * Extends mxShape.
  571. */
  572. function mxShapeMockupMapNavigator(bounds, fill, stroke, strokewidth)
  573. {
  574. mxShape.call(this);
  575. this.bounds = bounds;
  576. this.fill = fill;
  577. this.stroke = stroke;
  578. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  579. };
  580. /**
  581. * Extends mxShape.
  582. */
  583. mxUtils.extend(mxShapeMockupMapNavigator, mxShape);
  584. mxShapeMockupMapNavigator.prototype.cst = {
  585. SHAPE_MAP_NAVIGATOR : 'mxgraph.mockup.navigation.mapNavigator',
  586. FILL_COLOR2 : 'fillColor2',
  587. STROKE_COLOR2 : 'strokeColor2',
  588. STROKE_COLOR3 : 'strokeColor3'
  589. };
  590. mxShapeMockupMapNavigator.prototype.customProperties = [
  591. {name: 'fillColor2', dispName: 'Fill2 Color', type: 'color'},
  592. {name: 'strokeColor2', dispName: 'Stroke2 Color', type: 'color'},
  593. {name: 'strokeColor3', dispName: 'Stroke3 Color', type: 'color'}
  594. ];
  595. /**
  596. * Function: paintVertexShape
  597. *
  598. * Paints the vertex shape.
  599. */
  600. mxShapeMockupMapNavigator.prototype.paintVertexShape = function(c, x, y, w, h)
  601. {
  602. c.translate(x, y);
  603. this.background(c, w, h);
  604. c.setShadow(false);
  605. this.foreground(c, w, h);
  606. };
  607. mxShapeMockupMapNavigator.prototype.background = function(c, w, h)
  608. {
  609. c.ellipse(0, 0, w, h * 0.6);
  610. c.fillAndStroke();
  611. c.begin();
  612. c.moveTo(w * 0.35, h * 0.584);
  613. c.lineTo(w * 0.35, h * 0.95);
  614. c.arcTo(w * 0.083, h * 0.05, 0, 0, 0, w * 0.43, h);
  615. c.lineTo(w * 0.56, h);
  616. c.arcTo(w * 0.083, h * 0.05, 0, 0, 0, w * 0.65, h * 0.95);
  617. c.lineTo(w * 0.65, h * 0.584);
  618. c.fillAndStroke();
  619. }
  620. mxShapeMockupMapNavigator.prototype.foreground = function(c, w, h)
  621. {
  622. var fillColor2 = mxUtils.getValue(this.style, mxShapeMockupMapNavigator.prototype.cst.FILL_COLOR2, '#99ddff');
  623. var strokeColor2 = mxUtils.getValue(this.style, mxShapeMockupMapNavigator.prototype.cst.STROKE_COLOR2, 'none');
  624. var strokeColor3 = mxUtils.getValue(this.style, mxShapeMockupMapNavigator.prototype.cst.STROKE_COLOR3, '#ffffff');
  625. c.setFillColor(fillColor2);
  626. c.setStrokeColor(strokeColor2);
  627. c.ellipse(w * 0.4, h * 0.65, w * 0.2, h * 0.12);
  628. c.fillAndStroke();
  629. c.ellipse(w * 0.4, h * 0.85, w * 0.2, h * 0.12);
  630. c.fillAndStroke();
  631. c.begin();
  632. c.moveTo(w * 0.1806, h * 0.34);
  633. c.lineTo(w * 0.1357, h * 0.366);
  634. c.lineTo(w * 0.0228, h * 0.3);
  635. c.lineTo(w * 0.1357, h * 0.234);
  636. c.lineTo(w * 0.1806, h * 0.26);
  637. c.lineTo(w * 0.1142, h * 0.3);
  638. c.close();
  639. c.fillAndStroke();
  640. c.begin();
  641. c.moveTo(w * 0.433, h * 0.108);
  642. c.lineTo(w * 0.3881, h * 0.08);
  643. c.lineTo(w * 0.4994, h * 0.012);
  644. c.lineTo(w * 0.6123, h * 0.08);
  645. c.lineTo(w * 0.5658, h * 0.108);
  646. c.lineTo(w * 0.4994, h * 0.068);
  647. c.close();
  648. c.fillAndStroke();
  649. c.begin();
  650. c.moveTo(w * 0.8198, h * 0.262);
  651. c.lineTo(w * 0.868, h * 0.233);
  652. c.lineTo(w * 0.9776, h * 0.3);
  653. c.lineTo(w * 0.868, h * 0.367);
  654. c.lineTo(w * 0.8198, h * 0.341);
  655. c.lineTo(w * 0.8863, h * 0.3);
  656. c.close();
  657. c.fillAndStroke();
  658. c.begin();
  659. c.moveTo(w * 0.5641, h * 0.493);
  660. c.lineTo(w * 0.6123, h * 0.522);
  661. c.lineTo(w * 0.4994, h * 0.588);
  662. c.lineTo(w * 0.3881, h * 0.521);
  663. c.lineTo(w * 0.4363, h * 0.493);
  664. c.lineTo(w * 0.4994, h * 0.533);
  665. c.close();
  666. c.fillAndStroke();
  667. c.begin();
  668. c.moveTo(w * 0.3333, h * 0.32);
  669. c.lineTo(w * 0.3333, h * 0.28);
  670. c.lineTo(w * 0.4163, h * 0.3);
  671. c.close();
  672. c.moveTo(w * 0.4662, h * 0.2);
  673. c.lineTo(w * 0.5326, h * 0.2);
  674. c.lineTo(w * 0.4994, h * 0.25);
  675. c.close()
  676. c.moveTo(w * 0.6654, h * 0.28);
  677. c.lineTo(w * 0.6654, h * 0.32);
  678. c.lineTo(w * 0.5824, h * 0.3);
  679. c.close();
  680. c.moveTo(w * 0.5326, h * 0.4);
  681. c.lineTo(w * 0.4662, h * 0.4);
  682. c.lineTo(w * 0.4994, h * 0.35);
  683. c.close();
  684. c.fillAndStroke();
  685. c.setStrokeWidth(2);
  686. c.setStrokeColor(strokeColor3);
  687. c.begin();
  688. c.moveTo(w * 0.5, h * 0.67);
  689. c.lineTo(w * 0.5, h * 0.75);
  690. c.moveTo(w * 0.43, h * 0.71);
  691. c.lineTo(w * 0.57, h * 0.71);
  692. c.moveTo(w * 0.43, h * 0.91);
  693. c.lineTo(w * 0.57, h * 0.91);
  694. c.stroke();
  695. };
  696. mxCellRenderer.registerShape(mxShapeMockupMapNavigator.prototype.cst.SHAPE_MAP_NAVIGATOR, mxShapeMockupMapNavigator);
  697. //**********************************************************************************************************************************************************
  698. //Anchor (a dummy shape without visuals used for anchoring)
  699. //**********************************************************************************************************************************************************
  700. /**
  701. * Extends mxShape.
  702. */
  703. function mxShapeMockupNavigationAnchor(bounds, fill, stroke, strokewidth)
  704. {
  705. mxShape.call(this);
  706. this.bounds = bounds;
  707. };
  708. /**
  709. * Extends mxShape.
  710. */
  711. mxUtils.extend(mxShapeMockupNavigationAnchor, mxShape);
  712. mxShapeMockupNavigationAnchor.prototype.cst = {
  713. ANCHOR : 'mxgraph.mockup.navigation.anchor'
  714. };
  715. /**
  716. * Function: paintVertexShape
  717. *
  718. * Paints the vertex shape.
  719. */
  720. mxShapeMockupNavigationAnchor.prototype.paintVertexShape = function(c, x, y, w, h)
  721. {
  722. };
  723. mxCellRenderer.registerShape(mxShapeMockupNavigationAnchor.prototype.cst.ANCHOR, mxShapeMockupNavigationAnchor);