2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
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];