author | rougeronj |
Fri, 23 Jan 2015 10:09:59 +0100 | |
changeset 135 | d3066fa80a81 |
parent 134 | 119b6193c493 |
child 136 | 83a5ab5e2e81 |
permissions | -rw-r--r-- |
98 | 1 |
/** |
2 |
* js/annotsvizview.js |
|
3 |
* |
|
4 |
* This is the starting point for your application. |
|
5 |
* Take a look at http://browserify.org/ for more info |
|
6 |
*/ |
|
103 | 7 |
|
8 |
'use strict'; |
|
9 |
||
10 |
var PIXI = require('pixi'); |
|
11 |
var _ = require('lodash'); |
|
12 |
var DoubleRoll = require('./doubleroll.js'); |
|
13 |
var AnnotsTimeLine = require('./annotstimeline.js'); |
|
14 |
var AnnotsRoll = require('./annotsroll.js'); |
|
121
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
15 |
var Utils = require('./utils.js'); |
103 | 16 |
|
108 | 17 |
var defaultOptions = { |
103 | 18 |
xInit: 0, |
19 |
yInit: 0, |
|
104 | 20 |
width: 1024, |
126
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
21 |
height: 768 |
103 | 22 |
}; |
23 |
||
24 |
function AnnotsVizView(options){ |
|
25 |
var _this = this; |
|
26 |
var opts = _(options).defaults(defaultOptions).value(); |
|
108 | 27 |
|
103 | 28 |
this.container = new PIXI.DisplayObjectContainer(); |
29 |
this.container.x = opts.xInit; |
|
30 |
this.container.y = opts.yInit; |
|
31 |
this.width = opts.width; |
|
32 |
this.height= opts.height; |
|
113 | 33 |
this.timeBegin = opts.timeBegin; |
34 |
this.timeEnd = opts.timeEnd; |
|
128
9f2334598088
add archive variable to desactivate the socket listening for the static timeLines
rougeronj
parents:
126
diff
changeset
|
35 |
this.annotCategories = []; |
121
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
36 |
|
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
37 |
Utils.getAnnotCategories(opts.urlCategories, this.annotCategories); |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
38 |
|
103 | 39 |
var wsPianoroll = opts.wsPianoroll; |
40 |
var wsAnnot = opts.wsAnnot; |
|
41 |
var stageView = opts.stageView; |
|
126
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
42 |
var currentTime = Date.now() + 3600*1000; |
128
9f2334598088
add archive variable to desactivate the socket listening for the static timeLines
rougeronj
parents:
126
diff
changeset
|
43 |
var eventCode = opts.eventCode; |
133 | 44 |
var eventCodeSessionDay1 = opts.eventCodeSessionDay1; |
135 | 45 |
console.log("OUOAUOAUOAUAOUAOUA"); |
46 |
console.log(eventCodeSessionDay1); |
|
128
9f2334598088
add archive variable to desactivate the socket listening for the static timeLines
rougeronj
parents:
126
diff
changeset
|
47 |
var channel = opts.channel; |
133 | 48 |
var serverUrl = opts.serverUrl; |
131 | 49 |
|
103 | 50 |
stageView.registerComponent(this); |
108 | 51 |
|
126
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
52 |
var timeLineDay2 = new AnnotsTimeLine.AnnotsTimeLine({ |
103 | 53 |
stageView : stageView, |
54 |
logger: logger, |
|
131 | 55 |
ws: wsAnnot, |
103 | 56 |
xInit: 0, |
57 |
yInit: 0, |
|
104 | 58 |
width: 1024 - 200 - 200, |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
59 |
height: 768-200, |
113 | 60 |
timeBegin: this.timeBegin, |
61 |
timeEnd: this.timeEnd, |
|
103 | 62 |
intervalWidth: 6, |
63 |
intervalHeight: 10, |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
64 |
maxCellHeight: 70, |
104 | 65 |
radius: 200, |
128
9f2334598088
add archive variable to desactivate the socket listening for the static timeLines
rougeronj
parents:
126
diff
changeset
|
66 |
eventCode: eventCode, |
9f2334598088
add archive variable to desactivate the socket listening for the static timeLines
rougeronj
parents:
126
diff
changeset
|
67 |
channel: channel, |
133 | 68 |
serverUrl: serverUrl, |
108 | 69 |
annotCategories: this.annotCategories |
103 | 70 |
}); |
126
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
71 |
|
129
7181e1f28eb0
Merge with f9dd7bfed9976461c79bf521ed01bf4caaf4fbcf
rougeronj
parents:
128
diff
changeset
|
72 |
//Archive day 1 |
126
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
73 |
var timeLineDay1 = new AnnotsTimeLine.AnnotsTimeLine({ |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
74 |
stageView : stageView, |
128
9f2334598088
add archive variable to desactivate the socket listening for the static timeLines
rougeronj
parents:
126
diff
changeset
|
75 |
archive: true, |
126
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
76 |
xInit: 0, |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
77 |
yInit: 0, |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
78 |
width: 1024 - 200 - 200, |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
79 |
height: 768-200, |
129
7181e1f28eb0
Merge with f9dd7bfed9976461c79bf521ed01bf4caaf4fbcf
rougeronj
parents:
128
diff
changeset
|
80 |
timeBegin: Date.parse("2015-01-22T09:30:00+01:00"), |
7181e1f28eb0
Merge with f9dd7bfed9976461c79bf521ed01bf4caaf4fbcf
rougeronj
parents:
128
diff
changeset
|
81 |
timeEnd: Date.parse("2015-01-22T18:30:00+01:00"), |
126
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
82 |
circleX: timeLineDay2.circleX, |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
83 |
circleY: timeLineDay2.circleY, |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
84 |
intervalWidth: (timeLineDay2.radius*2/3)* timeLineDay2.intervalWidth / timeLineDay2.radius, |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
85 |
intervalHeight: (timeLineDay2.intervalHeight * (timeLineDay2.radius - timeLineDay2.radius*2/3))/ timeLineDay2.maxCellHeight, |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
86 |
maxCellHeight: (timeLineDay2.radius - timeLineDay2.radius*2/3)/4, |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
87 |
radius: timeLineDay2.radius*2/3, |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
88 |
annotCategories: this.annotCategories, |
133 | 89 |
eventCode: eventCodeSessionDay1, |
128
9f2334598088
add archive variable to desactivate the socket listening for the static timeLines
rougeronj
parents:
126
diff
changeset
|
90 |
channel: channel, |
133 | 91 |
serverUrl: serverUrl, |
126
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
92 |
showClockGraphics:false |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
93 |
}); |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
94 |
|
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
95 |
var currentTimeText = new PIXI.Text("-- : -- : --", { font: '18pt Gothic Standard', fill: '#646464' }); |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
96 |
currentTimeText.x = timeLineDay2.circleX - currentTimeText.width/2; |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
97 |
currentTimeText.y = timeLineDay2.circleY - currentTimeText.height/2; |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
98 |
this.container.addChild(currentTimeText); |
108 | 99 |
|
126
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
100 |
var timeLineDay3 = new PIXI.Graphics(); |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
101 |
timeLineDay3.lineStyle(1, 0x646464) |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
102 |
.drawCircle(timeLineDay2.circleX, timeLineDay2.circleY, timeLineDay2.radius/3) |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
103 |
.endFill() |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
104 |
this.container.addChild(timeLineDay3); |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
105 |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
106 |
var doubleRollH = new DoubleRoll.DoubleRoll({ |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
107 |
stageView : stageView, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
108 |
logger: logger, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
109 |
ws: wsPianoroll, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
110 |
yInit: (this.height - 200), |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
111 |
sceneHeight: 200, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
112 |
pianorolls : [ |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
113 |
{ |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
114 |
height: 200, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
115 |
timeWidth: 10, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
116 |
lineInterval: 5000, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
117 |
noteHeight: 10 |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
118 |
}, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
119 |
] |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
120 |
}); |
108 | 121 |
|
103 | 122 |
var doubleRollV = new DoubleRoll.DoubleRoll({ |
123 |
stageView : stageView, |
|
124 |
logger: logger, |
|
125 |
ws: wsPianoroll, |
|
126 |
orientation: 'vertical', |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
127 |
sceneHeight: 768-200, |
103 | 128 |
pianorolls : [ |
129 |
{ |
|
104 | 130 |
height: 200, |
103 | 131 |
timeWidth: 60, |
132 |
lineInterval: 5000, |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
133 |
noteHeight: 5, |
103 | 134 |
}, |
135 |
] |
|
136 |
}); |
|
108 | 137 |
|
103 | 138 |
var annotsRoll = new AnnotsRoll.AnnotsRoll({ |
139 |
stageView : stageView, |
|
140 |
logger: logger, |
|
141 |
ws: wsAnnot, |
|
142 |
parentContainer: doubleRollV.stage, |
|
104 | 143 |
xInit: 1024 - 200 - 200, |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
144 |
yInit: 768-200, |
104 | 145 |
width: 200 + 200, |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
146 |
height: 768-200, |
104 | 147 |
widthRoll: 200, |
103 | 148 |
framerate: doubleRollV.framerate, |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
149 |
pixelsPerSecond: Math.floor(1024 / 60), |
108 | 150 |
annotColors: this.annotCategories |
103 | 151 |
}); |
108 | 152 |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
153 |
var limiters = new PIXI.Graphics() |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
154 |
.lineStyle(1, 0x646464) |
103 | 155 |
.moveTo(annotsRoll.container.x, annotsRoll.container.y) |
156 |
.lineTo(annotsRoll.container.x, annotsRoll.container.y - annotsRoll.height) |
|
157 |
.moveTo(annotsRoll.container.x + annotsRoll.widthRoll, annotsRoll.container.y) |
|
158 |
.lineTo(annotsRoll.container.x + annotsRoll.widthRoll, annotsRoll.container.y - annotsRoll.height) |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
159 |
.moveTo(0, this.height - 200) |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
160 |
.lineTo(this.width, this.height - 200) |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
161 |
.drawRect(0, 0, this.width -1, this.height -1) |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
162 |
.beginFill(0xECECEC) |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
163 |
.drawRect(1024 - 200, 0, 200, 768-200) |
103 | 164 |
.endFill(); |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
165 |
this.container.addChild(limiters); |
108 | 166 |
|
103 | 167 |
this.init = function(){ |
126
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
168 |
}; |
108 | 169 |
|
126
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
170 |
this.updateTime = function(){ |
129
7181e1f28eb0
Merge with f9dd7bfed9976461c79bf521ed01bf4caaf4fbcf
rougeronj
parents:
128
diff
changeset
|
171 |
currentTimeText.setText(Utils.formatTime(Date.now())); |
126
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
172 |
}; |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
173 |
|
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
174 |
var refreshTimeInterval; |
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
175 |
|
103 | 176 |
this.start = function() { |
126
13d9a532a0a7
Add timeline of the 2nd day - take out from the clock annotstimeline and put it in annotsvizview - make the clocks graphics optional through showClockGraphics
rougeronj
parents:
121
diff
changeset
|
177 |
refreshTimeInterval = setInterval(function() {_this.updateTime();}, 1000); |
103 | 178 |
}; |
108 | 179 |
|
103 | 180 |
this.refresh = function() { |
181 |
}; |
|
108 | 182 |
|
103 | 183 |
this.stop = function(){ |
184 |
}; |
|
108 | 185 |
|
103 | 186 |
return this; |
108 | 187 |
|
103 | 188 |
} |
189 |
||
190 |
module.exports = { |
|
191 |
AnnotsVizView: AnnotsVizView |
|
108 | 192 |
}; |