JAL-244 JAL-4091 allow calculation of label id width off screen including sequence...
[jalview.git] / src / jalview / gui / AlignmentPanel.java
index 0442c8b..baf9e26 100644 (file)
@@ -302,7 +302,11 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
   /**
    * Calculate the width of the alignment labels based on the displayed names
-   * and any bounds on label width set in preferences.
+   * and any bounds on label width set in preferences. Also includes annotations
+   * not actually visible.
+   * 
+   * FIXME JAL-244 JAL-4091 - doesn't include sequence associated annotation
+   * label decorators and only called during tests
    * 
    * @param maxwidth
    *          -1 or maximum width allowed for IdWidth
@@ -313,7 +317,17 @@ public class AlignmentPanel extends GAlignmentPanel implements
   {
     return calculateIdWidth(maxwidth, true, false);
   }
-
+  /**
+   * Calculate the width of the alignment labels based on the displayed names
+   * and any bounds on label width set in preferences.
+   * 
+   * @param maxwidth
+   *          -1 or maximum width allowed for IdWidth
+   * @param includeAnnotations - when true includes width of any additional marks in annotation id panel 
+   * @param visibleOnly -  
+   * @return Dimension giving the maximum width of the alignment label panel
+   *         that should be used.
+   */
   public Dimension calculateIdWidth(int maxwidth,
           boolean includeAnnotations, boolean visibleOnly)
   {
@@ -340,8 +354,9 @@ public class AlignmentPanel extends GAlignmentPanel implements
     {
       if (Jalview.isHeadlessMode())
       {
-        AnnotationLabels aal = this.getAlabels();
-        int stringWidth = aal.drawLabels(null, false, idWidth, false, fm);
+        AnnotationLabels aal = getAlabels();
+        int stringWidth = aal.drawLabels(null, false, idWidth, false, false,
+                fm,false);
         idWidth = Math.max(idWidth, stringWidth);
       }
       else
@@ -566,7 +581,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     // this is called after loading new annotation onto alignment
     if (alignFrame.getHeight() == 0)
     {
-      System.out.println("NEEDS FIXING");
+      jalview.bin.Console.outPrintln("NEEDS FIXING");
     }
     validateAnnotationDimensions(true);
     addNotify();
@@ -997,7 +1012,15 @@ public class AlignmentPanel extends GAlignmentPanel implements
           Graphics idGraphics, Graphics alignmentGraphics)
           throws PrinterException
   {
-    final int idWidth = getVisibleIdWidth(false);
+    final int idWidth;
+    if (getIdPanel()!=null && getIdPanel().getWidth()>0)
+    {
+      // use the current IdPanel's width, if its set and non-zero
+      idWidth = getIdPanel().getWidth();
+    } else { 
+      // otherwise calculate it
+      idWidth = getVisibleIdWidth(false);
+    }
 
     /*
      * Get the horizontal offset to where we draw the sequences.
@@ -1064,7 +1087,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     List<SequenceI> selection = av.getSelectionGroup() == null ? null
             : av.getSelectionGroup().getSequences(null);
     idCanvas.drawIds((Graphics2D) idGraphics, av, startSeq, endSeq - 1,
-            selection);
+            selection, false);
 
     idGraphics.setFont(av.getFont());
     idGraphics.translate(0, -scaleHeight);
@@ -1088,7 +1111,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
       int offset = getAlabels().getScrollOffset();
       idGraphics.translate(0, -offset);
       idGraphics.translate(0, alignmentDrawnHeight);
-      getAlabels().drawComponent(idGraphics, idWidth);
+      getAlabels().drawComponentNotGUI(idGraphics, idWidth);
       idGraphics.translate(0, -alignmentDrawnHeight);
 
       /*
@@ -1169,7 +1192,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
      * draw sequence ids and annotation labels (if shown)
      */
     IdCanvas idCanvas = getIdPanel().getIdCanvas();
-    idCanvas.drawIdsWrapped((Graphics2D) g, av, 0, totalHeight);
+    idCanvas.drawIdsWrappedNoGUI((Graphics2D) g, av, 0, totalHeight);
 
     g.translate(idWidth, 0);
 
@@ -1229,7 +1252,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
           throws ImageOutputException
   {
     makeAlignmentImage(type, file, renderer,
-            BitmapImageSizing.nullBitmapImageSizing());
+            BitmapImageSizing.defaultBitmapImageSizing());
   }
 
   /**