client/annotviz/app/js/annotstimeline.js
changeset 113 7531e4180915
parent 109 8546e2181a73
child 114 9fcb0e0991ed
equal deleted inserted replaced
112:3e075a48e19e 113:7531e4180915
    44     this.circleY = opts.circleY || (this.height/2);
    44     this.circleY = opts.circleY || (this.height/2);
    45     this.radius = opts.radius;
    45     this.radius = opts.radius;
    46     this.perimeter = 2*Math.PI* this.radius;
    46     this.perimeter = 2*Math.PI* this.radius;
    47     this.intervalDuration = (this.intervalWidth * this.duration / this.perimeter);
    47     this.intervalDuration = (this.intervalWidth * this.duration / this.perimeter);
    48 
    48 
    49     var currentTime = this.timeBegin;
    49     var currentTime = Date.now() + 3600*1000;
    50     var totalIndex = Math.floor(this.perimeter/this.intervalWidth);
    50     var totalIndex = Math.floor(this.perimeter/this.intervalWidth);
    51 
    51 
    52     this.cells = []
    52     this.cells = []
    53     for (var i=0; i<(this.perimeter/this.intervalWidth) ; i++){
    53     for (var i=0; i<(this.perimeter/this.intervalWidth) ; i++){
    54     	this.cells[i] = [];
    54     	this.cells[i] = [];
    55     	this.cells[i].i = i;
    55     	this.cells[i].i = i;
    56     	this.cells[i].totalAnnots = 0;
    56     	this.cells[i].totalAnnots = 0;
    57     	this.cells[i].categories = {};
    57     	this.cells[i].categories = {};
    58 
    58     	
    59     	for (var category in this.annotCategories[0].colors){
    59     	for (var category in this.annotCategories[0].colors){
    60     		this.cells[i].categories[category] = {
    60     		this.cells[i].categories[category] = {
    61 				"count": 0,
    61 				"count": 0,
    62 				"color": this.annotCategories[0].colors[category]
    62 				"color": this.annotCategories[0].colors[category]
    63     		};
    63     		};
   105 			this.cells[i].totalAnnots +=1;
   105 			this.cells[i].totalAnnots +=1;
   106 			this.redrawCell(this.cells[i], i);
   106 			this.redrawCell(this.cells[i], i);
   107     	}
   107     	}
   108     };
   108     };
   109 
   109 
   110     this.initGraphics = function(cell){
   110     this.initCell = function(cell){
   111     	cell.graphics = new PIXI.Graphics();
   111     	cell.graphics = new PIXI.Graphics();
   112     	cell.graphics.position.x = this.circleX + this.radius * Math.sin(cell.i*(360/totalIndex)*(Math.PI/180));
   112     	cell.graphics.position.x = this.circleX + this.radius * Math.sin(cell.i*(360/totalIndex)*(Math.PI/180));
   113     	cell.graphics.position.y = this.circleY - this.radius * Math.cos(cell.i*(360/totalIndex)*(Math.PI/180));
   113     	cell.graphics.position.y = this.circleY - this.radius * Math.cos(cell.i*(360/totalIndex)*(Math.PI/180));
   114     	cell.graphics.rotation = (cell.i)*(360/totalIndex)*(Math.PI/180) + (360/(totalIndex*2))*(Math.PI/180);
   114     	cell.graphics.rotation = (cell.i)*(360/totalIndex)*(Math.PI/180) + (360/(totalIndex*2))*(Math.PI/180);
   115     	this.container.addChild(cell.graphics);
   115     	this.container.addChild(cell.graphics);
   146 
   146 
   147     //Draw the cellule
   147     //Draw the cellule
   148     this.redrawCell = function(cell){
   148     this.redrawCell = function(cell){
   149 
   149 
   150     	if (typeof(cell.graphics) === 'undefined'){
   150     	if (typeof(cell.graphics) === 'undefined'){
   151     		this.initGraphics(cell);
   151     		this.initCell(cell);
   152     	} else {
   152     	} else {
   153     		cell.graphics.clear();
   153     		cell.graphics.clear();
   154     	}
   154     	}
   155 
   155 
   156     	var y = 0;
   156     	var y = 0;
   179 
   179 
   180     	this.initTimeTexts();
   180     	this.initTimeTexts();
   181     };
   181     };
   182 
   182 
   183     this.updateTime = function(){
   183     this.updateTime = function(){
   184     	currentTime += 1000;
   184     	currentTime = Date.now() + 3600*1000;
   185 
   185 
   186         var nbSec = currentTime / 1000;
   186         var nbSec = currentTime / 1000;
   187         var hours = Math.floor( nbSec / 3600 ) % 24;
   187         var hours = Math.floor( nbSec / 3600 ) % 24;
   188         var minutes = Math.floor( nbSec / 60 ) % 60;
   188         var minutes = Math.floor( nbSec / 60 ) % 60;
   189         var seconds = Math.floor(nbSec % 60);
   189         var seconds = Math.floor(nbSec % 60);