X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignmentPanel.java;h=31277319d6333abfe6c5be9e65270eb2f8942a8c;hb=ca160187a050f6d4e50158cd5b51f75c83a7179e;hp=cd9b70c557679450a27181768026e69b961bdca2;hpb=7050afe69de0bcfb55cdd28c913fd75357148cd0;p=jalview.git diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index cd9b70c..3127731 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -317,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) { @@ -342,29 +352,10 @@ public class AlignmentPanel extends GAlignmentPanel implements // Also check annotation label widths if (includeAnnotations && al.getAlignmentAnnotation() != null) { - if (Jalview.isHeadlessMode()) - { - AnnotationLabels aal = getAlabels(); - int stringWidth = aal.drawLabels(null, false, idWidth, false, false, - fm); - idWidth = Math.max(idWidth, stringWidth); - } - else - { - fm = c.getFontMetrics(getAlabels().getFont()); - - for (i = 0; i < al.getAlignmentAnnotation().length; i++) - { - AlignmentAnnotation aa = al.getAlignmentAnnotation()[i]; - if (visibleOnly && !aa.visible) - { - continue; - } - String label = aa.label; - int stringWidth = fm.stringWidth(label); - idWidth = Math.max(idWidth, stringWidth); - } - } + AnnotationLabels aal = getAlabels(); + int stringWidth = aal.drawLabels(null, false, idWidth, false, false, + fm, !visibleOnly); + idWidth = Math.max(idWidth, stringWidth); } int w = maxwidth < 0 ? idWidth : Math.min(maxwidth, idWidth); @@ -1002,16 +993,16 @@ public class AlignmentPanel extends GAlignmentPanel implements Graphics idGraphics, Graphics alignmentGraphics) throws PrinterException { - 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); - } - + final int idWidth, idWidthForGui; + // otherwise calculate it + idWidth = getVisibleIdWidth(false); +// if (getIdPanel()!=null && getIdPanel().getWidth()>0) +// { +// // use the current IdPanel's width, if its set and non-zero +// idWidthForGui = getIdPanel().getWidth(); +// } else { +// idWidthForGui=0; +// } /* * Get the horizontal offset to where we draw the sequences. * This is idWidth if using a single Graphics context, else zero. @@ -1060,6 +1051,9 @@ public class AlignmentPanel extends GAlignmentPanel implements } final int alignmentDrawnHeight = (endSeq - startSeq) * charHeight + 3; + alignmentGraphics.setColor(Color.white); + alignmentGraphics.fillRect(0, 0, pageWidth, pageHeight+scaleHeight); + /* * draw the Scale at horizontal offset, then reset to top left (0, 0) */ @@ -1076,8 +1070,9 @@ public class AlignmentPanel extends GAlignmentPanel implements IdCanvas idCanvas = getIdPanel().getIdCanvas(); List selection = av.getSelectionGroup() == null ? null : av.getSelectionGroup().getSequences(null); + idCanvas.drawIds((Graphics2D) idGraphics, av, startSeq, endSeq - 1, - selection, false); + selection, false,idWidth); idGraphics.setFont(av.getFont()); idGraphics.translate(0, -scaleHeight); @@ -1224,7 +1219,7 @@ public class AlignmentPanel extends GAlignmentPanel implements // see if rendering offscreen - check preferences and calc width accordingly if (!onscreen && Cache.getDefault("FIGURE_AUTOIDWIDTH", false)) { - return calculateIdWidth(-1).width; + return calculateIdWidth(-1,true,true).width; } Integer idwidth = onscreen ? null : Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH");