*/
package jalview.gui;
+import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.gui.SeqPanel.MousePos;
import jalview.io.SequenceAnnotationReport;
import jalview.util.MessageManager;
import jalview.util.Platform;
public void mouseMoved(MouseEvent e)
{
SeqPanel sp = alignPanel.getSeqPanel();
- int seq = Math.max(0, sp.findSeq(e));
- if (seq > -1 && seq < av.getAlignment().getHeight())
+ MousePos pos = sp.findMousePosition(e);
+ if (pos.annotationIndex != -1)
{
- SequenceI sequence = av.getAlignment().getSequenceAt(seq);
- StringBuilder tip = new StringBuilder(64);
- seqAnnotReport.createTooltipAnnotationReport(tip, sequence,
- av.isShowDBRefs(), av.isShowNPFeats(), sp.seqCanvas.fr);
- setToolTipText(JvSwingUtils.wrapTooltip(true,
- sequence.getDisplayId(true) + " " + tip.toString()));
+ /*
+ * mouse is over an annotation label in wrapped mode
+ */
+ AlignmentAnnotation annotation = av.getAlignment()
+ .getAlignmentAnnotation()[pos.annotationIndex];
+ setToolTipText(AnnotationLabels.getTooltip(annotation));
+ }
+ else
+ {
+ int seq = Math.max(0, pos.seqIndex);
+ if (seq < av.getAlignment().getHeight())
+ {
+ SequenceI sequence = av.getAlignment().getSequenceAt(seq);
+ StringBuilder tip = new StringBuilder(64);
+ seqAnnotReport.createTooltipAnnotationReport(tip, sequence,
+ av.isShowDBRefs(), av.isShowNPFeats(), sp.seqCanvas.fr);
+ setToolTipText(JvSwingUtils.wrapTooltip(true,
+ sequence.getDisplayId(true) + " " + tip.toString()));
+ }
}
}
{
mouseDragging = true;
- int seq = Math.max(0, alignPanel.getSeqPanel().findSeq(e));
+ MousePos pos = alignPanel.getSeqPanel().findMousePosition(e);
+ if (pos.annotationIndex != -1)
+ {
+ // mouse is over annotation label in wrapped mode
+ return;
+ }
+
+ int seq = Math.max(0, pos.seqIndex);
if (seq < lastid)
{
return;
}
- int seq = alignPanel.getSeqPanel().findSeq(e);
+ MousePos pos = alignPanel.getSeqPanel().findMousePosition(e);
+ if (pos.annotationIndex != -1)
+ {
+ // mouse is over annotation label in wrapped mode
+ return;
+ }
+
+ int seq = pos.seqIndex;
String id = av.getAlignment().getSequenceAt(seq).getName();
String url = Preferences.sequenceUrlLinks.getPrimaryUrl(id);
return;
}
+ MousePos pos = alignPanel.getSeqPanel().findMousePosition(e);
+ if (pos.annotationIndex != -1)
+ {
+ // mouse is over an annotation label in wrapped mode
+ return;
+ }
+
if (e.isPopupTrigger()) // Mac reports this in mousePressed
{
- showPopupMenu(e);
+ showPopupMenu(e, pos);
return;
}
av.getSelectionGroup().setEndRes(av.getAlignment().getWidth() - 1);
}
- int seq = alignPanel.getSeqPanel().findSeq(e);
if (e.isShiftDown() && (lastid != -1))
{
- selectSeqs(lastid, seq);
+ selectSeqs(lastid, pos.seqIndex);
}
else
{
- selectSeq(seq);
+ selectSeq(pos.seqIndex);
}
av.isSelectionGroupChanged(true);
*
* @param e
*/
- void showPopupMenu(MouseEvent e)
+ void showPopupMenu(MouseEvent e, MousePos pos)
{
- int seq2 = alignPanel.getSeqPanel().findSeq(e);
- Sequence sq = (Sequence) av.getAlignment().getSequenceAt(seq2);
+ Sequence sq = (Sequence) av.getAlignment().getSequenceAt(pos.seqIndex);
/*
* build a new links menu based on the current links
{
if (sf.links != null)
{
- for (String link : sf.links)
- {
- nlinks.add(link);
- }
+ nlinks.addAll(sf.links);
}
}
{
scrollThread.running = false;
}
+ MousePos pos = alignPanel.getSeqPanel().findMousePosition(e);
+ if (pos.annotationIndex != -1)
+ {
+ // mouse is over an annotation label in wrapped mode
+ return;
+ }
mouseDragging = false;
PaintRefresher.Refresh(this, av.getSequenceSetId());
if (e.isPopupTrigger()) // Windows reports this in mouseReleased
{
- showPopupMenu(e);
+ showPopupMenu(e, pos);
}
}
.getAlignmentAnnotation();
int rowOffsetPx = yOffsetPx - alignmentHeightPixels;
annIndex = AnnotationPanel.getRowIndex(rowOffsetPx, anns);
+ // also last sequence in alignment (for backwards compatible behaviour)
+ seq = alignmentHeight - 1;
}
else
{
}
else
{
- if (x > seqCanvas.getX() + seqCanvas.getWidth())
- {
- // make sure we calculate relative to visible alignment, rather than
- // right-hand gutter
- x = seqCanvas.getX() + seqCanvas.getWidth();
- }
+ /*
+ * make sure we calculate relative to visible alignment,
+ * rather than right-hand gutter
+ */
+ x = Math.min(x, seqCanvas.getX() + seqCanvas.getWidth());
res = (x / av.getCharWidth()) + startRes;
- if (res > av.getRanges().getEndRes())
- {
- // moused off right
- res = av.getRanges().getEndRes();
- }
+ res = Math.min(res, av.getRanges().getEndRes());
}
if (av.hasHiddenColumns())
}
return res;
-
- }
-
- /**
- * Answers the index in the alignment (0...) of the sequence under the mouse
- * position. If the mouse is below the alignment (say, over annotations),
- * answers the index of the last sequence.
- *
- * @param evt
- * @return
- */
- int findSeq(MouseEvent evt)
- {
- int seq = 0;
- int y = evt.getY();
-
- int charHeight = av.getCharHeight();
- int alignmentHeight = av.getAlignment().getHeight();
- if (av.getWrapAlignment())
- {
- int hgap = charHeight;
- if (av.getScaleAboveWrapped())
- {
- hgap += charHeight;
- }
-
- int alignmentHeightPixels = alignmentHeight * charHeight;
- int cHeight = alignmentHeightPixels + hgap
- + seqCanvas.getAnnotationHeight();
-
- y -= hgap;
-
- int yOffsetPx = y % cHeight; // yPos below repeating width(s)
-// if (yOffsetPx > alignmentHeightPixels)
-// {
-// seq = -1; // cursor is over annotation or below alignment entirely
-// }
-// else
- // {
- seq = Math.min(yOffsetPx / charHeight, alignmentHeight - 1);
-// }
- }
- else
- {
- seq = Math.min((y / charHeight) + av.getRanges().getStartSeq(),
- alignmentHeight - 1);
- }
-
- return seq;
}
/**
@Override
public void mouseReleased(MouseEvent evt)
{
+ MousePos pos = findMousePosition(evt);
+ if (pos.annotationIndex != -1)
+ {
+ // mouse is over annotation row in wrapped mode
+ return;
+ }
+
boolean didDrag = mouseDragging; // did we come here after a drag
mouseDragging = false;
mouseWheelPressed = false;
if (evt.isPopupTrigger()) // Windows: mouseReleased
{
- showPopupMenu(evt);
+ showPopupMenu(evt, pos);
evt.consume();
return;
}
public void mousePressed(MouseEvent evt)
{
lastMousePress = evt.getPoint();
+ MousePos pos = findMousePosition(evt);
+ if (pos.annotationIndex != -1)
+ {
+ // mouse is over an annotation row in wrapped mode
+ return;
+ }
if (SwingUtilities.isMiddleMouseButton(evt))
{
}
else
{
- doMousePressedDefineMode(evt);
+ doMousePressedDefineMode(evt, pos);
return;
}
- int seq = findSeq(evt);
- int res = findColumn(evt);
+ int seq = pos.seqIndex;
+ int res = pos.column;
if (seq < 0 || res < 0)
{
mouseMovedOverAnnotation(mousePos);
return;
}
- final int seq = mousePos.seqIndex;// findSeq(evt);
+ final int seq = mousePos.seqIndex;
final int column = mousePos.column;
if (column < 0 || seq < 0 || seq >= av.getAlignment().getHeight())
@Override
public void mouseDragged(MouseEvent evt)
{
+ MousePos pos = findMousePosition(evt);
+ if (pos.annotationIndex != -1)
+ {
+ // mouse is over annotation row in wrapped mode
+ return;
+ }
+
if (mouseWheelPressed)
{
boolean inSplitFrame = ap.av.getCodingComplement() != null;
return;
}
- int res = findColumn(evt);
+ int res = pos.column;
if (res < 0)
{
public void mouseClicked(MouseEvent evt)
{
SequenceGroup sg = null;
- SequenceI sequence = av.getAlignment().getSequenceAt(findSeq(evt));
+ MousePos pos = findMousePosition(evt);
+ if (pos.annotationIndex != -1)
+ {
+ // mouse is over annotation label in wrapped mode
+ return;
+ }
+
if (evt.getClickCount() > 1)
{
sg = av.getSelectionGroup();
av.setSelectionGroup(null);
}
- int column = findColumn(evt);
+ int column = pos.column;
/*
* find features at the position (if not gapped), or straddling
* the position (if at a gap)
*/
+ SequenceI sequence = av.getAlignment().getSequenceAt(pos.seqIndex);// findSeq(evt));
List<SequenceFeature> features = seqCanvas.getFeatureRenderer()
.findFeaturesAtColumn(sequence, column + 1);
/**
* DOCUMENT ME!
*
- * @param evt
+ * @param pos
* DOCUMENT ME!
*/
- public void doMousePressedDefineMode(MouseEvent evt)
+ protected void doMousePressedDefineMode(MouseEvent evt, MousePos pos)
{
- final int res = findColumn(evt);
- final int seq = findSeq(evt);
+ if (pos.annotationIndex != -1)
+ {
+ // JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ // MessageManager.getString(
+ // "label.cannot_edit_annotations_in_wrapped_view"),
+ // MessageManager.getString("label.wrapped_view_no_edit"),
+ // JvOptionPane.WARNING_MESSAGE);
+ return;
+ }
+
+ final int res = pos.column;
+ final int seq = pos.seqIndex;
oldSeq = seq;
updateOverviewAndStructs = false;
startWrapBlock = wrappedBlock;
- if (av.getWrapAlignment() && seq > av.getAlignment().getHeight())
- {
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
- MessageManager.getString(
- "label.cannot_edit_annotations_in_wrapped_view"),
- MessageManager.getString("label.wrapped_view_no_edit"),
- JvOptionPane.WARNING_MESSAGE);
- return;
- }
-
if (seq < 0 || res < 0)
{
return;
if (evt.isPopupTrigger()) // Mac: mousePressed
{
- showPopupMenu(evt);
+ showPopupMenu(evt, pos);
return;
}
if (av.cursorMode)
{
- seqCanvas.cursorX = findColumn(evt);
- seqCanvas.cursorY = findSeq(evt);
+ seqCanvas.cursorX = res;
+ seqCanvas.cursorY = seq;
seqCanvas.repaint();
return;
}
/**
* Build and show a pop-up menu at the right-click mouse position
- *
+ *
* @param evt
- * @param res
- * @param sequences
+ * @param pos
*/
- void showPopupMenu(MouseEvent evt)
+ void showPopupMenu(MouseEvent evt, MousePos pos)
{
- final int column = findColumn(evt);
- final int seq = findSeq(evt);
+ final int column = pos.column;
+ final int seq = pos.seqIndex;
SequenceI sequence = av.getAlignment().getSequenceAt(seq);
List<SequenceFeature> features = ap.getFeatureRenderer()
.findFeaturesAtColumn(sequence, column + 1);
*/
public void doMouseDraggedDefineMode(MouseEvent evt)
{
- int res = findColumn(evt);
- int y = findSeq(evt);
+ MousePos pos = findMousePosition(evt);
+ if (pos.annotationIndex != -1)
+ {
+ // mouse is over annotation in wrapped mode
+ return;
+ }
+
+ int res = pos.column;
+ int y = pos.seqIndex;
if (wrappedBlock != startWrapBlock)
{