import jalview.util.Platform;
import jalview.viewmodel.AlignmentViewport;
import jalview.viewmodel.ViewportRanges;
+import jalview.viewmodel.seqfeatures.IdColumn;
+import jalview.viewmodel.seqfeatures.IdColumns;
+import jalview.viewmodel.seqfeatures.IdColumns.ColumnCell;
/**
* This panel hosts alignment sequence ids and responds to mouse clicks on them,
SequenceI sequence = av.getAlignment().getSequenceAt(seq);
StringBuilder tip = new StringBuilder(64);
tip.append(sequence.getDisplayId(true)).append(" ");
- seqAnnotReport.createTooltipAnnotationReport(tip, sequence,
- av.isShowDBRefs(), av.isShowNPFeats(), sp.seqCanvas.fr);
+ IdColumn col = locateColumnFor(e);
+ if (col != null)
+ {
+ // tooltip for column
+ tip.append(getTooltipFor(col, sequence));
+ }
+ else
+ {
+ seqAnnotReport.createTooltipAnnotationReport(tip, sequence,
+ av.isShowDBRefs(), av.isShowNPFeats(), sp.seqCanvas.fr);
+ }
setToolTipText(JvSwingUtils.wrapTooltip(true, tip.toString()));
StringBuilder text = new StringBuilder();
}
}
+ private Object getTooltipFor(IdColumn col, SequenceI seq)
+ {
+ ColumnCell cell = av.getIdColumns().getCellFor(seq, col);
+ if (cell != null)
+ {
+ return "" + col.getLabel() + ": " + cell.label;
+ }
+ return "";
+ }
+
+ private IdColumn locateColumnFor(MouseEvent e)
+ {
+ // TODO COMBINE SAME CODE IN IDCANVAS!!!
+
+ IdColumns id_cols = av.getIdColumns();
+ List<IdColumn> visible = id_cols.getVisible();
+ /**
+ * width of an idColumn
+ */
+ int colWid = 20;
+ int panelWidth = Math.max(idCanvas.getWidth() / 2,
+ idCanvas.getWidth() - (colWid * visible.size()));
+ int p = 0;
+ while (panelWidth < idCanvas.getWidth() && p < visible.size())
+ {
+
+ if (e.getX() >= panelWidth && e.getX() < panelWidth + colWid)
+ return visible.get(p);
+ p++;
+ panelWidth += colWid;
+ }
+ return null;
+ }
+
/**
* Responds to a mouse drag by selecting the sequences under the dragged
* region.