enable mouseover between DNA coding regions and translated peptide location
[jalview.git] / src / jalview / gui / AlignViewport.java
index 96c1f67..eb5ef20 100755 (executable)
@@ -29,6 +29,7 @@ import jalview.bin.*;
 import jalview.datamodel.*;
 
 import jalview.schemes.*;
+import jalview.structure.StructureSelectionManager;
 
 /**
  * DOCUMENT ME!
@@ -206,7 +207,7 @@ public class AlignViewport
                 11f,
                 AlignmentAnnotation.BAR_GRAPH);
             conservation.hasText = true;
-            conservation.autoCalculated = true;
+            conservation.autoCalculated=true;
 
 
             if (Cache.getDefault("SHOW_CONSERVATION", true))
@@ -223,7 +224,7 @@ public class AlignViewport
                                                 11f,
                                                 AlignmentAnnotation.BAR_GRAPH);
               quality.hasText = true;
-              quality.autoCalculated = true;
+              quality.autoCalculated=true;
 
               alignment.addAnnotation(quality);
             }
@@ -233,7 +234,7 @@ public class AlignViewport
                                                new Annotation[1], 0f, 100f,
                                                AlignmentAnnotation.BAR_GRAPH);
           consensus.hasText = true;
-          consensus.autoCalculated = true;
+          consensus.autoCalculated=true;
 
            if (Cache.getDefault("SHOW_IDENTITY", true))
            {
@@ -300,7 +301,7 @@ public class AlignViewport
             {
               if (ap != null)
               {
-              ap.paintAlignment(true);
+                ap.paintAlignment(false);
               }
               Thread.sleep(200);
             }
@@ -496,7 +497,7 @@ public class AlignViewport
           {
             if (ap != null)
             {
-            ap.paintAlignment(true);
+            ap.paintAlignment(false);
             }
 
             Thread.sleep(200);
@@ -916,7 +917,15 @@ public class AlignViewport
      */
     public void setAlignment(AlignmentI align)
     {
+      if (alignment!=null && alignment.getCodonFrames()!=null)
+      {
+        StructureSelectionManager.getStructureSelectionManager().removeMappings(alignment.getCodonFrames());
+      }
         this.alignment = align;
+        if (alignment.getCodonFrames()!=null)
+        {
+          StructureSelectionManager.getStructureSelectionManager().addMappings(alignment.getCodonFrames());
+        }
     }
 
     /**
@@ -1466,8 +1475,10 @@ public class AlignViewport
     }
 
     /**
-     * This method returns the a new SequenceI [] with
-     * the selection sequence and start and end points adjusted
+     * This method returns an array of new SequenceI objects
+     * derived from the whole alignment or just the current
+     * selection with start and end points adjusted
+     * @note if you need references to the actual SequenceI objects in the alignment or currently selected then use getSequenceSelection()
      * @return String[]
      */
     public SequenceI[] getSelectionAsNewSequence()
@@ -1477,6 +1488,11 @@ public class AlignViewport
       if (selectionGroup == null)
     {
         sequences = alignment.getSequencesArray();
+        AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
+        for (int i=0; i<sequences.length; i++)
+        {
+          sequences[i] = new Sequence(sequences[i], annots); // construct new sequence with subset of visible annotation
+        }
     }
       else
     {
@@ -1485,7 +1501,23 @@ public class AlignViewport
 
       return sequences;
     }
-
+    /**
+     * get the currently selected sequence objects or all the sequences in the alignment.
+     * @return array of references to sequence objects
+     */
+    public SequenceI[] getSequenceSelection()
+    {
+      SequenceI[] sequences;
+      if (selectionGroup==null)
+      {
+        sequences = alignment.getSequencesArray();
+      }
+      else
+      {
+        sequences = selectionGroup.getSequencesInOrder(alignment);
+      }
+      return sequences;
+    }
     /**
      * This method returns the visible alignment as text, as
      * seen on the GUI, ie if columns are hidden they will not