ensure annotation height adjuster doesn't disappear off top of screen on
authorjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 29 Jun 2011 16:51:15 +0000 (17:51 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 29 Jun 2011 16:51:15 +0000 (17:51 +0100)
resize, and fixed some bugs with height calculation for annotation panel
JAL-564

src/jalview/appletgui/AlignmentPanel.java

index 9bb3e4d..60e8cb1 100644 (file)
@@ -105,6 +105,9 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
       public void componentResized(ComponentEvent evt)
       {
         setScrollValues(av.getStartRes(), av.getStartSeq());
+        if (getSize().height>0 && annotationPanelHolder.getSize().height>0) {
+          validateAnnotationDimensions(false);
+        }
         repaint();
       }
       
@@ -419,7 +422,6 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
     apvscroll.addNotify();
     hscroll.addNotify();
     validate();
-    addNotify();
     repaint();
   }
   /**
@@ -427,34 +429,45 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
    * need to do repaints/notifys afterwards. 
    */
   protected void validateAnnotationDimensions(boolean adjustPanelHeight) {
+    boolean modified=false;
     int height = annotationPanel.calcPanelHeight();
+    int minsize=0;
     if (hscroll.isVisible())
     {
-      height += hscroll.getPreferredSize().height;
+      height += (minsize=hscroll.getPreferredSize().height);
+    }
+    if (apvscroll.isVisible()) {
+      minsize+=apvscroll.getPreferredSize().height;
     }
     int mheight = height;
+    Dimension d=sequenceHolderPanel.getSize(),e=idPanel.getSize(); 
+    int seqandannot=d.height-scalePanelHolder.getSize().height;
     // sets initial preferred height
-    if ((height+40) > getSize().height / 2)
+    if ((height+40) > seqandannot / 2)
     {
-      height = getSize().height / 2;
+      height = seqandannot / 2;
     }
     if (!adjustPanelHeight)
     {
       // maintain same window layout whilst updating sliders
-      height=seqPanelHolder.getSize().height;
+      height=annotationPanelHolder.getSize().height;
+    }
+            
+    if (seqandannot-height<5)
+    {
+      height = seqandannot;
     }
-    Dimension d=seqPanelHolder.getSize(),e=idPanel.getSize(); 
     annotationPanel.setSize(new Dimension(d.width,height));
-    alabels.setSize(e.width,height);
+    alabels.setSize(new Dimension(e.width,height));
     annotationSpaceFillerHolder.setSize(new Dimension(e.width, height));
     annotationPanelHolder.setSize(new Dimension(d.width, height));
-    seqPanelHolder.setSize(d.width,d.height-height);
+    seqPanelHolder.setSize(d.width,seqandannot-height);
     int s=apvscroll.getValue();
     if (s>mheight-height)
     {
       s = 0;
     }
-    apvscroll.setValues(apvscroll.getValue(), height, 0, mheight);
+    apvscroll.setValues(s, height, 0, mheight);
     annotationPanel.setScrollOffset(apvscroll.getValue());
     alabels.setScrollOffset(apvscroll.getValue());
   }