JAL-3253 AlignmentPanel opaque white may provide white earlier?
[jalview.git] / src / jalview / gui / AlignmentPanel.java
index f27b9b7..fa30e09 100644 (file)
@@ -23,6 +23,7 @@ package jalview.gui;
 import jalview.analysis.AnnotationSorter;
 import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
+import jalview.api.SequenceRenderer;
 import jalview.bin.Cache;
 import jalview.bin.Jalview;
 import jalview.datamodel.AlignmentI;
@@ -117,7 +118,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
    */
   public AlignmentPanel(AlignFrame af, final AlignViewport av)
   {
-//     setBackground(Color.white);  // BH 2019
+    setBackground(Color.white); // BH 2019
+    setOpaque(true);
     alignFrame = af;
     this.av = av;
     setSeqPanel(new SeqPanel(av, this));
@@ -543,6 +545,15 @@ public class AlignmentPanel extends GAlignmentPanel implements
    */
   protected void validateAnnotationDimensions(boolean adjustPanelHeight)
   {
+    // BH 2018.04.18 comment: addNotify() is not appropriate here. We
+    // are not changing ancestors, and keyboard action listeners do
+    // not need to be reset. addNotify() is a very expensive operation,
+    // requiring a full re-layout of all parents and children.
+    // Note in JComponent:
+    // This method is called by the toolkit internally and should
+    // not be called directly by programs.
+    // I note that addNotify() is called in several areas of Jalview.
+
     int annotationHeight = getAnnotationPanel().adjustPanelHeight();
     annotationHeight = getAnnotationPanel()
             .adjustForAlignFrame(adjustPanelHeight, annotationHeight);
@@ -554,6 +565,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     Dimension e = idPanel.getSize();
     alabels.setSize(new Dimension(e.width, annotationHeight));
 
+
     annotationSpaceFillerHolder.setPreferredSize(new Dimension(
             annotationSpaceFillerHolder.getWidth(), annotationHeight));
     annotationScroller.validate();
@@ -731,7 +743,6 @@ public class AlignmentPanel extends GAlignmentPanel implements
       }
       ranges.setViewportStartAndHeight(y, height);
     }
-    seqPanel.seqCanvas.clearFastPaint();
     repaint();
   }
 
@@ -1139,13 +1150,13 @@ public class AlignmentPanel extends GAlignmentPanel implements
   public int getVisibleIdWidth(boolean onscreen)
   {
     // see if rendering offscreen - check preferences and calc width accordingly
-    if (!onscreen && Cache.getDefault("FIGURE_AUTOIDWIDTH", false))
+    if (!onscreen && Cache.getDefault(Preferences.FIGURE_AUTOIDWIDTH, false))
     {
       return calculateIdWidth(-1).width + 4;
     }
     Integer idwidth = null;
     if (onscreen || (idwidth = Cache
-            .getIntegerProperty("FIGURE_FIXEDIDWIDTH")) == null)
+            .getIntegerProperty(Preferences.FIGURE_FIXEDIDWIDTH)) == null)
     {
       int w = getIdPanel().getWidth();
       return (w > 0 ? w : calculateIdWidth().width + 4);
@@ -1367,8 +1378,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
   {
     int seqPanelWidth = getSeqPanel().seqCanvas.getWidth();
 
-    if (System.getProperty("java.awt.headless") != null
-            && System.getProperty("java.awt.headless").equals("true"))
+    if (Jalview.isHeadlessMode())
     {
       seqPanelWidth = alignFrame.getWidth() - getVisibleIdWidth()
               - vscroll.getPreferredSize().width
@@ -1714,4 +1724,10 @@ public class AlignmentPanel extends GAlignmentPanel implements
     return calculationDialog;
   }
 
+  @Override
+  public SequenceRenderer getSequenceRenderer()
+  {
+    return seqPanel.seqCanvas.getSequenceRenderer();
+  }
+
 }