2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.commands;
21 import jalview.datamodel.*;
23 public class SlideSequencesCommand extends EditCommand
25 boolean gapsInsertedBegin = false;
27 public SlideSequencesCommand(String description, SequenceI[] seqsLeft,
28 SequenceI[] seqsRight, int slideSize, char gapChar)
30 this.description = description;
32 int lSize = seqsLeft.length;
33 gapsInsertedBegin = false;
35 for (i = 0; i < lSize; i++)
37 for (j = 0; j < slideSize; j++)
38 if (!jalview.util.Comparison.isGap(seqsLeft[i].getCharAt(j)))
40 gapsInsertedBegin = true;
45 if (!gapsInsertedBegin)
47 { new Edit(DELETE_GAP, seqsLeft, 0, slideSize, gapChar) };
50 { new Edit(INSERT_GAP, seqsRight, 0, slideSize, gapChar) };
55 public boolean getGapsInsertedBegin()
57 return gapsInsertedBegin;
60 public boolean appendSlideCommand(SlideSequencesCommand command)
64 if (command.edits[0].seqs.length == edits[0].seqs.length)
67 for (int i = 0; i < command.edits[0].seqs.length; i++)
69 if (edits[0].seqs[i] != command.edits[0].seqs[i])
78 Edit[] temp = new Edit[command.edits.length + 1];
79 System.arraycopy(command.edits, 0, temp, 0, command.edits.length);
81 command.edits[command.edits.length - 1] = edits[0];