separated alignment annotation height calculation from panel height adjustment
[jalview.git] / src / jalview / gui / AnnotationPanel.java
index 01c933a..8a93f79 100755 (executable)
@@ -132,6 +132,24 @@ public class AnnotationPanel extends JPanel implements MouseListener,
    */
   public int adjustPanelHeight()
   {
+    int height=calcPanelHeight();
+    this.setPreferredSize(new Dimension(1, height));
+    if (ap != null)
+    {
+      // revalidate only when the alignment panel is fully constructed
+      ap.validate();
+    }
+
+    return height;
+  }
+
+  /**
+   * calculate the height for visible annotation, revalidating bounds where necessary
+   * ABSTRACT GUI METHOD
+   * @return total height of annotation
+   */
+  public int calcPanelHeight()
+  {
     // setHeight of panels
     AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
     int height = 0;
@@ -180,14 +198,6 @@ public class AnnotationPanel extends JPanel implements MouseListener,
       // set minimum
       height = 20;
     }
-
-    this.setPreferredSize(new Dimension(1, height));
-    if (ap != null)
-    {
-      // revalidate only when the alignment panel is fully constructed
-      ap.validate();
-    }
-
     return height;
   }