JAL-244 JAL-4091 allow calculation of label id width off screen including sequence...
[jalview.git] / src / jalview / gui / AnnotationLabels.java
index d9d6b9f..a3f7e00 100755 (executable)
@@ -1211,7 +1211,7 @@ public class AnnotationLabels extends JPanel
         Graphics2D g2d = (Graphics2D) g;
         Graphics dummy = g2d.create();
         int newAnnotationIdWidth = drawLabels(dummy, clip, width, false, forGUI,
-                null);
+                null, false);
         dummy.dispose();
         Dimension d = ap.calculateDefaultAlignmentIdWidth();
         int alignmentIdWidth = d.width;
@@ -1245,10 +1245,10 @@ public class AnnotationLabels extends JPanel
     }
     else
     {
-      int newAnnotationIdWidth = drawLabels(g, clip, width, false, forGUI, null);
+      int newAnnotationIdWidth = drawLabels(g, clip, width, false, forGUI, null, false);
       width = Math.max(newAnnotationIdWidth, givenWidth);
     }
-    drawLabels(g, clip, width, true, forGUI, null);
+    drawLabels(g, clip, width, true, forGUI, null, false);
   }
 
   /**
@@ -1257,8 +1257,6 @@ public class AnnotationLabels extends JPanel
    * occur, but the widest label width will be returned. If g is null then
    * fmetrics must be supplied.
    * 
-   * Returns the width of the annotation labels.
-   * 
    * @param g
    *          Graphics2D instance (used for rendering and font scaling if no fmetrics supplied) 
    * @param clip
@@ -1270,9 +1268,11 @@ public class AnnotationLabels extends JPanel
    * @param forGUI - when false, GUI relevant marks like indicators for dragging annotation panel height are not rendered
    * @param fmetrics
    *          FontMetrics if Graphics object g is null
+   * @param includeHidden - when true returned width includes labels in hidden row width calculation 
+   * @return the width of the annotation labels.
    */
   public int drawLabels(Graphics g0, boolean clip, int width,
-          boolean actuallyDraw, boolean forGUI, FontMetrics fmetrics)
+          boolean actuallyDraw, boolean forGUI, FontMetrics fmetrics, boolean includeHidden)
   {
     if (clip)
     {
@@ -1361,7 +1361,7 @@ public class AnnotationLabels extends JPanel
       for (int i = 0; i < aa.length; i++)
       {
         visible = true;
-        if (!aa[i].visible)
+        if (!aa[i].visible && !includeHidden)
         {
           hasHiddenRows = true;
           continue;
@@ -1369,7 +1369,7 @@ public class AnnotationLabels extends JPanel
         olY = y;
         // look ahead to next annotation
         for (nexAA = i + 1; nexAA < aa.length
-                && !aa[nexAA].visible; nexAA++)
+                && (!aa[nexAA].visible && includeHidden); nexAA++)
           ;
         y += aa[i].height;
         if (clip)