JAL-516 JAL-759 JAL-1066 group & group colourscheme always gets notified when group...
[jalview.git] / src / jalview / appletgui / SeqPanel.java
index f121d11..a7345db 100644 (file)
@@ -287,7 +287,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       else
       {
         // Now add any sequences between min and max
-        sg.getSequences(null).removeAllElements();
+        sg.clear();
         for (int i = min; i < max; i++)
         {
           sg.addSequence(av.getAlignment().getSequenceAt(i), false);
@@ -1036,13 +1036,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
 
     if (groupEditing)
     {
-      Vector vseqs = sg.getSequences(av.getHiddenRepSequences());
-      int g, groupSize = vseqs.size();
-      SequenceI[] groupSeqs = new SequenceI[groupSize];
-      for (g = 0; g < groupSeqs.length; g++)
-      {
-        groupSeqs[g] = (SequenceI) vseqs.elementAt(g);
-      }
+      SequenceI[] groupSeqs = sg.getSequences(av.getHiddenRepSequences()).toArray(new SequenceI[0]);
 
       // drag to right
       if (insertGap)
@@ -1064,11 +1058,11 @@ public class SeqPanel extends Panel implements MouseMotionListener,
         {
           blank = true;
 
-          for (g = 0; g < groupSize; g++)
+          for (SequenceI gs:groupSeqs)
           {
             for (int j = 0; j < startres - lastres; j++)
             {
-              if (!jalview.util.Comparison.isGap(groupSeqs[g]
+              if (!jalview.util.Comparison.isGap(gs
                       .getCharAt(fixedRight - j)))
               {
                 blank = false;
@@ -1121,16 +1115,16 @@ public class SeqPanel extends Panel implements MouseMotionListener,
         // / Are we able to delete?
         // ie are all columns blank?
 
-        for (g = 0; g < groupSize; g++)
+        for (SequenceI gs:groupSeqs)
         {
           for (int j = startres; j < lastres; j++)
           {
-            if (groupSeqs[g].getLength() <= j)
+            if (gs.getLength() <= j)
             {
               continue;
             }
 
-            if (!jalview.util.Comparison.isGap(groupSeqs[g].getCharAt(j)))
+            if (!jalview.util.Comparison.isGap(gs.getCharAt(j)))
             {
               // Not a gap, block edit not valid
               endEditing();
@@ -1417,28 +1411,16 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       return;
     }
 
+    stretchGroup.recalcConservation(); // always do this - annotation has own
+                                       // state
     if (stretchGroup.cs != null)
     {
-      if (stretchGroup.cs instanceof ClustalxColourScheme)
-      {
-        ((ClustalxColourScheme) stretchGroup.cs).resetClustalX(
-                stretchGroup.getSequences(av.getHiddenRepSequences()),
-                stretchGroup.getWidth());
-      }
-
-      if (stretchGroup.cs instanceof Blosum62ColourScheme
-              || stretchGroup.cs instanceof PIDColourScheme
-              || stretchGroup.cs.conservationApplied()
-              || stretchGroup.cs.getThreshold() > 0)
-      {
-        stretchGroup.recalcConservation();
-      }
-
+      stretchGroup.cs.alignmentChanged(stretchGroup,av.getHiddenRepSequences());
+      
       if (stretchGroup.cs.conservationApplied())
       {
         SliderPanel.setConservationSlider(ap, stretchGroup.cs,
                 stretchGroup.getName());
-        stretchGroup.recalcConservation();
       }
       else
       {
@@ -1787,7 +1769,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     
     row = row<0 ? ap.av.startSeq : row;
     column = column<0 ? ap.av.startRes : column;
-    ap.scrollTo(row, row, column, true, true);
+    ap.scrollTo(column, column, row, true, true);
   }
   /**
    * scroll to the given row - or nearest visible location
@@ -1797,7 +1779,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
   {
     
     row = row<0 ? ap.av.startSeq : row;
-    ap.scrollTo(row, row, ap.av.startRes, true, true);
+    ap.scrollTo(ap.av.startRes, ap.av.startRes, row, true, true);
   }
   /**
    * scroll to the given column - or nearest visible location
@@ -1807,7 +1789,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
   {
     
     column = column<0 ? ap.av.startRes : column;
-    ap.scrollTo(ap.av.startRes, ap.av.startRes, column, true, true);
+    ap.scrollTo( column, column, ap.av.startSeq, true, true);
   }
 
 }