*/
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;
* @author $author$
* @version $Revision$
*/
-public class IdPanel extends JPanel implements MouseListener,
- MouseMotionListener, MouseWheelListener
+public class IdPanel extends JPanel
+ implements MouseListener, MouseMotionListener, MouseWheelListener
{
private IdCanvas idCanvas;
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.isOverAnnotation())
{
- SequenceI sequence = av.getAlignment().getSequenceAt(seq);
- StringBuilder tip = new StringBuilder(64);
- seqAnnotReport.createTooltipAnnotationReport(tip, sequence,
- av.isShowDBRefs(), av.isShowNPFeats(),
- sp.seqCanvas.fr.getMinMax());
- 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.isOverAnnotation())
+ {
+ // mouse is over annotation label in wrapped mode
+ return;
+ }
+
+ int seq = Math.max(0, pos.seqIndex);
if (seq < lastid)
{
}
lastid = seq;
- alignPanel.paintAlignment(true);
+ alignPanel.paintAlignment(false, false);
}
/**
public void mouseWheelMoved(MouseWheelEvent e)
{
e.consume();
- if (e.getWheelRotation() > 0)
+ double wheelRotation = e.getPreciseWheelRotation();
+ if (wheelRotation > 0)
{
if (e.isShiftDown())
{
av.getRanges().scrollUp(false);
}
}
- else
+ else if (wheelRotation < 0)
{
if (e.isShiftDown())
{
return;
}
- int seq = alignPanel.getSeqPanel().findSeq(e);
+ MousePos pos = alignPanel.getSeqPanel().findMousePosition(e);
+ if (pos.isOverAnnotation())
+ {
+ // 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.isOverAnnotation())
+ {
+ // mouse is over an annotation label in wrapped mode
+ return;
+ }
+
if (e.isPopupTrigger()) // Mac reports this in mousePressed
{
- showPopupMenu(e);
+ showPopupMenu(e, pos);
return;
}
}
if ((av.getSelectionGroup() == null)
- || (!jalview.util.Platform.isControlDown(e) && !e.isShiftDown() && av
- .getSelectionGroup() != null))
+ || (!jalview.util.Platform.isControlDown(e) && !e.isShiftDown()
+ && av.getSelectionGroup() != null))
{
av.setSelectionGroup(new SequenceGroup());
av.getSelectionGroup().setStartRes(0);
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);
- alignPanel.paintAlignment(true);
+ alignPanel.paintAlignment(false, false);
}
/**
*
* @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
* and any non-positional features
*/
List<String> nlinks = Preferences.sequenceUrlLinks.getLinksForMenu();
- for (SequenceFeature sf : sq.getFeatures().getNonPositionalFeatures())
+ List<SequenceFeature> features = sq.getFeatures().getNonPositionalFeatures();
+ for (SequenceFeature sf : features)
{
if (sf.links != null)
{
- for (String link : sf.links)
- {
- nlinks.add(link);
- }
+ nlinks.addAll(sf.links);
}
}
- PopupMenu pop = new PopupMenu(alignPanel, sq, nlinks,
+ PopupMenu pop = new PopupMenu(alignPanel, sq, features,
Preferences.getGroupURLLinks());
pop.show(this, e.getX(), e.getY());
}
for (int i = start; i <= end; i++)
{
- av.getSelectionGroup().addSequence(
- av.getAlignment().getSequenceAt(i), i == end);
+ av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i),
+ i == end);
}
}
{
scrollThread.running = false;
}
+ MousePos pos = alignPanel.getSeqPanel().findMousePosition(e);
+ if (pos.isOverAnnotation())
+ {
+ // 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);
}
}
running = false;
}
- alignPanel.paintAlignment(false);
+ alignPanel.paintAlignment(false, false);
try
{