From 24eb9d2701c4f51c1a3a8ce9536ed579988f0179 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Tue, 25 Jul 2023 09:18:47 +0100 Subject: [PATCH] JAL-244 testing without AlignFrame for --wrap --- src/jalview/gui/AnnotationLabels.java | 58 ++++++++++++++------------ test/files/annotation_label_width/sample.a2m | 30 ++++++------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 26276ae..afee3d0 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -1195,35 +1195,39 @@ public class AnnotationLabels extends JPanel public void drawComponent(Graphics g, boolean clip, int givenWidth) { int width = givenWidth; - IdwidthAdjuster iwa = ap.idwidthAdjuster; - if ((Cache.getDefault(ADJUST_ANNOTATION_LABELS_WIDTH_PREF, true) - || Jalview.isHeadlessMode())) + IdwidthAdjuster iwa = null; + if (ap != null) { - Graphics2D g2d = (Graphics2D) g; - Graphics dummy = g2d.create(); - int newAnnotationIdWidth = drawLabels(dummy, clip, width, false, - null); - Dimension d = ap.calculateDefaultAlignmentIdWidth(); - int alignmentIdWidth = d.width; - if (!iwa.manuallyAdjusted()) + iwa = ap.idwidthAdjuster; + if ((Cache.getDefault(ADJUST_ANNOTATION_LABELS_WIDTH_PREF, true) + || Jalview.isHeadlessMode())) { - // If no manual adjustment to ID column with has been made then adjust - // width match widest of alignment or annotation id widths - width = Math.max(alignmentIdWidth, newAnnotationIdWidth); - } - else if (newAnnotationIdWidth != annotationIdWidth - && newAnnotationIdWidth > givenWidth - && newAnnotationIdWidth > alignmentIdWidth) - { - // otherwise if the annotation id width has become larger than the - // current id width, increase - width = newAnnotationIdWidth; - annotationIdWidth = newAnnotationIdWidth; - } - // set the width if it's changed - if (width != ap.av.getIdWidth()) - { - iwa.setWidth(width); + Graphics2D g2d = (Graphics2D) g; + Graphics dummy = g2d.create(); + int newAnnotationIdWidth = drawLabels(dummy, clip, width, false, + null); + Dimension d = ap.calculateDefaultAlignmentIdWidth(); + int alignmentIdWidth = d.width; + if (iwa != null && !iwa.manuallyAdjusted()) + { + // If no manual adjustment to ID column with has been made then adjust + // width match widest of alignment or annotation id widths + width = Math.max(alignmentIdWidth, newAnnotationIdWidth); + } + else if (newAnnotationIdWidth != annotationIdWidth + && newAnnotationIdWidth > givenWidth + && newAnnotationIdWidth > alignmentIdWidth) + { + // otherwise if the annotation id width has become larger than the + // current id width, increase + width = newAnnotationIdWidth; + annotationIdWidth = newAnnotationIdWidth; + } + // set the width if it's changed + if (width != ap.av.getIdWidth()) + { + iwa.setWidth(width); + } } } drawLabels(g, clip, width, true, null); diff --git a/test/files/annotation_label_width/sample.a2m b/test/files/annotation_label_width/sample.a2m index 664868e..0ca6801 100644 --- a/test/files/annotation_label_width/sample.a2m +++ b/test/files/annotation_label_width/sample.a2m @@ -3,77 +3,77 @@ P.I...A..Q..I.....H.....I........L.......E........G.......R.......S....D.......E T..LI....RE...V.S.E...A...I......S.......R...S.......L........D....A.....P......L................... ..........T......S.......V.......R......V...I....I.......T......E.....M........A....K.........G..... .H..........F..........G........I..........G........G......E........L....A...SK ->UPI 38 0.235 1.216E+00 0 57 59 69 136 151 +>UPI P.Hye.V..S..V.....T.....M........P.......T........G.......Wl......N....T.......V.......R.....K....Q. G..MI....DA...V.T.R...A...L......L.......E...A.......I........A....T.....P......F................... ..........D......Essrfr..V.......R......C...L....I.......P......E.....I........P....D.........G..... .N..........W..........G........S..........G........Gya....L........P....L...S- ->SRR 56 0.275 5.500E-07 0 58 59 66 134 140 +>SRR P.H...V..A..V.....K.....L........Y.......P........G.......R.......T....E.......Q.......Q.....K....E. Q..LA....RA...I.A.D...D...V......M.......R...I.......L........G....S.....S......E................... ..........A......S.......V.......S......V...S....I.......E......E.....V........D....A.........A..... .D..........W..........A........EkvyrplivegG........G......T........L....Y...KK ->SRR 56 0.260 5.500E-07 0 58 59 99 167 172 +>SRR P.H...V..I..V.....K.....L........W.......P........G.......R.......S....E.......P.......Q.....K....Q. K..LV....ES...V.T.K...A...V......T.......T...S.......L........G....Y.....S......D................... ..........E......A.......V.......S......V...S....L.......Q......E.....V........P....S.........D..... .Q..........WtekvyrpdilG........T..........A........G......R........L....Y...KK ->MGY 52 0.227 1.338E-05 0 58 59 1 79 191 +>MGY P.I...V..R..I.....T.....M........F.......E........G.......R.......T....K.......E.......Q.....K....Q. E..LA....RV...I.T.E...A...V......V.......N...I.......A........K....T.....T......P................... ..........D......A.......T.......E......VkdqI....L.......Q......K.....VllvrslrlP....PppasrrqvsG..... .A..........W..........S........A..........D........G......K........P....T...SE ->446 51 0.202 2.534E-05 0 58 59 41 109 115 +>446 P.H...V..I..V.....K.....L........W.......P........G.......K.......S....E.......R.......E.....E....T. Q..LA....EA...I.T.K...S...V......T.......E...T.......L........N....F.....G......P................... ..........E......S.......V.......S......V...A....F.......E......E.....I........P....A.........K..... .D..........W..........AskvyhadiI..........Gne......G......K........L....Y...KK ->SRR 48 0.250 4.494E-04 0 58 59 12 79 182 +>SRR P.L...V..R..I.....T.....Y........P.......R........Ga......L.......S....P.......E.......H.....K....T. R..IA....RA...L.T.E...I...V......L.......D...Vevdaa..T........D....A.....G......R................... ..........M......V.......T.......V......V...H....F.......N......E.....A........A....P.........D..... .D..........W..........A........V..........G........G......Eirs.....T....A...AE ->SRR 46 0.235 2.223E-03 0 58 59 68 135 197 +>SRR P.L...V..R..I.....T.....Y........P.......R........Ga......L.......S....P.......D.......H.....K....R. R..IA....RE...L.T.E...I...V......L.......D...Vevdaa..T........D....A.....G......R................... ..........M......V.......T.......V......I...H....F.......N......E.....A........A....A.........D..... .D..........W..........A........V..........G........G......Eirs.....T....A...AE ->SRR 45 0.250 4.216E-03 0 58 59 65 132 177 +>SRR P.R...Y..R..Vip...T.....V........P.......E........G.......Qy......S....N.......E.......S.....R....K. A..LV....KD...V.T.E...A...V......V.......R...A.......D........G....G.....K......Y................... ..........E......Dvapr...V.......W......V...F....P.......T......E.....I........P....D.........G..... .Q..........W..........G........S..........R........Gvi....R........P....L...PE ->SRR 45 0.264 4.216E-03 0 58 59 253 320 363 +>SRR P.R...Y..R..Iip...T.....V........P.......E........G.......Qy......S....N.......E.......S.....R....K. A..LV....KD...V.T.E...A...V......V.......R...A.......D........G....G.....K......Y................... ..........E......Dvapr...V.......W......V...F....P.......T......E.....I........P....D.........G..... .Q..........W..........G........S..........R........Gvi....R........P....L...PE ->SRR 39 0.231 5.146E-01 0 58 59 36 104 105 +>SRR P.V...I..E..M.....F.....V........P.......E........G.......La......D....A.......E.......A.....K....R. A..LH....DR...V.S.R...Q...V......L.......E...V.......E........G....AtydesP......L................... ..........A......Qsi.....T.......W......M...L....I.......Q......E.....V........L....E.........C..... .G..........W..........S........V..........G........S......K........Avw..A...SE ->SRR 39 0.308 5.146E-01 0 58 59 23 90 161 +>SRR P.I...I..E..M.....H.....V........Q.......E........Gv......L.......D....E.......E.......T.....K....R. T..LH....ER...V.G.R...Q...V......L.......E...I.......E........G....Any...D......E................... ..........N......D.......Varllt..F......M...F....I.......R......E.....H........P....E.........G..... .G..........F..........S........I..........G........G......E........M....It..SE ->SRR 38 0.197 7.091E-01 0 55 59 12 82 121 +>SRR P.Lyr.V..D..V.....T.....V........P.......E........Gsmihg..Q.......G....Pwal....S.......R.....R....R. A..IV....RE...V.T.E...I...V......L.......E...A.......E........G....S.....D......P................... ..........Slgeaw.R.......V.......W......V...V....L.......R......E.....V........G....D.........A..... .F..........W..........G........A..........A........G......E........L....-...-- ->SRR 38 0.271 1.347E+00 0 54 59 17 86 122 +>SRR P.Lyr.V..Q..I.....T.....V........P.......E........Gsmlhg..Q.......G....Pwai....E.......R.....R....R. E..LV....RA...V.S.K...A...V......L.......D...A.......E........G....Teyn..P......A................... ..........Saw....R.......V.......W......V...L....M.......S......E.....I........S....E.........T..... .H..........W..........G........A..........A........G......E........-....-...-- ->SRR 37 0.222 2.559E+00 0 57 59 54 125 137 +>SRR P.L...V..E..M.....S.....F........P.......V........Gv......L.......T....L.......D.......Q.....K....A. A..MI....KS...V.T.D...V...V......R.......G...A.......M........K....L.....P......P................... ..........Dpar...K.......L.......F......V...E....I.......F......E.....T........P....G.........G..... .G..........F..........G........Vtakvvvvp..G........Gky....R........P....A...P- ->SRR 36 0.141 3.528E+00 0 54 59 15 99 112 +>SRR P.L...V..E..I.....D.....L........L.......E........A.......W.......A....P.......D.......Q.....I....D. A..IA....DA...I.H.E...A...M......V.......E...T.......L........G....V.....P......Eraagrdsatkqhfysrfaa llaeratvqsA......D.......L.......T......A...V....L.......V......E.....N........S....R.........D..... -- 1.7.10.2