author | rougeronj |
Thu, 22 Jan 2015 09:29:49 +0100 | |
changeset 112 | 3e075a48e19e |
parent 111 | a7b72620d227 |
parent 109 | 8546e2181a73 |
child 117 | c0034b35c44e |
permissions | -rw-r--r-- |
89
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
1 |
/** |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
2 |
* js/annotsRoll.js |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
3 |
* |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
4 |
* annotsRoll basic component |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
5 |
* |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
6 |
*/ |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
7 |
|
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
8 |
'use strict'; |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
9 |
|
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
10 |
var PIXI = require('pixi'); |
98 | 11 |
var _ = require('lodash'); |
89
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
12 |
|
98 | 13 |
var DEFAULT_ANNOT_COLOR = '#bababa'; |
14 |
||
15 |
var defaultAnnotStyles = { |
|
106
9b20ddf1fc70
Add WordWrap to annots text style to crates multilines if the text is to large
rougeronj
parents:
105
diff
changeset
|
16 |
'label': { font: '16pt Arial Bold', fill: '#65A954', wordWrap: true}, |
9b20ddf1fc70
Add WordWrap to annots text style to crates multilines if the text is to large
rougeronj
parents:
105
diff
changeset
|
17 |
'text' : { font: '12pt Arial Regular', fill: '#444444', wordWrap: true}, |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
103
diff
changeset
|
18 |
'user' : { font: '14pt Arial regular', fill: '#666666' }, |
98 | 19 |
}; |
20 |
||
21 |
var defaultOptions = { |
|
22 |
externalRefresh: false, |
|
23 |
defaultColor: DEFAULT_ANNOT_COLOR, |
|
111
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
24 |
annotStyles: defaultAnnotStyles, |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
25 |
ignoreAnnots:false |
98 | 26 |
}; |
27 |
||
28 |
function AnnotsRoll(options) { |
|
29 |
||
30 |
//parentContainer, xInit, yInit, width, height, widthRoll, pixelsPerSecond, annotColors |
|
89
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
31 |
var _this = this; |
98 | 32 |
var opts = _(options).defaults(defaultOptions).value(); |
33 |
||
34 |
||
89
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
35 |
this.container = new PIXI.DisplayObjectContainer(); |
98 | 36 |
this.container.x = opts.xInit; |
37 |
this.container.y = opts.yInit; |
|
38 |
this.container.width = opts.width; |
|
39 |
||
40 |
this.height = opts.height; |
|
41 |
this.width = opts.width; |
|
42 |
this.widthRoll = opts.widthRoll; |
|
43 |
this.pixelsPerSecond = opts.pixelsPerSecond; |
|
44 |
this.annotColors = opts.annotColors; |
|
111
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
45 |
this.startTs = opts.startTs || Date.now(); |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
46 |
this.ignoreAnnots = opts.ignoreAnnots; |
89
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
47 |
|
98 | 48 |
var yInit = opts.yInit; |
49 |
var annotStyles = _(opts.annotStyles).defaults(defaultAnnotStyles).value(); |
|
106
9b20ddf1fc70
Add WordWrap to annots text style to crates multilines if the text is to large
rougeronj
parents:
105
diff
changeset
|
50 |
for(var style in annotStyles) { |
9b20ddf1fc70
Add WordWrap to annots text style to crates multilines if the text is to large
rougeronj
parents:
105
diff
changeset
|
51 |
if (annotStyles[style].wordWrap === true){ |
9b20ddf1fc70
Add WordWrap to annots text style to crates multilines if the text is to large
rougeronj
parents:
105
diff
changeset
|
52 |
annotStyles[style].wordWrapWidth = this.widthRoll; |
9b20ddf1fc70
Add WordWrap to annots text style to crates multilines if the text is to large
rougeronj
parents:
105
diff
changeset
|
53 |
} |
9b20ddf1fc70
Add WordWrap to annots text style to crates multilines if the text is to large
rougeronj
parents:
105
diff
changeset
|
54 |
} |
98 | 55 |
var started = false; |
56 |
var ws = opts.ws; |
|
57 |
var externalRefresh = opts.externalRefresh; |
|
100 | 58 |
var stageView = opts.stageView; |
111
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
59 |
var waitInterval; |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
60 |
var wait = 0; |
100 | 61 |
|
62 |
stageView.registerComponent(this); |
|
98 | 63 |
|
64 |
var isHidden = function(child) { |
|
65 |
// TODO: the origin point is an approximation. Should refine this |
|
66 |
var globalPos = child.toGlobal(new PIXI.Point(0,0)); |
|
67 |
return ((globalPos.x + child.width) < 0) || ((globalPos.y + child.height) < 0) ; |
|
68 |
}; |
|
69 |
||
70 |
this.addAnnots = function(data) { |
|
71 |
||
72 |
//var title = data.content.category.label; |
|
73 |
//var user = data.content.user; |
|
74 |
//Test cat and color |
|
75 |
//var colorAnnot = 0x65A954; |
|
76 |
var category = data.content.category.label, |
|
77 |
text = data.content.text, |
|
78 |
user = data.content.user, |
|
79 |
ts = Date.parse(data.ts), |
|
80 |
color = this.getColor(ts, data.content.category.code); |
|
81 |
||
82 |
this.addAnnot(category, text, user, color, ts); |
|
83 |
}; |
|
89
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
84 |
|
98 | 85 |
this.getColor = function(ts, code) { |
86 |
var colorsDef; |
|
87 |
_(this.annotColors).eachRight(function(cdef) { |
|
88 |
console.log("cDef", cdef); |
|
89 |
console.log("cDef ts", cdef.ts, ts); |
|
90 |
if(cdef.ts < ts) { |
|
91 |
colorsDef = cdef.colors; |
|
92 |
return false; |
|
93 |
} |
|
94 |
}); |
|
95 |
var resColor; |
|
96 |
console.log("colorsDef", colorsDef); |
|
97 |
if(colorsDef) { |
|
98 |
resColor = colorsDef[code]; |
|
99 |
} |
|
100 |
if(!resColor) { |
|
101 |
resColor = DEFAULT_ANNOT_COLOR; |
|
102 |
} |
|
103 |
return resColor; |
|
104 |
} |
|
105 |
||
106 |
this.addAnnot = function(category, text, user, catColor, ts){ |
|
107 |
||
108 |
var color = catColor ? catColor : DEFAULT_ANNOT_COLOR; |
|
109 |
var x = 0; |
|
110 |
var y = (ts-this.startTs) * this.pixelsPerSecond / 1000 + yInit; |
|
111 |
||
112 |
var colorHex = parseInt(color.replace(/^#/, ''), 16); |
|
113 |
||
111
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
114 |
if (wait === 0){ |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
115 |
var graphics = new PIXI.Graphics() |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
116 |
.beginFill(colorHex) |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
117 |
.drawRect(x, y, 10, 3) |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
118 |
.endFill(); |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
119 |
|
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
120 |
this.container.addChild(graphics); |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
121 |
|
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
122 |
var textHeight = 0; |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
123 |
var catLabel = new PIXI.Text( |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
124 |
category, |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
125 |
_(annotStyles.label).extend({fill: color}).value() |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
126 |
); |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
127 |
catLabel.x = x + 20; |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
128 |
catLabel.y = y - 23; |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
129 |
this.container.addChild(catLabel); |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
130 |
textHeight += (catLabel.height - 23 + 2); |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
131 |
|
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
132 |
if(text) { |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
133 |
var catText = new PIXI.Text(text, annotStyles.text); |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
134 |
catText.x = x + 20; |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
135 |
catText.y = y; |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
136 |
this.container.addChild(catText); |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
137 |
textHeight += (catText.height + 2); |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
138 |
} |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
139 |
|
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
140 |
var catUser = new PIXI.Text(user, annotStyles.user); |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
141 |
catUser.x = x + 20; |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
142 |
catUser.y = y + textHeight; |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
143 |
this.container.addChild(catUser); |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
144 |
textHeight += (catUser.height + 8); |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
145 |
|
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
146 |
if (this.ignoreAnnots === true){ |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
147 |
wait = textHeight / this.pixelsPerSecond; |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
148 |
waitInterval = setInterval(function() {_this.refreshWait();}, 1000); |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
149 |
} |
98 | 150 |
} |
151 |
||
152 |
this.addAnnotLine(colorHex, y); |
|
89
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
153 |
}; |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
154 |
|
98 | 155 |
this.addAnnotLine = function(color, y) { |
156 |
var x = this.widthRoll; |
|
157 |
||
158 |
||
159 |
var graphics = new PIXI.Graphics() |
|
160 |
.beginFill(color) |
|
161 |
.drawRect(x, y, this.width - x, 3) |
|
162 |
.endFill(); |
|
163 |
||
89
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
164 |
this.container.addChild(graphics); |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
165 |
}; |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
166 |
|
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
167 |
this.moveTo = function(diffTime){ |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
168 |
this.container.y = Math.floor(diffTime*this.pixelsPerSecond); |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
169 |
}; |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
170 |
|
98 | 171 |
this.move = this.refresh = function() { |
172 |
var diff = (this.startTs - Date.now())/1000; |
|
173 |
this.moveTo(diff); |
|
174 |
}; |
|
111
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
175 |
|
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
176 |
this.refreshWait = function(){ |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
177 |
wait -= 1; |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
178 |
if (wait < 0){ |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
179 |
wait = 0; |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
180 |
clearInterval(waitInterval); |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
181 |
} |
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
182 |
}; |
98 | 183 |
|
89
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
184 |
this.removePassedObjets = function(){ |
98 | 185 |
var childrenToRemove = []; |
186 |
_(_this.container.children).forEach(function(child) { |
|
187 |
return typeof(child) === 'undefined' || |
|
188 |
(isHidden(child) && childrenToRemove.push(child)); |
|
189 |
}); |
|
89
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
190 |
childrenToRemove.forEach(function(child) { |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
191 |
_this.container.removeChild(child); |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
192 |
}); |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
193 |
}; |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
194 |
|
98 | 195 |
this.init = function() { |
196 |
||
197 |
ws.message(function(data) { |
|
198 |
_this.addAnnots(data); |
|
199 |
}); |
|
200 |
||
201 |
}; |
|
111
a7b72620d227
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
rougeronj
parents:
106
diff
changeset
|
202 |
|
98 | 203 |
|
204 |
this.start = function() { |
|
205 |
if(!started) { |
|
206 |
this.startTs = Date.now(); |
|
207 |
started = true; |
|
208 |
} |
|
209 |
this.cleanInterval = setInterval(function () { _this.removePassedObjets(); }, 1000 * this.height / this.pixelsPerSecond ); |
|
210 |
if(!externalRefresh) { |
|
211 |
this.refreshInterval = setInterval(function() {_this.move();}, 1000/this.framerate); |
|
212 |
} |
|
213 |
}; |
|
214 |
||
215 |
this.stop = function() { |
|
216 |
clearInterval(this.cleanInterval); |
|
217 |
if(!externalRefresh) { |
|
218 |
clearInterval(this.refreshInterval); |
|
219 |
} |
|
220 |
}; |
|
89
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
221 |
|
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
222 |
} |
b4bd49f01837
add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents:
diff
changeset
|
223 |
|
98 | 224 |
module.exports = { |
225 |
AnnotsRoll: AnnotsRoll, |
|
226 |
}; |