From 8afe00d88c23cb2f3c7ffa98ea44a31512999d54 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Tue, 2 Apr 2024 20:27:50 +0100 Subject: [PATCH] JAL-4380 Improved annotation tooltips especially secondary structure tooltips --- src/jalview/gui/AnnotationPanel.java | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 24cd8bc..57c147b 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -1334,32 +1334,37 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, .highlightPositionsOn(ann.sequenceRef, highlightPos, null); } } - return tooltip; + return tooltip == null || tooltip.length() == 0 ? null : tooltip; } private static String getAnnotationBriefSummary(Annotation a) { - String tt = a.description; - if (tt == null || tt.trim().length() == 0) + StringBuilder ttSB = new StringBuilder(); + if (a.secondaryStructure != 0 && a.secondaryStructure != ' ') { - tt = String.valueOf(a.displayCharacter); + ttSB.append(a.secondaryStructure); } - if ((tt == null || tt.length() == 0) && !Float.isNaN(a.value)) + else if (a.description != null && a.description.trim().length() > 0) + { + ttSB.append(a.description); + } + else if (a.displayCharacter != null + && a.displayCharacter.trim().length() > 0) + { + ttSB.append(a.displayCharacter); + } + else if (!Float.isNaN(a.value)) { if (a.value == Math.floor(a.value)) // likely integer value { - tt = String.format("%.0f", a.value); + ttSB.append(String.format("%.0f", a.value)); } else // display as is { - tt = String.valueOf(a.value); + ttSB.append(String.valueOf(a.value)); } } - if (tt == null || tt.trim().length() == 0) - { - tt = String.valueOf(a.secondaryStructure); - } - return tt; + return ttSB.toString(); } /** -- 1.7.10.2