刘光辉
11 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import OutlineProvider from 'bpmn-js/lib/features/outline/OutlineProvider.js';
import { attr as svgAttr, create as svgCreate } from 'tiny-svg';
import { isLabel } from 'bpmn-js/lib/util/LabelUtil';
import { typeConfig } from '../config';
import { typeCondition, typeConfluence } from '../config/variableName';
class YmOutlineProvider extends OutlineProvider {
  private offset: number = 0;
  private _styles;
  private _type;
  constructor(outline: any, styles: any, type: any) {
    super(outline, styles);
    this._styles = styles;
    this._type = type;
  }
 
  getOutline(element: any) {
    const OUTLINE_STYLE = this._styles.cls('djs-outline', ['no-fill']);
    var outline;
    if (isLabel(element)) return;
    let { renderer } = typeConfig[element.type];
    const { attr } = renderer;
    outline = svgCreate('rect');
    svgAttr(
      outline,
      Object.assign(
        {
          x: attr.x,
          y: attr.y,
          rx: attr.rx ? attr.rx : 3,
          width: (this._type === 0 || element.wnType === typeCondition) && isLabel(element) ? 128 : element.wnType === typeConfluence ? 0 : attr.width,
          height: (this._type === 0 || element.wnType === typeCondition) && isLabel(element) ? 28 : element.wnType === typeConfluence ? 0 : attr.height,
        },
        OUTLINE_STYLE,
      ),
    );
    return outline;
  }
 
  updateOutline(element: any, outline: any): any {
    svgAttr(outline, {
      x: 0,
      y: 0,
      width: (this._type === 0 || element.wnType === typeCondition) && isLabel(element) ? 128 : element.width + this.offset * 2,
      height: (this._type === 0 || element.wnType === typeCondition) && isLabel(element) ? 28 : element.height + this.offset * 2,
    });
    return outline;
  }
}
 
// 注入的依赖项
YmOutlineProvider.$inject = ['outline', 'styles', 'config.type'];
 
export default YmOutlineProvider;