JAL-4290 Fix image comparison between gui and headless output. Images are now the...
[jalview.git] / src / jalview / gui / AlignmentPanel.java
index d3f80ce..0f5a9e8 100644 (file)
@@ -42,6 +42,7 @@ import java.io.FileWriter;
 import java.io.PrintWriter;
 import java.util.List;
 
+import javax.swing.BoundedRangeModel;
 import javax.swing.SwingUtilities;
 
 import jalview.analysis.AnnotationSorter;
@@ -387,7 +388,10 @@ public class AlignmentPanel extends GAlignmentPanel implements
     // Also check annotation label widths
     if (includeAnnotations && al.getAlignmentAnnotation() != null)
     {
-      fm = c.getFontMetrics(getAlabels().getFont());
+      if (legacy)
+      {
+        fm = c.getFontMetrics(getAlabels().getFont());
+      }
 
       if (!legacy || Jalview.isHeadlessMode())
       {
@@ -789,6 +793,22 @@ public class AlignmentPanel extends GAlignmentPanel implements
   }
 
   /**
+   * Answers true if the panel has no horizontal scrollbar, or the scrollbar is
+   * at its rightmost position, else false.
+   * 
+   * @return
+   */
+  boolean isScrolledFullyRight()
+  {
+    if (hscroll == null)
+    {
+      return true;
+    }
+    BoundedRangeModel model = hscroll.getModel();
+    return (model.getExtent() + model.getValue() >= model.getMaximum());
+  }
+
+  /**
    * Respond to adjustment event when horizontal or vertical scrollbar is
    * changed
    * 
@@ -1283,8 +1303,9 @@ public class AlignmentPanel extends GAlignmentPanel implements
       return idwidth.intValue() + ID_WIDTH_PADDING;
     }
 
-    int w = getIdPanel().getWidth();
-    w = calculateIdWidth(-1, true, true).width;
+    // int w = getIdPanel().getWidth();
+    // w = calculateIdWidth(-1, true, true).width;
+    int w = calculateIdWidth(-1, true, true).width;
     return (w > 0 ? w : calculateIdWidth().width);
   }
 
@@ -1362,7 +1383,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
         // need to obtain default alignment width and then add in any
         // additional allowance for id margin
         // this duplicates the calculation in getWrappedHeight but adjusts for
-        // offscreen idWith
+        // offscreen idWidth
         width = alignFrame.getWidth() - vscroll.getPreferredSize().width
                 - alignFrame.getInsets().left - alignFrame.getInsets().right
                 - getVisibleIdWidth() + getVisibleIdWidth(false);