JAL-2600 updates following review
[jalview.git] / src / jalview / gui / IdCanvas.java
index cfbc403..4642741 100755 (executable)
@@ -153,7 +153,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI
    * @param vertical
    *          DOCUMENT ME!
    */
-  public void fastPaint(int vertical, boolean isresize)
+  public void fastPaint(int vertical)
   {
     if (gg == null)
     {
@@ -171,37 +171,26 @@ public class IdCanvas extends JPanel implements ViewportListenerI
     int es = ranges.getEndSeq();
     int transY = 0;
 
-    if (isresize)
+    if (vertical > 0) // scroll down
     {
-      if (vertical != 0)
+      ss = es - vertical;
+
+      if (ss < ranges.getStartSeq())
+      { // ie scrolling too fast, more than a page at a time
+        ss = ranges.getStartSeq();
+      }
+      else
       {
         transY = imgHeight - ((vertical + 1) * av.getCharHeight());
-        ss = es - vertical - ss;
       }
     }
-    else
+    else if (vertical < 0) // scroll up
     {
-      if (vertical > 0) // scroll down
-      {
-        ss = es - vertical;
+      es = ss - vertical;
 
-        if (ss < ranges.getStartSeq())
-        { // ie scrolling too fast, more than a page at a time
-          ss = ranges.getStartSeq();
-        }
-        else
-        {
-          transY = imgHeight - ((vertical + 1) * av.getCharHeight());
-        }
-      }
-      else if (vertical < 0) // scroll up
+      if (es > ranges.getEndSeq())
       {
-        es = ss - vertical;
-
-        if (es > ranges.getEndSeq())
-        {
-          es = ranges.getEndSeq();
-        }
+        es = ranges.getEndSeq();
       }
     }
 
@@ -535,13 +524,14 @@ public class IdCanvas extends JPanel implements ViewportListenerI
   public void propertyChange(PropertyChangeEvent evt)
   {
     // Respond to viewport range changes (e.g. alignment panel was scrolled)
-    if (evt.getPropertyName().equals("startseq"))
-    {
-      fastPaint((int) evt.getNewValue() - (int) evt.getOldValue(), false);
-    }
-    else if (evt.getPropertyName().equals("endseq"))
+    // Both scrolling and resizing change viewport ranges: scrolling changes
+    // both start and end points, but resize only changes end values.
+    // Here we only want to fastpaint on a scroll, with resize using a normal
+    // paint, so scroll events are identified as changes to the horizontal or
+    // vertical start value.
+    if (evt.getPropertyName().equals(ViewportRanges.STARTSEQ))
     {
-      fastPaint((int) evt.getNewValue() - (int) evt.getOldValue(), true);
+      fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
     }
   }
 }