Commit 4fba51e7 authored by Marc Duez's avatar Marc Duez
Browse files

model.js: store tag info to model.js

remove tag from global var
parent badc80b0
......@@ -188,7 +188,7 @@ Builder.prototype = {
//reset
listTag.innerHTML = "";
for (var i = 0; i < tag.length; i++) {
for (var i = 0; i < this.m.tag.length; i++) {
(function (i) {
var span3 = document.createElement('span');
span3.onclick = function (tag) {
......@@ -310,7 +310,7 @@ Builder.prototype = {
var input = document.createElement('input');
input.type = "text";
input.id = "new_tag_name";
input.value = tag[tagID].name;
input.value = this.m.tag[tagID].name;
input.style.width = "100px";
input.style.border = "0px";
input.style.margin = "0px";
......@@ -339,7 +339,7 @@ Builder.prototype = {
event.preventDefault()
var newTagName = document.getElementById("new_tag_name")
.value;
tag[tagID].name = newTagName
this.m.tag[tagID].name = newTagName
self.build_tagSelector()
self.build_displaySelector()
self.m.analysisHasChanged = true
......@@ -407,7 +407,7 @@ Builder.prototype = {
listGermline.innerHTML = "";
//init tag list
for (var i = 0; i < tag.length; i++) {
for (var i = 0; i < this.m.tag.length; i++) {
(function (i) {
var span3 = document.createElement('span');
span3.onclick = function (tag) {
......@@ -834,7 +834,7 @@ Builder.prototype = {
break;
case "Tag":
for (var i = 0; i < tag.length; i++) {
for (var i = 0; i < this.m.tag.length; i++) {
var spantag = document.createElement('span');
spantag.className = "tagColorBox tagColor" + i
spantag.id = "fastTag" + i
......@@ -865,17 +865,17 @@ Builder.prototype = {
},
initTag: function (){
for (var i =0; i<tag.length; i++){
$(".tagColor"+i).prop("title", tag[i].name);
$(".tagName"+i).html(tag[i].name);
for (var i =0; i<this.m.tag.length; i++){
$(".tagColor"+i).prop("title", this.m.tag[i].name);
$(".tagName"+i).html(this.m.tag[i].name);
}
this.updateTagBox();
},
updateTagBox: function(){
for (var i =0; i<tag.length; i++){
if (tag[i].display){
for (var i =0; i<this.m.tag.length; i++){
if (this.m.tag[i].display){
$(".tagColor"+i).removeClass("inactiveTag")
}else{
$(".tagColor"+i).addClass("inactiveTag")
......@@ -885,8 +885,8 @@ Builder.prototype = {
nextDisplayTag: function(elem){
var id_tag = elem.id.charAt( elem.id.length-1 )
var s = tag[id_tag].display;
tag[id_tag].display = !s;
var s = this.m.tag[id_tag].display;
this.m.tag[id_tag].display = !s;
this.m.update();
},
......
......@@ -372,12 +372,12 @@ Clone.prototype = {
if (this.tag) {
return this.tag;
} else {
return default_tag;
return this.m.default_tag;
}
},
getTagName: function () {
return tag[this.getTag()].name
return this.m.tag[this.getTag()].name
},
......@@ -393,10 +393,10 @@ Clone.prototype = {
if (size == 0){
this.color = "";
}else{
this.color = colorGenerator(this.m.scale_color(size * this.m.precision), color_s, color_v);
this.color = colorGenerator(this.m.scale_color(size * this.m.precision));
}
}else if (this.m.colorMethod == "Tag"){
this.color = tag[this.getTag()].color;
this.color = this.m.tag[this.getTag()].color;
}else if (this.m.colorMethod == "dbscan"){
this.color = this.colorDBSCAN;
}else if (this.m.colorMethod == "V" && this.getV() != "undefined V"){
......@@ -536,7 +536,7 @@ Clone.prototype = {
},
enable: function (top) {
if (this.top <= top && tag[this.getTag()].display && this.id != "other") {
if (this.top <= top && this.m.tag[this.getTag()].display && this.id != "other") {
this.active = true;
}
},
......
......@@ -185,15 +185,13 @@ Germline.prototype = {
var tmp = this.allele[key[i]];
this.allele[key[i]] = {};
this.allele[key[i]].seq = tmp;
this.allele[key[i]].color = colorGenerator((30 + (i / key.length) * 290),
color_s, color_v);
this.allele[key[i]].color = colorGenerator((30 + (i / key.length) * 290));
var elem = key[i].split('*')[0];
if (elem != elem2) {
this.gene[elem2] = {};
this.gene[elem2].n = n2;
this.gene[elem2].color = colorGenerator((30 + ((i - 1) / key.length) * 290),
color_s, color_v);
this.gene[elem2].color = colorGenerator((30 + ((i - 1) / key.length) * 290));
this.gene[elem2].rank = n;
n++;
n2 = 0;
......@@ -206,8 +204,7 @@ Germline.prototype = {
this.gene[elem2] = {};
this.gene[elem2].n = n2;
this.gene[elem2].rank = n
this.gene[elem2].color = colorGenerator((30 + ((i - 1) / key.length) * 290),
color_s, color_v);
this.gene[elem2].color = colorGenerator((30 + ((i - 1) / key.length) * 290));
}
return callback
......
......@@ -322,7 +322,7 @@ List.prototype = {
var path = document.createElementNS('http://www.w3.org/2000/svg', 'path')
path.setAttribute('d', this.starPath);
path.setAttribute('id', 'color' + cloneID);
path.setAttribute("fill", tag[this.m.clone(cloneID).getTag()].color);
path.setAttribute("fill", this.m.tag[this.m.clone(cloneID).getTag()].color);
svg.appendChild(path);
span_star.appendChild(svg)
......
......@@ -16,7 +16,7 @@ var segment = new Segment("bot-container",m);
var builder = new Builder(m);
var pdf = new PDF(m, "visu2_svg")
var report = new Report()
var report = new Report(m)
var db = new Database("plop!", m);
......
......@@ -64,6 +64,12 @@ function initMenu () {
}
}
function changeStyle(newStyle){
if (newStyle=="solarizeD") document.getElementById("palette").href="css/dark.css";
if (newStyle=="solarizeL") document.getElementById("palette").href="css/light.css";
m.update()
}
function loadData() {
myConsole.closePopupMsg()
......
......@@ -98,7 +98,6 @@ Model.prototype = {
this.nbr = 0;
this.nodes = null;
this.edges = null;
this.cluster_key = ""
//segmented status
......@@ -117,9 +116,25 @@ Model.prototype = {
"= SEG, but no window",
];
this.tag = [
{"color" : "#dc322f", "name" : "clone 1", "display" : true},
{"color" : "#cb4b16", "name" : "clone 2", "display" : true},
{"color" : "#b58900", "name" : "clone 3", "display" : true},
{"color" : "#268bd2", "name" : "standard", "display" : true},
{"color" : "#6c71c4", "name" : "standard (noise)", "display" : true},
{"color" : "#2aa198", "name" : "custom 1", "display" : true},
{"color" : "#d33682", "name" : "custom 2", "display" : true},
{"color" : "#859900", "name" : "custom 3", "display" : true},
{"color" : "", "name" : "-/-", "display" : true}
]
this.default_tag=8;
},
start: function() {
var self = this;
var dataURL = ""
......@@ -475,11 +490,11 @@ Model.prototype = {
var keys = Object.keys(s.names);
for (var i=0; i<keys.length; i++){
tag[parseInt(keys[i])].name = s.names[keys[i]]
this.tag[parseInt(keys[i])].name = s.names[keys[i]]
}
for (var i=0; i<s.hide.length; i++){
tag[s.hide[i]].display = false;
this.tag[s.hide[i]].display = false;
}
}
......@@ -544,7 +559,7 @@ Model.prototype = {
// COLOR_N
for (var i = 0; i < this.clones.length; i++) {
var clone = this.clone(i)
clone.colorN = colorGenerator((((clone.getNlength() / n_max) - 1) * (-250)), color_s, color_v);
clone.colorN = colorGenerator((((clone.getNlength() / n_max) - 1) * (-250)));
}
this.applyAnalysis(this.analysis);
......@@ -559,7 +574,7 @@ Model.prototype = {
for (key in this.data){
if (this.data[key].length == this.samples.number){
this.data_info[key] = {
"color" : tag[i].color,
"color" : this.tag[i].color,
"isActive" : false
}
i++
......@@ -741,9 +756,9 @@ Model.prototype = {
//tags
analysisData.tags.names = {}
analysisData.tags.hide = []
for (var i=0; i<tag.length; i++){
analysisData.tags.names[""+i] = tag[i].name
if (!tag[i].display) analysisData.tags.hide.push(i)
for (var i=0; i<this.tag.length; i++){
analysisData.tags.names[""+i] = this.tag[i].name
if (!this.tag[i].display) analysisData.tags.hide.push(i)
}
......@@ -2027,7 +2042,7 @@ Model.prototype = {
var maxCluster = this.dbscan.clusters.length;
for (var i = 0; i < this.clones.length; i++) {
if (typeof(this.clone(i)) != 'undefined') {
this.clone(i).colorDBSCAN = colorGenerator( ( (270 / maxCluster) * (this.tabRandomColor[this.clone(i)] + 1) ), color_s, color_v);
this.clone(i).colorDBSCAN = colorGenerator( ( (270 / maxCluster) * (this.tabRandomColor[this.clone(i)] + 1) ));
}
else
this.clone(i).colorDBSCAN = "";
......
......@@ -190,7 +190,7 @@ PDF.prototype = {
//clones style
for (var i = 0; i < this.m.clones.length; i++) {
var polyline = elem.querySelectorAll('[id="polyline'+i+'"]')[0]
var color = tag[this.m.clone(i).getTag()].color
var color = this.m.tag[this.m.clone(i).getTag()].color
if (polyline.getAttribute("d").indexOf("Z") != -1){
polyline.setAttribute("style", "stroke-width:0px");
......@@ -208,7 +208,7 @@ PDF.prototype = {
//selected clones style
for (var i = 0; i < this.list.length; i++) {
var polyline = elem.querySelectorAll('[id="polyline'+this.list[i]+'"]')[0]
var color = tag[this.m.clone(this.list[i]).getTag()].color
var color = this.m.tag[this.m.clone(this.list[i]).getTag()].color
polyline.setAttribute("stroke", color);
polyline.setAttribute("style", "stroke-width: "+opt.strokeSize+"px");
......@@ -345,7 +345,7 @@ PDF.prototype = {
info_clone: function (cloneID) {
this.checkPage(20)
var color = tag[this.m.clone(cloneID).getTag()].color
var color = this.m.tag[this.m.clone(cloneID).getTag()].color
this.icon(cloneID, this.marge, this.y - 6, 18, 8)
......@@ -472,7 +472,7 @@ PDF.prototype = {
icon: function (cloneID, x, y, w, h) {
var color = tag[m.clone(cloneID).tag].color
var color = this.m.tag[m.clone(cloneID).tag].color
var polyline = document.getElementById("polyline" + cloneID)
.cloneNode(true);
......
......@@ -521,7 +521,7 @@ ScatterPlot.prototype = {
//If the link's length is lower than distanceMax, color the link
if (this.edge[i].len <= this.distanceMax)
//colorGenerator usage for color red (0) to blue (270), by gap: 270/distanceMax
this.edge[i].color = colorGenerator((270 / this.distanceMax) * this.edge[i].len, color_s, color_v);
this.edge[i].color = colorGenerator((270 / this.distanceMax) * this.edge[i].len);
//If the link is not interesting, we attribute the white color (usefull for the activeAllLine() function)
else this.edge[i].color = "white";
}
......
......@@ -421,7 +421,7 @@ Segment.prototype = {
var path = document.createElementNS('http://www.w3.org/2000/svg', 'path')
path.setAttribute('d', this.starPath);
path.setAttribute('id', 'color' + cloneID);
if (typeof this.m.clone(cloneID).tag != 'undefined') path.setAttribute("fill", tag[this.m.clone(cloneID).tag].color);
if (typeof this.m.clone(cloneID).tag != 'undefined') path.setAttribute("fill", this.m.tag[this.m.clone(cloneID).tag].color);
else path.setAttribute("fill", "");
svg_star.appendChild(path);
......
......@@ -21,26 +21,11 @@
* along with "Vidjil". If not, see <http://www.gnu.org/licenses/>
*/
var color_s = 0.8; //pureté
var color_v = 0.72; //brightness
tag = [
{"color" : "#dc322f", "name" : "clone 1", "display" : true},
{"color" : "#cb4b16", "name" : "clone 2", "display" : true},
{"color" : "#b58900", "name" : "clone 3", "display" : true},
{"color" : "#268bd2", "name" : "standard", "display" : true},
{"color" : "#6c71c4", "name" : "standard (noise)", "display" : true},
{"color" : "#2aa198", "name" : "custom 1", "display" : true},
{"color" : "#d33682", "name" : "custom 2", "display" : true},
{"color" : "#859900", "name" : "custom 3", "display" : true},
{"color" : "", "name" : "-/-", "display" : true}
]
var default_tag=8;
/*ressort une couleur format RGB*/
function colorGenerator(h,s,v){
s = typeof s !== 'undefined' ? s : 0.8
v = typeof v !== 'undefined' ? v : 0.72
h=h/60;
var i=Math.floor(h);
var f=h-i;
......@@ -69,11 +54,5 @@ var default_tag=8;
}
}
function changeStyle(newStyle){
if (newStyle=="solarizeD") document.getElementById("palette").href="css/dark.css";
if (newStyle=="solarizeL") document.getElementById("palette").href="css/light.css";
m.update()
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment