doors.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  1. /**
  2. * $Id: mxDoors.js,v 1.0 2015/11/17 14:19:14 mate Exp $
  3. * Copyright (c) 2006-2013, JGraph Ltd
  4. */
  5. //**********************************************************************************************************************************************************
  6. //Doors Mockup parent shape
  7. //**********************************************************************************************************************************************************
  8. function mxDoorsMockup(bounds, fill, stroke, strokewidth)
  9. {
  10. mxShape.call(this);
  11. this.bounds = bounds;
  12. this.fill = fill;
  13. this.stroke = stroke;
  14. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  15. };
  16. /**
  17. * Extends mxSwimlane.
  18. */
  19. mxUtils.extend(mxDoorsMockup, mxShape);
  20. //constants
  21. mxDoorsMockup.prototype.cst = {
  22. DECORATED_LABEL : 'mxgraph.doorsMockup.decoratedLabel',
  23. COMBO_BOX : 'mxgraph.doorsMockup.comboBox',
  24. SPINNER : 'mxgraph.doorsMockup.spinner',
  25. TAB_ITEM : 'mxgraph.doorsMockup.tabItem',
  26. IS_DISABLED : 'uiElementDisabled',
  27. IS_SELECTED : 'uiElementSelected',
  28. DISABLED_FILL_COLOR : '#aaaaaa',
  29. DISABLED_STROKE_COLOR : '#666666',
  30. SELECTED_COLOR : '#83A9E2',
  31. CENTER_TEXT : 'uiElementText',
  32. RIGHT_TEXT : 'uiElementRightText',
  33. SHOW_SCROLLBAR : 'uiElementScrollbar',
  34. ICON_ID : 'uiElementIcon',
  35. ICON_STROKE : 'uiElementIconStrokeColor',
  36. ICON_FILL : 'uiElementIconFillColor'
  37. };
  38. //**********************************************************************************************************************************************************
  39. //Vertical Stack Container
  40. //**********************************************************************************************************************************************************
  41. function mxDoorsMockupVerticalStackContainer(bounds, fill, stroke, strokewidth)
  42. {
  43. mxShape.call(this);
  44. this.bounds = bounds;
  45. this.fill = fill;
  46. this.stroke = stroke;
  47. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  48. };
  49. /**
  50. * Extends mxSwimlane.
  51. */
  52. mxUtils.extend(mxDoorsMockupVerticalStackContainer, mxSwimlane);
  53. mxCellRenderer.registerShape('mxgraph.doorsMockup.verticalStackContainer', mxDoorsMockupVerticalStackContainer);
  54. //**********************************************************************************************************************************************************
  55. //Decorated Label
  56. //**********************************************************************************************************************************************************
  57. function mxDoorsMockupDecoratedLabel(bounds, fill, stroke, strokewidth)
  58. {
  59. mxShape.call(this);
  60. this.bounds = bounds;
  61. this.fill = fill;
  62. this.stroke = stroke;
  63. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  64. };
  65. /**
  66. * Extends mxShape.
  67. */
  68. mxUtils.extend(mxDoorsMockupDecoratedLabel, mxDoorsMockup);
  69. /**
  70. * Function: paintVertexShape
  71. *
  72. * Paints the vertex shape.
  73. */
  74. mxDoorsMockupDecoratedLabel.prototype.paintVertexShape = function(c, x, y, w, h)
  75. {
  76. c.translate(x, y);
  77. var iconStroke = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.ICON_STROKE, '#000000');
  78. var iconFill = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.ICON_FILL, '#ffffff');
  79. var iconId = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.ICON_ID, '0');
  80. var centerText = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.CENTER_TEXT, '').toString();
  81. var rightText = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.RIGHT_TEXT, '').toString();
  82. var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '12');
  83. var fontColor = mxUtils.getValue(this.style, mxConstants.STYLE_FONTCOLOR, '#000000');
  84. var isDisabled = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.IS_DISABLED, '0');
  85. var isSelected = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.IS_SELECTED, '0');
  86. if (isDisabled == '1')
  87. {
  88. iconStroke = mxDoorsMockup.prototype.cst.DISABLED_FILL_COLOR;
  89. iconFill = mxDoorsMockup.prototype.cst.DISABLED_FILL_COLOR;
  90. fontColor = mxDoorsMockup.prototype.cst.DISABLED_FILL_COLOR;
  91. }
  92. else if (isSelected == '1')
  93. {
  94. c.setStrokeColor('none');
  95. c.setFillColor(mxDoorsMockup.prototype.cst.SELECTED_COLOR);
  96. }
  97. c.begin();
  98. c.rect(0, 0, w, h);
  99. c.fillAndStroke();
  100. c.setShadow(false);
  101. this.drawIcon(c, h * 0.1, h * 0.1, h * 0.8, h * 0.8, iconStroke, iconFill, iconId);
  102. var indent = 10;
  103. c.setFontSize(fontSize);
  104. c.setFontColor(fontColor);
  105. c.text(w - indent, h * 0.5, 0, 0, rightText, mxConstants.ALIGN_RIGHT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  106. if (iconId > 0)
  107. {
  108. indent = h + indent;
  109. }
  110. c.text(indent, h * 0.5, 0, 0, centerText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  111. };
  112. mxCellRenderer.registerShape(mxDoorsMockup.prototype.cst.DECORATED_LABEL, mxDoorsMockupDecoratedLabel);
  113. //**********************************************************************************************************************************************************
  114. //Icon draw functions
  115. //**********************************************************************************************************************************************************
  116. mxDoorsMockup.prototype.drawIcon = function(c, x, y, w, h, iconStroke, iconFill, iconId)
  117. {
  118. c.save();
  119. c.translate(x, y);
  120. c.setStrokeColor(iconStroke);
  121. c.setFillColor(iconFill);
  122. c.begin();
  123. if (iconId == 2)
  124. {
  125. this.drawClosedFolderIcon(c, 0, h * 0.065, w, h * 0.87);
  126. }
  127. else if (iconId == 3)
  128. {
  129. this.drawOpenFolderIcon(c, 0, h * 0.095, w, h * 0.81);
  130. }
  131. else if (iconId == 4)
  132. {
  133. this.drawPlusBoxIcon(c, 0, 0, w, h);
  134. }
  135. else if (iconId == 5)
  136. {
  137. this.drawMinusBoxIcon(c, 0, 0, w, h);
  138. }
  139. else if (iconId == 6)
  140. {
  141. this.drawRadioButtonOffIcon(c, h * 0.25, h * 0.25, h * 0.5, h * 0.5);
  142. }
  143. else if (iconId == 7)
  144. {
  145. this.drawRadioButtonOnIcon(c, h * 0.25, h * 0.25, h * 0.5, h * 0.5);
  146. }
  147. else if (iconId == 8)
  148. {
  149. this.drawCheckboxOffIcon(c, 0, 0, w, h);
  150. }
  151. else if (iconId == 9)
  152. {
  153. this.drawCheckboxOnIcon(c, 0, 0, w, h);
  154. }
  155. else if (iconId == 10)
  156. {
  157. this.drawCheckboxIndeterminateIcon(c, 0, 0, w, h);
  158. }
  159. else if (iconId == 11)
  160. {
  161. this.drawPlainCheckIcon(c, w * 0.085, h * 0.125, w * 0.83, h * 0.75);
  162. }
  163. else if (iconId == 12)
  164. {
  165. this.drawCircleIcon(c, h * 0.25, h * 0.25, h * 0.5, h * 0.5);
  166. }
  167. else if (iconId == 13)
  168. {
  169. this.drawTwistyClosedIcon(c, w * 0.05, 0, w * 0.9, h);
  170. }
  171. else if (iconId == 14)
  172. {
  173. this.drawTwistyOpenIcon(c, 0, h * 0.05, w, h * 0.9);
  174. }
  175. else if (iconId == 15)
  176. {
  177. this.drawFileIcon(c, w * 0.11, 0, w * 0.78, h);
  178. };
  179. c.restore();
  180. };
  181. mxDoorsMockup.prototype.drawClosedFolderIcon = function(c, x, y, w, h)
  182. {
  183. c.translate(x, y);
  184. c.moveTo(0, h);
  185. c.lineTo(0, h * 0.0805);
  186. c.arcTo(w * 0.07, h * 0.0805, 0, 0, 1, w * 0.07, 0);
  187. c.lineTo(w * 0.35, 0);
  188. c.arcTo(w * 0.07, h * 0.0805, 0, 0, 1, w * 0.42, h * 0.0805);
  189. c.lineTo(w * 0.42, h * 0.1494);
  190. c.lineTo(w * 0.93, h * 0.1494);
  191. c.arcTo(w * 0.07, h * 0.0805, 0, 0, 1, w, h * 0.2299);
  192. c.lineTo(w, h);
  193. c.close();
  194. c.fillAndStroke();
  195. };
  196. mxDoorsMockup.prototype.drawOpenFolderIcon = function(c, x, y, w, h)
  197. {
  198. c.translate(x, y);
  199. c.moveTo(0, h);
  200. c.lineTo(0, h * 0.06173);
  201. c.arcTo(w * 0.05, h * 0.06173, 0, 0, 1, w * 0.05, 0);
  202. c.lineTo(w * 0.28, 0);
  203. c.arcTo(w * 0.05, h * 0.06173, 0, 0, 1, w * 0.33, h * 0.06173);
  204. c.lineTo(w * 0.33, h * 0.1358);
  205. c.lineTo(w * 0.78, h * 0.1358);
  206. c.arcTo(w * 0.05, h * 0.06173, 0, 0, 1, w * 0.83, h * 0.1975);
  207. c.lineTo(w * 0.83, h * 0.2716);
  208. c.lineTo(w, h * 0.2716);
  209. c.lineTo(w * 0.83, h);
  210. c.close();
  211. c.stroke();
  212. c.setShadow(false);
  213. c.begin();
  214. c.moveTo(0, h);
  215. c.lineTo(w * 0.12, h * 0.2716);
  216. c.lineTo(w, h * 0.2716);
  217. c.lineTo(w * 0.83, h);
  218. c.fillAndStroke();
  219. };
  220. mxDoorsMockup.prototype.drawPlusBoxIcon = function(c, x, y, w, h)
  221. {
  222. c.translate(x, y);
  223. c.rect(0, 0, w, h);
  224. c.stroke();
  225. c.setStrokeWidth(4);
  226. c.begin();
  227. c.moveTo(w * 0.1, h * 0.5);
  228. c.lineTo(w * 0.9, h * 0.5);
  229. c.moveTo(w * 0.5, h * 0.1);
  230. c.lineTo(w * 0.5, h * 0.9);
  231. c.stroke();
  232. };
  233. mxDoorsMockup.prototype.drawMinusBoxIcon = function(c, x, y, w, h)
  234. {
  235. c.translate(x, y);
  236. c.rect(0, 0, w, h);
  237. c.stroke();
  238. c.setStrokeWidth(4);
  239. c.begin();
  240. c.moveTo(w * 0.1, h * 0.5);
  241. c.lineTo(w * 0.9, h * 0.5);
  242. c.stroke();
  243. };
  244. mxDoorsMockup.prototype.drawRadioButtonOffIcon = function(c, x, y, w, h)
  245. {
  246. c.translate(x, y);
  247. c.ellipse(0, 0, w, h);
  248. c.stroke();
  249. };
  250. mxDoorsMockup.prototype.drawRadioButtonOnIcon = function(c, x, y, w, h)
  251. {
  252. c.translate(x, y);
  253. c.ellipse(0, 0, w, h);
  254. c.stroke();
  255. c.ellipse(w * 0.15, h * 0.15, w * 0.7, h * 0.7);
  256. c.fill();
  257. };
  258. mxDoorsMockup.prototype.drawCheckboxOffIcon = function(c, x, y, w, h)
  259. {
  260. c.translate(x, y);
  261. c.rect(0, 0, w, h);
  262. c.stroke();
  263. };
  264. mxDoorsMockup.prototype.drawCheckboxOnIcon = function(c, x, y, w, h)
  265. {
  266. c.translate(x, y);
  267. c.rect(0, 0, w, h);
  268. c.stroke();
  269. c.setStrokeWidth(4);
  270. c.setLineJoin('round');
  271. c.setLineCap('round');
  272. c.begin();
  273. c.moveTo(w * 0.08, h * 0.64);
  274. c.lineTo(w * 0.31, h * 0.9);
  275. c.lineTo(w * 0.91, h * 0.15);
  276. c.stroke();
  277. };
  278. mxDoorsMockup.prototype.drawCheckboxIndeterminateIcon = function(c, x, y, w, h)
  279. {
  280. c.translate(x, y);
  281. c.rect(0, 0, w, h);
  282. c.stroke();
  283. c.begin();
  284. c.rect(w * 0.1, h * 0.1, w * 0.8, h * 0.8);
  285. c.fill();
  286. };
  287. mxDoorsMockup.prototype.drawPlainCheckIcon = function(c, x, y, w, h)
  288. {
  289. c.translate(x, y);
  290. c.setStrokeWidth(4);
  291. c.setLineJoin('round');
  292. c.setLineCap('round');
  293. c.begin();
  294. c.moveTo(0, h * 0.6533);
  295. c.lineTo(w * 0.2771, h);
  296. c.lineTo(w, 0);
  297. c.stroke();
  298. };
  299. mxDoorsMockup.prototype.drawCircleIcon = function(c, x, y, w, h)
  300. {
  301. c.translate(x, y);
  302. c.ellipse(0, 0, w, h);
  303. c.fillAndStroke();
  304. };
  305. mxDoorsMockup.prototype.drawTwistyClosedIcon = function(c, x, y, w, h)
  306. {
  307. c.translate(x, y);
  308. c.moveTo(0, 0);
  309. c.lineTo(w, h * 0.5);
  310. c.lineTo(0, h);
  311. c.close();
  312. c.fillAndStroke();
  313. };
  314. mxDoorsMockup.prototype.drawTwistyOpenIcon = function(c, x, y, w, h)
  315. {
  316. c.translate(x, y);
  317. c.moveTo(0, 0);
  318. c.lineTo(w * 0.5, h);
  319. c.lineTo(w, 0);
  320. c.close();
  321. c.fillAndStroke();
  322. };
  323. mxDoorsMockup.prototype.drawFileIcon = function(c, x, y, w, h)
  324. {
  325. c.translate(x, y);
  326. c.moveTo(w * 0.0641, h);
  327. c.arcTo(w * 0.0641, h * 0.05, 0, 0, 1, 0, h * 0.95);
  328. c.lineTo(0, h * 0.05);
  329. c.arcTo(w * 0.0641, h * 0.05, 0, 0, 1, w * 0.0641, 0);
  330. c.lineTo(w * 0.6667, 0);
  331. c.lineTo(w, h * 0.2);
  332. c.lineTo(w, h * 0.95);
  333. c.arcTo(w * 0.0641, h * 0.05, 0, 0, 1, w * 0.9359, h);
  334. c.close();
  335. c.moveTo(w * 0.0897, h * 0.92);
  336. c.lineTo(w * 0.9103, h * 0.92);
  337. c.lineTo(w * 0.9103, h * 0.26);
  338. c.lineTo(w * 0.577, h * 0.26);
  339. c.arcTo(w * 0.0641, h * 0.05, 0, 0, 1, w * 0.5385, h * 0.23);
  340. c.lineTo(w * 0.5385, h * 0.08);
  341. c.lineTo(w * 0.0897, h * 0.08);
  342. c.close();
  343. c.moveTo(w * 0.2308, h * 0.8);
  344. c.lineTo(w * 0.2308, h * 0.73);
  345. c.lineTo(w * 0.7821, h * 0.73);
  346. c.lineTo(w * 0.7821, h * 0.8);
  347. c.close();
  348. c.moveTo(w * 0.2308, h * 0.63);
  349. c.lineTo(w * 0.2308, h * 0.56);
  350. c.lineTo(w * 0.7821, h * 0.56);
  351. c.lineTo(w * 0.7821, h * 0.63);
  352. c.close();
  353. c.moveTo(w * 0.2308, h * 0.44);
  354. c.lineTo(w * 0.2308, h * 0.37);
  355. c.lineTo(w * 0.7821, h * 0.37);
  356. c.lineTo(w * 0.7821, h * 0.44);
  357. c.close();
  358. c.moveTo(w * 0.2308, h * 0.26);
  359. c.lineTo(w * 0.2308, h * 0.19);
  360. c.lineTo(w * 0.4231, h * 0.19);
  361. c.lineTo(w * 0.4231, h * 0.26);
  362. c.close();
  363. c.fillAndStroke();
  364. };
  365. //**********************************************************************************************************************************************************
  366. //Listbox
  367. //**********************************************************************************************************************************************************
  368. function mxDoorsMockupListbox(bounds, fill, stroke, strokewidth)
  369. {
  370. mxShape.call(this);
  371. this.bounds = bounds;
  372. this.fill = fill;
  373. this.stroke = stroke;
  374. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  375. };
  376. /**
  377. * Extends mxSwimlane.
  378. */
  379. mxUtils.extend(mxDoorsMockupListbox, mxSwimlane);
  380. /**
  381. * Function: paintVertexShape
  382. *
  383. * Paints the swimlane vertex shape.
  384. */
  385. mxDoorsMockupListbox.prototype.paintVertexShape = function(c, x, y, w, h)
  386. {
  387. var start = this.getTitleSize();
  388. var fill = mxUtils.getValue(this.style, mxConstants.STYLE_SWIMLANE_FILLCOLOR, mxConstants.NONE);
  389. var swimlaneLine = mxUtils.getValue(this.style, mxConstants.STYLE_SWIMLANE_LINE, 1) == 1;
  390. var r = 0;
  391. start = Math.min(start, h);
  392. c.translate(x, y);
  393. this.paintSwimlane(c, x, y, w, h, start, fill, swimlaneLine);
  394. var sep = mxUtils.getValue(this.style, mxConstants.STYLE_SEPARATORCOLOR, mxConstants.NONE);
  395. this.paintSeparator(c, x, y, w, h, start, sep);
  396. if (this.image != null)
  397. {
  398. var bounds = this.getImageBounds(x, y, w, h);
  399. c.image(bounds.x - x, bounds.y - y, bounds.width, bounds.height,
  400. this.image, false, false, false);
  401. }
  402. if (this.glass)
  403. {
  404. c.setShadow(false);
  405. this.paintGlassEffect(c, 0, 0, w, start, r);
  406. }
  407. };
  408. /**
  409. * Function: paintSwimlane
  410. *
  411. * Paints the swimlane vertex shape.
  412. */
  413. //TODO resolve inheritance issue
  414. // for now, if you want to see the scrollbar, switch the comment on the two lines below
  415. // if upper line is enabled, no scrollbar will be visible
  416. // the lower line enables scrollbar visibility, but messes up other shapes based on mxSwimlane
  417. mxDoorsMockupListbox.prototype.paintSwimlane = function(c, x, y, w, h, start, fill, swimlaneLine)
  418. //mxSwimlane.prototype.paintSwimlane = function(c, x, y, w, h, start, fill, swimlaneLine)
  419. {
  420. if (fill != mxConstants.NONE)
  421. {
  422. c.save();
  423. c.setFillColor(fill);
  424. c.rect(0, 0, w, h);
  425. c.fillAndStroke();
  426. c.restore();
  427. c.setShadow(false);
  428. }
  429. c.begin();
  430. c.moveTo(0, start);
  431. c.lineTo(0, 0);
  432. c.lineTo(w, 0);
  433. c.lineTo(w, start);
  434. if (swimlaneLine || start >= h)
  435. {
  436. c.close();
  437. }
  438. c.fillAndStroke();
  439. var showScrollbar = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.SHOW_SCROLLBAR, '0');
  440. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  441. var sbw = 20; //scrollbar width
  442. if (showScrollbar == 1 && (h - start - 2 * sbw > 0) && (w > sbw))
  443. {
  444. c.save();
  445. c.begin();
  446. c.rect(w - sbw, start, sbw, h - start);
  447. c.stroke();
  448. c.begin();
  449. c.moveTo(w - sbw, start + sbw);
  450. c.lineTo(w, start + sbw);
  451. c.moveTo(w - sbw, h - sbw);
  452. c.lineTo(w, h - sbw);
  453. c.stroke();
  454. c.setFillColor(strokeColor);
  455. c.begin();
  456. c.moveTo(w - sbw * 0.8, start + sbw * 0.8);
  457. c.lineTo(w - sbw * 0.5, start + sbw * 0.2);
  458. c.lineTo(w - sbw * 0.2, start + sbw * 0.8);
  459. c.close();
  460. c.moveTo(w - sbw * 0.8, h - sbw * 0.8);
  461. c.lineTo(w - sbw * 0.5, h - sbw * 0.2);
  462. c.lineTo(w - sbw * 0.2, h - sbw * 0.8);
  463. c.close();
  464. c.fill();
  465. if (h > start + sbw * 5.2)
  466. {
  467. c.rect(w - sbw * 0.8, start + sbw * 1.2, sbw * 0.6, sbw * 3);
  468. c.fill();
  469. }
  470. else if (h > start + sbw * 2.4)
  471. {
  472. c.rect(w - sbw * 0.8, start + sbw * 1.2, sbw * 0.6, h - start - 2.4 * sbw);
  473. c.fill();
  474. }
  475. c.restore();
  476. }
  477. // Transparent content area
  478. if (start < h && fill == mxConstants.NONE)
  479. {
  480. c.pointerEvents = false;
  481. c.begin();
  482. c.moveTo(0, start);
  483. c.lineTo(0, h);
  484. c.lineTo(w, h);
  485. c.lineTo(w, start);
  486. c.stroke();
  487. }
  488. };
  489. mxCellRenderer.registerShape('mxgraph.doorsMockup.listbox', mxDoorsMockupListbox);
  490. //**********************************************************************************************************************************************************
  491. //Combo box
  492. //**********************************************************************************************************************************************************
  493. function mxDoorsMockupComboBox(bounds, fill, stroke, strokewidth)
  494. {
  495. mxShape.call(this);
  496. this.bounds = bounds;
  497. this.fill = fill;
  498. this.stroke = stroke;
  499. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  500. };
  501. /**
  502. * Extends mxShape.
  503. */
  504. mxUtils.extend(mxDoorsMockupComboBox, mxDoorsMockup);
  505. /**
  506. * Function: paintVertexShape
  507. *
  508. * Paints the vertex shape.
  509. */
  510. mxDoorsMockupComboBox.prototype.paintVertexShape = function(c, x, y, w, h)
  511. {
  512. c.translate(x, y);
  513. this.background(c, x, y, w, h);
  514. c.setShadow(false);
  515. this.foreground(c, x, y, w, h);
  516. };
  517. mxDoorsMockupComboBox.prototype.background = function(c, x, y, w, h)
  518. {
  519. var isDisabled = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.IS_DISABLED, '0');
  520. c.save();
  521. if (isDisabled == 1)
  522. {
  523. c.setStrokeColor(mxDoorsMockup.prototype.cst.DISABLED_STROKE_COLOR);
  524. c.setFillColor(mxDoorsMockup.prototype.cst.DISABLED_FILL_COLOR);
  525. c.setFontColor(mxDoorsMockup.prototype.cst.DISABLED_STROKE_COLOR);
  526. }
  527. else
  528. {
  529. c.setFillColor('#ffffff');
  530. }
  531. c.rect(0, 0, w, h);
  532. c.fillAndStroke();
  533. c.restore();
  534. };
  535. mxDoorsMockupComboBox.prototype.foreground = function(c, x, y, w, h)
  536. {
  537. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  538. var isDisabled = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.IS_DISABLED, '0');
  539. var isSelected = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.IS_SELECTED, '0');
  540. if (isDisabled == 1)
  541. {
  542. c.setStrokeColor(mxDoorsMockup.prototype.cst.DISABLED_STROKE_COLOR);
  543. c.setFillColor(mxDoorsMockup.prototype.cst.DISABLED_FILL_COLOR);
  544. }
  545. else if (isSelected == 1)
  546. {
  547. c.setFillColor(mxDoorsMockup.prototype.cst.SELECTED_COLOR);
  548. }
  549. if (w > h)
  550. {
  551. c.rect(w - h, 0, h, h);
  552. c.fillAndStroke();
  553. if (isDisabled == 1 || isSelected == 1)
  554. {
  555. c.setFillColor(mxDoorsMockup.prototype.cst.DISABLED_STROKE_COLOR);
  556. }
  557. else
  558. {
  559. c.setFillColor(strokeColor);
  560. }
  561. c.begin();
  562. c.moveTo(w - h * 0.8, h * 0.2);
  563. c.lineTo(w - h * 0.2, h * 0.2);
  564. c.lineTo(w - h * 0.5, h * 0.8);
  565. c.close();
  566. c.fill();
  567. }
  568. var centerText = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.CENTER_TEXT, '').toString();
  569. c.setFontSize(mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '12'));
  570. if (isDisabled == 1)
  571. {
  572. c.setFontColor(mxDoorsMockup.prototype.cst.DISABLED_STROKE_COLOR);
  573. }
  574. else
  575. {
  576. c.setFontColor(mxUtils.getValue(this.style, mxConstants.STYLE_FONTCOLOR, '#000000'));
  577. }
  578. c.text(10, h * 0.5, 0, 0, centerText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  579. };
  580. mxCellRenderer.registerShape(mxDoorsMockup.prototype.cst.COMBO_BOX, mxDoorsMockupComboBox);
  581. //**********************************************************************************************************************************************************
  582. //Spinner
  583. //**********************************************************************************************************************************************************
  584. function mxDoorsMockupSpinner(bounds, fill, stroke, strokewidth)
  585. {
  586. mxShape.call(this);
  587. this.bounds = bounds;
  588. this.fill = fill;
  589. this.stroke = stroke;
  590. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  591. };
  592. /**
  593. * Extends mxShape.
  594. */
  595. mxUtils.extend(mxDoorsMockupSpinner, mxDoorsMockup);
  596. /**
  597. * Function: paintVertexShape
  598. *
  599. * Paints the vertex shape.
  600. */
  601. mxDoorsMockupSpinner.prototype.paintVertexShape = function(c, x, y, w, h)
  602. {
  603. c.translate(x, y);
  604. this.background(c, x, y, w, h);
  605. c.setShadow(false);
  606. this.foreground(c, x, y, w, h);
  607. };
  608. mxDoorsMockupSpinner.prototype.background = function(c, x, y, w, h)
  609. {
  610. var isDisabled = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.IS_DISABLED, '0');
  611. c.save();
  612. if (isDisabled == 1)
  613. {
  614. c.setStrokeColor(mxDoorsMockup.prototype.cst.DISABLED_STROKE_COLOR);
  615. c.setFontColor(mxDoorsMockup.prototype.cst.DISABLED_STROKE_COLOR);
  616. }
  617. else
  618. {
  619. c.setFillColor('#ffffff');
  620. }
  621. c.rect(0, 0, w, h);
  622. c.fillAndStroke();
  623. c.restore();
  624. };
  625. mxDoorsMockupSpinner.prototype.foreground = function(c, x, y, w, h)
  626. {
  627. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  628. var isDisabled = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.IS_DISABLED, '0');
  629. if (isDisabled == 1)
  630. {
  631. c.setStrokeColor(mxDoorsMockup.prototype.cst.DISABLED_STROKE_COLOR);
  632. c.setFillColor(mxDoorsMockup.prototype.cst.DISABLED_FILL_COLOR);
  633. }
  634. if (w > h)
  635. {
  636. if (isDisabled == 1)
  637. {
  638. c.setFillColor(mxDoorsMockup.prototype.cst.DISABLED_FILL_COLOR);
  639. }
  640. c.rect(w - h, 0, h, h);
  641. c.fillAndStroke();
  642. if (isDisabled == 1)
  643. {
  644. c.setFillColor(mxDoorsMockup.prototype.cst.DISABLED_STROKE_COLOR);
  645. }
  646. else
  647. {
  648. c.setFillColor(strokeColor);
  649. }
  650. c.begin();
  651. c.moveTo(w - h * 0.2, h * 0.4);
  652. c.lineTo(w - h * 0.5, h * 0.2);
  653. c.lineTo(w - h * 0.8, h * 0.4);
  654. c.close();
  655. c.moveTo(w - h * 0.2, h * 0.6);
  656. c.lineTo(w - h * 0.8, h * 0.6);
  657. c.lineTo(w - h * 0.5, h * 0.8);
  658. c.close();
  659. c.fill();
  660. }
  661. var centerText = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.CENTER_TEXT, '').toString();
  662. c.setFontSize(mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '12'));
  663. if (isDisabled == 1)
  664. {
  665. c.setFontColor(mxDoorsMockup.prototype.cst.DISABLED_STROKE_COLOR);
  666. }
  667. else
  668. {
  669. c.setFontColor(mxUtils.getValue(this.style, mxConstants.STYLE_FONTCOLOR, '#000000'));
  670. }
  671. c.text(10, h * 0.5, 0, 0, centerText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  672. };
  673. mxCellRenderer.registerShape(mxDoorsMockup.prototype.cst.SPINNER, mxDoorsMockupSpinner);
  674. //**********************************************************************************************************************************************************
  675. //Tab Item
  676. //**********************************************************************************************************************************************************
  677. function mxDoorsMockupTabItem(bounds, fill, stroke, strokewidth)
  678. {
  679. mxShape.call(this);
  680. this.bounds = bounds;
  681. this.fill = fill;
  682. this.stroke = stroke;
  683. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  684. };
  685. /**
  686. * Extends mxShape.
  687. */
  688. mxUtils.extend(mxDoorsMockupTabItem, mxDoorsMockup);
  689. /**
  690. * Function: paintVertexShape
  691. *
  692. * Paints the vertex shape.
  693. */
  694. mxDoorsMockupTabItem.prototype.paintVertexShape = function(c, x, y, w, h)
  695. {
  696. c.translate(x, y);
  697. this.background(c, x, y, w, h);
  698. c.setShadow(false);
  699. this.foreground(c, x, y, w, h);
  700. };
  701. mxDoorsMockupTabItem.prototype.background = function(c, x, y, w, h)
  702. {
  703. var isDisabled = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.IS_DISABLED, '0');
  704. var isSelected = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.IS_SELECTED, '0');
  705. c.save();
  706. if (isDisabled == 1)
  707. {
  708. c.setStrokeColor(mxDoorsMockup.prototype.cst.DISABLED_STROKE_COLOR);
  709. c.setFillColor(mxDoorsMockup.prototype.cst.DISABLED_FILL_COLOR);
  710. c.setFontColor(mxDoorsMockup.prototype.cst.DISABLED_STROKE_COLOR);
  711. }
  712. else if(isSelected == 1)
  713. {
  714. c.setFillColor(mxDoorsMockup.prototype.cst.SELECTED_COLOR);
  715. }
  716. else
  717. {
  718. c.setFillColor('#ffffff');
  719. }
  720. var rSize = 10;
  721. if (rSize > h || 2 * rSize > w)
  722. {
  723. c.rect(0, 0, w, h);
  724. }
  725. else
  726. {
  727. c.begin();
  728. c.moveTo(0, h);
  729. c.lineTo(0, rSize);
  730. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  731. c.lineTo(w - rSize, 0);
  732. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  733. c.lineTo(w, h);
  734. c.close();
  735. }
  736. c.fillAndStroke();
  737. c.restore();
  738. if (isDisabled == 1)
  739. {
  740. c.setFontColor(mxDoorsMockup.prototype.cst.DISABLED_STROKE_COLOR);
  741. }
  742. else if (isSelected == 1)
  743. {
  744. c.setFontColor('#ffffff');
  745. }
  746. else
  747. {
  748. c.setFontColor(mxUtils.getValue(this.style, mxConstants.STYLE_FONTCOLOR, '#000000'));
  749. }
  750. };
  751. mxDoorsMockupTabItem.prototype.foreground = function(c, x, y, w, h)
  752. {
  753. var centerText = mxUtils.getValue(this.style, mxDoorsMockup.prototype.cst.CENTER_TEXT, '').toString();
  754. c.setFontSize(mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '12'));
  755. c.text(w * 0.5, h * 0.5, 0, 0, centerText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  756. };
  757. mxCellRenderer.registerShape(mxDoorsMockup.prototype.cst.TAB_ITEM, mxDoorsMockupTabItem);
  758. /**
  759. * Order is relevant. Do not move to start of file!
  760. */
  761. Draw.loadPlugin(function(ui)
  762. {
  763. var w = 100;
  764. var h = 100;
  765. var s = 'dashed=0;shape=mxgraph.doorsMockup.';
  766. var gn = 'mxgraph.doorsMockup';
  767. var dt = '';
  768. // Avoids having to bind all functions to "this"
  769. var sb = ui.sidebar;
  770. // Reusable cells
  771. var field = new mxCell('item: attribute', new mxGeometry(0, 0, 100, 20), 'label;html=1;fontStyle=0;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;overflow=hidden;' +
  772. 'spacingRight=4;whiteSpace=wrap;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;imageWidth=16;imageHeight=16;image=' + sb.gearImage);
  773. field.vertex = true;
  774. // Default tags
  775. var dt = 'uml static class ';
  776. var fns = [
  777. sb.addEntry(dt + 'tree', function()
  778. {
  779. var cell = new mxCell('Tree', new mxGeometry(0, 0, 140, 110),
  780. 'swimlane;html=1;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=none;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=1;marginBottom=0;swimlaneFillColor=#ffffff;');
  781. cell.vertex = true;
  782. var first = field.clone();
  783. first.style += ';spacingLeft=28;';
  784. cell.insert(first);
  785. var second = field.clone();
  786. second.style += ';spacingLeft=48;';
  787. cell.insert(second);
  788. var third = field.clone();
  789. third.style += ';spacingLeft=68;';
  790. cell.insert(third);
  791. return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Tree');
  792. }),
  793. sb.createVertexTemplateEntry(s + 'verticalStackContainer;swimlane;childLayout=stackLayout;horizontal=1;startSize=26;strokeColor=#000000;fillColor=none;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=0;marginBottom=0;swimlaneFillColor=#ffffff;', w * 2, h * 3, 'vStack', 'Vertical Stack Container', null, null, null),
  794. sb.createVertexTemplateEntry(s + 'verticalStackContainer;swimlane;childLayout=stackLayout;horizontal=1;startSize=0;strokeColor=#000000;fillColor=none;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=0;marginBottom=0;swimlaneFillColor=#ffffff;', w * 2, h * 3, '', 'Vertical Stack Container (no header)', null, null, null),
  795. sb.createVertexTemplateEntry(s + 'verticalStackContainer;swimlane;childLayout=stackLayout;horizontal=0;startSize=26;strokeColor=#000000;fillColor=none;horizontalStack=1;resizeParent=1;resizeLast=0;collapsible=0;marginBottom=0;swimlaneFillColor=#ffffff;', w * 3, h * 2, 'hStack', 'Horizontal Stack Container', null, null, null),
  796. sb.createVertexTemplateEntry(s + 'decoratedLabel;dashed=0;strokeWidth=2;strokeColor=none;fillColor=none;uiElementText=Toggle;uiElementRightText=Right Text;uiElementIcon=11;uiElementIconStrokeColor=#000000;uiElementIconFillColor=#000000;fontSize=14;fontColor=#000000;uiElementDisabled=0;uiElementSelected=0;', w * 2, h * 0.4, '', 'Decorated Label', null, null, null),
  797. sb.createVertexTemplateEntry(s + 'verticalStackContainer;swimlane;childLayout=stackLayout;horizontal=1;startSize=0;strokeColor=#000000;fillColor=none;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=0;marginBottom=0;swimlaneFillColor=#ffffff;', w * 2, h * 3, '', 'Menu', null, null, null),
  798. sb.createVertexTemplateEntry(s + 'listbox;swimlane;childLayout=stackLayout;startSize=0;strokeColor=#000000;fillColor=none;horizontalStack=0;resizeParent=1;resizeLast=0;collapsible=0;marginBottom=0;swimlaneFillColor=#ffffff;uiElementScrollbar=1;marginRight=20;', w * 2, h * 3, '', 'Listbox', null, null, null),
  799. sb.createVertexTemplateEntry(s + 'comboBox;dashed=0;strokeWidth=1;strokeColor=#000000;fillColor=#ffffff;fontSize=14;fontColor=#000000;uiElementDisabled=0;uiElementSelected=0;align=left;verticalAlign=middle;uiElementText=Text;', w * 2, h * 0.4, '', 'Combo box', null, null, null),
  800. sb.createVertexTemplateEntry(s + 'spinner;dashed=0;strokeWidth=1;strokeColor=#000000;fillColor=#ffffff;fontSize=14;fontColor=#000000;uiElementDisabled=0;uiElementSelected=0;align=left;verticalAlign=middle;uiElementText=100;', w * 1, h * 0.3, '', 'Spinner', null, null, null),
  801. sb.createVertexTemplateEntry(s + 'spinner;dashed=0;strokeWidth=1;strokeColor=#B3B3B3;fillColor=#ffffff;fontSize=14;fontColor=#B3B3B3;uiElementDisabled=0;uiElementSelected=0;align=left;verticalAlign=middle;uiElementText=100;', w * 1, h * 0.3, '', 'Spinner', null, null, null),
  802. sb.createVertexTemplateEntry(s + 'verticalStackContainer;swimlane;childLayout=stackLayout;horizontal=0;startSize=0;strokeColor=none;fillColor=none;horizontalStack=1;resizeParent=1;resizeLast=0;collapsible=0;marginBottom=0;swimlaneFillColor=none;', w * 5, h * 0.4, '', 'Tabbar', null, null, null),
  803. sb.createVertexTemplateEntry(s + 'tabItem;dashed=0;strokeWidth=1;strokeColor=#000000;fillColor=#ffffff;fontSize=14;fontColor=#000000;uiElementDisabled=0;uiElementSelected=0;align=left;verticalAlign=middle;uiElementText=Tab one;', w * 1, h * 0.3, '', 'Tab Item', null, null, null)
  804. ];
  805. ui.sidebar.addPaletteFunctions('doorsMockup', 'Doors Mockup', true, fns);
  806. // Collapses default sidebar entry and inserts this before
  807. var c = ui.sidebar.container;
  808. c.firstChild.click();
  809. c.insertBefore(c.lastChild, c.firstChild);
  810. c.insertBefore(c.lastChild, c.firstChild);
  811. });