From: amwaterhouse Date: Wed, 25 Oct 2006 14:00:35 +0000 (+0000) Subject: Adjusts columnSelection correctly X-Git-Tag: Release_2_2~235 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ff5c339a6388a1f983a21008ef571cd15cacadd0;p=jalview.git Adjusts columnSelection correctly --- diff --git a/src/jalview/commands/TrimRegionCommand.java b/src/jalview/commands/TrimRegionCommand.java index 8ada376..5a5dcd1 100644 --- a/src/jalview/commands/TrimRegionCommand.java +++ b/src/jalview/commands/TrimRegionCommand.java @@ -19,8 +19,8 @@ package jalview.commands; import jalview.util.ShiftList; - import jalview.datamodel.*; +import java.util.Vector; public class TrimRegionCommand extends EditCommand @@ -32,18 +32,26 @@ public class TrimRegionCommand int [] start; + ShiftList shiftList; + + SequenceGroup selectionGroup; + + Vector deletedHiddenColumns; + public TrimRegionCommand(String description, String command, SequenceI[] seqs, int column, AlignmentI al, - ColumnSelection colSel) + ColumnSelection colSel, + SequenceGroup selectedRegion) { this.description = description; + this.selectionGroup = selectedRegion; + this.colSel = colSel; if (command.equalsIgnoreCase(TRIM_LEFT)) { edits = new Edit[] { new Edit(CUT, seqs, 0, column, al)}; - this.colSel = colSel; } else if (command.equalsIgnoreCase(TRIM_RIGHT)) { @@ -68,16 +76,32 @@ public class TrimRegionCommand { if(command.position==0) { + //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 column = command.seqs[j].findPosition(command.position)-1; command.seqs[j].setEnd(column); } } + super.cut(command); + + if (command.position == 0) + { + deletedHiddenColumns = colSel.compensateForEdit(0, command.number); + if(selectionGroup!=null) + selectionGroup.adjustForRemoveLeft(command.number); + } + else + { + deletedHiddenColumns = colSel.compensateForEdit(command.position, command.number); + if(selectionGroup!=null) + selectionGroup.adjustForRemoveRight(command.position); + } } void paste(Edit command) @@ -98,12 +122,24 @@ public class TrimRegionCommand } } - if(command.position==0) + if (command.position == 0) + { + colSel.compensateForEdit(0, -command.number); + if(selectionGroup!=null) + selectionGroup.adjustForRemoveLeft(-command.number); + } + + if (deletedHiddenColumns != null) { - ShiftList slist = new ShiftList(); - slist.addShift(0, -command.number); - colSel.compensateForEdits(slist); + int[] region; + for (int i = 0; i < deletedHiddenColumns.size(); i++) + { + region = (int[]) deletedHiddenColumns.elementAt(i); + colSel.hideColumns(region[0], region[1]); + } } + + } }