Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabil Alikhan authored and Nabil Alikhan committed Jul 4, 2017
2 parents 30f0cf5 + 0e5112a commit 425b8d0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
1 change: 1 addition & 0 deletions MSTree_holder.html
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ <h3 id="headertag" style="font-family: times, serif; font-size:12pt; font-style:
if (the_tree) {
the_tree.svg.remove();
the_tree.legend_div[0].remove();
resetGridColumns();
}
$("#waiting-information").text("Loading Data");
the_tree = null;
Expand Down
2 changes: 1 addition & 1 deletion grapetree/templates/MSTree_launch.html
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@ <h3 id="headertag" style="font-family: times, serif; font-size:12pt; font-style:
var item = the_tree.metadata[id];
var barcode = Enterobase.encodeBarcode(id,db_code);
lines.push(barcode+"\t"+item["Name"]);

}
var text= lines.join("\n");
Enterobase.showSaveDialog(text,"tree.json");
Expand Down Expand Up @@ -833,6 +832,7 @@ <h3 id="headertag" style="font-family: times, serif; font-size:12pt; font-style:
if (the_tree) {
the_tree.svg.remove();
the_tree.legend_div[0].remove();
resetGridColumns();
}
$("#waiting-information").text("Loading Data");
the_tree = null;
Expand Down
4 changes: 2 additions & 2 deletions static/js/tree/base_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1234,8 +1234,8 @@ D3BaseTree.prototype.updateLegend = function(title, ordered_groups){
legend.selectAll('.legend-title').remove();
legend.append('text').attr('class', 'legend-title').attr('x', 22).attr('y', 20).attr('font-weight', 'bold').text(title);
var legend_dim = legend_svg[0][0].getBBox();
legend_svg.attr('width', 180).attr('height', legend_dim.height + 10);
this.legend_div.width(180);
legend_svg.attr('width', 220).attr('height', legend_dim.height + 10);
this.legend_div.width(220);
var l_height = $("#legend-svg").height();
var height = l_height+10;
this.legend_div.css({"top":"0px","right":"0px","max-height":height+"px"});
Expand Down
5 changes: 3 additions & 2 deletions static/js/tree/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,14 @@ $("#collapse_node").click(function(e) {
for (var id in selected_nodes) {
var node_id = selected_nodes[id].id;
for (var jd in the_tree.hypo_record[node_id]) {
the_tree.manual_collapsing[jd] = 1;
the_tree.manual_collapsing[jd] = 2;
}
}
$( "#spinner-collapse-nodes" ).trigger("change");
});
$("#uncollapse_all").click(function(e) {
the_tree.manual_collapsing = {};
$( "#spinner-collapse-nodes" ).val(0);
$( "#spinner-collapse-nodes" ).trigger("change");
});

Expand All @@ -258,7 +259,7 @@ $("#uncollapse_node").click(function(e) {
for (var id in selected_nodes) {
var node_id = selected_nodes[id].id;
for (var jd in the_tree.hypo_record[node_id]) {
delete the_tree.manual_collapsing[jd];
the_tree.manual_collapsing[jd] = 1;
}
}
$( "#spinner-collapse-nodes" ).trigger("change");
Expand Down
23 changes: 17 additions & 6 deletions static/js/tree/d3_m_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,13 @@ D3MSTree.prototype._collapseNodes=function(max_distance,layout){
}
}
}

if (max_distance > this.node_collapsed_value) {
for(var id in this.manual_collapsing) {
if (this.manual_collapsing[id] == 1) {
delete this.manual_collapsing[id];
}
}
}
if (max_distance<=this.node_collapsed_value || (! this.force_nodes) || this.force_nodes.length == 0){

this.clearSelection();
Expand All @@ -513,16 +519,18 @@ D3MSTree.prototype._collapseNodes=function(max_distance,layout){
this.manual_collapsing_value = Object.keys(this.manual_collapsing).length;
if (this.manual_collapsing_value > 0) {
for (var id in this.manual_collapsing) {
to_collapse[id] = 1;
to_collapse[id] = this.manual_collapsing[id];
}

var collapsed = 1;
while (collapsed) {
collapsed = 0;
for(var jd in this.force_links) {
var link = this.force_links[jd];
if (to_collapse[link.source.id] && ! to_collapse[link.target.id]) {
to_collapse[link.target.id] = 1;
var s_c = to_collapse[link.source.id] ? to_collapse[link.source.id] : 0;
var t_c = to_collapse[link.target.id] ? to_collapse[link.target.id] : 0;
if (s_c > t_c) {
to_collapse[link.target.id] = s_c;
collapsed = 1;
}
}
Expand All @@ -533,6 +541,7 @@ D3MSTree.prototype._collapseNodes=function(max_distance,layout){
var link = this.force_links[index];
link.target.link = link;
}
/*
this.force_links.sort(function(l1, l2) {return l1.value - l2.value;});
var link_len = [];
for (var index in this.force_links) {
Expand All @@ -558,8 +567,10 @@ D3MSTree.prototype._collapseNodes=function(max_distance,layout){
}
}
}
}
if (!l || (l.value > max_distance && ! to_collapse[l.source.id])) continue;
}*/
for (var index=this.force_links.length-1; index >=0; index --) {
var l = this.force_links[index];
if ( !l || (l.value > max_distance && to_collapse[l.source.id] !== 2) || (l.value > 1e-8 && to_collapse[l.source.id] === 1) ) continue;
l.remove=l.target.remove=true;
this.grouped_nodes[l.source.id]=this.grouped_nodes[l.source.id].concat(this.grouped_nodes[l.target.id]);

Expand Down
3 changes: 3 additions & 0 deletions static/js/tree/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@
$("#replace-div").toggle(150).css("top",yy).css("left",xx).css("position","fixed").show();
});

function resetGridColumns() {
grid.setColumns(default_columns);
};

function updateMetadataTable(select_moveUp) {
if (! the_tree) {
Expand Down

0 comments on commit 425b8d0

Please sign in to comment.