mxWaterFlowComponent.js
2.03 KB
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
54
55
56
57
58
59
60
61
function mxWaterFlowComponent(bounds, fill, stroke, strokewidth) {
  mxConnector.call(this);
  this.stroke = stroke;
  this.strokewidth = (strokewidth != null) ? strokewidth : 1;
}
mxUtils.extend(mxWaterFlowComponent, mxConnector)
mxWaterFlowComponent.prototype.customProperties = [
  { componentType: 'waterFlow' }
]
mxWaterFlowComponent.prototype.shapeKey = 'mxgraph.thingskit/waterFlowComponent'
mxWaterFlowComponent.prototype.paintEdgeShape = function (c, x, y, w, h) {
  this.foreground(c, x, y, w, h)
}
mxWaterFlowComponent.prototype.foreground = function (svgCanvas, x, y, w, h) {
  var status = getCellStatus(this.state.view.graph)
  if (status === 'sidebar') {
    svgCanvas.image(0, 0, 200, 200, IMAGE_PATH + '/thingskit/waterFlow.svg')
  } else {
    mxConnector.prototype.paintEdgeShape.apply(this, arguments);
    var shape = this.state.shape
    var node = shape.node
    var waterFlowBg = node.getElementsByTagName('path')[0]
    var waterFlowLine = node.getElementsByTagName('path')[1]
    waterFlowBg.setAttribute('stroke', '#d3d3d3')
    waterFlowBg.setAttribute('visibility', 'visible')
    waterFlowLine.setAttribute('stroke-dasharray', '20')
    waterFlowLine.setAttribute('class', 'water-flow-animation')
  }
}
mxWaterFlowComponent.prototype.configureCanvas = function (a, b, c, d) {
  mxShape.prototype.configureCanvas.apply(this, arguments)
  a.setFontColor(this.color);
  a.setFontFamily(this.family);
  a.setFontSize(this.size);
  a.setFontStyle(this.fontStyle)
}
mxWaterFlowComponent.prototype.updateMargin = function () {
  this.margin = mxUtils.getAlignmentAsPoint(this.align, this.valign)
}
mxWaterFlowComponent.prototype.apply = function (a) {
  mxText.prototype.apply.apply(this, arguments);
  this.opacity = mxUtils.getValue(this.style, mxConstants.STYLE_OPACITY, 100)
}
mxWaterFlowComponent.prototype.getThumbSize = function (x, y, w, h) {
  const offset = Math.min(x, y)
  const size = Math.max(w, h)
  return [offset, offset, size, size]
}
mxCellRenderer.registerShape(mxWaterFlowComponent.prototype.shapeKey, mxWaterFlowComponent)