-
Notifications
You must be signed in to change notification settings - Fork 0
/
abstractNodeVisuals.js
104 lines (91 loc) · 2.83 KB
/
abstractNodeVisuals.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
/*
* A general superclass for the a graphic engine used by nodes on the Pedigree graph. Contains
* information about positioning of the graphical elements of the node
*/
var AbstractNodeVisuals = Class.create({
initialize: function(node, x, y) {
this._node = node;
this._absoluteX = x;
this._absoluteY = y;
},
/*
* Returns the node for which the graphics are being drawn
*/
getNode: function() {
return this._node;
},
/*
* Returns the current X coordinate of this node on the canvas, taking into consideration transformation data.
*/
getX: function() {
return this._absoluteX;
},
/*
* Changes the X coordinate of the node
*
* @param x the x coordinate on the canvas
* @param animate set to true if you want to animate the transition
* @param callback the function called at the end of the animation
*/
setX: function(x, animate, callback) {
this.setPos(x, this.getY(), animate, callback);
},
/*
* Returns the current Y coordinate of this node on the canvas, taking into consideration transformation data.
*/
getY: function() {
return this._absoluteY;
},
/*
* Changes the Y coordinate of the node
*
* @param y the y coordinate on the canvas
* @param animate set to true if you want to animate the transition
* @param callback the function called at the end of the animation
*/
setY: function(y, animate, callback) {
this.setPos(y, this.getX(), animate, callback);
},
/*
* Returns an array containing the x and y coordinates of the node on canvas.
*/
getPos: function() {
return [this.getX(), this.getY()];
},
/*
* [Abstract Method]
* Changes the position of the node to (X,Y)
*
* @param x the x coordinate on the canvas
* @param y the y coordinate on the canvas
* @param animate set to true if you want to animate the transition
* @param callback the function called at the end of the animation
*/
setPos: function(x, y, animate, callback) {
},
/*
* Determines whether this node is selected
*/
setSelected: function(isSelected) {
this._isSelected = isSelected;
},
/*
* Returns a Raphael set of all the graphics and labels associated with this node.
*/
getAllGraphics: function() {
return editor.getPaper().set(this.getShapes());
},
/*
* Returns a Raphael set of graphic elements of which the icon of the node consists. Does not
* include hoverbox elements or labels.
*/
getShapes: function() {
return editor.getPaper().set()
},
/*
* Removes all the graphical elements of this node from the canvas
*/
remove: function() {
this.getAllGraphics().remove();
}
});