+ synchronized void slideSequences(boolean right, int size)
+ {
+ Vector sg = new Vector();
+ if (viewport.cursorMode)
+ {
+ sg.addElement(viewport.alignment
+ .getSequenceAt(alignPanel.seqPanel.seqCanvas.cursorY));
+ }
+ else if (viewport.getSelectionGroup() != null
+ && viewport.getSelectionGroup().getSize() != viewport.alignment
+ .getHeight())
+ {
+ sg = viewport.getSelectionGroup().getSequences(
+ viewport.hiddenRepSequences);
+ }
+
+ if (sg.size() < 1)
+ {
+ return;
+ }
+
+ Vector invertGroup = new Vector();
+
+ for (int i = 0; i < viewport.alignment.getHeight(); i++)
+ {
+ if (!sg.contains(viewport.alignment.getSequenceAt(i)))
+ invertGroup.add(viewport.alignment.getSequenceAt(i));
+ }
+
+ SequenceI[] seqs1 = new SequenceI[sg.size()];
+ for (int i = 0; i < sg.size(); i++)
+ seqs1[i] = (SequenceI) sg.elementAt(i);
+
+ SequenceI[] seqs2 = new SequenceI[invertGroup.size()];
+ for (int i = 0; i < invertGroup.size(); i++)
+ seqs2[i] = (SequenceI) invertGroup.elementAt(i);
+
+ SlideSequencesCommand ssc;
+ if (right)
+ ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1,
+ size, viewport.getGapCharacter());
+ else
+ ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2,
+ size, viewport.getGapCharacter());
+
+ int groupAdjustment = 0;
+ if (ssc.getGapsInsertedBegin() && right)
+ {
+ if (viewport.cursorMode)
+ alignPanel.seqPanel.moveCursor(size, 0);
+ else
+ groupAdjustment = size;
+ }
+ else if (!ssc.getGapsInsertedBegin() && !right)
+ {
+ if (viewport.cursorMode)
+ alignPanel.seqPanel.moveCursor(-size, 0);
+ else
+ groupAdjustment = -size;
+ }
+
+ if (groupAdjustment != 0)
+ {
+ viewport.getSelectionGroup().setStartRes(
+ viewport.getSelectionGroup().getStartRes() + groupAdjustment);
+ viewport.getSelectionGroup().setEndRes(
+ viewport.getSelectionGroup().getEndRes() + groupAdjustment);
+ }
+
+ boolean appendHistoryItem = false;
+ if (viewport.historyList != null && viewport.historyList.size() > 0
+ && viewport.historyList.peek() instanceof SlideSequencesCommand)
+ {
+ appendHistoryItem = ssc
+ .appendSlideCommand((SlideSequencesCommand) viewport.historyList
+ .peek());
+ }