JAL-3493 fix patch for 2.11.1_js (nb - these changes should not be merged to 2.11.2!)
[jalview.git] / src / jalview / gui / AlignmentPanel.java
index b57bc08..277e11d 100644 (file)
@@ -123,6 +123,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
    */
   public AlignmentPanel(AlignFrame af, final AlignViewport av)
   {
+    setName("AligmentPanel");
     // setBackground(Color.white); // BH 2019
     alignFrame = af;
     this.av = av;
@@ -601,19 +602,9 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
   /**
    * update alignment layout for viewport settings
-   * 
-   * @param wrap
-   *          DOCUMENT ME!
    */
   public void updateLayout()
   {
-    // BH 2020.06.09 avoiding negative values for SequencePanel and SeqCanvas
-    // dimensions.
-    
-     if (getTopLevelAncestor() == null)
-     return;
-
-    
     ViewportRanges ranges = av.getRanges();
     fontChanged();
     setAnnotationVisible(av.isShowAnnotation());
@@ -632,9 +623,24 @@ public class AlignmentPanel extends GAlignmentPanel implements
     {
       annotationScroller.setVisible(true);
       annotationSpaceFillerHolder.setVisible(true);
-      validateAnnotationDimensions(false);
     }
 
+    idSpaceFillerPanel1.setVisible(!wrap);
+
+    /*
+     * defer dimension calculations if panel not yet added to a Window
+     * BH 2020.06.09
+     */
+    if (getTopLevelAncestor() == null)
+    {
+      repaint();
+      return;
+    }
+
+    if (!wrap && av.isShowAnnotation())
+    {
+      validateAnnotationDimensions(false);
+    }
     int canvasWidth = getSeqPanel().seqCanvas.getWidth();
     if (canvasWidth > 0)
     { // may not yet be laid out
@@ -655,16 +661,12 @@ public class AlignmentPanel extends GAlignmentPanel implements
       }
     }
 
-    idSpaceFillerPanel1.setVisible(!wrap);
-
     // System.out.println("ap dim = " + getSize());
-
     // these values will go negative if getSize() returns (0,0):
-
     // System.out.println("seqpan dim = " + getSeqPanel().getSize());
     // System.out.println("seqcan dim = " + getSeqPanel().seqCanvas.getSize());
 
-    // BH not added to anything yet! repaint();
+    repaint();
   }
 
   /**
@@ -860,12 +862,12 @@ public class AlignmentPanel extends GAlignmentPanel implements
     if (updateOverview)
     {
       alignFrame.repaint();
-
       if (overviewPanel != null)
       {
         overviewPanel.updateOverviewImage();
       }
     } else {
+      invalidate(); // needed so that the id width adjuster works correctly
       repaint();
     }
   }
@@ -873,6 +875,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
   @Override
   public void paintComponent(Graphics g)
   {
+    // BH OUCH!
     invalidate(); // needed so that the id width adjuster works correctly
 
     Dimension d = getIdPanel().getIdCanvas().getPreferredSize();
@@ -1939,7 +1942,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     }
     av.setSelectionGroup(null);
     av.getColumnSelection().clear();
-    av.setSelectionGroup(null);
+    av.setSearchResults(null);
     getIdPanel().getIdCanvas().searchResults = null;
     av.sendSelection();
     // JAL-2034 - should delegate to