dag-config.ts 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. export const X6_NODE_NAME = 'dag-task'
  18. export const X6_EDGE_NAME = 'dag-edge'
  19. export const X6_PORT_OUT_NAME = 'dag-port-out'
  20. const EDGE_COLOR = '#999999'
  21. const BG_BLUE = '#DFE9F7'
  22. const BG_WHITE = '#FFFFFF'
  23. const NODE_BORDER = '#CCCCCC'
  24. const TITLE = '#333333'
  25. const STROKE_BLUE = '#288FFF'
  26. const NODE_SHADOW = 'drop-shadow(3px 3px 4px rgba(0, 0, 0, 0.2))'
  27. const EDGE_SHADOW = 'drop-shadow(3px 3px 2px rgba(0, 0, 0, 0.2))'
  28. export const PORT = {
  29. groups: {
  30. [X6_PORT_OUT_NAME]: {
  31. position: {
  32. name: 'absolute',
  33. args: {
  34. x: 200,
  35. y: 24
  36. }
  37. },
  38. markup: [
  39. {
  40. tagName: 'g',
  41. selector: 'body',
  42. children: [
  43. {
  44. tagName: 'circle',
  45. selector: 'circle-outer'
  46. },
  47. {
  48. tagName: 'text',
  49. selector: 'plus-text'
  50. },
  51. {
  52. tagName: 'circle',
  53. selector: 'circle-inner'
  54. }
  55. ]
  56. }
  57. ],
  58. attrs: {
  59. body: {
  60. magnet: true
  61. },
  62. 'plus-text': {
  63. fontSize: 12,
  64. fill: NODE_BORDER,
  65. text: '+',
  66. textAnchor: 'middle',
  67. x: 0,
  68. y: 3
  69. },
  70. 'circle-outer': {
  71. stroke: NODE_BORDER,
  72. strokeWidth: 1,
  73. r: 6,
  74. fill: BG_WHITE
  75. },
  76. 'circle-inner': {
  77. r: 4,
  78. fill: 'transparent'
  79. }
  80. }
  81. }
  82. }
  83. }
  84. export const PORT_HOVER = {
  85. groups: {
  86. [X6_PORT_OUT_NAME]: {
  87. attrs: {
  88. 'circle-outer': {
  89. stroke: STROKE_BLUE,
  90. fill: BG_BLUE,
  91. r: 8
  92. },
  93. 'circle-inner': {
  94. fill: STROKE_BLUE,
  95. r: 6
  96. }
  97. }
  98. }
  99. }
  100. }
  101. export const PORT_SELECTED = {
  102. groups: {
  103. [X6_PORT_OUT_NAME]: {
  104. attrs: {
  105. 'plus-text': {
  106. fill: STROKE_BLUE
  107. },
  108. 'circle-outer': {
  109. stroke: STROKE_BLUE,
  110. fill: BG_WHITE
  111. }
  112. }
  113. }
  114. }
  115. }
  116. export const NODE_STATUS_MARKUP = [
  117. {
  118. tagName: 'foreignObject',
  119. selector: 'fo',
  120. children: [
  121. {
  122. tagName: 'body',
  123. selector: 'fo-body',
  124. ns: 'http://www.w3.org/1999/xhtml',
  125. children: [
  126. {
  127. tagName: 'div',
  128. selector: 'status'
  129. }
  130. ]
  131. }
  132. ]
  133. }
  134. ]
  135. export const NODE = {
  136. width: 220,
  137. height: 48,
  138. markup: [
  139. {
  140. tagName: 'rect',
  141. selector: 'body',
  142. className: 'dag-task-body'
  143. },
  144. {
  145. tagName: 'image',
  146. selector: 'image'
  147. },
  148. {
  149. tagName: 'text',
  150. selector: 'title'
  151. }
  152. ],
  153. attrs: {
  154. body: {
  155. refWidth: '100%',
  156. refHeight: '100%',
  157. rx: 6,
  158. ry: 6,
  159. pointerEvents: 'visiblePainted',
  160. fill: BG_WHITE,
  161. stroke: NODE_BORDER,
  162. strokeWidth: 1,
  163. strokeDasharray: 'none',
  164. filter: 'none'
  165. },
  166. image: {
  167. width: 30,
  168. height: 30,
  169. refX: 12,
  170. refY: 9
  171. },
  172. title: {
  173. refX: 45,
  174. refY: 18,
  175. fontFamily: 'Microsoft Yahei',
  176. fontSize: 12,
  177. fontWeight: 'bold',
  178. fill: TITLE,
  179. strokeWidth: 0
  180. },
  181. fo: {
  182. refX: '46%',
  183. refY: -25
  184. }
  185. },
  186. ports: {
  187. ...PORT,
  188. items: [
  189. {
  190. id: X6_PORT_OUT_NAME,
  191. group: X6_PORT_OUT_NAME
  192. }
  193. ]
  194. },
  195. tools: [
  196. {
  197. name: 'contextmenu'
  198. }
  199. ]
  200. }
  201. export const NODE_HOVER = {
  202. attrs: {
  203. body: {
  204. fill: BG_BLUE,
  205. stroke: STROKE_BLUE,
  206. strokeDasharray: '5,2'
  207. },
  208. title: {
  209. fill: STROKE_BLUE
  210. }
  211. }
  212. }
  213. export const NODE_SELECTED = {
  214. attrs: {
  215. body: {
  216. filter: NODE_SHADOW,
  217. fill: BG_WHITE,
  218. stroke: STROKE_BLUE,
  219. strokeDasharray: '5,2',
  220. strokeWidth: '1.5'
  221. },
  222. title: {
  223. fill: STROKE_BLUE
  224. }
  225. }
  226. }
  227. export const EDGE = {
  228. attrs: {
  229. line: {
  230. stroke: EDGE_COLOR,
  231. strokeWidth: 1,
  232. targetMarker: {
  233. tagName: 'path',
  234. fill: EDGE_COLOR,
  235. strokeWidth: 0,
  236. d: 'M 6 -3 0 0 6 3 Z'
  237. },
  238. filter: 'none'
  239. }
  240. },
  241. connector: {
  242. name: 'rounded'
  243. },
  244. router: {
  245. name: 'manhattan',
  246. args: {
  247. endDirections: ['top', 'bottom', 'left']
  248. }
  249. },
  250. defaultLabel: {
  251. markup: [
  252. {
  253. tagName: 'rect',
  254. selector: 'body'
  255. },
  256. {
  257. tagName: 'text',
  258. selector: 'label'
  259. }
  260. ],
  261. attrs: {
  262. label: {
  263. fill: EDGE_COLOR,
  264. fontSize: 14,
  265. textAnchor: 'middle',
  266. textVerticalAnchor: 'middle',
  267. pointerEvents: 'none'
  268. },
  269. body: {
  270. ref: 'label',
  271. fill: BG_WHITE,
  272. stroke: EDGE_COLOR,
  273. strokeWidth: 1,
  274. rx: 4,
  275. ry: 4,
  276. refWidth: '140%',
  277. refHeight: '140%',
  278. refX: '-20%',
  279. refY: '-20%'
  280. }
  281. },
  282. position: {
  283. distance: 0.5,
  284. options: {
  285. absoluteDistance: true,
  286. reverseDistance: true
  287. }
  288. }
  289. }
  290. }
  291. export const EDGE_HOVER = {
  292. attrs: {
  293. line: {
  294. stroke: STROKE_BLUE,
  295. targetMarker: {
  296. fill: STROKE_BLUE
  297. }
  298. }
  299. },
  300. defaultLabel: {
  301. attrs: {
  302. label: {
  303. fill: STROKE_BLUE
  304. },
  305. body: {
  306. fill: BG_WHITE,
  307. stroke: STROKE_BLUE
  308. }
  309. }
  310. }
  311. }
  312. export const EDGE_SELECTED = {
  313. attrs: {
  314. line: {
  315. stroke: STROKE_BLUE,
  316. targetMarker: {
  317. fill: STROKE_BLUE
  318. },
  319. strokeWidth: 2,
  320. filter: EDGE_SHADOW
  321. }
  322. },
  323. defaultLabel: {
  324. attrs: {
  325. label: {
  326. fill: STROKE_BLUE
  327. },
  328. body: {
  329. fill: BG_WHITE,
  330. stroke: STROKE_BLUE
  331. }
  332. }
  333. }
  334. }