Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / com / stevesoft / pat / OrMark.js
1 Clazz.declarePackage ("com.stevesoft.pat");
2 Clazz.load (["com.stevesoft.pat.Or", "$.SubMark"], "com.stevesoft.pat.OrMark", null, function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.sm = null;
5 this.id = 0;
6 Clazz.instantialize (this, arguments);
7 }, com.stevesoft.pat, "OrMark", com.stevesoft.pat.Or);
8 Clazz.prepareFields (c$, function () {
9 this.sm =  new com.stevesoft.pat.SubMark ();
10 });
11 Clazz.makeConstructor (c$, 
12 function (i) {
13 Clazz.superConstructor (this, com.stevesoft.pat.OrMark, []);
14 this.sm.om = this;
15 this.id = i;
16 }, "~N");
17 Clazz.overrideMethod (c$, "leftForm", 
18 function () {
19 return "(";
20 });
21 Clazz.defineMethod (c$, "getNext", 
22 function () {
23 return this.sm;
24 });
25 Clazz.defineMethod (c$, "matchInternal", 
26 function (pos, pt) {
27 this.sm.next = Clazz.superCall (this, com.stevesoft.pat.OrMark, "getNext", []);
28 if (pt.marks == null) {
29 var n2 = 2 * pt.nMarks + 2;
30 pt.marks =  Clazz.newIntArray (n2, 0);
31 for (var i = 0; i < n2; i++) {
32 pt.marks[i] = -1;
33 }
34 }pt.marks[this.id] = pos;
35 var ret = Clazz.superCall (this, com.stevesoft.pat.OrMark, "matchInternal", [pos, pt]);
36 if (ret < 0) {
37 pt.marks[this.id] = -1;
38 } else if (pt.marks[this.id] > pt.marks[this.id + pt.nMarks]) {
39 var swap = pt.marks[this.id];
40 pt.marks[this.id] = pt.marks[this.id + pt.nMarks] + 1;
41 pt.marks[this.id + pt.nMarks] = swap + 1;
42 }return ret;
43 }, "~N,com.stevesoft.pat.Pthings");
44 Clazz.overrideMethod (c$, "clone1", 
45 function (h) {
46 var om =  new com.stevesoft.pat.OrMark (this.id);
47 h.put (om, om);
48 h.put (this, om);
49 for (var i = 0; i < this.v.size (); i++) {
50 om.v.addElement ((this.v.elementAt (i)).clone (h));
51 }
52 return om;
53 }, "java.util.Hashtable");
54 });