mxPidInstruments.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. /**
  2. * Copyright (c) 2006-2013, JGraph Holdings Ltd
  3. */
  4. //**********************************************************************************************************************************************************
  5. //Discrete Instrument
  6. //**********************************************************************************************************************************************************
  7. /**
  8. * Extends mxShape.
  9. */
  10. function mxShapePidDiscInst(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(mxShapePidDiscInst, mxShape);
  22. mxShapePidDiscInst.prototype.cst = {
  23. SHAPE_DISC_INST : 'mxgraph.pid2inst.discInst',
  24. MOUNTING : 'mounting',
  25. FIELD : 'field',
  26. ROOM : 'room',
  27. INACCESSIBLE : 'inaccessible',
  28. LOCAL : 'local'
  29. };
  30. mxShapePidDiscInst.prototype.customProperties = [
  31. {name: 'mounting', dispName: 'Mounting', type: 'enum', defVal:'field',
  32. enumList: [
  33. {val:'field', dispName:'Field'},
  34. {val:'room', dispName:'Room'},
  35. {val:'inaccessible', dispName:'Inaccessible'},
  36. {val:'local', dispName:'Local'}
  37. ]}
  38. ];
  39. /**
  40. * Function: paintVertexShape
  41. *
  42. * Paints the vertex shape.
  43. */
  44. mxShapePidDiscInst.prototype.paintVertexShape = function(c, x, y, w, h)
  45. {
  46. c.translate(x, y);
  47. this.background(c, x, y, w, h);
  48. c.setShadow(false);
  49. this.foreground(c, x, y, w, h);
  50. };
  51. mxShapePidDiscInst.prototype.background = function(c, x, y, w, h)
  52. {
  53. c.ellipse(0, 0, w, h);
  54. c.fillAndStroke();
  55. };
  56. mxShapePidDiscInst.prototype.foreground = function(c, x, y, w, h)
  57. {
  58. var mounting = mxUtils.getValue(this.style, mxShapePidDiscInst.prototype.cst.MOUNTING, 'field');
  59. if (mounting === mxShapePidDiscInst.prototype.cst.ROOM)
  60. {
  61. c.begin();
  62. c.moveTo(0, h * 0.5);
  63. c.lineTo(w, h * 0.5);
  64. c.stroke();
  65. }
  66. else if (mounting === mxShapePidDiscInst.prototype.cst.INACCESSIBLE)
  67. {
  68. c.setDashed(true);
  69. c.begin();
  70. c.moveTo(0, h * 0.5);
  71. c.lineTo(w, h * 0.5);
  72. c.stroke();
  73. }
  74. else if (mounting === mxShapePidDiscInst.prototype.cst.LOCAL)
  75. {
  76. c.begin();
  77. c.moveTo(w * 0.005, h * 0.48);
  78. c.lineTo(w * 0.995, h * 0.48);
  79. c.moveTo(w * 0.005, h * 0.52);
  80. c.lineTo(w * 0.995, h * 0.52);
  81. c.stroke();
  82. }
  83. };
  84. mxCellRenderer.registerShape(mxShapePidDiscInst.prototype.cst.SHAPE_DISC_INST, mxShapePidDiscInst);
  85. mxShapePidDiscInst.prototype.constraints = [
  86. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  87. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  88. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  89. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  90. new mxConnectionConstraint(new mxPoint(0.145, 0.145), false),
  91. new mxConnectionConstraint(new mxPoint(0.145, 0.855), false),
  92. new mxConnectionConstraint(new mxPoint(0.855, 0.145), false),
  93. new mxConnectionConstraint(new mxPoint(0.855, 0.855), false)
  94. ];
  95. //**********************************************************************************************************************************************************
  96. //Shared Control/Display
  97. //**********************************************************************************************************************************************************
  98. /**
  99. * Extends mxShape.
  100. */
  101. function mxShapePidSharedCont(bounds, fill, stroke, strokewidth)
  102. {
  103. mxShape.call(this);
  104. this.bounds = bounds;
  105. this.fill = fill;
  106. this.stroke = stroke;
  107. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  108. };
  109. /**
  110. * Extends mxShape.
  111. */
  112. mxUtils.extend(mxShapePidSharedCont, mxShape);
  113. mxShapePidSharedCont.prototype.cst = {
  114. SHAPE_SHARED_CONT : 'mxgraph.pid2inst.sharedCont',
  115. MOUNTING : 'mounting',
  116. FIELD : 'field',
  117. ROOM : 'room',
  118. INACCESSIBLE : 'inaccessible',
  119. LOCAL : 'local'
  120. };
  121. mxShapePidSharedCont.prototype.customProperties = [
  122. {name: 'mounting', dispName: 'Mounting', type: 'enum', defVal:'field',
  123. enumList: [
  124. {val:'field', dispName:'Field'},
  125. {val:'room', dispName:'Room'},
  126. {val:'inaccessible', dispName:'Inaccessible'},
  127. {val:'local', dispName:'Local'}
  128. ]}
  129. ];
  130. /**
  131. * Function: paintVertexShape
  132. *
  133. * Paints the vertex shape.
  134. */
  135. mxShapePidSharedCont.prototype.paintVertexShape = function(c, x, y, w, h)
  136. {
  137. c.translate(x, y);
  138. this.background(c, x, y, w, h);
  139. c.setShadow(false);
  140. this.foreground(c, x, y, w, h);
  141. };
  142. mxShapePidSharedCont.prototype.background = function(c, x, y, w, h)
  143. {
  144. c.rect(0, 0, w, h);
  145. c.fillAndStroke();
  146. };
  147. mxShapePidSharedCont.prototype.foreground = function(c, x, y, w, h)
  148. {
  149. var mounting = mxUtils.getValue(this.style, mxShapePidSharedCont.prototype.cst.MOUNTING, 'field');
  150. c.ellipse(0, 0, w, h);
  151. c.fillAndStroke();
  152. if (mounting === mxShapePidSharedCont.prototype.cst.ROOM)
  153. {
  154. c.begin();
  155. c.moveTo(0, h * 0.5);
  156. c.lineTo(w, h * 0.5);
  157. c.stroke();
  158. }
  159. else if (mounting === mxShapePidSharedCont.prototype.cst.INACCESSIBLE)
  160. {
  161. c.setDashed(true);
  162. c.begin();
  163. c.moveTo(0, h * 0.5);
  164. c.lineTo(w, h * 0.5);
  165. c.stroke();
  166. }
  167. else if (mounting === mxShapePidDiscInst.prototype.cst.LOCAL)
  168. {
  169. c.begin();
  170. c.moveTo(w * 0.005, h * 0.48);
  171. c.lineTo(w * 0.995, h * 0.48);
  172. c.moveTo(w * 0.005, h * 0.52);
  173. c.lineTo(w * 0.995, h * 0.52);
  174. c.stroke();
  175. }
  176. };
  177. mxCellRenderer.registerShape(mxShapePidSharedCont.prototype.cst.SHAPE_SHARED_CONT, mxShapePidSharedCont);
  178. mxShapePidSharedCont.prototype.constraints = [
  179. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  180. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  181. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  182. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  183. new mxConnectionConstraint(new mxPoint(0, 0), false),
  184. new mxConnectionConstraint(new mxPoint(0, 1), false),
  185. new mxConnectionConstraint(new mxPoint(1, 0), false),
  186. new mxConnectionConstraint(new mxPoint(1, 1), false)
  187. ];
  188. //**********************************************************************************************************************************************************
  189. //Computer Function
  190. //**********************************************************************************************************************************************************
  191. /**
  192. * Extends mxShape.
  193. */
  194. function mxShapePidCompFunc(bounds, fill, stroke, strokewidth)
  195. {
  196. mxShape.call(this);
  197. this.bounds = bounds;
  198. this.fill = fill;
  199. this.stroke = stroke;
  200. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  201. };
  202. /**
  203. * Extends mxShape.
  204. */
  205. mxUtils.extend(mxShapePidCompFunc, mxShape);
  206. mxShapePidCompFunc.prototype.cst = {
  207. SHAPE_COMP_FUNC : 'mxgraph.pid2inst.compFunc',
  208. MOUNTING : 'mounting',
  209. FIELD : 'field',
  210. ROOM : 'room',
  211. INACCESSIBLE : 'inaccessible',
  212. LOCAL : 'local'
  213. };
  214. mxShapePidCompFunc.prototype.customProperties = [
  215. {name: 'mounting', dispName: 'Mounting', type: 'enum', defVal:'field',
  216. enumList: [
  217. {val:'field', dispName:'Field'},
  218. {val:'room', dispName:'Room'},
  219. {val:'inaccessible', dispName:'Inaccessible'},
  220. {val:'local', dispName:'Local'}
  221. ]}
  222. ];
  223. /**
  224. * Function: paintVertexShape
  225. *
  226. * Paints the vertex shape.
  227. */
  228. mxShapePidCompFunc.prototype.paintVertexShape = function(c, x, y, w, h)
  229. {
  230. c.translate(x, y);
  231. this.background(c, x, y, w, h);
  232. c.setShadow(false);
  233. this.foreground(c, x, y, w, h);
  234. };
  235. mxShapePidCompFunc.prototype.background = function(c, x, y, w, h)
  236. {
  237. c.begin();
  238. c.moveTo(0, h * 0.5);
  239. c.lineTo(w * 0.25, 0);
  240. c.lineTo(w * 0.75, 0);
  241. c.lineTo(w, h * 0.5);
  242. c.lineTo(w * 0.75, h);
  243. c.lineTo(w * 0.25, h);
  244. c.close();
  245. c.fillAndStroke();
  246. };
  247. mxShapePidCompFunc.prototype.foreground = function(c, x, y, w, h)
  248. {
  249. var mounting = mxUtils.getValue(this.style, mxShapePidCompFunc.prototype.cst.MOUNTING, 'field');
  250. if (mounting === mxShapePidCompFunc.prototype.cst.ROOM)
  251. {
  252. c.begin();
  253. c.moveTo(0, h * 0.5);
  254. c.lineTo(w, h * 0.5);
  255. c.stroke();
  256. }
  257. else if (mounting === mxShapePidCompFunc.prototype.cst.INACCESSIBLE)
  258. {
  259. c.setDashed(true);
  260. c.begin();
  261. c.moveTo(0, h * 0.5);
  262. c.lineTo(w, h * 0.5);
  263. c.stroke();
  264. }
  265. else if (mounting === mxShapePidDiscInst.prototype.cst.LOCAL)
  266. {
  267. c.begin();
  268. c.moveTo(w * 0.01, h * 0.48);
  269. c.lineTo(w * 0.99, h * 0.48);
  270. c.moveTo(w * 0.01, h * 0.52);
  271. c.lineTo(w * 0.99, h * 0.52);
  272. c.stroke();
  273. }
  274. };
  275. mxCellRenderer.registerShape(mxShapePidCompFunc.prototype.cst.SHAPE_COMP_FUNC, mxShapePidCompFunc);
  276. mxShapePidCompFunc.prototype.constraints = [
  277. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  278. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  279. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  280. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  281. new mxConnectionConstraint(new mxPoint(0.25, 0), false),
  282. new mxConnectionConstraint(new mxPoint(0.75, 0), false),
  283. new mxConnectionConstraint(new mxPoint(0.25, 1), false),
  284. new mxConnectionConstraint(new mxPoint(0.75, 1), false)
  285. ];
  286. //**********************************************************************************************************************************************************
  287. //Computer Function
  288. //**********************************************************************************************************************************************************
  289. /**
  290. * Extends mxShape.
  291. */
  292. function mxShapePidProgLogCont(bounds, fill, stroke, strokewidth)
  293. {
  294. mxShape.call(this);
  295. this.bounds = bounds;
  296. this.fill = fill;
  297. this.stroke = stroke;
  298. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  299. };
  300. /**
  301. * Extends mxShape.
  302. */
  303. mxUtils.extend(mxShapePidProgLogCont, mxShape);
  304. mxShapePidProgLogCont.prototype.cst = {
  305. SHAPE_PROG_LOG_CONT : 'mxgraph.pid2inst.progLogCont',
  306. MOUNTING : 'mounting',
  307. FIELD : 'field',
  308. ROOM : 'room',
  309. INACCESSIBLE : 'inaccessible',
  310. LOCAL : 'local'
  311. };
  312. mxShapePidProgLogCont.prototype.customProperties = [
  313. {name: 'mounting', dispName: 'Mounting', type: 'enum', defVal:'field',
  314. enumList: [
  315. {val:'field', dispName:'Field'},
  316. {val:'room', dispName:'Room'},
  317. {val:'inaccessible', dispName:'Inaccessible'},
  318. {val:'local', dispName:'Local'}
  319. ]}
  320. ];
  321. /**
  322. * Function: paintVertexShape
  323. *
  324. * Paints the vertex shape.
  325. */
  326. mxShapePidProgLogCont.prototype.paintVertexShape = function(c, x, y, w, h)
  327. {
  328. c.translate(x, y);
  329. this.background(c, x, y, w, h);
  330. c.setShadow(false);
  331. this.foreground(c, x, y, w, h);
  332. };
  333. mxShapePidProgLogCont.prototype.background = function(c, x, y, w, h)
  334. {
  335. c.rect(0, 0, w, h);
  336. c.fillAndStroke();
  337. };
  338. mxShapePidProgLogCont.prototype.foreground = function(c, x, y, w, h)
  339. {
  340. var mounting = mxUtils.getValue(this.style, mxShapePidProgLogCont.prototype.cst.MOUNTING, 'field');
  341. c.begin();
  342. c.moveTo(0, h * 0.5);
  343. c.lineTo(w * 0.5, 0);
  344. c.lineTo(w, h * 0.5);
  345. c.lineTo(w * 0.5, h);
  346. c.close();
  347. c.stroke();
  348. if (mounting === mxShapePidProgLogCont.prototype.cst.ROOM)
  349. {
  350. c.begin();
  351. c.moveTo(0, h * 0.5);
  352. c.lineTo(w, h * 0.5);
  353. c.stroke();
  354. }
  355. else if (mounting === mxShapePidProgLogCont.prototype.cst.INACCESSIBLE)
  356. {
  357. c.setDashed(true);
  358. c.begin();
  359. c.moveTo(0, h * 0.5);
  360. c.lineTo(w, h * 0.5);
  361. c.stroke();
  362. }
  363. else if (mounting === mxShapePidDiscInst.prototype.cst.LOCAL)
  364. {
  365. c.begin();
  366. c.moveTo(w * 0.02, h * 0.48);
  367. c.lineTo(w * 0.98, h * 0.48);
  368. c.moveTo(w * 0.02, h * 0.52);
  369. c.lineTo(w * 0.98, h * 0.52);
  370. c.stroke();
  371. }
  372. };
  373. mxCellRenderer.registerShape(mxShapePidProgLogCont.prototype.cst.SHAPE_PROG_LOG_CONT, mxShapePidProgLogCont);
  374. mxShapePidProgLogCont.prototype.constraints = [
  375. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  376. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  377. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  378. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  379. new mxConnectionConstraint(new mxPoint(0, 0), false),
  380. new mxConnectionConstraint(new mxPoint(0, 1), false),
  381. new mxConnectionConstraint(new mxPoint(1, 0), false),
  382. new mxConnectionConstraint(new mxPoint(1, 1), false)
  383. ];
  384. //**********************************************************************************************************************************************************
  385. //Indicator
  386. //**********************************************************************************************************************************************************
  387. /**
  388. * Extends mxShape.
  389. */
  390. function mxShapePidIndicator(bounds, fill, stroke, strokewidth)
  391. {
  392. mxShape.call(this);
  393. this.bounds = bounds;
  394. this.fill = fill;
  395. this.stroke = stroke;
  396. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  397. };
  398. /**
  399. * Extends mxShape.
  400. */
  401. mxUtils.extend(mxShapePidIndicator, mxShape);
  402. mxShapePidIndicator.prototype.cst = {
  403. SHAPE_INDICATOR : 'mxgraph.pid2inst.indicator',
  404. MOUNTING : 'mounting',
  405. FIELD : 'field',
  406. ROOM : 'room',
  407. INACCESSIBLE : 'inaccessible',
  408. LOCAL : 'local',
  409. IND_TYPE : 'indType',
  410. INSTRUMENT : 'inst',
  411. CONTROL : 'ctrl',
  412. FUNCTION : 'func',
  413. PLC : 'plc'
  414. };
  415. mxShapePidIndicator.prototype.customProperties = [
  416. {name: 'mounting', dispName: 'Mounting', type: 'enum', defVal:'field',
  417. enumList: [
  418. {val:'field', dispName:'Field'},
  419. {val:'room', dispName:'Room'},
  420. {val:'inaccessible', dispName:'Inaccessible'},
  421. {val:'local', dispName:'Local'}
  422. ]},
  423. {name: 'indType', dispName: 'Type', type: 'enum', defVal:'inst',
  424. enumList: [
  425. {val:'inst', dispName:'Instrument'},
  426. {val:'ctrl', dispName:'Control'},
  427. {val:'func', dispName:'Function'},
  428. {val:'plc', dispName:'PLC'}
  429. ]}
  430. ];
  431. /**
  432. * Function: paintVertexShape
  433. *
  434. * Paints the vertex shape.
  435. */
  436. mxShapePidIndicator.prototype.paintVertexShape = function(c, x, y, w, h)
  437. {
  438. c.translate(x, y);
  439. this.background(c, x, y, w, h);
  440. c.setShadow(false);
  441. this.foreground(c, x, y, w, h);
  442. };
  443. mxShapePidIndicator.prototype.background = function(c, x, y, w, h)
  444. {
  445. var type = mxUtils.getValue(this.style, mxShapePidIndicator.prototype.cst.IND_TYPE, 'inst');
  446. c.begin();
  447. c.moveTo(w * 0.5, w);
  448. c.lineTo(w * 0.5, h);
  449. c.stroke();
  450. if (type === mxShapePidIndicator.prototype.cst.INSTRUMENT)
  451. {
  452. c.ellipse(0, 0, w, w);
  453. c.fillAndStroke();
  454. }
  455. else if (type === mxShapePidIndicator.prototype.cst.CONTROL)
  456. {
  457. c.rect(0, 0, w, w);
  458. c.fillAndStroke();
  459. }
  460. else if (type === mxShapePidIndicator.prototype.cst.FUNCTION)
  461. {
  462. c.begin();
  463. c.moveTo(0, w * 0.5);
  464. c.lineTo(w * 0.25, 0);
  465. c.lineTo(w * 0.75, 0);
  466. c.lineTo(w, w * 0.5);
  467. c.lineTo(w * 0.75, w);
  468. c.lineTo(w * 0.25, w);
  469. c.close();
  470. c.fillAndStroke();
  471. }
  472. else if (type === mxShapePidIndicator.prototype.cst.PLC)
  473. {
  474. c.rect(0, 0, w, w);
  475. c.fillAndStroke();
  476. }
  477. };
  478. mxShapePidIndicator.prototype.foreground = function(c, x, y, w, h)
  479. {
  480. var mounting = mxUtils.getValue(this.style, mxShapePidIndicator.prototype.cst.MOUNTING, 'field');
  481. var type = mxUtils.getValue(this.style, mxShapePidIndicator.prototype.cst.IND_TYPE, 'inst');
  482. if (type === mxShapePidIndicator.prototype.cst.CONTROL)
  483. {
  484. c.ellipse(0, 0, w, w);
  485. c.stroke();
  486. }
  487. else if (type === mxShapePidIndicator.prototype.cst.PLC)
  488. {
  489. c.begin();
  490. c.moveTo(0, w * 0.5);
  491. c.lineTo(w * 0.5, 0);
  492. c.lineTo(w, w * 0.5);
  493. c.lineTo(w * 0.5, w);
  494. c.close();
  495. c.stroke();
  496. }
  497. if (mounting === mxShapePidIndicator.prototype.cst.ROOM)
  498. {
  499. c.begin();
  500. c.moveTo(0, w * 0.5);
  501. c.lineTo(w, w * 0.5);
  502. c.stroke();
  503. }
  504. else if (mounting === mxShapePidIndicator.prototype.cst.INACCESSIBLE)
  505. {
  506. c.setDashed(true);
  507. c.begin();
  508. c.moveTo(0, w * 0.5);
  509. c.lineTo(w, w * 0.5);
  510. c.stroke();
  511. }
  512. else if (mounting === mxShapePidIndicator.prototype.cst.LOCAL)
  513. {
  514. c.begin();
  515. c.moveTo(w * 0.005, w * 0.48);
  516. c.lineTo(w * 0.995, w * 0.48);
  517. c.moveTo(w * 0.005, w * 0.52);
  518. c.lineTo(w * 0.995, w * 0.52);
  519. c.stroke();
  520. }
  521. };
  522. mxCellRenderer.registerShape(mxShapePidIndicator.prototype.cst.SHAPE_INDICATOR, mxShapePidIndicator);
  523. mxShapePidIndicator.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.5, 1), true)];
  524. //**********************************************************************************************************************************************************
  525. //Logic
  526. //**********************************************************************************************************************************************************
  527. /**
  528. * Extends mxShape.
  529. */
  530. function mxShapePidLogic(bounds, fill, stroke, strokewidth)
  531. {
  532. mxShape.call(this);
  533. this.bounds = bounds;
  534. this.fill = fill;
  535. this.stroke = stroke;
  536. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  537. };
  538. /**
  539. * Extends mxShape.
  540. */
  541. mxUtils.extend(mxShapePidLogic, mxShape);
  542. mxShapePidLogic.prototype.cst = {
  543. SHAPE_LOGIC : 'mxgraph.pid2inst.logic',
  544. MOUNTING : 'mounting',
  545. FIELD : 'field',
  546. ROOM : 'room',
  547. INACCESSIBLE : 'inaccessible',
  548. LOCAL : 'local'
  549. };
  550. mxShapePidLogic.prototype.customProperties = [
  551. {name: 'mounting', dispName: 'Mounting', type: 'enum', defVal:'field',
  552. enumList: [
  553. {val:'field', dispName:'Field'},
  554. {val:'room', dispName:'Room'},
  555. {val:'inaccessible', dispName:'Inaccessible'},
  556. {val:'local', dispName:'Local'}
  557. ]}
  558. ];
  559. /**
  560. * Function: paintVertexShape
  561. *
  562. * Paints the vertex shape.
  563. */
  564. mxShapePidLogic.prototype.paintVertexShape = function(c, x, y, w, h)
  565. {
  566. c.translate(x, y);
  567. this.background(c, x, y, w, h);
  568. c.setShadow(false);
  569. this.foreground(c, x, y, w, h);
  570. };
  571. mxShapePidLogic.prototype.background = function(c, x, y, w, h)
  572. {
  573. c.begin();
  574. c.moveTo(0, h * 0.5);
  575. c.lineTo(w * 0.5, 0);
  576. c.lineTo(w, h * 0.5);
  577. c.lineTo(w * 0.5, h);
  578. c.close();
  579. c.fillAndStroke();
  580. };
  581. mxShapePidLogic.prototype.foreground = function(c, x, y, w, h)
  582. {
  583. var mounting = mxUtils.getValue(this.style, mxShapePidLogic.prototype.cst.MOUNTING, 'field');
  584. if (mounting === mxShapePidLogic.prototype.cst.ROOM)
  585. {
  586. c.begin();
  587. c.moveTo(0, h * 0.5);
  588. c.lineTo(w, h * 0.5);
  589. c.stroke();
  590. }
  591. else if (mounting === mxShapePidLogic.prototype.cst.INACCESSIBLE)
  592. {
  593. c.setDashed(true);
  594. c.begin();
  595. c.moveTo(0, h * 0.5);
  596. c.lineTo(w, h * 0.5);
  597. c.stroke();
  598. }
  599. else if (mounting === mxShapePidLogic.prototype.cst.LOCAL)
  600. {
  601. c.begin();
  602. c.moveTo(w * 0.02, h * 0.48);
  603. c.lineTo(w * 0.98, h * 0.48);
  604. c.moveTo(w * 0.02, h * 0.52);
  605. c.lineTo(w * 0.98, h * 0.52);
  606. c.stroke();
  607. }
  608. };
  609. mxCellRenderer.registerShape(mxShapePidLogic.prototype.cst.SHAPE_LOGIC, mxShapePidLogic);
  610. mxShapePidLogic.prototype.constraints = [
  611. new mxConnectionConstraint(new mxPoint(0.5, 0), true),
  612. new mxConnectionConstraint(new mxPoint(0.5, 1), true),
  613. new mxConnectionConstraint(new mxPoint(0, 0.5), true),
  614. new mxConnectionConstraint(new mxPoint(1, 0.5), true),
  615. new mxConnectionConstraint(new mxPoint(0.25, 0.25), false),
  616. new mxConnectionConstraint(new mxPoint(0.25, 0.75), false),
  617. new mxConnectionConstraint(new mxPoint(0.75, 0.25), false),
  618. new mxConnectionConstraint(new mxPoint(0.75, 0.75), false)
  619. ];