1 Clazz.declarePackage ("jalview.commands");
2 Clazz.load (["jalview.commands.CommandI"], "jalview.commands.ChangeCaseCommand", ["java.lang.StringBuffer"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.description = null;
8 Clazz.instantialize (this, arguments);
9 }, jalview.commands, "ChangeCaseCommand", null, jalview.commands.CommandI);
10 Clazz.makeConstructor (c$,
11 function (description, seqs, regions, caseChange) {
12 this.description = description;
14 this.regions = regions;
15 this.caseChange = caseChange;
16 this.doCommand (null);
17 }, "~S,~A,java.util.List,~N");
18 Clazz.overrideMethod (c$, "getDescription",
20 return this.description;
22 Clazz.overrideMethod (c$, "getSize",
26 Clazz.overrideMethod (c$, "doCommand",
28 this.changeCase (true);
30 Clazz.overrideMethod (c$, "undoCommand",
32 this.changeCase (false);
34 Clazz.defineMethod (c$, "changeCase",
35 function (doCommand) {
40 for (var r, $r = this.regions.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) {
42 for (var s = 0; s < this.seqs.length; s++) {
43 sequence = this.seqs[s].getSequenceAsString ();
44 var newSeq = new StringBuffer ();
45 if (r[1] > sequence.length) {
46 end = sequence.length;
50 newSeq.append (sequence.substring (0, start));
51 }if ((this.caseChange == jalview.commands.ChangeCaseCommand.TO_UPPER && doCommand) || (this.caseChange == jalview.commands.ChangeCaseCommand.TO_LOWER && !doCommand)) {
52 newSeq.append (sequence.substring (start, end).toUpperCase ());
53 } else if ((this.caseChange == jalview.commands.ChangeCaseCommand.TO_LOWER && doCommand) || (this.caseChange == jalview.commands.ChangeCaseCommand.TO_UPPER && !doCommand)) {
54 newSeq.append (sequence.substring (start, end).toLowerCase ());
56 for (var c = start; c < end; c++) {
57 nextChar = sequence.charAt (c);
58 if ('a' <= nextChar && nextChar <= 'z') {
59 nextChar = String.fromCharCode (nextChar.charCodeAt (0) - (32));
60 } else if ('A' <= nextChar && nextChar <= 'Z') {
61 nextChar = String.fromCharCode (nextChar.charCodeAt (0) + (32));
62 }newSeq.append (nextChar);
64 }if (end < sequence.length) {
65 newSeq.append (sequence.substring (end));
66 }this.seqs[s].setSequence (newSeq.toString ());
70 Clazz.defineStatics (c$,