JAL-2491 Scrolling and interaction with overview/find working in desktop
authorkiramt <k.mourao@dundee.ac.uk>
Fri, 5 May 2017 10:59:58 +0000 (11:59 +0100)
committerkiramt <k.mourao@dundee.ac.uk>
Fri, 5 May 2017 10:59:58 +0000 (11:59 +0100)
src/jalview/gui/AlignmentPanel.java

index 8695583..795146d 100644 (file)
@@ -48,6 +48,8 @@ import java.awt.Graphics;
 import java.awt.Insets;
 import java.awt.event.AdjustmentEvent;
 import java.awt.event.AdjustmentListener;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
 import java.awt.print.PageFormat;
 import java.awt.print.Printable;
 import java.awt.print.PrinterException;
@@ -142,6 +144,28 @@ public class AlignmentPanel extends GAlignmentPanel implements
     hscroll.addAdjustmentListener(this);
     vscroll.addAdjustmentListener(this);
 
+    addComponentListener(new ComponentAdapter()
+    {
+      @Override
+      public void componentResized(ComponentEvent evt)
+      {
+        // reset the viewport ranges when the alignment panel is resized
+        // in particular, this initialises the end residue value when Jalview
+        // is initialised
+        int widthInRes = (getSeqPanel().seqCanvas.getWidth() / av
+                .getCharWidth()) - 1;
+        int currentStartRes = vpRanges.getStartRes();
+        if (av.getWrapAlignment())
+        {
+          widthInRes = getSeqPanel().seqCanvas
+                  .getWrappedCanvasWidth(getSeqPanel().seqCanvas.getWidth());
+        }
+
+        vpRanges.setStartEndRes(currentStartRes, widthInRes);
+      }
+
+    });
+
     final AlignmentPanel ap = this;
     propertyChangeListener = new PropertyChangeListener()
     {