From 5f01d4060ac01ebac24998f906e1e52959d568ec Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 16 Jun 2020 12:47:12 +0100 Subject: [PATCH] JAL-3446 defer size calculations until panel added to window --- src/jalview/gui/AlignmentPanel.java | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index cf45483..7758dae 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -602,18 +602,9 @@ public class AlignmentPanel extends GAlignmentPanel implements /** * update alignment layout for viewport settings - * - * @param wrap - * DOCUMENT ME! */ public void updateLayout() { - // BH 2020.06.09 avoid negative values for SequencePanel and SeqCanvas dimensions -// if (getTopLevelAncestor() == null) -// { -// return; -// } - ViewportRanges ranges = av.getRanges(); fontChanged(); setAnnotationVisible(av.isShowAnnotation()); @@ -632,9 +623,24 @@ public class AlignmentPanel extends GAlignmentPanel implements { annotationScroller.setVisible(true); annotationSpaceFillerHolder.setVisible(true); - validateAnnotationDimensions(false); } + idSpaceFillerPanel1.setVisible(!wrap); + + /* + * defer dimension calculations if panel not yet added to a Window + * BH 2020.06.09 + */ + if (getTopLevelAncestor() == null) + { + repaint(); + return; + } + + if (!wrap && av.isShowAnnotation()) + { + validateAnnotationDimensions(false); + } int canvasWidth = getSeqPanel().seqCanvas.getWidth(); if (canvasWidth > 0) { // may not yet be laid out @@ -655,12 +661,8 @@ public class AlignmentPanel extends GAlignmentPanel implements } } - idSpaceFillerPanel1.setVisible(!wrap); - // System.out.println("ap dim = " + getSize()); - // these values will go negative if getSize() returns (0,0): - // System.out.println("seqpan dim = " + getSeqPanel().getSize()); // System.out.println("seqcan dim = " + getSeqPanel().seqCanvas.getSize()); -- 1.7.10.2