/**
* Calculates the width of the alignment labels based on the displayed names
- * and any bounds on label width set in preferences. The calculated width is
- * also set as a property of the viewport.
+ * and any bounds on label width set in preferences.
+ *
+ * The calculated width is set as a property of the viewport and the layout is
+ * updated.
*
* @return Dimension giving the maximum width of the alignment label panel
* that should be used.
public Dimension calculateDefaultAlignmentIdWidth()
{
+ return calculateIdWidth(-1, false, false);
+ }
+ /**
+ * pre 2.11.3 Id width calculation - used when importing old projects only
+ * @return
+ */
+ public int getLegacyIdWidth()
+ {
int afwidth = (alignFrame != null ? alignFrame.getWidth() : 300);
int idWidth = Math.min(afwidth - 200, 2 * afwidth / 3);
int maxwidth = Math.max(IdwidthAdjuster.MIN_ID_WIDTH, idWidth);
- return calculateIdWidth(-1, false, false);
+ Dimension w = calculateIdWidthOrLegacy(true, maxwidth, false, false);
+ return w.width;
}
/**
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, annotation label widths are also accounted for
+ * @param visibleOnly - when true, ignore label widths for hidden annotation rows
+ * @return Dimension giving the maximum width of the alignment label panel
+ * that should be used.
+ */
public Dimension calculateIdWidth(int maxwidth,
boolean includeAnnotations, boolean visibleOnly)
{
+ return calculateIdWidthOrLegacy(false, maxwidth, includeAnnotations, visibleOnly);
+ }
+
+ /**
+ * legacy mode or post 2.11.3 ID width calculation
+ * @param legacy - uses annotation labels, not rendered label width (excludes additional decorators)
+ * @param maxwidth
+ * @param includeAnnotations
+ * @param visibleOnly
+ * @return
+ */
+ private Dimension calculateIdWidthOrLegacy(boolean legacy, int maxwidth,
+ boolean includeAnnotations, boolean visibleOnly)
+ {
Container c = new Container();
FontMetrics fm = c.getFontMetrics(
// Also check annotation label widths
if (includeAnnotations && al.getAlignmentAnnotation() != null)
{
- if (Jalview.isHeadlessMode())
+ fm = c.getFontMetrics(getAlabels().getFont());
+
+ if (!legacy || Jalview.isHeadlessMode())
{
AnnotationLabels aal = getAlabels();
int stringWidth = aal.drawLabels(null, false, idWidth, false, false, fm);
}
else
{
- fm = c.getFontMetrics(getAlabels().getFont());
-
for (i = 0; i < al.getAlignmentAnnotation().length; i++)
{
AlignmentAnnotation aa = al.getAlignmentAnnotation()[i];
// this is called after loading new annotation onto alignment
if (alignFrame.getHeight() == 0)
{
- jalview.bin.Console.outPrintln("NEEDS FIXING");
+ jalview.bin.Console.error("adjustAnnotationHeight called with zero height alignment window");
}
validateAnnotationDimensions(true);
addNotify();
Dimension e = idPanel.getSize();
int idWidth = e.width;
boolean manuallyAdjusted = this.getIdPanel().getIdCanvas()
- .manuallyAdjusted();
+ .isManuallyAdjusted();
annotationScroller.setPreferredSize(new Dimension(
manuallyAdjusted ? idWidth : annotationScroller.getWidth(),
annotationHeight));
}
int w = getIdPanel().getWidth();
- w = this.calculateIdWidth(-1, true, true).width;
+ w = calculateIdWidth(-1, true, true).width;
return (w > 0 ? w : calculateIdWidth().width);
}
overviewPanel = null;
}
}
-
}