Skip to content

Commit

Permalink
Merge pull request #251 from Rothamsted/201710_new_Lucene
Browse files Browse the repository at this point in the history
201710 new lucene
  • Loading branch information
AjitPS authored Mar 7, 2018
2 parents 16ffed0 + ae1ebab commit 70be47d
Show file tree
Hide file tree
Showing 21 changed files with 781 additions and 189 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ stdout.log
*swp
.vagrant/
common/client/nb-configuration.xml
*.oxl
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//var data_url = "https://ondex.rothamsted.ac.uk/arabidopsis_data/";
var data_url = "http://knetminer.rothamsted.ac.uk/arabidopsis_data/";
//var data_url = "http://qtlnetminer-test.rothamsted.ac.uk/arabidopsis_data/"; // now, using HTTP instead of HTTPS
//var data_url = "http://maize-dev.rothamsted.ac.uk/arabidopsis_data/"; // test on maize-dev
//var applet_url = "https://ondex.rothamsted.ac.uk/OndexWebBeta/";
//var data_url = "http://qtlnetminer-test.rothamsted.ac.uk/arabidopsis_data/"; // test
//var data_url = "http://maize-dev.rothamsted.ac.uk/arabidopsis_data/"; // test
var species = "Arabidopsis Genome";
var reference_genome = true; //true if you are providing a reference genome
var multiorganisms = false; //true if you specified more than one taxid in the server file config.xml (ie: <entry key="SpeciesTaxId">4113,4081</entry>)
Expand Down
1 change: 1 addition & 0 deletions common/client/src/main/webapp/WEB-INF/tags/layout/page.tag
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0/jquery.qtip.min.js"></script>
<script src="html/KnetMaps/libs/cytoscape-qtip.js"></script>
<script src="html/KnetMaps/libs/jquery.maskloader.js"></script>
<script src="html/KnetMaps/libs/FileSaver.min.js"></script>
<!-- Layouts -->
<script src="html/KnetMaps/libs/cose_bilkent/cytoscape-cose-bilkent.js"></script>
<script src="html/KnetMaps/libs/ngraph_forceLayout/cytoscape-ngraph.forcelayout.js"></script>
Expand Down
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
136 changes: 49 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,73 +23,56 @@ 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.
// window.open().document.write(exportJson); // for text data
window.open('data:application/json;' + (window.btoa?'base64,'+btoa(JSON.stringify(exportJson)):JSON.stringify(exportJson))); // for JSON data
// Display in a new blank browser tab, e.g, window.open().document.write("text"); // for text data
// window.open('data:application/json;' + (window.btoa?'base64,'+btoa(JSON.stringify(exportJson)):JSON.stringify(exportJson))); // for JSON data

/* TO DO: use FileSaverJS to open directly open file downloader & write to local file. */
//
// use FileSaver.js to save using file downloader
// var kNet_json_Blob= new Blob([JSON.stringify(exportJson)], {type: "text/plain;charset=utf-8"});
// saveAs(kNet_json_Blob, "kNetwork.cyjs.json");
var kNet_json= new File([JSON.stringify(exportJson)], "kNetwork.cyjs.json", {type: "text/plain;charset=utf-8"});
saveAs(kNet_json);
}

// 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 blank browser window instead of having it in the same window.
window.open(png64,'Image','width=1200px,height=600px,resizable=1');
// Display the exported image in a new window.
//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 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.
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 @@ -131,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 @@ -143,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 @@ -174,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
Loading

0 comments on commit 70be47d

Please sign in to comment.