--- /dev/null
+ /*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
+package jalview.commands;\r
+\r
+import jalview.datamodel.*;\r
+\r
+public class ChangeCaseCommand implements CommandI\r
+{\r
+ String description;\r
+ public static int TO_LOWER = 0;\r
+ public static int TO_UPPER = 1;\r
+ public static int TOGGLE_CASE = 2;\r
+ int caseChange = -1;\r
+ SequenceI [] seqs;\r
+ int [][] regions;\r
+ public ChangeCaseCommand(String description,\r
+ SequenceI[] seqs,\r
+ int [][] regions,\r
+ int caseChange)\r
+ {\r
+ this.description = description;\r
+ this.seqs = seqs;\r
+ this.regions = regions;\r
+ this.caseChange = caseChange;\r
+ doCommand();\r
+ }\r
+\r
+ public String getDescription()\r
+ {\r
+ return description;\r
+ }\r
+\r
+ public int getSize()\r
+ {\r
+ return 1;\r
+ }\r
+\r
+ public void doCommand()\r
+ {\r
+ changeCase(true);\r
+ }\r
+\r
+ public void undoCommand()\r
+ {\r
+ changeCase(false);\r
+ }\r
+\r
+ void changeCase(boolean doCommand)\r
+ {\r
+ String sequence;\r
+ int start, end;\r
+ char nextChar;\r
+ for (int r = 0; r < regions.length; r++)\r
+ {\r
+ start = regions[r][0];\r
+ end = regions[r][1];\r
+ for (int s = 0; s < seqs.length; s++)\r
+ {\r
+ sequence = seqs[s].getSequence();\r
+ StringBuffer newSeq = new StringBuffer();\r
+\r
+ if (end > sequence.length())\r
+ end = sequence.length();\r
+\r
+ if (start > 0)\r
+ {\r
+ newSeq.append(sequence.substring(0, start));\r
+ }\r
+\r
+ if ( (caseChange == TO_UPPER && doCommand)\r
+ || (caseChange == TO_LOWER && !doCommand))\r
+ newSeq.append(sequence.substring(start, end).toUpperCase());\r
+\r
+ else if ( (caseChange == TO_LOWER && doCommand)\r
+ || (caseChange == TO_UPPER && !doCommand))\r
+ newSeq.append(sequence.substring(start, end).toLowerCase());\r
+\r
+ else //TOGGLE CASE\r
+ {\r
+ for (int c = start; c < end; c++)\r
+ {\r
+ nextChar = sequence.charAt(c);\r
+ if ('a' <= nextChar && nextChar <= 'z')\r
+ {\r
+ // TO UPPERCASE !!!\r
+ nextChar -= ('a' - 'A');\r
+ }\r
+ else if ('A' <= nextChar && nextChar <= 'Z')\r
+ {\r
+ // TO LOWERCASE !!!\r
+ nextChar += ('a' - 'A');\r
+ }\r
+ newSeq.append(nextChar);\r
+ }\r
+ }\r
+\r
+ if (end < sequence.length())\r
+ newSeq.append(sequence.substring(end));\r
+\r
+ seqs[s].setSequence(newSeq.toString());\r
+ }\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
+package jalview.commands;\r
+\r
+public interface CommandI\r
+{\r
+ public void doCommand();\r
+\r
+ public void undoCommand();\r
+\r
+ public String getDescription();\r
+\r
+ public int getSize();\r
+}\r
--- /dev/null
+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
+package jalview.commands;\r
+\r
+import jalview.datamodel.*;\r
+\r
+/**\r
+ *\r
+ * <p>Title: EditCommmand</p>\r
+ *\r
+ * <p>Description: Essential information for performing\r
+ * undo and redo for cut/paste insert/delete gap\r
+ * which can be stored in the HistoryList </p>\r
+ *\r
+ * <p>Copyright: Copyright (c) 2006</p>\r
+ *\r
+ * <p>Company: Dundee University</p>\r
+ *\r
+ * @author not attributable\r
+ * @version 1.0\r
+ */\r
+public class EditCommand implements CommandI\r
+{\r
+ public static String INSERT_GAP = "InsertGap";\r
+ public static String DELETE_GAP = "DeleteGap";\r
+ public static String CUT = "Cut";\r
+ public static String PASTE = "Paste";\r
+\r
+ Edit[] edits;\r
+\r
+ String description;\r
+\r
+ public EditCommand()\r
+ {}\r
+\r
+ public EditCommand(String description)\r
+ {\r
+ this.description = description;\r
+ }\r
+\r
+ public EditCommand(String description,\r
+ String command,\r
+ SequenceI[] seqs,\r
+ int position,\r
+ int number,\r
+ char gapChar)\r
+ {\r
+ this.description = description;\r
+\r
+ if (command.equalsIgnoreCase(INSERT_GAP)\r
+ || command.equalsIgnoreCase(DELETE_GAP))\r
+ {\r
+ edits = new Edit[] { new Edit(command, seqs, position, number, gapChar)};\r
+ }\r
+\r
+ performEdit(0);\r
+ }\r
+\r
+ public EditCommand( String description,\r
+ String command,\r
+ SequenceI[] seqs,\r
+ int position,\r
+ int number,\r
+ AlignmentI al)\r
+ {\r
+ this.description = description;\r
+ if ( command.equalsIgnoreCase(CUT) || command.equalsIgnoreCase(PASTE))\r
+ {\r
+ edits = new Edit[]{new Edit(command, seqs, position, number, al)};\r
+ }\r
+\r
+ performEdit(0);\r
+ }\r
+\r
+\r
+ public String getDescription()\r
+ {\r
+ return description;\r
+ }\r
+\r
+ public int getSize()\r
+ {\r
+ return edits==null?0:edits.length;\r
+ }\r
+\r
+\r
+ public void appendEdit(String command,\r
+ SequenceI[] seqs,\r
+ int position,\r
+ int number,\r
+ char gapChar,\r
+ boolean performEdit)\r
+ {\r
+ Edit edit = new Edit(command, seqs, position, number, gapChar);\r
+\r
+ if (edits != null)\r
+ {\r
+ Edit[] temp = new Edit[edits.length + 1];\r
+ System.arraycopy(edits, 0, temp, 0, edits.length);\r
+ edits = temp;\r
+ edits[edits.length - 1] = edit;\r
+ }\r
+ else\r
+ edits = new Edit[] { edit };\r
+\r
+ if (performEdit)\r
+ performEdit(edits.length - 1);\r
+ }\r
+\r
+ void performEdit(int commandIndex)\r
+ {\r
+ int eSize = edits.length;\r
+ for (int e = commandIndex; e < eSize; e++)\r
+ {\r
+ if (edits[e].command.equals(INSERT_GAP))\r
+ {\r
+ insertGap(edits[e]);\r
+ }\r
+ else if (edits[e].command.equals(DELETE_GAP))\r
+ {\r
+ deleteGap(edits[e]);\r
+ }\r
+ else if(edits[e].command.equals(CUT))\r
+ {\r
+ cut(edits[e]);\r
+ }\r
+ else if(edits[e].command.equals(PASTE))\r
+ {\r
+ paste(edits[e]);\r
+ }\r
+ }\r
+ }\r
+\r
+ public void doCommand()\r
+ {\r
+ performEdit(0);\r
+ }\r
+\r
+ public void undoCommand()\r
+ {\r
+ int e = 0, eSize = edits.length;\r
+ for (e = eSize-1; e > -1; e--)\r
+ {\r
+ if (edits[e].command.equals(INSERT_GAP))\r
+ {\r
+ deleteGap(edits[e]);\r
+ }\r
+ else if (edits[e].command.equals(DELETE_GAP))\r
+ {\r
+ insertGap(edits[e]);\r
+ }\r
+ else if (edits[e].command.equals(CUT))\r
+ {\r
+ paste(edits[e]);\r
+ }\r
+ else if (edits[e].command.equals(PASTE))\r
+ {\r
+ cut(edits[e]);\r
+ }\r
+ }\r
+ }\r
+\r
+ void insertGap(Edit command)\r
+ {\r
+ for(int s=0; s<command.seqs.length; s++)\r
+ {\r
+ command.seqs[s].insertCharAt(command.position,\r
+ command.number,\r
+ command.gapChar);\r
+ }\r
+ }\r
+\r
+ void deleteGap(Edit command)\r
+ {\r
+ for (int s = 0; s < command.seqs.length; s++)\r
+ {\r
+ command.seqs[s].deleteChars(command.position, command.position+command.number);\r
+ }\r
+ }\r
+\r
+ void cut(Edit command)\r
+ {\r
+ command.string = new String [command.seqs.length];\r
+\r
+ for(int i=0; i<command.seqs.length; i++)\r
+ {\r
+ command.string[i] = command.seqs[i].getSequence(command.position,\r
+ command.position + command.number);\r
+\r
+ command.seqs[i].deleteChars(command.position,\r
+ command.position+command.number);\r
+\r
+ if(command.seqs[i].getLength()<1)\r
+ {\r
+ command.al.deleteSequence(command.seqs[i]);\r
+ }\r
+ }\r
+ }\r
+\r
+ void paste(Edit command)\r
+ {\r
+ StringBuffer tmp;\r
+ for(int i=0; i<command.seqs.length; i++)\r
+ {\r
+ if(command.seqs[i].getLength()<1)\r
+ {\r
+ // ie this sequence was deleted, we need to\r
+ // read it to the alignment\r
+ if (command.alIndex[i] < command.al.getHeight())\r
+ command.al.getSequences().insertElementAt(command.seqs[i],\r
+ command.alIndex[i]);\r
+ else\r
+ command.al.addSequence(command.seqs[i]);\r
+ }\r
+ tmp = new StringBuffer(command.seqs[i].getSequence());\r
+ if(command.string!=null)\r
+ {\r
+ tmp.insert(command.position, command.string[i]);\r
+ command.string[i] = null;\r
+ }\r
+ command.seqs[i].setSequence(tmp.toString());\r
+ }\r
+\r
+ command.string = null;\r
+ }\r
+\r
+ class Edit\r
+ {\r
+ AlignmentI al;\r
+ String command;\r
+ String [] string;\r
+ SequenceI[] seqs;\r
+ int [] alIndex;\r
+ int position, number;\r
+ char gapChar;\r
+\r
+ Edit(String command,\r
+ SequenceI[] seqs,\r
+ int position,\r
+ int number,\r
+ char gapChar)\r
+ {\r
+ this.command = command;\r
+ this.seqs = seqs;\r
+ this.position = position;\r
+ this.number = number;\r
+ this.gapChar = gapChar;\r
+ }\r
+\r
+\r
+ Edit(String command,\r
+ SequenceI[] seqs,\r
+ int position,\r
+ int number,\r
+ AlignmentI al)\r
+ {\r
+ this.command = command;\r
+ this.seqs = seqs;\r
+ this.position = position;\r
+ this.number = number;\r
+ this.al = al;\r
+ alIndex = new int[seqs.length];\r
+ for(int i=0; i<seqs.length; i++)\r
+ alIndex[i] = al.findIndex(seqs[i]);\r
+ }\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+ /*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
+package jalview.commands;\r
+\r
+import jalview.datamodel.*;\r
+\r
+import jalview.analysis.AlignmentSorter;\r
+\r
+public class OrderCommand implements CommandI\r
+{\r
+ String description;\r
+ SequenceI [] seqs;\r
+ SequenceI [] seqs2;\r
+ AlignmentI al;\r
+\r
+ public OrderCommand(String description,\r
+ SequenceI[] seqs,\r
+ AlignmentI al)\r
+ {\r
+ this.description = description;\r
+ this.seqs = seqs;\r
+ this.seqs2 = al.getSequencesArray();\r
+ this.al = al;\r
+ doCommand();\r
+ }\r
+\r
+ public String getDescription()\r
+ {\r
+ return description;\r
+ }\r
+\r
+ public int getSize()\r
+ {\r
+ return 1;\r
+ }\r
+\r
+ public void doCommand()\r
+ {\r
+ AlignmentSorter.setOrder(al, seqs2);\r
+ }\r
+\r
+ public void undoCommand()\r
+ {\r
+ AlignmentSorter.setOrder(al, seqs);\r
+ }\r
+}\r
--- /dev/null
+package jalview.commands;\r
+ /*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
+\r
+import jalview.datamodel.*;\r
+\r
+public class RemoveGapColCommand extends EditCommand\r
+{\r
+ public RemoveGapColCommand(String description,\r
+ SequenceI[] seqs,\r
+ int start, int end, char gapChar)\r
+ {\r
+ this.description = description;\r
+\r
+ int j, jSize = seqs.length;\r
+\r
+ int startCol = -1, endCol = -1;\r
+ int deletedCols = 0;\r
+\r
+ edits = new Edit[0];\r
+\r
+ boolean delete = true;\r
+ for (int i = start; i <= end; i++)\r
+ {\r
+ delete = true;\r
+\r
+ for (j = 0; j < jSize; j++)\r
+ {\r
+ if (seqs[j].getLength() > i)\r
+ {\r
+ if (!jalview.util.Comparison.isGap(seqs[j].getCharAt(i)))\r
+ {\r
+ if (delete)\r
+ endCol = i;\r
+\r
+ delete = false;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ if (delete && startCol == -1)\r
+ {\r
+ startCol = i;\r
+ }\r
+\r
+ if (!delete && startCol > -1)\r
+ {\r
+ this.appendEdit(DELETE_GAP, seqs,\r
+ startCol - deletedCols,\r
+ endCol - startCol,\r
+ gapChar,\r
+ false);\r
+\r
+ deletedCols += (endCol - startCol);\r
+ startCol = -1;\r
+ endCol = -1;\r
+ }\r
+ }\r
+\r
+ if (delete && startCol > -1)\r
+ {\r
+ //This is for empty columns at the\r
+ //end of the alignment\r
+ int width = end-endCol;\r
+\r
+ if(endCol==-1)\r
+ width = end-start+1;\r
+\r
+\r
+ this.appendEdit(DELETE_GAP, seqs,\r
+ startCol - deletedCols,\r
+ width,\r
+ gapChar,\r
+ false);\r
+ }\r
+\r
+ performEdit(0);\r
+ }\r
+\r
+}\r
--- /dev/null
+package jalview.commands;\r
+ /*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
+\r
+import jalview.datamodel.*;\r
+\r
+public class RemoveGapsCommand extends EditCommand\r
+{\r
+ public RemoveGapsCommand( String description,\r
+ SequenceI[] seqs, char gapChar)\r
+ {\r
+ this.description = description;\r
+ int width = 0;\r
+ for(int i=0; i<seqs.length; i++)\r
+ if(seqs[i].getLength()>width)\r
+ width = seqs[i].getLength();\r
+\r
+ findGaps(seqs, 0, width, gapChar);\r
+ }\r
+\r
+ public RemoveGapsCommand( String description,\r
+ SequenceI[] seqs,\r
+ int start, int end, char gapChar)\r
+ {\r
+ this.description = description;\r
+ findGaps(seqs, start, end, gapChar);\r
+ }\r
+\r
+ void findGaps(SequenceI [] seqs, int start, int end, char gapChar)\r
+ {\r
+\r
+ int startCol = -1, endCol = -1;\r
+ int deletedCols = 0;\r
+\r
+ edits = new Edit[0];\r
+\r
+ boolean delete = true;\r
+ char [] sequence;\r
+ for(int s=0; s<seqs.length; s++)\r
+ {\r
+ deletedCols = 0;\r
+ startCol = -1;\r
+ endCol = -1;\r
+ sequence = seqs[s].getSequence().toCharArray();\r
+ for (int i = start; i < end; i++)\r
+ {\r
+ delete = true;\r
+\r
+ if (!jalview.util.Comparison.isGap(sequence[i]))\r
+ {\r
+ if (delete)\r
+ endCol = i;\r
+\r
+ delete = false;\r
+ }\r
+\r
+ if (delete && startCol == -1)\r
+ {\r
+ startCol = i;\r
+ }\r
+\r
+ if (!delete && startCol > -1)\r
+ {\r
+ this.appendEdit(DELETE_GAP, new SequenceI[]{seqs[s]},\r
+ startCol - deletedCols,\r
+ endCol - startCol,\r
+ gapChar,\r
+ false);\r
+\r
+ deletedCols += (endCol - startCol);\r
+ startCol = -1;\r
+ endCol = -1;\r
+ }\r
+ }\r
+ if (delete && startCol > -1)\r
+ {\r
+ int width = end - endCol;\r
+\r
+ if (endCol == -1)\r
+ width = end - start + 1;\r
+\r
+ //This is the end of the region.\r
+ this.appendEdit(DELETE_GAP, new SequenceI[]{seqs[s]},\r
+ startCol - deletedCols,\r
+ width,\r
+ gapChar,\r
+ false);\r
+ }\r
+\r
+ }\r
+\r
+ performEdit(0);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
+package jalview.commands;\r
+\r
+import jalview.util.ShiftList;\r
+\r
+import jalview.datamodel.*;\r
+\r
+public class TrimRegionCommand\r
+ extends EditCommand\r
+{\r
+ public static String TRIM_LEFT = "TrimLeft";\r
+ public static String TRIM_RIGHT = "TrimRight";\r
+\r
+ public ColumnSelection colSel = null;\r
+\r
+ int [] start;\r
+\r
+ public TrimRegionCommand(String description,\r
+ String command,\r
+ SequenceI[] seqs,\r
+ int column,\r
+ AlignmentI al,\r
+ ColumnSelection colSel)\r
+ {\r
+ this.description = description;\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
+ edits = new Edit[]\r
+ { new Edit(CUT, seqs, column+1, al.getWidth() - column, al)};\r
+ }\r
+\r
+ //We need to keep a record of the sequence start\r
+ //in order to restore the state after a redo\r
+ int i, isize = edits[0].seqs.length;\r
+ start = new int[isize];\r
+ for(i=0; i<isize; i++)\r
+ start[i] = edits[0].seqs[i].getStart();\r
+\r
+ performEdit(0);\r
+ }\r
+\r
+ void cut(Edit command)\r
+ {\r
+ int column, j, jSize = command.seqs.length;\r
+ for (j = 0; j < jSize; j++)\r
+ {\r
+ if(command.position==0)\r
+ {\r
+ column = command.seqs[j].findPosition(command.number);\r
+ command.seqs[j].setStart(column);\r
+ }\r
+ else\r
+ {\r
+ column = command.seqs[j].findPosition(command.position)-1;\r
+ command.seqs[j].setEnd(column);\r
+ }\r
+ }\r
+ super.cut(command);\r
+ }\r
+\r
+ void paste(Edit command)\r
+ {\r
+ super.paste(command);\r
+ int column, j, jSize = command.seqs.length;\r
+ for (j = 0; j < jSize; j++)\r
+ {\r
+ if(command.position==0)\r
+ {\r
+ command.seqs[j].setStart(start[j]);\r
+ }\r
+ else\r
+ {\r
+ column = command.seqs[j]\r
+ .findPosition(command.number+command.position)-1;\r
+ command.seqs[j].setEnd(column);\r
+ }\r
+ }\r
+\r
+ if(command.position==0)\r
+ {\r
+ ShiftList slist = new ShiftList();\r
+ slist.addShift(0, -command.number);\r
+ colSel.compensateForEdits(slist);\r
+ }\r
+ }\r
+\r
+}\r