JAL-4375 Pass through a flag to AnnotationRenderer.drawComponent(...) so it knows...
authorBen Soares <b.soares@dundee.ac.uk>
Wed, 7 Feb 2024 17:05:45 +0000 (17:05 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Wed, 7 Feb 2024 17:05:45 +0000 (17:05 +0000)
src/jalview/gui/AlignmentPanel.java
src/jalview/renderer/AnnotationRenderer.java

index 0f5a9e8..29b2203 100644 (file)
@@ -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;
index 0da5603..2856868 100644 (file)
@@ -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