mxCircularFlowMeterComponent.js
2.04 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
62
function mxCircularFlowMeterComponent(bounds, fill, stroke, strokewidth) {
mxShape.call(this);
this.bounds = bounds;
this.fill = fill;
this.stroke = stroke;
this.strokewidth = (strokewidth != null) ? strokewidth : 1;
}
mxUtils.extend(mxCircularFlowMeterComponent, mxShape)
mxCircularFlowMeterComponent.prototype.customProperties = [
{ componentType: 'text' }
]
mxCircularFlowMeterComponent.prototype.shapeKey = 'mxgraph.thingskit/circularFlowMeterComponent'
mxCircularFlowMeterComponent.prototype.paintVertexShape = function (c, x, y, w, h) {
this.paintBackground(c, x, y, w, h)
this.foreground(c, x, y, w, h)
}
mxCircularFlowMeterComponent.prototype.paintBackground = function (svgCanvas, x, y, w, h) {
svgCanvas.rect(x, y, w, h);
svgCanvas.fillAndStroke()
}
mxCircularFlowMeterComponent.prototype.foreground = function (svgCanvas, x, y, w, h) {
var cell = this.state.cell
var status = getCellStatus(this.state.view.graph)
if (status === 'sidebar') {
svgCanvas.image(...this.getThumbSize(x, y, w, h), IMAGE_PATH + '/thingskit/CircularFlowMeter.svg')
} else {
createComponent(this, svgCanvas, x, y, w, h)
setContainerSize(this, svgCanvas, x, y, w, h)
}
}
mxCircularFlowMeterComponent.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)
}
mxCircularFlowMeterComponent.prototype.updateMargin = function () {
this.margin = mxUtils.getAlignmentAsPoint(this.align, this.valign)
}
mxCircularFlowMeterComponent.prototype.apply = function (a) {
mxText.prototype.apply.apply(this, arguments);
this.opacity = mxUtils.getValue(this.style, mxConstants.STYLE_OPACITY, 100)
}
mxCircularFlowMeterComponent.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(mxCircularFlowMeterComponent.prototype.shapeKey, mxCircularFlowMeterComponent)