Race.pattern.metamodel 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. {
  2. "types": {
  3. "__pCar": [
  4. {
  5. "name": "__pLabel",
  6. "type": "string",
  7. "default": ""
  8. },
  9. {
  10. "name": "__pPivotIn",
  11. "type": "string",
  12. "default": ""
  13. },
  14. {
  15. "name": "__pPivotOut",
  16. "type": "string",
  17. "default": ""
  18. },
  19. {
  20. "name": "__pMatchSubtypes",
  21. "type": "boolean",
  22. "default": false
  23. },
  24. {
  25. "name": "name",
  26. "type": "code",
  27. "default": "\"[PYTHON]\"\n\"Example:\t result = True\"\n\"Example:\t result = getAttr()\"\n\n\"[JAVASCRIPT]\"\n\"Example:\t true\"\n\"Example:\t getAttr()\""
  28. },
  29. {
  30. "name": "position",
  31. "type": "code",
  32. "default": "\"[PYTHON]\"\n\"Example:\t result = True\"\n\"Example:\t result = getAttr()\"\n\n\"[JAVASCRIPT]\"\n\"Example:\t true\"\n\"Example:\t getAttr()\""
  33. }
  34. ],
  35. "__pUnitTrack": [
  36. {
  37. "name": "__pLabel",
  38. "type": "string",
  39. "default": ""
  40. },
  41. {
  42. "name": "__pPivotIn",
  43. "type": "string",
  44. "default": ""
  45. },
  46. {
  47. "name": "__pPivotOut",
  48. "type": "string",
  49. "default": ""
  50. },
  51. {
  52. "name": "__pMatchSubtypes",
  53. "type": "boolean",
  54. "default": false
  55. },
  56. {
  57. "name": "position",
  58. "type": "code",
  59. "default": "\"[PYTHON]\"\n\"Example:\t result = True\"\n\"Example:\t result = getAttr()\"\n\n\"[JAVASCRIPT]\"\n\"Example:\t true\"\n\"Example:\t getAttr()\""
  60. }
  61. ],
  62. "__pPositionable": [
  63. {
  64. "name": "__pLabel",
  65. "type": "string",
  66. "default": ""
  67. },
  68. {
  69. "name": "__pPivotIn",
  70. "type": "string",
  71. "default": ""
  72. },
  73. {
  74. "name": "__pPivotOut",
  75. "type": "string",
  76. "default": ""
  77. },
  78. {
  79. "name": "__pMatchSubtypes",
  80. "type": "boolean",
  81. "default": false
  82. },
  83. {
  84. "name": "position",
  85. "type": "code",
  86. "default": "\"[PYTHON]\"\n\"Example:\t result = True\"\n\"Example:\t result = getAttr()\"\n\n\"[JAVASCRIPT]\"\n\"Example:\t true\"\n\"Example:\t getAttr()\""
  87. }
  88. ],
  89. "__pnext": [
  90. {
  91. "name": "__pLabel",
  92. "type": "string",
  93. "default": ""
  94. },
  95. {
  96. "name": "__pPivotIn",
  97. "type": "string",
  98. "default": ""
  99. },
  100. {
  101. "name": "__pPivotOut",
  102. "type": "string",
  103. "default": ""
  104. },
  105. {
  106. "name": "__pMatchSubtypes",
  107. "type": "boolean",
  108. "default": false
  109. }
  110. ],
  111. "__ponTrack": [
  112. {
  113. "name": "__pLabel",
  114. "type": "string",
  115. "default": ""
  116. },
  117. {
  118. "name": "__pPivotIn",
  119. "type": "string",
  120. "default": ""
  121. },
  122. {
  123. "name": "__pPivotOut",
  124. "type": "string",
  125. "default": ""
  126. },
  127. {
  128. "name": "__pMatchSubtypes",
  129. "type": "boolean",
  130. "default": false
  131. }
  132. ]
  133. },
  134. "constraints": [
  135. {
  136. "name": "noAbstractInstances",
  137. "event": "pre-create",
  138. "code": "/* comment next line to enable this constraint */\nthrow \"IgnoredConstraint\"\nfalse",
  139. "targetType": "Positionable"
  140. }
  141. ],
  142. "actions": [
  143. {
  144. "name": "snapToTarget",
  145. "event": "post-connect",
  146. "code": "/* comment next line to enable this action */\nthrow \"IgnoredConstraint\"\n/*newline*/var neighborLinks = getNeighbors('>'),/*newline*/ neighborLink = neighborLinks[neighborLinks.length-1];/*newline*/if( neighborLink )/*newline*/{/*newline*/ if( getAttr('$type', neighborLink).match(/next/) )/*newline*/ {/*newline*/ var neighbor = getNeighbors('>','*',neighborLink)[0],/*newline*/ npos = getAttr('position',neighbor);/*newline*/ setAttr('position', [npos[0] - 75, npos[1]]);/*newline*/ }/*newline*/ else if( getAttr('$type', neighborLink).match(/onTrack/) )/*newline*/ {/*newline*/ var neighbor = getNeighbors('>','*',neighborLink)[0],/*newline*/ gpos = getAttr('position');/*newline*/ setAttr('position', [gpos[0] + 10, gpos[1] + 35], neighbor);/*newline*/ }/*newline*/ else/*newline*/ {/*newline*/ print('Invalid link');/*newline*/ }/*newline*/}",
  147. "targetType": "__pCar"
  148. },
  149. {
  150. "name": "snapToTarget",
  151. "event": "post-connect",
  152. "code": "/* comment next line to enable this action */\nthrow \"IgnoredConstraint\"\n/*newline*/var neighborLinks = getNeighbors('>'),/*newline*/ neighborLink = neighborLinks[neighborLinks.length-1];/*newline*/if( neighborLink )/*newline*/{/*newline*/ if( getAttr('$type', neighborLink).match(/next/) )/*newline*/ {/*newline*/ var neighbor = getNeighbors('>','*',neighborLink)[0],/*newline*/ npos = getAttr('position',neighbor);/*newline*/ setAttr('position', [npos[0] - 75, npos[1]]);/*newline*/ }/*newline*/ else if( getAttr('$type', neighborLink).match(/onTrack/) )/*newline*/ {/*newline*/ var neighbor = getNeighbors('>','*',neighborLink)[0],/*newline*/ gpos = getAttr('position');/*newline*/ setAttr('position', [gpos[0] + 10, gpos[1] + 35], neighbor);/*newline*/ }/*newline*/ else/*newline*/ {/*newline*/ print('Invalid link');/*newline*/ }/*newline*/}",
  153. "targetType": "__pUnitTrack"
  154. },
  155. {
  156. "name": "snapToTarget",
  157. "event": "post-connect",
  158. "code": "/* comment next line to enable this action */\nthrow \"IgnoredConstraint\"\n/*newline*/var neighborLinks = getNeighbors('>'),/*newline*/ neighborLink = neighborLinks[neighborLinks.length-1];/*newline*/if( neighborLink )/*newline*/{/*newline*/ if( getAttr('$type', neighborLink).match(/next/) )/*newline*/ {/*newline*/ var neighbor = getNeighbors('>','*',neighborLink)[0],/*newline*/ npos = getAttr('position',neighbor);/*newline*/ setAttr('position', [npos[0] - 75, npos[1]]);/*newline*/ }/*newline*/ else if( getAttr('$type', neighborLink).match(/onTrack/) )/*newline*/ {/*newline*/ var neighbor = getNeighbors('>','*',neighborLink)[0],/*newline*/ gpos = getAttr('position');/*newline*/ setAttr('position', [gpos[0] + 10, gpos[1] + 35], neighbor);/*newline*/ }/*newline*/ else/*newline*/ {/*newline*/ print('Invalid link');/*newline*/ }/*newline*/}",
  159. "targetType": "__pPositionable"
  160. },
  161. {
  162. "name": "distinctPLabels",
  163. "event": "post-create",
  164. "code": "if( getAttr(\"__pLabel\") == \"\" )\n{\n\tvar pLabels = getAllNodes().\n\t\t\t\t\t\t\tfilter( function(n) {return hasAttr(\"__pLabel\",n);} ).\n\t\t\t\t\t\t\t\tmap( function(n) {return getAttr(\"__pLabel\",n);} ),\n\t\t i\t\t\t= \"0\";\n\n\twhile( _utils.contains(pLabels,i) )\n\t\ti = String(parseInt(i)+1);\n\tsetAttr(\"__pLabel\",i);\n}",
  165. "targetType": "*"
  166. }
  167. ],
  168. "cardinalities": {
  169. "__pCar": [
  170. {
  171. "dir": "in",
  172. "type": "__ponTrack",
  173. "min": 0,
  174. "max": "Infinity"
  175. }
  176. ],
  177. "__pUnitTrack": [
  178. {
  179. "dir": "out",
  180. "type": "__pnext",
  181. "min": 0,
  182. "max": "Infinity"
  183. },
  184. {
  185. "dir": "in",
  186. "type": "__pnext",
  187. "min": 0,
  188. "max": "Infinity"
  189. },
  190. {
  191. "dir": "out",
  192. "type": "__ponTrack",
  193. "min": 0,
  194. "max": "Infinity"
  195. }
  196. ],
  197. "__pPositionable": [],
  198. "__pnext": [
  199. {
  200. "dir": "in",
  201. "type": "__pUnitTrack",
  202. "min": 0,
  203. "max": "1"
  204. },
  205. {
  206. "dir": "out",
  207. "type": "__pUnitTrack",
  208. "min": 0,
  209. "max": "1"
  210. }
  211. ],
  212. "__ponTrack": [
  213. {
  214. "dir": "in",
  215. "type": "__pUnitTrack",
  216. "min": 0,
  217. "max": "1"
  218. },
  219. {
  220. "dir": "out",
  221. "type": "__pCar",
  222. "min": 0,
  223. "max": "1"
  224. }
  225. ]
  226. },
  227. "legalConnections": {
  228. "__pUnitTrack": {
  229. "__pUnitTrack": [
  230. "__pnext"
  231. ],
  232. "__pCar": [
  233. "__ponTrack"
  234. ]
  235. }
  236. },
  237. "connectorTypes": {
  238. "__pnext": "visual",
  239. "__ponTrack": "containment"
  240. },
  241. "types2parentTypes": {
  242. "__pCar": [
  243. "__pPositionable"
  244. ],
  245. "__pUnitTrack": [
  246. "__pPositionable"
  247. ],
  248. "__pPositionable": [],
  249. "__pnext": [],
  250. "__ponTrack": []
  251. }
  252. }