mxMockupNavigation.js 25 KB

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