import javax.swing.Scrollable;
import javax.swing.ToolTipManager;
+import jalview.api.AlignViewportI;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.ContactListI;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceI;
import jalview.gui.JalviewColourChooser.ColourChooserListener;
import jalview.renderer.AnnotationRenderer;
import jalview.renderer.AwtRenderPanelI;
+import jalview.renderer.ContactGeometry;
import jalview.schemes.ResidueProperties;
import jalview.util.Comparison;
import jalview.util.MessageManager;
{
int yPos = evt.getY();
AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
-
- int row = getRowIndex(yPos, aa);
+ int rowAndOffset[] = getRowIndexAndOffset(yPos, aa);
+ int row = rowAndOffset[0];
if (row == -1)
{
if (row > -1 && ann.annotations != null
&& column < ann.annotations.length)
{
- String toolTip = buildToolTip(ann, column, aa);
+ String toolTip = buildToolTip(ann, column, aa, rowAndOffset[1], av);
setToolTipText(toolTip == null ? null
: JvSwingUtils.wrapTooltip(true, toolTip));
- String msg = getStatusMessage(av.getAlignment(), column, ann);
+ String msg = getStatusMessage(av.getAlignment(), column, ann,
+ rowAndOffset[1], av);
ap.alignFrame.setStatus(msg);
}
else
{
return -1;
}
+ return getRowIndexAndOffset(yPos, aa)[0];
+ }
+
+ static int[] getRowIndexAndOffset(int yPos, AlignmentAnnotation[] aa)
+ {
+ int[] res = new int[2];
+ if (aa == null)
+ {
+ res[0] = -1;
+ res[1] = 0;
+ return res;
+ }
int row = -1;
- int height = 0;
+ int height = 0, lheight = 0;
for (int i = 0; i < aa.length; i++)
{
if (aa[i].visible)
{
+ lheight = height;
height += aa[i].height;
}
if (height > yPos)
{
row = i;
+ res[0] = row;
+ res[1] = yPos - lheight;
break;
}
}
- return row;
+ return res;
}
/**
* @param ann
* @param column
* @param anns
+ * @param rowAndOffset
*/
static String buildToolTip(AlignmentAnnotation ann, int column,
- AlignmentAnnotation[] anns)
+ AlignmentAnnotation[] anns, int rowAndOffset, AlignViewportI av)
{
String tooltip = null;
if (ann.graphGroup > -1)
{
tooltip = ann.annotations[column].description;
}
-
+ // TODO abstract tooltip generator so different implementations can be built
+ if (ann.graph == AlignmentAnnotation.CUSTOMRENDERER)
+ {
+ ContactListI clist = av.getContactList(ann, column);
+ if (clist != null)
+ {
+ ContactGeometry cgeom = new ContactGeometry(clist, ann.graphHeight);
+ ContactGeometry.contactInterval ci = cgeom.mapFor(rowAndOffset,
+ rowAndOffset);
+ tooltip += "Contact from " + ci.cStart + " to " + ci.cEnd;
+ }
+ }
return tooltip;
}
* @param al
* @param column
* @param ann
+ * @param rowAndOffset
*/
static String getStatusMessage(AlignmentI al, int column,
- AlignmentAnnotation ann)
+ AlignmentAnnotation ann, int rowAndOffset, AlignViewportI av)
{
/*
* show alignment column and annotation description if any
Graphics2D gg = (Graphics2D) image.getGraphics();
- if (imgWidth>Math.abs(horizontal*av.getCharWidth())) {
- //scroll is less than imgWidth away so can re-use buffered graphics
+ if (imgWidth > Math.abs(horizontal * av.getCharWidth()))
+ {
+ // scroll is less than imgWidth away so can re-use buffered graphics
gg.copyArea(0, 0, imgWidth, getHeight(),
-horizontal * av.getCharWidth(), 0);
-
+
if (horizontal > 0) // scrollbar pulled right, image to the left
{
transX = (er - sr - horizontal) * av.getCharWidth();