adjustForRemoveLeft / Right added
authoramwaterhouse <Andrew Waterhouse>
Wed, 23 Mar 2005 16:27:38 +0000 (16:27 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 23 Mar 2005 16:27:38 +0000 (16:27 +0000)
src/jalview/datamodel/SequenceGroup.java
src/jalview/gui/AlignFrame.java

index 4c6420c..0cf954b 100755 (executable)
@@ -47,6 +47,43 @@ public class SequenceGroup
     endRes = end;\r
   }\r
 \r
+  public boolean adjustForRemoveLeft(int col)\r
+  {\r
+    // return value is true if the group still exists\r
+    if(startRes>=col)\r
+      startRes = startRes - col;\r
+    if(endRes>=col)\r
+    {\r
+      endRes = endRes - col;\r
+      if(startRes>endRes)\r
+        startRes = 0;\r
+    }\r
+    else\r
+    {\r
+        // must delete this group!!\r
+        return false;\r
+    }\r
+\r
+    return true;\r
+  }\r
+\r
+  public boolean adjustForRemoveRight(int col)\r
+  {\r
+\r
+    if(startRes>col)\r
+    {\r
+      // delete this group\r
+      return false;\r
+    }\r
+\r
+    if(endRes>=col)\r
+      endRes = col;\r
+\r
+\r
+    return true;\r
+  }\r
+\r
+\r
   public String getName()\r
   {\r
     return groupName;\r
index 7071d81..00961d6 100755 (executable)
@@ -462,6 +462,18 @@ public class AlignFrame extends GAlignFrame
       int min = colSel.getMin();\r
       viewport.getAlignment().trimLeft(min);\r
       colSel.compensateForEdit(0,min);\r
+\r
+      if(viewport.getSelectionGroup()!=null)\r
+        viewport.getSelectionGroup().adjustForRemoveLeft(min);\r
+\r
+      Vector groups = viewport.alignment.getGroups();\r
+      for(int i=0; i<groups.size(); i++)\r
+      {\r
+        SequenceGroup sg = (SequenceGroup) groups.get(i);\r
+        if(!sg.adjustForRemoveLeft(min))\r
+          viewport.alignment.deleteGroup(sg);\r
+      }\r
+\r
       alignPanel.RefreshPanels();\r
     }\r
   }\r
@@ -473,8 +485,19 @@ public class AlignFrame extends GAlignFrame
     if (colSel.size() > 0)\r
     {\r
       int max = colSel.getMax();\r
-      if(max>1)\r
-        viewport.getAlignment().trimRight(max);\r
+      viewport.getAlignment().trimRight(max);\r
+      if(viewport.getSelectionGroup()!=null)\r
+        viewport.getSelectionGroup().adjustForRemoveRight(max);\r
+\r
+      Vector groups = viewport.alignment.getGroups();\r
+      for(int i=0; i<groups.size(); i++)\r
+      {\r
+        SequenceGroup sg = (SequenceGroup) groups.get(i);\r
+        if(!sg.adjustForRemoveRight(max))\r
+          viewport.alignment.deleteGroup(sg);\r
+      }\r
+\r
+\r
 \r
       alignPanel.RefreshPanels();\r
     }\r