javadoc and constraint to ensure annotation labels are not wider than alignment frame
[jalview.git] / src / jalview / gui / AlignmentPanel.java
index 326ac07..95b4220 100755 (executable)
@@ -154,9 +154,9 @@ public class AlignmentPanel
   }
 
   /**
-   * DOCUMENT ME!
+   * Calculate the width of the alignment labels based on the displayed names and any bounds on label width set in preferences.
    *
-   * @return DOCUMENT ME!
+   * @return Dimension giving the maximum width of the alignment label panel that should be used.
    */
   public Dimension calculateIdWidth()
   {
@@ -166,7 +166,8 @@ public class AlignmentPanel
         new Font(av.font.getName(), Font.ITALIC, av.font.getSize()));
 
     AlignmentI al = av.getAlignment();
-
+    int afwidth = (alignFrame!=null ? alignFrame.getWidth() : 300); 
+    int maxwidth = Math.max(20,Math.min(afwidth-200,(int) 2*afwidth/3));  
     int i = 0;
     int idWidth = 0;
     String id;
@@ -205,7 +206,7 @@ public class AlignmentPanel
       }
     }
 
-    return new Dimension(idWidth, 12);
+    return new Dimension(Math.min(maxwidth, idWidth), 12);
   }
 
   /**