/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
- * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
- *
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
+ * Copyright (C) 2014 The Jalview Authors
+ *
* This file is part of Jalview.
- *
+ *
* Jalview is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * Jalview is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.commands;
-import java.util.*;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Annotation;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceI;
-import jalview.datamodel.*;
+import java.util.Hashtable;
+import java.util.List;
/**
- *
+ *
* <p>
* Title: EditCommmand
* </p>
- *
+ *
* <p>
* Description: Essential information for performing undo and redo for cut/paste
* insert/delete gap which can be stored in the HistoryList
* </p>
- *
+ *
* <p>
* Copyright: Copyright (c) 2006
* </p>
- *
+ *
* <p>
* Company: Dundee University
* </p>
- *
+ *
* @author not attributable
* @version 1.0
*/
public static final int REPLACE = 4;
- public static final int INSERT_NUC=5;
+ public static final int INSERT_NUC = 5;
Edit[] edits;
* operation affects more alignment objects than the one referenced in al (for
* example, cut or pasting whole sequences). Use the form with an additional
* AlignmentI[] views parameter.
- *
+ *
* @param command
* @param seqs
* @param position
/**
* append a new edit command with a set of alignment views that may be
* operated on
- *
+ *
* @param command
* @param seqs
* @param position
case REPLACE:
replace(edits[e]);
break;
- //TODO:add deleteNuc for UNDO
-// case INSERT_NUC:
-// insertNuc(edits[e]);
-// break;
+ // TODO:add deleteNuc for UNDO
+ // case INSERT_NUC:
+ // insertNuc(edits[e]);
+ // break;
}
}
}
@Override
final public void undoCommand(AlignmentI[] views)
- {
- int e = 0, eSize = edits.length;
- for (e = eSize - 1; e > -1; e--)
- {
- switch (edits[e].command)
- {
- case INSERT_GAP:
- deleteGap(edits[e]);
- break;
- case DELETE_GAP:
- insertGap(edits[e]);
- break;
- case CUT:
- paste(edits[e], views);
- break;
- case PASTE:
- cut(edits[e], views);
- break;
- case REPLACE:
- replace(edits[e]);
- break;
- }
+ {
+ for(Edit e : edits){
+ switch (e.command)
+ {
+ case INSERT_GAP:
+ deleteGap(e);
+ break;
+ case DELETE_GAP:
+ insertGap(e);
+ break;
+ case CUT:
+ paste(e, views);
+ break;
+ case PASTE:
+ cut(e, views);
+ break;
+ case REPLACE:
+ replace(e);
+ break;
+ }
}
}
{
command.seqs[s].insertCharAt(command.position, command.number,
command.gapChar);
-// System.out.println("pos: "+command.position+" number: "+command.number);
+ // System.out.println("pos: "+command.position+" number: "+command.number);
}
adjustAnnotations(command, true, false, null);
}
-//
-// final void insertNuc(Edit command)
-// {
-//
-// for (int s = 0; s < command.seqs.length; s++)
-// {
-// System.out.println("pos: "+command.position+" number: "+command.number);
-// command.seqs[s].insertCharAt(command.position, command.number,'A');
-// }
-//
-// adjustAnnotations(command, true, false, null);
-// }
+
+ //
+ // final void insertNuc(Edit command)
+ // {
+ //
+ // for (int s = 0; s < command.seqs.length; s++)
+ // {
+ // System.out.println("pos: "+command.position+" number: "+command.number);
+ // command.seqs[s].insertCharAt(command.position, command.number,'A');
+ // }
+ //
+ // adjustAnnotations(command, true, false, null);
+ // }
final void deleteGap(Edit command)
{
if (command.alIndex[i] < command.al.getHeight())
{
List<SequenceI> sequences;
- synchronized (sequences=command.al.getSequences()) {
- sequences.add(command.alIndex[i], command.seqs[i]);
+ synchronized (sequences = command.al.getSequences())
+ {
+ // int index = command.al.findIndex(command.seqs[i]);
+ // sequences.add(index, command.seqs[i]);
+ sequences.add(command.alIndex[i] < 0 ? 0 : command.alIndex[i], command.seqs[i]);
}
}
else
+ command.number);
}
if (command.seqs[i].getStart() == start)
+ {
newstart--;
+ }
else
+ {
newend++;
+ }
}
}
command.string[i] = null;
command.number = start + command.string[0].length;
for (int i = 0; i < command.seqs.length; i++)
{
- boolean newDSWasNeeded = command.oldds != null && command.oldds[i] != null;
+ boolean newDSWasNeeded = command.oldds != null
+ && command.oldds[i] != null;
/**
* cut addHistoryItem(new EditCommand("Cut Sequences", EditCommand.CUT,
* cut, sg.getStartRes(), sg.getEndRes()-sg.getStartRes()+1,
* viewport.alignment));
- *
+ *
*/
/**
* then addHistoryItem(new EditCommand( "Add sequences",
* EditCommand.PASTE, sequences, 0, alignment.getWidth(), alignment) );
- *
+ *
*/
oldstring = command.seqs[i].getSequenceAsString();
tmp = new StringBuffer(oldstring.substring(0, start));
fullseq = osp.substring(0, ipos) + nogaprep
+ osp.substring(ipos + nogaprep.length());
newds.setSequence(fullseq.toUpperCase());
- // TODO: JAL-1131 ensure newly created dataset sequence is added to the set of
+ // TODO: JAL-1131 ensure newly created dataset sequence is added to
+ // the set of
// dataset sequences associated with the alignment.
// TODO: JAL-1131 fix up any annotation associated with new dataset
// sequence to ensure that original sequence/annotation relationships
{
temp = new Annotation[aSize + command.number];
if (annotations[a].padGaps)
+ {
for (int aa = 0; aa < temp.length; aa++)
{
temp[aa] = new Annotation(command.gapChar + "", null, ' ', 0);
}
+ }
}
else
{
int copylen = Math.min(command.position,
annotations[a].annotations.length);
if (copylen > 0)
+ {
System.arraycopy(annotations[a].annotations, 0, temp, 0,
copylen); // command.position);
+ }
Annotation[] deleted = new Annotation[command.number];
if (copylen >= command.position)