JAL-147 correct width out-by-one drawing ids
[jalview.git] / src / jalview / appletgui / IdCanvas.java
index 991f3ea..48c0c40 100755 (executable)
@@ -101,7 +101,7 @@ public class IdCanvas extends Panel implements ViewportListenerI
 
   public void fastPaint(int vertical)
   {
-    if (gg == null)
+    if (gg == null || av.getWrapAlignment())
     {
       repaint();
       return;
@@ -306,8 +306,7 @@ public class IdCanvas extends Panel implements ViewportListenerI
 
     int cHeight = alheight * avcharHeight + hgap + annotationHeight;
 
-    int rowSize = av.getRanges().getEndRes()
-            - av.getRanges().getStartRes();
+    int rowSize = av.getRanges().getViewportWidth();
 
     // hardwired italic IDs in applet currently
     Font italic = new Font(av.getFont().getName(), Font.ITALIC, av
@@ -318,8 +317,9 @@ public class IdCanvas extends Panel implements ViewportListenerI
      * draw repeating sequence ids until out of sequence data or
      * out of visible space, whichever comes first
      */
-    for (int ypos = hgap, row = av.getRanges().getStartRes(); (ypos <= getSize().height)
-            && (row < maxwidth); ypos += cHeight, row += rowSize)
+    int ypos = hgap;
+    int row = av.getRanges().getStartRes();
+    while ((ypos <= getHeight()) && (row < maxwidth))
     {
       for (int i = starty; i < alheight; i++)
       {
@@ -339,6 +339,8 @@ public class IdCanvas extends Panel implements ViewportListenerI
         labels.drawComponent(gg, getSize().width);
         gg.translate(0, -ypos - (alheight * avcharHeight));
       }
+      ypos += cHeight;
+      row += rowSize;
     }
   }