-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathistar-association-is-a.js
More file actions
73 lines (54 loc) · 1.49 KB
/
istar-association-is-a.js
File metadata and controls
73 lines (54 loc) · 1.49 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
63
64
65
66
67
68
69
70
71
72
73
import { ModelShapePath } from 'direwolf-modeler/model-shape-path';
export class IStarAssociationIsA extends ModelShapePath {
constructor(id, createdLocally, pathArray = []) {
super(id, createdLocally, pathArray);
}
createSVGElement(viewport) {
let group = super.createSVGElement(viewport);
// add arrow head
this.path.marker('end', 15, 15, function(add) {
add.polyline('0,0 5,3 0,6').fill('none').stroke({ width: 1, color: 'black' });
this.ref(5, 3);
this.size(25, 25);
});
// add relationship attribute
this.text = group.text('is-a');
this.redrawPath();
return group;
}
get descriptiveName() {
return `Is-a-Association`;
}
get properties() {
return Object.assign(super.properties, {
});
}
redrawPath() {
super.redrawPath();
if (this._pathArray && (this._pathArray.length > 0)) {
let mid = this._midPoint(this._pathArray[0], this._pathArray[1]);
if (this.text) {
this.text.cx(mid[0]);
this.text.cy(mid[1]);
}
}
}
_midPoint(start, end) {
// kudos https://stackoverflow.com/questions/43920474/svg-js-line-marker-mid/44010722
return [
(start[0] + end[0]) / 2,
(start[1] + end[1]) / 2
];
}
/**
* Direwolf-specific methods
*/
sharedStateAvailable(sharedState) {
super.sharedStateAvailable(sharedState);
if (this._createdLocally) {
}
}
handleSharedStateChanged(event) {
super.handleSharedStateChanged(event);
}
}