X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fcommands%2FEditCommand.java;h=72d82aa070cd60e1b6a09fd0cebdcee3038098d6;hb=ac86da576d0e56841b3d2c765b880c6e5765b855;hp=83e44174ba49be74307137bd15c2349ab57da63d;hpb=63f7dffaa9b668ad5ab7d8092e5232908e4b0bcb;p=jalview.git diff --git a/src/jalview/commands/EditCommand.java b/src/jalview/commands/EditCommand.java index 83e4417..72d82aa 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)}; } @@ -105,7 +104,7 @@ public class EditCommand implements CommandI } - public void appendEdit(String command, + public void appendEdit(int command, SequenceI[] seqs, int position, int number, @@ -133,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]); } @@ -162,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]); } @@ -201,14 +200,14 @@ 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; icommand.position) { command.string[i] = command.seqs[i].getSequence(command.position, - command.position + command.number); + command.position + command.number).toCharArray(); command.seqs[i].deleteChars(command.position, command.position + command.number); @@ -263,14 +262,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, @@ -284,7 +283,7 @@ public class EditCommand implements CommandI } - Edit(String command, + Edit(int command, SequenceI[] seqs, int position, int number,