--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/client/annotviz/app/annotstimeline.html Tue Jan 20 18:38:18 2015 +0100
@@ -0,0 +1,91 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width,initial-scale=1">
+ <meta name="description" content="">
+ <meta name="author" content="I.R.I">
+ <link rel="shortcut icon" href="/img/favicon.ico">
+
+ <title>AnnotsTimeLine</title>
+
+ <!-- Custom styles for this template -->
+ <link href="/css/annotviz.css" rel="stylesheet">
+</head>
+
+<body>
+ <h1>Piano Roll vertical</h1>
+ <noscript>You must enable JavaScript</noscript>
+ <div id="canvasContainer"></div>
+ <p>
+ <a href="#" onclick="stop(); return false;">stop intervals</a> -
+ <a href="#" onclick="start(); return false;">start intervals</a> -
+ temps écoulé : <span id="timeStarted"></span>
+ </p>
+ <!--pre id="log"></pre-->
+ <script src="/js/libs-annotviz.js"></script>
+ <script src="/js/annotviz.js"></script>
+ <script>
+ var annotationChannel = 'ANNOT';
+ var eventCode = 'test_1';
+ var wsUri;
+ if (window.location.protocol === 'file:') {
+ wsUri = 'ws://127.0.0.1:8090/broadcast';
+ }
+ else {
+ wsUri = 'ws://' + window.location.hostname + ':8090/broadcast';
+ }
+ wsUriAnnotation = wsUri + '?channel=' + annotationChannel + '&event_code=' + eventCode;
+
+ var logger = new annotviz.ConsoleLogger(true);
+
+ var stageView = new annotviz.StageView({
+ logger: logger
+ });
+
+ var annotstimeline = new annotviz.AnnotsTimeLine({
+ stageView : stageView,
+ logger: logger,
+ ws: new annotviz.WsWrapper(wsUriAnnotation, logger),
+ xInit: 0,
+ yInit: 0,
+ width: 1920 - 435 - 300,
+ height: 1080,
+ timeBegin: Date.now(),
+ timeEnd: Date.now() + 300000,
+ intervalWidth: 30,
+ intervalHeight: 10,
+ maxCellHeight: 50,
+ annotCategories: [{
+ ts: 0,
+ colors: {
+ 'ntm': '#CDC83F',
+ 'iam': '#CDC83F',
+ 'hip': '#CDC83F',
+ 'hop': '#CDC83F',
+ 'rock': '#DE8B53',
+ 'rap': '#DE8B53',
+ 'classic': '#DE8B53',
+ 'drums': '#C5A3CA',
+ 'guitar': '#C5A3CA',
+ 'bass': '#79BB92',
+ 'default': '#808080'
+ },
+ order: ['ntm', 'iam', 'hip', 'hop', 'rock', 'rap', 'classic', 'drums', 'guitar', 'bass', 'default']
+ }]
+ });
+
+ function stop() {
+ stageView.stop();
+ }
+ function start() {
+ stageView.start();
+ }
+
+ window.onload = function() {
+ stageView.init();
+ start();
+ }
+ </script>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/client/annotviz/app/js/stageview.js Tue Jan 20 18:38:18 2015 +0100
@@ -0,0 +1,127 @@
+/**
+* scripts/stageview.js
+*
+* This is the starting point for your application.
+* Take a look at http://browserify.org/ for more info
+*/
+
+/* global document: false */
+
+'use strict';
+
+
+var PIXI = require('pixi');
+var _ = require('lodash');
+
+var defaultConfig = {
+ externalRefresh: false,
+ logger: undefined,
+ sceneWidth: 1920,
+ sceneHeight: 1080,
+ framerate: 25,
+ sceneBgColor: 0xFFFFFF,
+ canvasContainer: 'canvasContainer',
+ timeContainer: 'timeStarted'
+};
+
+function StageView(options) {
+
+ var _this = this;
+ var opts = _(options).defaults(defaultConfig).value();
+
+ var externalRefresh = opts.externalRefresh;
+
+ this.logger = opts.logger;
+ this.framerate = opts.framerate;
+ var sceneBgColor = opts.sceneBgColor;
+ var sceneWidth = opts.sceneWidth;
+ var sceneHeight = opts.sceneHeight;
+ var canvasContainer = opts.canvasContainer;
+ var timeContainer = opts.timeContainer;
+
+ //create an new instance of a pixi stage
+ this.stage = new PIXI.Stage(sceneBgColor);
+ //create a renderer instance.
+ var renderer = PIXI.autoDetectRenderer(sceneWidth, sceneHeight);
+ var components = [];
+
+ this.init = function() {
+
+ if(typeof(canvasContainer) === 'string') {
+ canvasContainer = document.getElementById(canvasContainer);
+ }
+ if(typeof(timeContainer) === 'string') {
+ timeContainer = document.getElementById(timeContainer);
+ }
+
+ canvasContainer.appendChild(renderer.view);
+
+ components.forEach(function(c){
+ c.init();
+ });
+ };
+
+ this.registerComponent = function(component) {
+ components.push(component);
+ this.stage.addChild(component.container);
+ };
+
+ this.refresh = function() {
+ components.forEach(function(c){
+ c.refresh();
+ });
+ renderer.render(this.stage);
+ };
+
+ // Init page and intervals
+ var refreshInterval;
+ var refreshTimeInterval;
+ var startTs;
+
+ this.updateTime = function(){
+ var nbSec = (Date.now() - startTs) / 1000;
+ var hours = Math.floor( nbSec / 3600 ) % 24;
+ var minutes = Math.floor( nbSec / 60 ) % 60;
+ var seconds = Math.floor(nbSec % 60);
+ var timeStr = (hours < 10 ? '0' + hours : hours) + ':' + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds);
+ timeContainer.innerHTML = timeStr;
+ };
+
+ this.start = function() {
+
+ startTs = Date.now();
+ if(!externalRefresh) {
+ refreshInterval = setInterval(function() {_this.refresh();}, 1000/this.framerate);
+ }
+ refreshTimeInterval = setInterval(function() {_this.updateTime();}, 1000);
+
+ components.forEach(function(c){
+ c.start();
+ });
+ };
+
+ this.stop = function() {
+ if(!externalRefresh) {
+ clearInterval(refreshInterval);
+ }
+ clearInterval(refreshTimeInterval);
+
+ components.forEach(function(c){
+ c.stop();
+ });
+ };
+
+
+ this.log = function(m) {
+ if(this.logger) {
+ this.logger.log(m);
+ }
+ };
+
+
+ return this;
+}
+
+module.exports = {
+ StageView: StageView
+};