X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fcommands%2FTrimRegionCommand.java;h=b4d92a03880ee6c5c028755cd9c57bb1a3dfa560;hb=a97a5c93ecd4b0ecd0c55ae2c58c6174c05190f0;hp=4110bd1fcd5ecb1c1c5fe82ceb52cdad531679ec;hpb=fa93bb578999b13c0364a712ae368ca8841012a1;p=jalview.git diff --git a/src/jalview/commands/TrimRegionCommand.java b/src/jalview/commands/TrimRegionCommand.java index 4110bd1..b4d92a0 100644 --- a/src/jalview/commands/TrimRegionCommand.java +++ b/src/jalview/commands/TrimRegionCommand.java @@ -1,32 +1,37 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ 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. - * - * This program 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. - * + * + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.commands; -import java.util.*; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.ColumnSelection; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; +import jalview.util.ShiftList; -import jalview.datamodel.*; -import jalview.util.*; +import java.util.List; -public class TrimRegionCommand - extends EditCommand +public class TrimRegionCommand extends EditCommand { public static String TRIM_LEFT = "TrimLeft"; + public static String TRIM_RIGHT = "TrimRight"; public ColumnSelection colSel = null; @@ -37,17 +42,13 @@ public class TrimRegionCommand SequenceGroup selectionGroup; - Vector deletedHiddenColumns; + List deletedHiddenColumns; int columnsDeleted; - public TrimRegionCommand(String description, - String command, - SequenceI[] seqs, - int column, - AlignmentI al, - ColumnSelection colSel, - SequenceGroup selectedRegion) + public TrimRegionCommand(String description, String command, + SequenceI[] seqs, int column, AlignmentI al, + ColumnSelection colSel, SequenceGroup selectedRegion) { this.description = description; this.selectionGroup = selectedRegion; @@ -61,9 +62,7 @@ public class TrimRegionCommand columnsDeleted = column; - edits = new Edit[] - { - new Edit(CUT, seqs, 0, column, al)}; + setEdit(new Edit(Action.CUT, seqs, 0, column, al)); } else if (command.equalsIgnoreCase(TRIM_RIGHT)) { @@ -75,21 +74,19 @@ public class TrimRegionCommand columnsDeleted = width - 1; - edits = new Edit[] - { - new Edit(CUT, seqs, column + 1, width, al)}; + setEdit(new Edit(Action.CUT, seqs, column + 1, width, al)); } - //We need to keep a record of the sequence start - //in order to restore the state after a redo - int i, isize = edits[0].seqs.length; + // We need to keep a record of the sequence start + // in order to restore the state after a redo + int i, isize = getEdit(0).seqs.length; start = new int[isize]; for (i = 0; i < isize; i++) { - start[i] = edits[0].seqs[i].getStart(); + start[i] = getEdit(0).seqs[i].getStart(); } - performEdit(0,null); + performEdit(0, null); } void cut(Edit command) @@ -99,13 +96,13 @@ public class TrimRegionCommand { if (command.position == 0) { - //This is a TRIM_LEFT command + // This is a TRIM_LEFT command column = command.seqs[j].findPosition(command.number); command.seqs[j].setStart(column); } else { - //This is a TRIM_RIGHT command + // This is a TRIM_RIGHT command column = command.seqs[j].findPosition(command.position) - 1; command.seqs[j].setEnd(column); } @@ -124,7 +121,7 @@ public class TrimRegionCommand else { deletedHiddenColumns = colSel.compensateForEdit(command.position, - command.number); + command.number); if (selectionGroup != null) { selectionGroup.adjustForRemoveRight(command.position); @@ -144,8 +141,8 @@ public class TrimRegionCommand } else { - column = command.seqs[j] - .findPosition(command.number + command.position) - 1; + column = command.seqs[j].findPosition(command.number + + command.position) - 1; command.seqs[j].setEnd(column); } } @@ -155,7 +152,7 @@ public class TrimRegionCommand colSel.compensateForEdit(0, -command.number); if (selectionGroup != null) { - selectionGroup.adjustForRemoveLeft( -command.number); + selectionGroup.adjustForRemoveLeft(-command.number); } } @@ -164,7 +161,7 @@ public class TrimRegionCommand int[] region; for (int i = 0; i < deletedHiddenColumns.size(); i++) { - region = (int[]) deletedHiddenColumns.elementAt(i); + region = deletedHiddenColumns.get(i); colSel.hideColumns(region[0], region[1]); } }