X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdPanel.java;h=94eab765148b26d1cc0ad2f9dd3def0576122129;hb=d0e1239635b38ef37d3cd35a6943dc0cd713d903;hp=f0aefb1438fc998ff375e38abc873b7797f864dc;hpb=4fc6139132c466c51c607f11836853843197b7e7;p=jalview.git diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index f0aefb1..94eab76 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -20,10 +20,12 @@ */ 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; @@ -102,16 +104,28 @@ public class IdPanel extends JPanel 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.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())); + } } } @@ -126,7 +140,14 @@ public class IdPanel extends JPanel { 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) { @@ -138,7 +159,7 @@ public class IdPanel extends JPanel } lastid = seq; - alignPanel.paintAlignment(false); + alignPanel.paintAlignment(false, false); } /** @@ -148,24 +169,25 @@ public class IdPanel extends JPanel public void mouseWheelMoved(MouseWheelEvent e) { e.consume(); - if (e.getWheelRotation() > 0) + double wheelRotation = e.getPreciseWheelRotation(); + if (wheelRotation > 0) { if (e.isShiftDown()) { av.getRanges().scrollRight(true); } - else if (!av.getWrapAlignment()) + else { av.getRanges().scrollUp(false); } } - else + else if (wheelRotation < 0) { if (e.isShiftDown()) { av.getRanges().scrollRight(false); } - else if (!av.getWrapAlignment()) + else { av.getRanges().scrollUp(true); } @@ -196,7 +218,14 @@ public class IdPanel extends JPanel 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); @@ -276,9 +305,16 @@ public class IdPanel extends JPanel 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; } @@ -301,19 +337,18 @@ public class IdPanel extends JPanel 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(false); + alignPanel.paintAlignment(false, false); } /** @@ -321,10 +356,9 @@ public class IdPanel extends JPanel * * @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 @@ -336,10 +370,7 @@ public class IdPanel extends JPanel { if (sf.links != null) { - for (String link : sf.links) - { - nlinks.add(link); - } + nlinks.addAll(sf.links); } } @@ -410,6 +441,12 @@ public class IdPanel extends JPanel { 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()); @@ -418,7 +455,7 @@ public class IdPanel extends JPanel if (e.isPopupTrigger()) // Windows reports this in mouseReleased { - showPopupMenu(e); + showPopupMenu(e, pos); } } @@ -508,7 +545,7 @@ public class IdPanel extends JPanel running = false; } - alignPanel.paintAlignment(false); + alignPanel.paintAlignment(false, false); try {