author | rougeronj |
Thu, 22 Jan 2015 15:03:58 +0100 | |
changeset 121 | df6b39f962bc |
parent 113 | 7531e4180915 |
child 126 | 13d9a532a0a7 |
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, |
21 |
height: 768, |
|
121
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
22 |
// annotCategories: [ |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
23 |
// { |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
24 |
// "ts": 1421928213000, |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
25 |
// "colors": { |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
26 |
// "transgressions": "#b90000", |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
27 |
// "rythmique": "#af931e", |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
28 |
// "narration": "#4bdd71", |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
29 |
// "relation": "#1c28ba" |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
30 |
// }, |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
31 |
// "order": [ |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
32 |
// "transgressions", |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
33 |
// "rythmique", |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
34 |
// "narration", |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
35 |
// "relation" |
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 |
// "defaultColor": "#536991" |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
38 |
// }] |
103 | 39 |
}; |
40 |
||
41 |
function AnnotsVizView(options){ |
|
42 |
var _this = this; |
|
43 |
var opts = _(options).defaults(defaultOptions).value(); |
|
108 | 44 |
|
103 | 45 |
this.container = new PIXI.DisplayObjectContainer(); |
46 |
this.container.x = opts.xInit; |
|
47 |
this.container.y = opts.yInit; |
|
48 |
this.width = opts.width; |
|
49 |
this.height= opts.height; |
|
113 | 50 |
this.timeBegin = opts.timeBegin; |
51 |
this.timeEnd = opts.timeEnd; |
|
121
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
52 |
|
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
53 |
this.annotCategories = []; |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
54 |
Utils.getAnnotCategories(opts.urlCategories, this.annotCategories); |
df6b39f962bc
Add getAnnotCategories to utils and propagate the modification to annotsvizview and annotstimeline
rougeronj
parents:
113
diff
changeset
|
55 |
|
103 | 56 |
var wsPianoroll = opts.wsPianoroll; |
57 |
var wsAnnot = opts.wsAnnot; |
|
58 |
var stageView = opts.stageView; |
|
108 | 59 |
|
103 | 60 |
stageView.registerComponent(this); |
108 | 61 |
|
103 | 62 |
var timeLine = new AnnotsTimeLine.AnnotsTimeLine({ |
63 |
stageView : stageView, |
|
64 |
logger: logger, |
|
65 |
ws: new annotviz.WsWrapper(wsUriAnnotation, logger), |
|
66 |
xInit: 0, |
|
67 |
yInit: 0, |
|
104 | 68 |
width: 1024 - 200 - 200, |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
69 |
height: 768-200, |
113 | 70 |
timeBegin: this.timeBegin, |
71 |
timeEnd: this.timeEnd, |
|
103 | 72 |
intervalWidth: 6, |
73 |
intervalHeight: 10, |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
74 |
maxCellHeight: 70, |
104 | 75 |
radius: 200, |
108 | 76 |
annotCategories: this.annotCategories |
103 | 77 |
}); |
108 | 78 |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
79 |
var doubleRollH = new DoubleRoll.DoubleRoll({ |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
80 |
stageView : stageView, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
81 |
logger: logger, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
82 |
ws: wsPianoroll, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
83 |
yInit: (this.height - 200), |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
84 |
sceneHeight: 200, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
85 |
pianorolls : [ |
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 |
height: 200, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
88 |
timeWidth: 10, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
89 |
lineInterval: 5000, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
90 |
noteHeight: 10 |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
91 |
}, |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
92 |
] |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
93 |
}); |
108 | 94 |
|
103 | 95 |
var doubleRollV = new DoubleRoll.DoubleRoll({ |
96 |
stageView : stageView, |
|
97 |
logger: logger, |
|
98 |
ws: wsPianoroll, |
|
99 |
orientation: 'vertical', |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
100 |
sceneHeight: 768-200, |
103 | 101 |
pianorolls : [ |
102 |
{ |
|
104 | 103 |
height: 200, |
103 | 104 |
timeWidth: 60, |
105 |
lineInterval: 5000, |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
106 |
noteHeight: 5, |
103 | 107 |
}, |
108 |
] |
|
109 |
}); |
|
108 | 110 |
|
103 | 111 |
var annotsRoll = new AnnotsRoll.AnnotsRoll({ |
112 |
stageView : stageView, |
|
113 |
logger: logger, |
|
114 |
ws: wsAnnot, |
|
115 |
parentContainer: doubleRollV.stage, |
|
104 | 116 |
xInit: 1024 - 200 - 200, |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
117 |
yInit: 768-200, |
104 | 118 |
width: 200 + 200, |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
119 |
height: 768-200, |
104 | 120 |
widthRoll: 200, |
103 | 121 |
framerate: doubleRollV.framerate, |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
122 |
pixelsPerSecond: Math.floor(1024 / 60), |
108 | 123 |
annotColors: this.annotCategories |
103 | 124 |
}); |
108 | 125 |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
126 |
var limiters = new PIXI.Graphics() |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
127 |
.lineStyle(1, 0x646464) |
103 | 128 |
.moveTo(annotsRoll.container.x, annotsRoll.container.y) |
129 |
.lineTo(annotsRoll.container.x, annotsRoll.container.y - annotsRoll.height) |
|
130 |
.moveTo(annotsRoll.container.x + annotsRoll.widthRoll, annotsRoll.container.y) |
|
131 |
.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
|
132 |
.moveTo(0, this.height - 200) |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
133 |
.lineTo(this.width, this.height - 200) |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
134 |
.drawRect(0, 0, this.width -1, this.height -1) |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
135 |
.beginFill(0xECECEC) |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
136 |
.drawRect(1024 - 200, 0, 200, 768-200) |
103 | 137 |
.endFill(); |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
138 |
this.container.addChild(limiters); |
108 | 139 |
|
103 | 140 |
// var doubleRollV = new DoubleRoll.DoubleRoll({}); |
108 | 141 |
|
103 | 142 |
this.init = function(){ |
108 | 143 |
|
103 | 144 |
} |
108 | 145 |
|
103 | 146 |
this.start = function() { |
147 |
}; |
|
108 | 148 |
|
103 | 149 |
this.refresh = function() { |
150 |
}; |
|
108 | 151 |
|
103 | 152 |
this.stop = function(){ |
153 |
}; |
|
108 | 154 |
|
103 | 155 |
return this; |
108 | 156 |
|
103 | 157 |
} |
158 |
||
159 |
module.exports = { |
|
160 |
AnnotsVizView: AnnotsVizView |
|
108 | 161 |
}; |