JAL-3368 JAL-2365 JAL-2642
[jalview.git] / src / jalview / gui / SeqCanvas.java
index 536bfef..5165aea 100755 (executable)
@@ -75,7 +75,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
 
   private final SequenceRenderer seqRdr;
 
-  boolean fastPaint = false;
+  private boolean fastPaint = false;
 
   private boolean fastpainting = false;
 
@@ -371,7 +371,10 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
   @Override
   public void paintComponent(Graphics g)
   {
-
+    if (av.getAlignPanel().getHoldRepaint())
+    {
+      return;
+    }
     int charHeight = av.getCharHeight();
     int charWidth = av.getCharWidth();
 
@@ -381,8 +384,6 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
     availWidth -= (availWidth % charWidth);
     availHeight -= (availHeight % charHeight);
 
-    // BH 2019 can't possibly fastPaint if either width or height is 0
-
     if (availWidth == 0 || availHeight == 0)
     {
       return;
@@ -394,28 +395,6 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
     int endRes = ranges.getEndRes();
     int endSeq = ranges.getEndSeq();
 
-    // [JAL-3226] problem that JavaScript (or Java) may consolidate multiple
-    // repaint() requests in unpredictable ways. In this case, the issue was
-    // that in response to a CTRL-C/CTRL-V paste request, in Java a fast
-    // repaint request preceded two full requests, thus resulting
-    // in a full request for paint. In constrast, in JavaScript, the three
-    // requests were bundled together into one, so the fastPaint flag was
-    // still present for the second and third request.
-    //
-    // This resulted in incomplete painting.
-    //
-    // The solution was to set seqCanvas.fastPaint and idCanvas.fastPaint false
-    // in PaintRefresher when the target to be painted is one of those two
-    // components.
-    //
-    // BH 2019.04.22
-    //
-    // An initial idea; can be removed once we determine this issue is closed:
-    // if (av.isFastPaintDisabled())
-    // {
-    // fastPaint = false;
-    // }
-
     Rectangle vis, clip;
     if (img != null
             && (fastPaint
@@ -523,16 +502,16 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
 
   /**
    * Using the current font, determine fields labelWidthEast and labelWidthWest,
-   * and return the number of residues that can fill the remaining width.
+   * and return the number of residues that can fill the remaining width
    * 
-   * @param width
+   * @param w
    *          the width in pixels (possibly including scales)
    * 
    * @return the visible width in residues, after allowing for East or West
    *         scales (if shown)
    * 
    */
-  public int getWrappedCanvasWidth(int width)
+  public int getWrappedCanvasWidth(int w)
   {
     int charWidth = av.getCharWidth();
 
@@ -546,7 +525,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
 
     labelWidthWest = av.getScaleLeftWrapped() ? labelWidth : 0;
 
-    return (width - labelWidthEast - labelWidthWest) / charWidth;
+    return (w - labelWidthEast - labelWidthWest) / charWidth;
   }
 
   /**
@@ -1706,11 +1685,6 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
       // typically scroll, but possibly just the end changed
       fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue());
       return;
-    case ViewportRanges.ENDRES:
-    case ViewportRanges.ENDSEQ:
-      // meaning second event along with "START" -- ENDONLY,NOTSTART
-      // TODO: ignore??
-      return;
     case ViewportRanges.STARTRES:
       // meaning STARTOREND
       scrollX = (int) evt.getNewValue() - (int) evt.getOldValue();
@@ -1731,6 +1705,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
 
       }
       break;
+    default:
+      return;
     }
 
     ViewportRanges vpRanges = av.getRanges();
@@ -2244,4 +2220,13 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
     return labelWidthWest;
   }
 
+  /**
+   * Clears the flag that allows a 'fast paint' on the next repaint, so
+   * requiring a full repaint
+   */
+  public void setNoFastPaint()
+  {
+    fastPaint = false;
+  }
+
 }