Skip to content

Commit

Permalink
Fix issue:iVis-at-Bilkent/software-artifact-analyzer #50 : png full m…
Browse files Browse the repository at this point in the history
…ethod added
  • Loading branch information
LaraMerdol committed Jan 8, 2024
1 parent 06a9fb9 commit e13d077
Show file tree
Hide file tree
Showing 7 changed files with 1,456 additions and 544 deletions.
2 changes: 2 additions & 0 deletions demo/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ <h2 class="accordion-header" id="panelsStayOpen-headingOne">
Save
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
<li><a class="dropdown-item" href="#" onclick="exportPng()">PNG</a></li>
<li><a class="dropdown-item" href="#" onclick="exportPngAll()">PNG (all)</a></li>
<li><a class="dropdown-item" href="#" onclick="exportJson()">JSON</a></li>
<li><a class="dropdown-item" href="#" onclick="exportGraphml()">GraphML</a></li>
<li><a class="dropdown-item" href="#" onclick="exportSif()">SIF</a></li>
Expand Down
39 changes: 39 additions & 0 deletions demo/file-operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,45 @@ function exportJson() {
str2file(JSON.stringify(elements, undefined, 4), 'sample-graph.json');
}

function exportPng() {
const options = { bg: 'white', scale: 3, full: false };
let base64png;
base64png = cy.pngFull(options);
base64png.then((result) => {
fetch(result)
.then(res => res.blob())
.then(x => {
const anchor = document.createElement('a');
anchor.download = 'sample.png';
anchor.href = (window.URL).createObjectURL(x);
anchor.click();
return x;
})
}).catch((error) => {
console.error(error); // Handle errors
});
}

function exportPngAll() {
const options = { bg: 'white', scale: 3, full: true };
let base64png;
base64png = cy.pngFull(options);
base64png.then((result) => {
fetch(result)
.then(res => res.blob())
.then(x => {
const anchor = document.createElement('a');
anchor.download = 'sample.png';
anchor.href = (window.URL).createObjectURL(x);
anchor.click();
return x;
})
}).catch((error) => {
console.error(error); // Handle errors
});
}


function exportGraphml() {
str2file(cy.graphml(), 'sample-graph.graphml');
}
Expand Down
Loading

0 comments on commit e13d077

Please sign in to comment.