mxPidInstruments.js 20 KB

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