JAL-2337 fix: only adjust once for scroll offset bug/JAL-2277_refactorPrintUnwrapped
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 22 Nov 2016 16:41:36 +0000 (16:41 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 22 Nov 2016 16:41:36 +0000 (16:41 +0000)
src/jalview/gui/AlignmentPanel.java

index 6554655..921429b 100644 (file)
@@ -1062,7 +1062,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
             + 3;
 
     /*
-     * draw the Scale at horizontal offset, then reset to origin
+     * draw the Scale at horizontal offset, then reset to top left (0, 0)
      */
     alignmentGraphics.translate(alignmentGraphicsOffset, 0);
     getScalePanel().drawScale(alignmentGraphics, startRes, endRes,
@@ -1071,7 +1071,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
     /*
      * Draw the sequence ids, offset for scale height,
-     * then reset to origin
+     * then reset to top left (0, 0)
      */
     idGraphics.translate(0, scaleHeight);
     idGraphics.setFont(getIdPanel().getIdCanvas().getIdfont());
@@ -1122,7 +1122,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
     /*
      * draw the sequences, offset for scale height, and id width (if using a
-     * single graphics context), then reset to origin + scale height
+     * single graphics context), then reset to (0, scale height)
      */
     alignmentGraphics.translate(alignmentGraphicsOffset, scaleHeight);
     getSeqPanel().seqCanvas.drawPanel(alignmentGraphics, startRes, endRes,
@@ -1132,16 +1132,19 @@ public class AlignmentPanel extends GAlignmentPanel implements
     if (av.isShowAnnotation() && (endSeq == alignmentHeight))
     {
       /*
-       * draw annotation labels, offset for current scroll position
-       * then reset to origin + scale height
+       * draw annotation labels; drawComponent() translates by
+       * getScrollOffset(), so compensate for that first;
+       * then reset to (0, scale height)
        */
-      int offset = -getAlabels().getScrollOffset();
-      idGraphics.translate(0, offset + alignmentDrawnHeight);
+      int offset = getAlabels().getScrollOffset();
+      idGraphics.translate(0, -offset);
+      idGraphics.translate(0, alignmentDrawnHeight);
       getAlabels().drawComponent(idGraphics, idWidth);
-      idGraphics.translate(0, -offset - alignmentDrawnHeight);
+      idGraphics.translate(0, -alignmentDrawnHeight);
 
       /*
-       * draw the annotations
+       * draw the annotations starting at 
+       * (idOffset, alignmentHeight) from (0, scaleHeight)
        */
       alignmentGraphics.translate(alignmentGraphicsOffset, alignmentDrawnHeight);
       getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av,