mxMockupNavigation.js 24 KB

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