package jalview.commands;\r
\r
import jalview.util.ShiftList;\r
-\r
import jalview.datamodel.*;\r
+import java.util.Vector;\r
\r
public class TrimRegionCommand\r
extends EditCommand\r
\r
int [] start;\r
\r
+ ShiftList shiftList;\r
+\r
+ SequenceGroup selectionGroup;\r
+\r
+ Vector deletedHiddenColumns;\r
+\r
public TrimRegionCommand(String description,\r
String command,\r
SequenceI[] seqs,\r
int column,\r
AlignmentI al,\r
- ColumnSelection colSel)\r
+ ColumnSelection colSel,\r
+ SequenceGroup selectedRegion)\r
{\r
this.description = description;\r
+ this.selectionGroup = selectedRegion;\r
+ this.colSel = colSel;\r
if (command.equalsIgnoreCase(TRIM_LEFT))\r
{\r
edits = new Edit[] { new Edit(CUT, seqs, 0, column, al)};\r
- this.colSel = colSel;\r
}\r
else if (command.equalsIgnoreCase(TRIM_RIGHT))\r
{\r
{\r
if(command.position==0)\r
{\r
+ //This is a TRIM_LEFT command\r
column = command.seqs[j].findPosition(command.number);\r
command.seqs[j].setStart(column);\r
}\r
else\r
{\r
+ //This is a TRIM_RIGHT command\r
column = command.seqs[j].findPosition(command.position)-1;\r
command.seqs[j].setEnd(column);\r
}\r
}\r
+\r
super.cut(command);\r
+\r
+ if (command.position == 0)\r
+ {\r
+ deletedHiddenColumns = colSel.compensateForEdit(0, command.number);\r
+ if(selectionGroup!=null)\r
+ selectionGroup.adjustForRemoveLeft(command.number);\r
+ }\r
+ else\r
+ {\r
+ deletedHiddenColumns = colSel.compensateForEdit(command.position, command.number);\r
+ if(selectionGroup!=null)\r
+ selectionGroup.adjustForRemoveRight(command.position);\r
+ }\r
}\r
\r
void paste(Edit command)\r
}\r
}\r
\r
- if(command.position==0)\r
+ if (command.position == 0)\r
+ {\r
+ colSel.compensateForEdit(0, -command.number);\r
+ if(selectionGroup!=null)\r
+ selectionGroup.adjustForRemoveLeft(-command.number);\r
+ }\r
+\r
+ if (deletedHiddenColumns != null)\r
{\r
- ShiftList slist = new ShiftList();\r
- slist.addShift(0, -command.number);\r
- colSel.compensateForEdits(slist);\r
+ int[] region;\r
+ for (int i = 0; i < deletedHiddenColumns.size(); i++)\r
+ {\r
+ region = (int[]) deletedHiddenColumns.elementAt(i);\r
+ colSel.hideColumns(region[0], region[1]);\r
+ }\r
}\r
+\r
+\r
}\r
\r
}\r