From bfc58576f8b1bc505fbd27e5b573f26acd0f75b8 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Wed, 7 Feb 2024 17:05:45 +0000 Subject: [PATCH] JAL-4375 Pass through a flag to AnnotationRenderer.drawComponent(...) so it knows when a full width render is required, adjusting the g2dCopy.setClip(...) width accordingly --- src/jalview/gui/AlignmentPanel.java | 2 +- src/jalview/renderer/AnnotationRenderer.java | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 0f5a9e8..29b2203 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -1182,7 +1182,7 @@ public class AlignmentPanel extends GAlignmentPanel implements alignmentDrawnHeight); updateLayout(); getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av, - alignmentGraphics, -1, startRes, endRes + 1); + alignmentGraphics, -1, startRes, endRes + 1, true); } return Printable.PAGE_EXISTS; diff --git a/src/jalview/renderer/AnnotationRenderer.java b/src/jalview/renderer/AnnotationRenderer.java index 0da5603..2856868 100644 --- a/src/jalview/renderer/AnnotationRenderer.java +++ b/src/jalview/renderer/AnnotationRenderer.java @@ -525,6 +525,14 @@ public class AnnotationRenderer AlignViewportI av, Graphics g, int activeRow, int startRes, int endRes) { + return drawComponent(annotPanel, av, g, activeRow, startRes, endRes, + false); + } + + public boolean drawComponent(AwtRenderPanelI annotPanel, + AlignViewportI av, Graphics g, int activeRow, int startRes, + int endRes, boolean forExport) + { if (g instanceof EpsGraphics2D || g instanceof SVGGraphics2D) { this.setVectorRendering(true); @@ -780,7 +788,13 @@ public class AnnotationRenderer // This removes artifacts from text when side scrolling // (particularly in wrap format), but can result in clipped // characters until a full paint is drawn. - g2dCopy.setClip(0, (int) yPos - charHeight, imgWidth - 1, + // If we're in an image export, set the clip width to be the + // entire width of the annotation. + + int clipWidth = forExport + ? row_annotations.length * charWidth - 1 + : imgWidth - 1; + g2dCopy.setClip(0, (int) yPos - charHeight, clipWidth, charHeight); /* * translate to drawing position _before_ applying any scaling -- 1.7.10.2