Skip to content

Commit

Permalink
Merge pull request #355 from SynBioDex/fix-image-export-of-plasmid-edges
Browse files Browse the repository at this point in the history
Exported images of plasmids fix
  • Loading branch information
cjmyers authored Nov 21, 2024
2 parents 8e452c6 + 863cd66 commit 1824b80
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions SBOLCanvasFrontend/src/app/graph-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,22 @@ export class GraphHelpers extends GraphBase {
return false
}

/**
* Returns true if there is a Chromosomal Locus or Circular Backbone
* in the current graph view
*/
protected atLeastOneCircularOrChromosomalInGraph() {
let allGraphCells = this.graph.getDefaultParent().children
if (allGraphCells != null) {
for (let i = 0; i < allGraphCells.length; i++) {
if (allGraphCells[i].hasCircularBackbone() || allGraphCells[i].hasChromosomalLocus()) {
return true
}
}
}
return false
}

/**
* Made specifically for undo, since it does not affect glyph info.
* Removes "Circular" from the "otherTypes" property of Circuit Containers.
Expand Down
12 changes: 12 additions & 0 deletions SBOLCanvasFrontend/src/app/graph.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,12 @@ export class GraphService extends GraphHelpers {
var bounds = this.graph.getGraphBounds()
var vs = this.graph.view.scale

// To prevent the plasmid edges from being cut off in exported images
if(this.atLeastOneCircularOrChromosomalInGraph()){
bounds.x -= 50
bounds.width += 100
}

// Prepares SVG document that holds the output
var svgDoc = mx.mxUtils.createXmlDocument()
var root = (svgDoc.createElementNS != null) ?
Expand Down Expand Up @@ -1580,6 +1586,12 @@ export class GraphService extends GraphHelpers {
let bounds = this.graph.getGraphBounds()
let vs = this.graph.view.scale

// To prevent the plasmid edges from being cut off in exported images
if(this.atLeastOneCircularOrChromosomalInGraph()){
bounds.x -= 50
bounds.width += 100
}

let xmlDoc = mx.mxUtils.createXmlDocument()
let root = xmlDoc.createElement('output')
xmlDoc.appendChild(root)
Expand Down

0 comments on commit 1824b80

Please sign in to comment.