JAL-3132 status message for sequence and/or graph group annotation
[jalview.git] / src / jalview / gui / AnnotationLabels.java
index 0ff6b73..6da6cc3 100755 (executable)
@@ -674,16 +674,65 @@ public class AnnotationLabels extends JPanel
     if (selectedRow > -1 && ap.av.getAlignment()
             .getAlignmentAnnotation().length > selectedRow)
     {
-      AlignmentAnnotation aa = ap.av.getAlignment()
-              .getAlignmentAnnotation()[selectedRow];
+      AlignmentAnnotation[] anns = ap.av.getAlignment()
+              .getAlignmentAnnotation();
+      AlignmentAnnotation aa = anns[selectedRow];
 
       String desc = getTooltip(aa);
       this.setToolTipText(desc);
-      ap.alignFrame.setStatus(aa.label);
+      String msg = getStatusMessage(aa, anns);
+      ap.alignFrame.setStatus(msg);
     }
   }
 
   /**
+   * Constructs suitable text to show in the status bar when over an annotation
+   * label, containing the associated sequence name (if any), and the annotation
+   * labels (or all labels for a graph group annotation)
+   * 
+   * @param aa
+   * @param anns
+   * @return
+   */
+  static String getStatusMessage(AlignmentAnnotation aa,
+          AlignmentAnnotation[] anns)
+  {
+    if (aa == null)
+    {
+      return null;
+    }
+
+    StringBuilder msg = new StringBuilder(32);
+    if (aa.sequenceRef != null)
+    {
+      msg.append(aa.sequenceRef.getName()).append(" : ");
+    }
+
+    if (aa.graphGroup == -1)
+    {
+      msg.append(aa.label);
+    }
+    else if (anns != null)
+    {
+      boolean first = true;
+      for (int i = anns.length - 1; i >= 0; i--)
+      {
+        if (anns[i].graphGroup == aa.graphGroup)
+        {
+          if (!first)
+          {
+            msg.append(", ");
+          }
+          msg.append(anns[i].label);
+          first = false;
+        }
+      }
+    }
+
+    return msg.toString();
+  }
+
+  /**
    * Answers a tooltip, formatted as html, containing the annotation description
    * (prefixed by associated sequence id if applicable), and the annotation
    * (non-positional) score if it has one. Answers null if neither description