JAL-1674 more correct status bars in splitframe mouseover (applet)
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 25 Aug 2015 09:42:45 +0000 (10:42 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 25 Aug 2015 09:42:45 +0000 (10:42 +0100)
src/jalview/appletgui/SeqPanel.java

index 86dedfc..700f82d 100644 (file)
  */
 package jalview.appletgui;
 
-import java.awt.BorderLayout;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Panel;
-import java.awt.Point;
-import java.awt.event.InputEvent;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseMotionListener;
-import java.util.List;
-import java.util.Vector;
-
 import jalview.api.AlignViewportI;
 import jalview.commands.EditCommand;
 import jalview.commands.EditCommand.Action;
+import jalview.datamodel.AlignmentI;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.SearchResults;
 import jalview.datamodel.SearchResults.Match;
@@ -52,6 +41,17 @@ import jalview.util.MappingUtils;
 import jalview.util.MessageManager;
 import jalview.viewmodel.AlignmentViewport;
 
+import java.awt.BorderLayout;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.util.Vector;
+
 public class SeqPanel extends Panel implements MouseMotionListener,
         MouseListener, SequenceListener, SelectionListener
 {
@@ -483,23 +483,33 @@ public class SeqPanel extends Panel implements MouseMotionListener,
    * search results.
    * 
    * @param results
+   * @return true if results were matched, false if not
    */
-  private void setStatusMessage(SearchResults results)
+  private boolean setStatusMessage(SearchResults results)
   {
-    List<Match> matches = results.getResults();
-    if (!matches.isEmpty())
+    AlignmentI al = this.av.getAlignment();
+    int sequenceIndex = al.findIndex(results);
+    if (sequenceIndex == -1)
+    {
+      return false;
+    }
+    SequenceI ds = al.getSequenceAt(sequenceIndex).getDatasetSequence();
+    for (Match m : results.getResults())
     {
-      Match m = matches.get(0);
       SequenceI seq = m.getSequence();
-      int sequenceIndex = this.av.getAlignment().findIndex(seq);
 
-      /*
-       * Convert position in sequence (base 1) to sequence character array index
-       * (base 0)
-       */
-      int start = m.getStart() - 1;
-      setStatusMessage(seq, start, sequenceIndex);
+      if (seq == ds)
+      {
+        /*
+         * Convert position in sequence (base 1) to sequence character array
+         * index (base 0)
+         */
+        int start = m.getStart() - 1;
+        setStatusMessage(seq, start, sequenceIndex);
+        return true;
+      }
     }
+    return false;
   }
 
   public void mousePressed(MouseEvent evt)