Skip to content

Commit 1824b80

Browse files
authored
Merge pull request #355 from SynBioDex/fix-image-export-of-plasmid-edges
Exported images of plasmids fix
2 parents 8e452c6 + 863cd66 commit 1824b80

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

SBOLCanvasFrontend/src/app/graph-helpers.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,22 @@ export class GraphHelpers extends GraphBase {
18911891
return false
18921892
}
18931893

1894+
/**
1895+
* Returns true if there is a Chromosomal Locus or Circular Backbone
1896+
* in the current graph view
1897+
*/
1898+
protected atLeastOneCircularOrChromosomalInGraph() {
1899+
let allGraphCells = this.graph.getDefaultParent().children
1900+
if (allGraphCells != null) {
1901+
for (let i = 0; i < allGraphCells.length; i++) {
1902+
if (allGraphCells[i].hasCircularBackbone() || allGraphCells[i].hasChromosomalLocus()) {
1903+
return true
1904+
}
1905+
}
1906+
}
1907+
return false
1908+
}
1909+
18941910
/**
18951911
* Made specifically for undo, since it does not affect glyph info.
18961912
* Removes "Circular" from the "otherTypes" property of Circuit Containers.

SBOLCanvasFrontend/src/app/graph.service.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,12 @@ export class GraphService extends GraphHelpers {
15261526
var bounds = this.graph.getGraphBounds()
15271527
var vs = this.graph.view.scale
15281528

1529+
// To prevent the plasmid edges from being cut off in exported images
1530+
if(this.atLeastOneCircularOrChromosomalInGraph()){
1531+
bounds.x -= 50
1532+
bounds.width += 100
1533+
}
1534+
15291535
// Prepares SVG document that holds the output
15301536
var svgDoc = mx.mxUtils.createXmlDocument()
15311537
var root = (svgDoc.createElementNS != null) ?
@@ -1580,6 +1586,12 @@ export class GraphService extends GraphHelpers {
15801586
let bounds = this.graph.getGraphBounds()
15811587
let vs = this.graph.view.scale
15821588

1589+
// To prevent the plasmid edges from being cut off in exported images
1590+
if(this.atLeastOneCircularOrChromosomalInGraph()){
1591+
bounds.x -= 50
1592+
bounds.width += 100
1593+
}
1594+
15831595
let xmlDoc = mx.mxUtils.createXmlDocument()
15841596
let root = xmlDoc.createElement('output')
15851597
xmlDoc.appendChild(root)

0 commit comments

Comments
 (0)