author | ymh <ymh.work@gmail.com> |
Thu, 22 Jan 2015 07:04:42 +0100 | |
changeset 108 | 082b64a5c699 |
parent 105 | 25ac8802c189 |
child 110 | e4f0c105090d |
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'); |
|
15 |
||
108 | 16 |
var defaultOptions = { |
103 | 17 |
xInit: 0, |
18 |
yInit: 0, |
|
104 | 19 |
width: 1024, |
20 |
height: 768, |
|
108 | 21 |
annotCategories: [{ |
22 |
ts: 0, |
|
23 |
colors: { |
|
24 |
'ntm': '#CDC83F', |
|
25 |
'iam': '#CDC83F', |
|
26 |
'hip': '#CDC83F', |
|
27 |
'hop': '#CDC83F', |
|
28 |
'rock': '#DE8B53', |
|
29 |
'rap': '#DE8B53', |
|
30 |
'classic': '#DE8B53', |
|
31 |
'drums': '#C5A3CA', |
|
32 |
'guitar': '#C5A3CA', |
|
33 |
'bass': '#79BB92', |
|
34 |
'default': '#808080' |
|
35 |
}, |
|
36 |
order: ['ntm', 'iam', 'hip', 'hop', 'rock', 'rap', 'classic', 'drums', 'guitar', 'bass', 'default'] |
|
37 |
}] |
|
103 | 38 |
}; |
39 |
||
40 |
function AnnotsVizView(options){ |
|
41 |
var _this = this; |
|
42 |
var opts = _(options).defaults(defaultOptions).value(); |
|
108 | 43 |
|
103 | 44 |
this.container = new PIXI.DisplayObjectContainer(); |
45 |
this.container.x = opts.xInit; |
|
46 |
this.container.y = opts.yInit; |
|
47 |
this.width = opts.width; |
|
48 |
this.height= opts.height; |
|
108 | 49 |
this.annotCategories = opts.annotCategories; |
50 |
||
103 | 51 |
var wsPianoroll = opts.wsPianoroll; |
52 |
var wsAnnot = opts.wsAnnot; |
|
53 |
var stageView = opts.stageView; |
|
108 | 54 |
|
103 | 55 |
stageView.registerComponent(this); |
108 | 56 |
|
103 | 57 |
var timeLine = new AnnotsTimeLine.AnnotsTimeLine({ |
58 |
stageView : stageView, |
|
59 |
logger: logger, |
|
60 |
ws: new annotviz.WsWrapper(wsUriAnnotation, logger), |
|
61 |
xInit: 0, |
|
62 |
yInit: 0, |
|
104 | 63 |
width: 1024 - 200 - 200, |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
64 |
height: 768-200, |
103 | 65 |
timeBegin: Date.now(), |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
66 |
timeEnd: Date.now() + 3000000, |
103 | 67 |
intervalWidth: 6, |
68 |
intervalHeight: 10, |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
69 |
maxCellHeight: 70, |
104 | 70 |
radius: 200, |
108 | 71 |
annotCategories: this.annotCategories |
103 | 72 |
}); |
108 | 73 |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
74 |
var doubleRollH = new DoubleRoll.DoubleRoll({ |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
75 |
stageView : stageView, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
76 |
logger: logger, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
77 |
ws: wsPianoroll, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
78 |
yInit: (this.height - 200), |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
79 |
sceneHeight: 200, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
80 |
pianorolls : [ |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
81 |
{ |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
82 |
height: 200, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
83 |
timeWidth: 10, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
84 |
lineInterval: 5000, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
85 |
noteHeight: 10 |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
86 |
}, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
87 |
] |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
88 |
}); |
108 | 89 |
|
103 | 90 |
var doubleRollV = new DoubleRoll.DoubleRoll({ |
91 |
stageView : stageView, |
|
92 |
logger: logger, |
|
93 |
ws: wsPianoroll, |
|
94 |
orientation: 'vertical', |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
95 |
sceneHeight: 768-200, |
103 | 96 |
pianorolls : [ |
97 |
{ |
|
104 | 98 |
height: 200, |
103 | 99 |
timeWidth: 60, |
100 |
lineInterval: 5000, |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
101 |
noteHeight: 5, |
103 | 102 |
}, |
103 |
] |
|
104 |
}); |
|
108 | 105 |
|
103 | 106 |
var annotsRoll = new AnnotsRoll.AnnotsRoll({ |
107 |
stageView : stageView, |
|
108 |
logger: logger, |
|
109 |
ws: wsAnnot, |
|
110 |
parentContainer: doubleRollV.stage, |
|
104 | 111 |
xInit: 1024 - 200 - 200, |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
112 |
yInit: 768-200, |
104 | 113 |
width: 200 + 200, |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
114 |
height: 768-200, |
104 | 115 |
widthRoll: 200, |
103 | 116 |
framerate: doubleRollV.framerate, |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
117 |
pixelsPerSecond: Math.floor(1024 / 60), |
108 | 118 |
annotColors: this.annotCategories |
103 | 119 |
}); |
108 | 120 |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
121 |
var limiters = new PIXI.Graphics() |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
122 |
.lineStyle(1, 0x646464) |
103 | 123 |
.moveTo(annotsRoll.container.x, annotsRoll.container.y) |
124 |
.lineTo(annotsRoll.container.x, annotsRoll.container.y - annotsRoll.height) |
|
125 |
.moveTo(annotsRoll.container.x + annotsRoll.widthRoll, annotsRoll.container.y) |
|
126 |
.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
|
127 |
.moveTo(0, this.height - 200) |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
128 |
.lineTo(this.width, this.height - 200) |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
129 |
.drawRect(0, 0, this.width -1, this.height -1) |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
130 |
.beginFill(0xECECEC) |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
131 |
.drawRect(1024 - 200, 0, 200, 768-200) |
103 | 132 |
.endFill(); |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
133 |
this.container.addChild(limiters); |
108 | 134 |
|
103 | 135 |
// var doubleRollV = new DoubleRoll.DoubleRoll({}); |
108 | 136 |
|
103 | 137 |
this.init = function(){ |
108 | 138 |
|
103 | 139 |
} |
108 | 140 |
|
103 | 141 |
this.start = function() { |
142 |
}; |
|
108 | 143 |
|
103 | 144 |
this.refresh = function() { |
145 |
}; |
|
108 | 146 |
|
103 | 147 |
this.stop = function(){ |
148 |
}; |
|
108 | 149 |
|
103 | 150 |
return this; |
108 | 151 |
|
103 | 152 |
} |
153 |
||
154 |
module.exports = { |
|
155 |
AnnotsVizView: AnnotsVizView |
|
108 | 156 |
}; |