refactor to allow distinct StructureSelectionManager instances for
[jalview.git] / src / jalview / appletgui / SeqPanel.java
old mode 100755 (executable)
new mode 100644 (file)
index 98dcc07..ade0afd
@@ -91,7 +91,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
 
     seqCanvas.addMouseMotionListener(this);
     seqCanvas.addMouseListener(this);
-    ssm = StructureSelectionManager.getStructureSelectionManager();
+    ssm = StructureSelectionManager.getStructureSelectionManager(av.applet);
     ssm.addStructureViewerListener(this);
 
     seqCanvas.repaint();
@@ -632,18 +632,22 @@ public class SeqPanel extends Panel implements MouseMotionListener,
   {
     String tmp = sequence.hashCode() + index + "";
     if (lastMessage == null || !lastMessage.equals(tmp))
-      ssm.mouseOverSequence(sequence, index, pos);
+      ssm.mouseOverSequence(sequence, index, pos, av);
 
     lastMessage = tmp;
   }
 
   public void highlightSequence(SearchResults results)
   {
-    seqCanvas.highlightSearchResults(results);
     if (av.followHighlight)
     {
-      ap.scrollToPosition(results);
+      if (ap.scrollToPosition(results, true))
+      {
+        ap.alignFrame.repaint();
+      }
     }
+    seqCanvas.highlightSearchResults(results);
+
   }
 
   public void updateColours(SequenceI seq, int index)
@@ -1683,6 +1687,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       }
     }
   }
+
   /**
    * modify current selection according to a received message.
    */
@@ -1693,9 +1698,8 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     // handles selection messages...
     // TODO: extend config options to allow user to control if selections may be
     // shared between viewports.
-    if (av!=null && (av == source
-            || !av.followSelection
-            || (source instanceof AlignViewport && ((AlignViewport) source)
+    if (av != null
+            && (av == source || !av.followSelection || (source instanceof AlignViewport && ((AlignViewport) source)
                     .getSequenceSetId().equals(av.getSequenceSetId()))))
     {
       return;
@@ -1708,13 +1712,15 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     if (av.selectionGroup == null || !av.isSelectionGroupChanged())
     {
       SequenceGroup sgroup = null;
-      if (seqsel != null)
+      if (seqsel != null && seqsel.getSize()>0)
       {
         if (av.alignment == null)
         {
-          System.out.println("Selection message: alignviewport av SeqSetId="
-                  + av.getSequenceSetId() + " ViewId=" + av.getViewId()
-                  + " 's alignment is NULL! returning immediatly.");
+          System.out
+                  .println("Selection message: alignviewport av SeqSetId="
+                          + av.getSequenceSetId() + " ViewId="
+                          + av.getViewId()
+                          + " 's alignment is NULL! returning immediatly.");
           return;
         }
         sgroup = seqsel.intersect(av.alignment,
@@ -1768,10 +1774,22 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     }
     if (repaint)
     {
-      // probably finessing with multiple redraws here
-      PaintRefresher.Refresh(this, av.getSequenceSetId());
-      // ap.paintAlignment(false);
+      ap.repaint();
+      //ap.paintAlignment(false);
     }
   }
 
+  /**
+   * scroll to the given row/column - or nearest visible location
+   * @param row
+   * @param column
+   */
+  public void scrollTo(int row, int column)
+  {
+    
+    row = row<0 ? ap.av.startSeq : row;
+    column = column<0 ? ap.av.startRes : column;
+    ap.scrollTo(row, row, column, true, true);
+  }
+
 }