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
/*
* mouse is over an annotation label in wrapped mode
*/
- AlignmentAnnotation annotation = av.getAlignment()
- .getAlignmentAnnotation()[pos.annotationIndex];
+ AlignmentAnnotation[] anns = av.getAlignment()
+ .getAlignmentAnnotation();
+ AlignmentAnnotation annotation = anns[pos.annotationIndex];
setToolTipText(AnnotationLabels.getTooltip(annotation));
- alignPanel.alignFrame.setStatus(annotation.label);
+ alignPanel.alignFrame.setStatus(
+ AnnotationLabels.getStatusMessage(annotation, anns));
}
else
{
ann.sequenceRef = null;
assertNull(AnnotationLabels.getTooltip(ann));
}
+
+ @Test(groups = "Functional")
+ public void testGetStatusMessage()
+ {
+ assertNull(AnnotationLabels.getStatusMessage(null, null));
+
+ /*
+ * simple label
+ */
+ AlignmentAnnotation aa = new AlignmentAnnotation("IUPredWS Short",
+ "Protein disorder", null);
+ assertEquals(AnnotationLabels.getStatusMessage(aa, null),
+ "IUPredWS Short");
+
+ /*
+ * with sequence ref
+ */
+ aa.setSequenceRef(new Sequence("FER_CAPAA", "MIGRKQL"));
+ assertEquals(AnnotationLabels.getStatusMessage(aa, null),
+ "FER_CAPAA : IUPredWS Short");
+
+ /*
+ * with graph group (degenerate, one annotation only)
+ */
+ aa.graphGroup = 1;
+ AlignmentAnnotation aa2 = new AlignmentAnnotation("IUPredWS Long",
+ "Protein disorder", null);
+ assertEquals(
+ AnnotationLabels.getStatusMessage(aa, new AlignmentAnnotation[]
+ { aa, aa2 }), "FER_CAPAA : IUPredWS Short");
+
+ /*
+ * graph group with two members; note labels are appended in
+ * reverse order (matching rendering order on screen)
+ */
+ aa2.graphGroup = 1;
+ assertEquals(
+ AnnotationLabels.getStatusMessage(aa, new AlignmentAnnotation[]
+ { aa, aa2 }), "FER_CAPAA : IUPredWS Long, IUPredWS Short");
+
+ /*
+ * graph group with no sequence ref
+ */
+ aa.sequenceRef = null;
+ assertEquals(
+ AnnotationLabels.getStatusMessage(aa, new AlignmentAnnotation[]
+ { aa, aa2 }), "IUPredWS Long, IUPredWS Short");
+ }
}