# HG changeset patch # User rougeronj # Date 1421915203 -3600 # Node ID a7b72620d227bd926d5161293c9aafbb993d3837 # Parent 9b20ddf1fc70db66849637ddcad8f63d5d377681 Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options diff -r 9b20ddf1fc70 -r a7b72620d227 client/annotviz/app/js/annotsroll.js --- a/client/annotviz/app/js/annotsroll.js Thu Jan 22 02:58:41 2015 +0100 +++ b/client/annotviz/app/js/annotsroll.js Thu Jan 22 09:26:43 2015 +0100 @@ -21,7 +21,8 @@ var defaultOptions = { externalRefresh: false, defaultColor: DEFAULT_ANNOT_COLOR, - annotStyles: defaultAnnotStyles + annotStyles: defaultAnnotStyles, + ignoreAnnots:false }; function AnnotsRoll(options) { @@ -41,7 +42,8 @@ this.widthRoll = opts.widthRoll; this.pixelsPerSecond = opts.pixelsPerSecond; this.annotColors = opts.annotColors; - this.startTs = options.startTs || Date.now(); + this.startTs = opts.startTs || Date.now(); + this.ignoreAnnots = opts.ignoreAnnots; var yInit = opts.yInit; var annotStyles = _(opts.annotStyles).defaults(defaultAnnotStyles).value(); @@ -50,11 +52,12 @@ annotStyles[style].wordWrapWidth = this.widthRoll; } } - console.log(annotStyles); var started = false; var ws = opts.ws; var externalRefresh = opts.externalRefresh; var stageView = opts.stageView; + var waitInterval; + var wait = 0; stageView.registerComponent(this); @@ -108,36 +111,44 @@ var colorHex = parseInt(color.replace(/^#/, ''), 16); - var graphics = new PIXI.Graphics() - .beginFill(colorHex) - .drawRect(x, y, 10, 3) - .endFill(); - - this.container.addChild(graphics); - - var textHeight = 0; - var catLabel = new PIXI.Text( - category, - _(annotStyles.label).extend({fill: color}).value() - ); - catLabel.x = x + 20; - catLabel.y = y - 23; - this.container.addChild(catLabel); - textHeight += (catLabel.height - 23 + 2); - - if(text) { - var catText = new PIXI.Text(text, annotStyles.text); - catText.x = x + 20; - catText.y = y + 2; - this.container.addChild(catText); - textHeight += (catText.height + 2); + if (wait === 0){ + var graphics = new PIXI.Graphics() + .beginFill(colorHex) + .drawRect(x, y, 10, 3) + .endFill(); + + this.container.addChild(graphics); + + var textHeight = 0; + var catLabel = new PIXI.Text( + category, + _(annotStyles.label).extend({fill: color}).value() + ); + catLabel.x = x + 20; + catLabel.y = y - 23; + this.container.addChild(catLabel); + textHeight += (catLabel.height - 23 + 2); + + if(text) { + var catText = new PIXI.Text(text, annotStyles.text); + catText.x = x + 20; + catText.y = y; + this.container.addChild(catText); + textHeight += (catText.height + 2); + } + + var catUser = new PIXI.Text(user, annotStyles.user); + catUser.x = x + 20; + catUser.y = y + textHeight; + this.container.addChild(catUser); + textHeight += (catUser.height + 8); + + if (this.ignoreAnnots === true){ + wait = textHeight / this.pixelsPerSecond; + waitInterval = setInterval(function() {_this.refreshWait();}, 1000); + } } - var catUser = new PIXI.Text(user, annotStyles.user); - catUser.x = x + 20; - catUser.y = y + 2 + textHeight; - this.container.addChild(catUser); - this.addAnnotLine(colorHex, y); }; @@ -161,6 +172,14 @@ var diff = (this.startTs - Date.now())/1000; this.moveTo(diff); }; + + this.refreshWait = function(){ + wait -= 1; + if (wait < 0){ + wait = 0; + clearInterval(waitInterval); + } + }; this.removePassedObjets = function(){ var childrenToRemove = []; @@ -180,6 +199,7 @@ }); }; + this.start = function() { if(!started) {