From 9562de1d70ad57b4fa89e5ac627bebd5fb812011 Mon Sep 17 00:00:00 2001 From: turner Date: Thu, 5 Sep 2024 15:44:59 -0400 Subject: [PATCH] Bug fix: Save Image - GroupBy graphical elements now save properly --- dev/issues/git-1886.html | 74 ++++++++++++++++++++++++++++++++++++++++ js/bam/alignmentTrack.js | 9 ++--- js/trackViewport.js | 5 ++- 3 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 dev/issues/git-1886.html diff --git a/dev/issues/git-1886.html b/dev/issues/git-1886.html new file mode 100644 index 000000000..a72b1556c --- /dev/null +++ b/dev/issues/git-1886.html @@ -0,0 +1,74 @@ + + + + + + Git Issue - 1886 + + + +
+

Git Issue - 1886

+
+ +
+
+
+ + + + diff --git a/js/bam/alignmentTrack.js b/js/bam/alignmentTrack.js index 90ef28273..752d8eb5a 100644 --- a/js/bam/alignmentTrack.js +++ b/js/bam/alignmentTrack.js @@ -304,6 +304,7 @@ class AlignmentTrack extends TrackBase { if (this.groupBy && groupName) { ctx.save() + ctx.font = '400 12px sans-serif' const textMetrics = ctx.measureText(groupName) const w = textMetrics.width + 10 @@ -314,14 +315,10 @@ class AlignmentTrack extends TrackBase { ctx.textAlign = "center" ctx.fillStyle = 'white' ctx.strokeStyle = 'lightGray' - ctx.beginPath() - ctx.roundRect(x, baselineY - textMetrics.actualBoundingBoxAscent - 5, w, h, 2) - ctx.fill() - ctx.stroke() + IGVGraphics.roundRect(ctx, x, baselineY - textMetrics.actualBoundingBoxAscent - 5, w, h, 2, 1, 1) ctx.fillStyle = 'black' ctx.fillText(groupName, x + w / 2, baselineY) - IGVGraphics.dashedLine(ctx, 0, alignmentY, pixelWidth, alignmentY) ctx.restore() @@ -1229,7 +1226,7 @@ class AlignmentTrack extends TrackBase { const y = clickState.y const offsetY = y - this.top const genomicLocation = clickState.genomicLocation - + if(features.packedGroups) { let minGroupY = Number.MAX_VALUE for (let group of features.packedGroups.values()) { diff --git a/js/trackViewport.js b/js/trackViewport.js index 80b675a4e..9a0acd9c7 100644 --- a/js/trackViewport.js +++ b/js/trackViewport.js @@ -475,7 +475,8 @@ class TrackViewport extends Viewport { context.saveWithTranslationAndClipRect(id, x, y, width, height, yClipOffset) - let {start, bpPerPixel} = this.referenceFrame + const {start, bpPerPixel} = this.referenceFrame + const pixelXOffset = Math.round((start - this.referenceFrame.start) / bpPerPixel) const config = { @@ -486,6 +487,8 @@ class TrackViewport extends Viewport { pixelTop: yClipOffset, pixelWidth: width, pixelHeight: height, + pixelXOffset, + pixelShift: pixelXOffset, bpStart: start, bpEnd: start + (width * bpPerPixel), bpPerPixel,