client/annotviz/app/js/annotsvizview.js
author rougeronj
Thu, 22 Jan 2015 02:21:15 +0100
changeset 105 25ac8802c189
parent 104 685c5ebc59d0
child 108 082b64a5c699
permissions -rw-r--r--
Improve interface + Add horizontal pianoroll to annotsvizview
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
98
72d767c5142d refactor and make work annotsroll
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
/**
72d767c5142d refactor and make work annotsroll
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
* js/annotsvizview.js
72d767c5142d refactor and make work annotsroll
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
*
72d767c5142d refactor and make work annotsroll
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
* This is the starting point for your application.
72d767c5142d refactor and make work annotsroll
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
* Take a look at http://browserify.org/ for more info
72d767c5142d refactor and make work annotsroll
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
*/
103
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
     7
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
     8
'use strict';
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
     9
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    10
var PIXI = require('pixi');
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    11
var _ = require('lodash');
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    12
var DoubleRoll = require('./doubleroll.js');
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    13
var AnnotsTimeLine = require('./annotstimeline.js');
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    14
var AnnotsRoll = require('./annotsroll.js');
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    15
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    16
var defaultOptions = {		
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    17
    xInit: 0,
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    18
    yInit: 0,
104
685c5ebc59d0 update resolution screen
rougeronj
parents: 103
diff changeset
    19
    width: 1024,
685c5ebc59d0 update resolution screen
rougeronj
parents: 103
diff changeset
    20
    height: 768,
103
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    21
};
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    22
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    23
function AnnotsVizView(options){
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    24
	var _this = this;
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    25
    var opts = _(options).defaults(defaultOptions).value();
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    26
    
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    27
    this.container = new PIXI.DisplayObjectContainer();
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    28
    this.container.x = opts.xInit;
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    29
    this.container.y = opts.yInit;
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    30
	this.width = opts.width;
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    31
	this.height= opts.height;
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    32
	
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    33
	var wsPianoroll = opts.wsPianoroll;
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    34
	var wsAnnot = opts.wsAnnot;
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    35
	var stageView = opts.stageView;
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    36
	
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    37
	stageView.registerComponent(this);
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    38
	
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    39
	var timeLine = new AnnotsTimeLine.AnnotsTimeLine({
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    40
    	stageView : stageView,
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    41
        logger: logger,
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    42
        ws: new annotviz.WsWrapper(wsUriAnnotation, logger),
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    43
        xInit: 0,
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    44
        yInit: 0,
104
685c5ebc59d0 update resolution screen
rougeronj
parents: 103
diff changeset
    45
        width: 1024 - 200 - 200,
105
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    46
        height: 768-200,
103
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    47
        timeBegin: Date.now(),
105
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    48
        timeEnd: Date.now() + 3000000,
103
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    49
        intervalWidth: 6,
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    50
        intervalHeight: 10,
105
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    51
        maxCellHeight: 70,
104
685c5ebc59d0 update resolution screen
rougeronj
parents: 103
diff changeset
    52
        radius: 200,
103
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    53
        annotCategories: [{
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    54
       		ts: 0, 
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    55
       		colors: {		
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    56
   	       		'ntm': '#CDC83F',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    57
   	       	    'iam': '#CDC83F',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    58
   	       	    'hip': '#CDC83F',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    59
   	       	    'hop': '#CDC83F',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    60
   	       	    'rock': '#DE8B53',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    61
   	       	    'rap': '#DE8B53',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    62
   	       	    'classic': '#DE8B53',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    63
   	       	    'drums': '#C5A3CA',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    64
   	       	    'guitar': '#C5A3CA',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    65
   	       	    'bass': '#79BB92',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    66
   	       	   	'default': '#808080'
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    67
			},
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    68
        	order: ['ntm', 'iam', 'hip', 'hop', 'rock', 'rap', 'classic', 'drums', 'guitar', 'bass', 'default']
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    69
       	}]
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    70
    });
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    71
	
105
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    72
	var doubleRollH = new DoubleRoll.DoubleRoll({
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    73
        stageView : stageView,
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    74
    	logger: logger,
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    75
        ws: wsPianoroll,
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    76
        yInit: (this.height - 200),
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    77
        sceneHeight: 200,
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    78
        pianorolls : [
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    79
            {
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    80
                height: 200,
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    81
                timeWidth: 10,
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    82
                lineInterval: 5000,
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    83
                noteHeight: 10
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    84
            },
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    85
        ]
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    86
    });
103
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    87
	
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    88
	var doubleRollV = new DoubleRoll.DoubleRoll({
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    89
        stageView : stageView,
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    90
    	logger: logger,
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    91
        ws: wsPianoroll,
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    92
        orientation: 'vertical',
105
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    93
        sceneHeight: 768-200,
103
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    94
        pianorolls : [
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    95
            {
104
685c5ebc59d0 update resolution screen
rougeronj
parents: 103
diff changeset
    96
                height: 200,
103
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    97
                timeWidth: 60,
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
    98
                lineInterval: 5000,
105
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
    99
                noteHeight: 5,
103
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   100
            },
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   101
        ]
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   102
    });
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   103
	
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   104
	var annotsRoll = new AnnotsRoll.AnnotsRoll({
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   105
    	stageView : stageView,
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   106
        logger: logger,
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   107
        ws: wsAnnot,
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   108
        parentContainer: doubleRollV.stage,
104
685c5ebc59d0 update resolution screen
rougeronj
parents: 103
diff changeset
   109
        xInit: 1024 - 200 - 200,
105
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
   110
        yInit: 768-200,
104
685c5ebc59d0 update resolution screen
rougeronj
parents: 103
diff changeset
   111
        width: 200 + 200,
105
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
   112
        height: 768-200,
104
685c5ebc59d0 update resolution screen
rougeronj
parents: 103
diff changeset
   113
        widthRoll: 200,
103
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   114
        framerate: doubleRollV.framerate,
105
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
   115
        pixelsPerSecond: Math.floor(1024 / 60),
103
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   116
        annotColors: [{
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   117
        	ts: 0, 
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   118
        	colors: {		
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   119
   	       		'ntm': '#CDC83F',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   120
   	       	    'iam': '#CDC83F',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   121
   	       	    'hip': '#CDC83F',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   122
   	       	    'hop': '#CDC83F',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   123
   	       	    'rock': '#DE8B53',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   124
   	       	    'rap': '#DE8B53',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   125
   	       	    'classic': '#DE8B53',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   126
   	       	    'drums': '#C5A3CA',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   127
   	       	    'guitar': '#C5A3CA',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   128
   	       	    'bass': '#79BB92',
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   129
   	       	   	'default': '#808080'
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   130
			}
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   131
        }]
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   132
    });
105
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
   133
	
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
   134
	var limiters = new PIXI.Graphics()
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
   135
		.lineStyle(1, 0x646464)
103
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   136
		.moveTo(annotsRoll.container.x, annotsRoll.container.y)
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   137
		.lineTo(annotsRoll.container.x, annotsRoll.container.y - annotsRoll.height)
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   138
		.moveTo(annotsRoll.container.x + annotsRoll.widthRoll, annotsRoll.container.y)
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   139
		.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
   140
		.moveTo(0, this.height - 200)
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
   141
		.lineTo(this.width, this.height - 200)
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
   142
		.drawRect(0, 0, this.width -1, this.height -1)
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
   143
		.beginFill(0xECECEC)
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
   144
		.drawRect(1024 - 200, 0, 200, 768-200)
103
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   145
		.endFill();
105
25ac8802c189 Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents: 104
diff changeset
   146
	this.container.addChild(limiters);
103
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   147
	
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   148
//	var doubleRollV = new DoubleRoll.DoubleRoll({});
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   149
	
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   150
	this.init = function(){
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   151
		
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   152
	}
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   153
	
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   154
	this.start = function() {
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   155
    };
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   156
    
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   157
    this.refresh = function() {
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   158
    };
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   159
    
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   160
    this.stop = function(){
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   161
    };
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   162
    
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   163
    return this;
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   164
	
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   165
}
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   166
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   167
module.exports = {
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   168
	AnnotsVizView: AnnotsVizView
123a611c7903 minor update of options and add annotsvizview
rougeronj
parents: 98
diff changeset
   169
};