1 Clazz.declarePackage ("jalview.commands");
2 Clazz.load (["jalview.commands.EditCommand"], "jalview.commands.TrimRegionCommand", null, function () {
3 c$ = Clazz.decorateAsClass (function () {
7 this.selectionGroup = null;
8 this.deletedHiddenColumns = null;
9 this.columnsDeleted = 0;
10 Clazz.instantialize (this, arguments);
11 }, jalview.commands, "TrimRegionCommand", jalview.commands.EditCommand);
12 Clazz.makeConstructor (c$,
13 function (description, command, seqs, column, al, colSel, selectedRegion) {
14 Clazz.superConstructor (this, jalview.commands.TrimRegionCommand, []);
15 this.description = description;
16 this.selectionGroup = selectedRegion;
18 if (command.equalsIgnoreCase (jalview.commands.TrimRegionCommand.TRIM_LEFT)) {
21 }this.columnsDeleted = column;
22 this.setEdit (Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, jalview.commands.EditCommand.Action.CUT, seqs, 0, column, al));
23 } else if (command.equalsIgnoreCase (jalview.commands.TrimRegionCommand.TRIM_RIGHT)) {
24 var width = al.getWidth () - column - 1;
27 }this.columnsDeleted = width - 1;
28 this.setEdit (Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, jalview.commands.EditCommand.Action.CUT, seqs, column + 1, width, al));
30 var isize = this.getEdit (0).seqs.length;
31 this.start = Clazz.newIntArray (isize, 0);
32 for (i = 0; i < isize; i++) {
33 this.start[i] = this.getEdit (0).seqs[i].getStart ();
35 this.performEdit (0, null);
36 }, "~S,~S,~A,~N,jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,jalview.datamodel.SequenceGroup");
37 Clazz.defineMethod (c$, "cut",
41 var jSize = command.seqs.length;
42 for (j = 0; j < jSize; j++) {
43 if (command.position == 0) {
44 column = command.seqs[j].findPosition (command.number);
45 command.seqs[j].setStart (column);
47 column = command.seqs[j].findPosition (command.position) - 1;
48 command.seqs[j].setEnd (column);
50 Clazz.superCall (this, jalview.commands.TrimRegionCommand, "cut", [command, null]);
51 if (command.position == 0) {
52 this.deletedHiddenColumns = this.colSel.compensateForEdit (0, command.number);
53 if (this.selectionGroup != null) {
54 this.selectionGroup.adjustForRemoveLeft (command.number);
56 this.deletedHiddenColumns = this.colSel.compensateForEdit (command.position, command.number);
57 if (this.selectionGroup != null) {
58 this.selectionGroup.adjustForRemoveRight (command.position);
59 }}}, "jalview.commands.EditCommand.Edit");
60 Clazz.defineMethod (c$, "paste",
62 Clazz.superCall (this, jalview.commands.TrimRegionCommand, "paste", [command, null]);
65 var jSize = command.seqs.length;
66 for (j = 0; j < jSize; j++) {
67 if (command.position == 0) {
68 command.seqs[j].setStart (this.start[j]);
70 column = command.seqs[j].findPosition (command.number + command.position) - 1;
71 command.seqs[j].setEnd (column);
73 if (command.position == 0) {
74 this.colSel.compensateForEdit (0, -command.number);
75 if (this.selectionGroup != null) {
76 this.selectionGroup.adjustForRemoveLeft (-command.number);
77 }}if (this.deletedHiddenColumns != null) {
79 for (var i = 0; i < this.deletedHiddenColumns.size (); i++) {
80 region = this.deletedHiddenColumns.get (i);
81 this.colSel.hideColumns (region[0], region[1]);
83 }}, "jalview.commands.EditCommand.Edit");
84 Clazz.overrideMethod (c$, "getSize",
86 return this.columnsDeleted;
88 Clazz.defineStatics (c$,
89 "TRIM_LEFT", "TrimLeft",
90 "TRIM_RIGHT", "TrimRight");