+ // clean the description ready for embedding in html
+ desc = new StringBuffer(Pattern.compile("<").matcher(desc)
+ .replaceAll("<"));
+ desc.insert(0, "<html>");
+ }
+ else
+ {
+ // remove terminating html if any
+ int i = desc.substring(desc.length() - 7).toLowerCase()
+ .lastIndexOf("</html>");
+ if (i > -1)
+ {
+ desc.setLength(desc.length() - 7 + i);
+ }
+ }
+ if (aa.hasScore())
+ {
+ desc.append("<br/>");
+ }
+ // if (aa.hasProperties())
+ // {
+ // desc.append("<table>");
+ // for (String prop : aa.getProperties())
+ // {
+ // desc.append("<tr><td>" + prop + "</td><td>"
+ // + aa.getProperty(prop) + "</td><tr>");
+ // }
+ // desc.append("</table>");
+ // }
+ }
+ else
+ {
+ // begin the tooltip's html fragment
+ desc.append("<html>");
+ if (aa.hasScore())
+ {
+ // TODO: limit precision of score to avoid noise from imprecise
+ // doubles
+ // (64.7 becomes 64.7+/some tiny value).
+ desc.append(" Score: " + aa.score);
+ }
+ }
+ if (desc.length() > 6)
+ {
+ desc.append("</html>");
+ this.setToolTipText(desc.toString());
+ }
+ else
+ {
+ this.setToolTipText(null);
+ }
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param evt
+ * DOCUMENT ME!
+ */
+ public void mouseClicked(MouseEvent evt)
+ {
+ final AlignmentAnnotation[] aa = ap.av.getAlignment()
+ .getAlignmentAnnotation();
+ if (SwingUtilities.isLeftMouseButton(evt))
+ {
+ if (selectedRow > -1 && selectedRow < aa.length)
+ {
+ if (aa[selectedRow].groupRef != null)
+ {
+ if (evt.getClickCount() >= 2)
+ {
+ // todo: make the ap scroll to the selection - not necessary, first
+ // click highlights/scrolls, second selects
+ ap.getSeqPanel().ap.getIdPanel().highlightSearchResults(null);
+ ap.av.setSelectionGroup(// new SequenceGroup(
+ aa[selectedRow].groupRef); // );
+ ap.paintAlignment(false);
+ PaintRefresher.Refresh(ap, ap.av.getSequenceSetId());
+ ap.av.sendSelection();
+ }
+ else
+ {
+ ap.getSeqPanel().ap.getIdPanel()
+ .highlightSearchResults(aa[selectedRow].groupRef
+ .getSequences(null));
+ }
+ return;