JAL-1807 explicit imports (jalview.gui)
[jalview.git] / src / jalview / gui / SeqPanel.java
index afd3242..875b3a7 100644 (file)
@@ -21,6 +21,7 @@
 package jalview.gui;
 
 import jalview.api.AlignViewportI;
+import jalview.bin.Cache;
 import jalview.commands.EditCommand;
 import jalview.commands.EditCommand.Action;
 import jalview.commands.EditCommand.Edit;
@@ -167,6 +168,13 @@ public class SeqPanel extends JPanel implements MouseListener,
 
   int wrappedBlock = -1;
 
+  /**
+   * Returns the aligned sequence position (base 0) at the mouse position, or
+   * the closest visible one
+   * 
+   * @param evt
+   * @return
+   */
   int findRes(MouseEvent evt)
   {
     int res = 0;
@@ -203,13 +211,18 @@ public class SeqPanel extends JPanel implements MouseListener,
     }
     else
     {
-      if (x > seqCanvas.getWidth() + seqCanvas.getWidth())
+      if (x > seqCanvas.getX() + seqCanvas.getWidth())
       {
         // make sure we calculate relative to visible alignment, rather than
         // right-hand gutter
         x = seqCanvas.getX() + seqCanvas.getWidth();
       }
       res = (x / av.getCharWidth()) + av.getStartRes();
+      if (res > av.getEndRes())
+      {
+        // moused off right
+        res = av.getEndRes();
+      }
     }
 
     if (av.hasHiddenColumns())
@@ -647,8 +660,15 @@ public class SeqPanel extends JPanel implements MouseListener,
   @Override
   public void highlightSequence(SearchResults results)
   {
-    if (av.followHighlight)
+    if (av.isFollowHighlight())
     {
+      /*
+       * if scrollToPosition requires a scroll adjustment, this flag prevents
+       * another scroll event being propagated back to the originator
+       * 
+       * @see AlignmentPanel#adjustmentValueChanged
+       */
+      ap.setFollowingComplementScroll(true);
       if (ap.scrollToPosition(results, false))
       {
         seqCanvas.revalidate();
@@ -1122,7 +1142,7 @@ public class SeqPanel extends JPanel implements MouseListener,
           {
             for (int j = 0; j < startres - lastres; j++)
             {
-              if (!jalview.util.Comparison.isGap(groupSeqs[g]
+              if (!Comparison.isGap(groupSeqs[g]
                       .getCharAt(fixedRight - j)))
               {
                 blank = false;
@@ -1185,7 +1205,7 @@ public class SeqPanel extends JPanel implements MouseListener,
               continue;
             }
 
-            if (!jalview.util.Comparison.isGap(groupSeqs[g].getCharAt(j)))
+            if (!Comparison.isGap(groupSeqs[g].getCharAt(j)))
             {
               // Not a gap, block edit not valid
               endEditing();
@@ -1320,7 +1340,7 @@ public class SeqPanel extends JPanel implements MouseListener,
 
       for (blankColumn = fixedColumn; blankColumn > j; blankColumn--)
       {
-        if (jalview.util.Comparison.isGap(seq[s].getCharAt(blankColumn)))
+        if (Comparison.isGap(seq[s].getCharAt(blankColumn)))
         {
           // Theres a space, so break and insert the gap
           break;
@@ -1566,7 +1586,7 @@ public class SeqPanel extends JPanel implements MouseListener,
         }
       }
 
-      jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(ap, null, links);
+      PopupMenu pop = new PopupMenu(ap, null, links);
       pop.show(this, evt.getX(), evt.getY());
       return;
     }
@@ -1908,7 +1928,7 @@ public class SeqPanel extends JPanel implements MouseListener,
     {
       if (av.getAlignment() == null)
       {
-        jalview.bin.Cache.log.warn("alignviewport av SeqSetId="
+        Cache.log.warn("alignviewport av SeqSetId="
                 + av.getSequenceSetId() + " ViewId=" + av.getViewId()
                 + " 's alignment is NULL! returning immediately.");
         return;