From 82c876a1b6312edb946dc98377dae0cd45837050 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Mon, 13 Nov 2023 19:03:03 +0000 Subject: [PATCH] JAL-4059 Fix the tooltip formatting for when, e.g. enclose=false --- src/jalview/gui/JvSwingUtils.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/jalview/gui/JvSwingUtils.java b/src/jalview/gui/JvSwingUtils.java index c00be98..b6b993e 100644 --- a/src/jalview/gui/JvSwingUtils.java +++ b/src/jalview/gui/JvSwingUtils.java @@ -70,21 +70,27 @@ public final class JvSwingUtils { Objects.requireNonNull(ttext, "Tootip text to format must not be null!"); - ttext = ttext.trim(); + if (enclose) + { + ttext = ttext.trim(); + } boolean maxLengthExceeded = false; boolean hasBr = false; for (String br : new String[] { "
", "
" }) { - hasBr = true; if (ttext.contains(br)) { + hasBr = true; String[] htmllines = ttext.split(br); StringBuilder sb = new StringBuilder(); for (String line : htmllines) { - line = line.replaceAll("\\s+", " "); - line = line.trim(); + if (enclose) + { + line = line.replaceAll("\\s+", " "); + line = line.trim(); + } if (line.length() == 0 || line.equals(" ")) { continue; @@ -99,10 +105,13 @@ public final class JvSwingUtils ttext = sb.toString(); } } - if (!hasBr) + if (enclose) { ttext = ttext.replaceAll("\\s+", " "); ttext = ttext.trim(); + } + if (!hasBr) + { maxLengthExceeded = ttext.length() > 60; } -- 1.7.10.2