Skip to content

Commit

Permalink
Merge pull request #250 from AjitPS/201710_new_Lucene
Browse files Browse the repository at this point in the history
201710 new lucene
  • Loading branch information
AjitPS authored Feb 27, 2018
2 parents 5eedc86 + ca3bf01 commit ae1ebab
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
eles.layout(circleNetworkLayout); // run the Circle layout.
}

// Set Euler layout.
function setEulerLayout(eles) {
//console.log("setEulerLayout()>> animate_layout= "+ animate_layout);
eles.layout(eulerNetworkLayout)/*.run()*/; // run the Euler layout.
}

// Set Random layout.
function setRandomLayout(eles) {
//console.log("setRandomLayout()>> animate_layout= "+ animate_layout);
eles.layout(randomNetworkLayout)/*.run()*/; // run the Random layout.
}

// Set Concentric layout.
function setConcentricLayout(eles) {
//console.log("setConcentricLayout()>> animate_layout= "+ animate_layout);
Expand Down
124 changes: 37 additions & 87 deletions common/client/src/main/webapp/html/KnetMaps/javascript/knet-menu.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
function onHover(thisBtn) {
var img= $(thisBtn).attr('src');
var img= $(thisBtn).attr('src');
// $("#"+img).attr('src', 'image/'+img+'_hover.png');
$(thisBtn).attr('src', img.replace('.png','_hover.png'));
}

function offHover(thisBtn) {
var img= $(thisBtn).attr('src');
var img= $(thisBtn).attr('src');
// $("#"+img).attr('src', 'image/'+img+'.png');
$(thisBtn).attr('src', img.replace('_hover.png','.png'));
}

function popupItemInfo() {
function popupItemInfo() {
openItemInfoPane();
showItemInfo(this);
}

// Go to Help docs.
function openKnetHelpPage() {
var helpURL = 'https://github.com/Rothamsted/knetmaps.js/wiki/KnetMaps.js';
Expand All @@ -22,55 +23,13 @@ function popupItemInfo() {

// Reset: Re-position the network graph.
function resetGraph() {
//console.log("resetGraph...");
/*cy*/$('#cy').cytoscape('get').reset().fit(); // reset the graph's zooming & panning properties.
// /*cy*/$('#cy').cytoscape('get').fit();
$('#cy').cytoscape('get').reset().fit(); // reset the graph's zooming & panning properties.
}

// Open advanced KnetMaps (using Twitter Bootstrap) menu.

// Layouts dropdown: onChange
/*$("#layouts_dropdown").selectmenu({
change: function( event, data ) {
console.log("layouts_dropdown:"+ data.item.value);
rerunLayout();
}
});
// Label visibility dropdown: onChange
$("#changeLabelVisibility").selectmenu();
$("#changeLabelVisibility").on( "selectmenuchange", function( event, data ) {console.log("changeLabelVisibility:"+ data.item.value);
showHideLabels(this.value);} );
// Label font dropdown: onChange
$("#changeLabelFont").selectmenu({
change: function( event, data ) {
console.log("changeLabelFont:"+ data.item.value);
changeLabelFontSize(this.value);
}
});*/

// Search the graph for a concept using BFS: breadthfirst search
function findConcept(conceptName) {
console.log("Search for concept value: "+ conceptName);
var foundID;
var cy= $('#cy').cytoscape('get');
cy.nodes().forEach(function( ele ) {
if(ele.data('conceptDisplay') === 'element') {
if(ele.data('value').indexOf(conceptName) > -1) {
console.log("Search found: "+ ele.data('value'));
foundID= ele.id(); // the found node

// select the matched concept.
cy.$('#'+foundID).select();
}
}
});
}

// Export the graph as a JSON object in a new Tab and allow users to save it.
function exportAsJson() {
var cy= $('#cy').cytoscape('get'); // now we have a global reference to `cy`

var exportJson= cy.json(); // get JSON object for the network graph.

// Display in a new blank browser tab, e.g, window.open().document.write("text"); // for text data
Expand All @@ -86,21 +45,34 @@ function popupItemInfo() {
// Export the graph as a .png image and allow users to save it.
function exportAsImage() {
var cy= $('#cy').cytoscape('get'); // now we have a global reference to `cy`

// Export as .png image
var png64= cy.png(); // .setAttribute('crossOrigin', 'anonymous');

// Display the exported image in a new window.
window.open(png64,'Image','width=1200px,height=600px,resizable=1');
//window.open(png64, 'Image', 'width=1200px,height=600px,resizable=1'); // Blocked on some browsers

// use FileSaver.js to save using file downloader; fails (creates corrupted png)
/*cy_image= new Image();
cy_image.src=png64;
var canvas= document.getElementById('my-canvas'); // use canvas
context= canvas.getContext('2d');
context.drawImage(cy_image, 0,0); // draw image on canvas
cy_image.src= png64;
var knet_canvas= document.getElementById('cy'); // use canvas
knet_context= knet_canvas.getContext('2d');
knet_context.drawImage(cy_image, 0,0); // draw image on canvas
// convert canvas to Blob & save using FileSaver.js.
canvas.toBlob(function(blob) {
saveAs(blob, "kNetwork.png");
knet_canvas.toBlob(function(blob) {
saveAs(knet_blob, "kNetwork.png");
}, "image/png");*/

// Use IFrame to open png image in a new browser tab
var cy_width= $('#cy').width();
var cy_height= $('#cy').height();
var knet_iframe_style= "border:1px solid black; top:0px; left:0px; bottom:0px; right:0px; width:"+ cy_width +"; height:"+ cy_height +";";
var knet_iframe = '<iframe src="'+ png64 +'" frameborder="0" style="'+ knet_iframe_style +'" allowfullscreen></iframe>';
var pngTab= window.open();
pngTab.document.open();
pngTab.document.write(knet_iframe);
pngTab.document.title="kNet_png";
pngTab.document.close();
}

// Remove hidden effect from nodes/ edges, if hidden.
Expand Down Expand Up @@ -143,7 +115,7 @@ function popupItemInfo() {
var cy= $('#cy').cytoscape('get'); // now we have a global reference to `cy`
var selected_elements= cy.$(':visible'); // get only the visible elements.

// Re-run the graph's layout, but only on the visible elements.
// Re-run the graph's layout, but only on the visible elements.
rerunGraphLayout(selected_elements);

// Reset the graph/ viewport.
Expand All @@ -155,21 +127,27 @@ function popupItemInfo() {
// var ld= document.getElementById("layouts_dropdown");
var ld_selected= /*ld.options[ld.selectedIndex].value*/$('#layouts_dropdown').val();
//console.log("layouts_dropdown selectedOption: "+ ld_selected)
if(ld_selected === "Circle_layout") {
if(ld_selected === "circle_layout") {
setCircleLayout(eles);
}
else if(ld_selected === "Cose_layout") {
else if(ld_selected === "cose_layout") {
setCoseLayout(eles);
}
else if(ld_selected === "Cose_Bilkent_layout") {
else if(ld_selected === "coseBilkent_layout") {
setCoseBilkentLayout(eles);
}
else if(ld_selected === "Concentric_layout") {
else if(ld_selected === "concentric_layout") {
setConcentricLayout(eles);
}
else if(ld_selected === "ngraph_force_layout") {
setNgraphForceLayout(eles);
}
else if(ld_selected === "euler_layout") {
setEulerLayout(eles);
}
else if(ld_selected === "random_layout") {
setRandomLayout(eles);
}
//console.log("Re-run layout complete...");
}

Expand All @@ -186,34 +164,6 @@ function popupItemInfo() {
}
}

/*
// Show all node labels.
function showConceptLabels() {
var cy= $('#cy').cytoscape('get'); // reference to `cy`
if(document.getElementById("show_ConceptLabels").checked) {
console.log("Show Concept labels...");
cy.nodes().style({'text-opacity': '1'});
}
else {
console.log("Hide Concept labels...");
cy.nodes().style({'text-opacity': '0'});
}
}
// Show all edge labels.
function showRelationLabels() {
var cy= $('#cy').cytoscape('get'); // reference to `cy`
if(document.getElementById("show_RelationLabels").checked) {
console.log("Show Relation labels...");
cy.edges().style({'text-opacity': '1'});
}
else {
console.log("Hide Relation labels...");
cy.edges().style({'text-opacity': '0'});
}
}
*/

// Show/ Hide labels for concepts and relations.
function showHideLabels(val) {
//console.log("cy.hideLabelsOnViewport= "+ $('#cy').cytoscape('get').hideLabelsOnViewport);
Expand Down
10 changes: 6 additions & 4 deletions common/client/src/main/webapp/html/javascript/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -973,11 +973,13 @@ function populateKnetMenu() {
"<input type='image' id='openItemInfoBtn' src='html/KnetMaps/image/openItemInfoBtn.png' onclick='popupItemInfo();' title='Show Info box' onmouseover='onHover($(this));' onmouseout='offHover($(this));'>"+
"<span class='knet-dropdowns'>"+
"<select id='layouts_dropdown' class='knet-dropdowns' onChange='rerunLayout();' title='Select network layout'>"+
"<option value='Cose_layout' selected='selected' title='using CoSE layout algorithm (useful for larger networks with clustering)'>CoSE layout</option>"+
"<option value='cose_layout' selected='selected' title='using CoSE layout algorithm (useful for larger networks with clustering)'>CoSE layout</option>"+
"<option value='ngraph_force_layout' title='using ngraph_force layout (works well on planar graphs)'>Force layout</option>"+
"<option value='Circle_layout'>Circular layout</option>"+
"<option value='Concentric_layout'>Concentric layout</option>"+
"<option value='Cose_Bilkent_layout' title='using CoSE-Bilkent layout (with node clustering, but performance-intensive for larger networks)'>CoSE-Bilkent layout</option>"+
"<option value='circle_layout'>Circular layout</option>"+
"<option value='concentric_layout'>Concentric layout</option>"+
"<option value='coseBilkent_layout' title='using CoSE-Bilkent layout (with node clustering, but performance-intensive for larger networks)'>CoSE-Bilkent layout</option>"+
/* "<option value='euler_layout'>Euler layout</option>"+
"<option value='random_layout'>Random layout</option>"+*/
"</select>"+
"<select id='changeLabelVisibility' class='knet-dropdowns' onChange='showHideLabels(this.value);' title='Select label visibility'>"+
"<option value='None' selected='selected'>Labels: None</option>"+
Expand Down

0 comments on commit ae1ebab

Please sign in to comment.