-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIcon.js
More file actions
executable file
·50 lines (43 loc) · 1.38 KB
/
Icon.js
File metadata and controls
executable file
·50 lines (43 loc) · 1.38 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
var ShapeType = require('app/components/visualization/Types.js').ShapeType;
var Shape = require('app/components/visualization/Shape.js').Shape;
var Icon = function (id, shape, height, x, y) {
this.shape = new Shape(shape, id)
this.height = height
this.x = x
this.y = y
this.width = 10
this.id = id
this.draw = function (graph) {
switch (this.shape.type) {
case ShapeType.Point:
this.shape.drawCircle(graph, this.x + this.shape.weight/2, this.y + this.height/2, this.shape.weight, this.id, this.shape.color)
this.width = this.shape.weight
break
case ShapeType.MultiPoint:
this.shape.drawCircle(graph, this.x + this.shape.weight/2, this.y + this.height/2, this.shape.weight, this.id, this.shape.color)
this.width = this.shape.weight
break
case ShapeType.Line:
this.shape.coordinates = [[this.x, this.y + this.height/2], [this.x + this.width, this.y + this.height/2]]
this.shape.drawLine(graph)
break
case ShapeType.Bar:
this.shape.coordinates = [this.x, this.y + this.height/2 - 2]
this.shape.drawRectangle(graph)
}
}
this.addOffset = function (x, y) {
this.x += x
this.y += y
}
this.setHeight = function (height) {
this.height = height
}
this.setX = function (x) {
this.x = x
}
this.setY = function (y) {
this.y = y
}
}
exports.Icon = Icon