From: Ben Soares Date: Tue, 20 Feb 2024 15:35:22 +0000 (+0000) Subject: JAL-4380 Added information to annotation tooltips when description is not present X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ae8edbda04dc4fabab67c71fe65c4b091b4b8073;p=jalview.git JAL-4380 Added information to annotation tooltips when description is not present --- diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index ea32684..c97ee53 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -1275,8 +1275,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (!first) { tip.append("
"); + first = false; } - first = false; tip.append(anns[i].label); String description = anns[i].annotations[column].description; if (description != null && description.length() > 0) @@ -1290,7 +1290,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, else if (column < ann.annotations.length && ann.annotations[column] != null) { - tooltip = ann.annotations[column].description; + tooltip = getAnnotationBriefSummary(ann.annotations[column]); } // TODO abstract tooltip generator so different implementations can be built if (ann.graph == AlignmentAnnotation.CONTACT_MAP) @@ -1337,6 +1337,31 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, return tooltip; } + private static String getAnnotationBriefSummary(Annotation a) + { + String tt = a.description; + if (tt == null || tt.trim().length() == 0) + { + tt = String.valueOf(a.displayCharacter); + } + if ((tt == null || tt.length() == 0) && !Float.isNaN(a.value)) + { + if (a.value == Math.floor(a.value)) // likely integer value + { + tt = String.format("%.0f", a.value); + } + else // display as is + { + tt = String.valueOf(a.value); + } + } + if (tt == null || tt.trim().length() == 0) + { + tt = String.valueOf(a.secondaryStructure); + } + return tt; + } + /** * Constructs and returns the status bar message * @@ -1357,7 +1382,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (column < ann.annotations.length && ann.annotations[column] != null) { - String description = ann.annotations[column].description; + String description = getAnnotationBriefSummary( + ann.annotations[column]); if (description != null && description.trim().length() > 0) { text.append(" ").append(description);