X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fcommands%2FEditCommand.java;h=be11d44706d8adfc9555250d5d15e3874f6423e6;hb=5951e3b0b9faea1c8b54914cb64ff3a08ba27cb6;hp=7218115323f4e4994994b814cd173b1ccbe42560;hpb=91d2b7cf873f1437a3e21049c5aa6c7a7117e820;p=jalview.git diff --git a/src/jalview/commands/EditCommand.java b/src/jalview/commands/EditCommand.java index 7218115..be11d44 100644 --- a/src/jalview/commands/EditCommand.java +++ b/src/jalview/commands/EditCommand.java @@ -37,10 +37,10 @@ import jalview.datamodel.*; */ public class EditCommand implements CommandI { - public static String INSERT_GAP = "InsertGap"; - public static String DELETE_GAP = "DeleteGap"; - public static String CUT = "Cut"; - public static String PASTE = "Paste"; + public static final int INSERT_GAP = 0; + public static final int DELETE_GAP = 1; + public static final int CUT = 2; + public static final int PASTE = 3; Edit[] edits; @@ -55,7 +55,7 @@ public class EditCommand implements CommandI } public EditCommand(String description, - String command, + int command, SequenceI[] seqs, int position, int number, @@ -63,8 +63,7 @@ public class EditCommand implements CommandI { this.description = description; - if (command.equalsIgnoreCase(INSERT_GAP) - || command.equalsIgnoreCase(DELETE_GAP)) + if (command==INSERT_GAP || command==DELETE_GAP) { edits = new Edit[] { new Edit(command, seqs, position, number, gapChar)}; } @@ -73,14 +72,14 @@ public class EditCommand implements CommandI } public EditCommand( String description, - String command, + int command, SequenceI[] seqs, int position, int number, AlignmentI al) { this.description = description; - if ( command.equalsIgnoreCase(CUT) || command.equalsIgnoreCase(PASTE)) + if ( command==CUT || command==PASTE) { edits = new Edit[]{new Edit(command, seqs, position, number, al)}; } @@ -99,8 +98,13 @@ public class EditCommand implements CommandI return edits==null?0:edits.length; } + public AlignmentI getAlignment() + { + return edits[0].al; + } + - public void appendEdit(String command, + public void appendEdit(int command, SequenceI[] seqs, int position, int number, @@ -128,19 +132,19 @@ public class EditCommand implements CommandI int eSize = edits.length; for (int e = commandIndex; e < eSize; e++) { - if (edits[e].command.equals(INSERT_GAP)) + if (edits[e].command==INSERT_GAP) { insertGap(edits[e]); } - else if (edits[e].command.equals(DELETE_GAP)) + else if (edits[e].command==DELETE_GAP) { deleteGap(edits[e]); } - else if(edits[e].command.equals(CUT)) + else if(edits[e].command==CUT) { cut(edits[e]); } - else if(edits[e].command.equals(PASTE)) + else if(edits[e].command==PASTE) { paste(edits[e]); } @@ -157,19 +161,19 @@ public class EditCommand implements CommandI int e = 0, eSize = edits.length; for (e = eSize-1; e > -1; e--) { - if (edits[e].command.equals(INSERT_GAP)) + if (edits[e].command==INSERT_GAP) { deleteGap(edits[e]); } - else if (edits[e].command.equals(DELETE_GAP)) + else if (edits[e].command==DELETE_GAP) { insertGap(edits[e]); } - else if (edits[e].command.equals(CUT)) + else if (edits[e].command==CUT) { paste(edits[e]); } - else if (edits[e].command.equals(PASTE)) + else if (edits[e].command==PASTE) { cut(edits[e]); } @@ -196,7 +200,7 @@ public class EditCommand implements CommandI void cut(Edit command) { - command.string = new String [command.seqs.length]; + command.string = new char [command.seqs.length][]; for(int i=0; i=tmp.length()) + { + //This occurs if padding is on, and residues + //are removed from end of alignment + int length = command.position-tmp.length(); + while (length > 0) + { + tmp.append(command.gapChar); + length--; + } + } tmp.insert(command.position, command.string[i]); command.string[i] = null; } @@ -247,14 +263,14 @@ public class EditCommand implements CommandI class Edit { AlignmentI al; - String command; - String [] string; + int command; + char [][] string; SequenceI[] seqs; int [] alIndex; int position, number; char gapChar; - Edit(String command, + Edit(int command, SequenceI[] seqs, int position, int number, @@ -268,12 +284,13 @@ public class EditCommand implements CommandI } - Edit(String command, + Edit(int command, SequenceI[] seqs, int position, int number, AlignmentI al) { + this.gapChar = al.getGapCharacter(); this.command = command; this.seqs = seqs; this.position = position;