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