-
Notifications
You must be signed in to change notification settings - Fork 1
/
fd-uml-sequence-actor.js
130 lines (116 loc) · 3.53 KB
/
fd-uml-sequence-actor.js
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
@module ember-flexberry-designer
*/
import { computed } from '@ember/object';
import joint from 'npm:jointjs';
import FdUmlElement from './fd-uml-element';
/**
An object that describes a Sequence Actor element on the UML diagram.
@class FdUmlSequenceActor
@extends FdUmlElement
*/
export default FdUmlElement.extend({
/**
The name of the SequenceActor.
@property attrs
@type String
*/
attrs: computed('primitive.Name.Text', function() {
return { text: { text: this.get('primitive.Name.Text') } };
}),
/**
See {{#crossLink "FdUmlPrimitive/JointJS:method"}}here{{/crossLink}}.
@method JointJS
*/
JointJS(graph) {
let properties = this.getProperties('id', 'attrs', 'size', 'position');
properties.graph = graph;
return new SequenceDiagramActor(properties);
},
});
/**
Defines the JointJS object, which represents a Sequence Actor in the UML diagram.
@for FdUmlSequenceActor
@class SequenceDiagramActor
@extends basic.Generic.
@namespace flexberry.uml
@constructor
*/
export let SequenceActor = joint.shapes.basic.Generic.define('flexberry.uml.SequenceActor', {
attrs: {
size: {},
rect: {},
link: undefined,
linklength: 20,
endLine: undefined,
text: {
'ref': 'image',
'ref-y': 50,
'ref-x': 0,
'text-anchor': 'start',
'y-alignment': 'end',
'font-weight': 'bold',
'fill': 'black',
'font-size': 12,
'font-family': 'Arial'
}
}
}, {
markup: '<g class="rotatable"><g class="scalable"><rect/></g><image/><text/></g>',
initialize: function () {
let width = this.attributes.attrs.size.width;
let height = this.attributes.attrs.size.height;
this.resize(width, height);
this.attributes.attrs.rect.width = width;
this.attributes.attrs.rect.height = height;
this.attributes.endLine = new joint.shapes.basic.Circle({
size: {
width: 10,
height: 10
}
});
this.attributes.link = new joint.dia.Link({
source: {
id: this.cid,
anchor: {
name: 'bottom'
}
},
target: {
id: this.attributes.endLine.cid
}
});
this.attributes.link.markup = '<path class="connection" stroke="black" ' +
'stroke-width="' +
this.attributes.attrs.rect['stroke-width'] +
'" d="M 0 0 0 0"/>';
let shift = this.attributes.attrs.rect.width / 2 - 4;
joint.shapes.basic.Generic.prototype.initialize.apply(this, arguments);
this.addTo(this.attributes.graph);
this.attributes.endLine.addTo(this.attributes.graph);
this.embed(this.attributes.endLine);
this.attributes.endLine.position(shift, 100, { parentRelative: true });
this.embed(this.attributes.endLine);
this.attributes.endLine.on('change:position', function (element, position) {
let actor = element.getParentCell();
let actorPosition = actor.position();
element.position(actorPosition.x + shift, position.y);
});
this.attributes.link.addTo(this.attributes.graph);
this.embed(this.attributes.link);
}
});
/**
Defines the JointJS object, which represents a Sequence Actor in the UML diagram.
@for FdUmlSequenceActor
@class SequenceDiagramActor
@extends SequenceActor
@namespace flexberry.uml
@constructor
*/
export let SequenceDiagramActor = SequenceActor.define('flexberry.uml.SequenceDiagramActor', {
attrs: {
size: { 'width': 24, 'height': 47 },
image: { 'xlink:href': '/assets/images/actor.svg' }
}
});