Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / javax / swing / SizeSequence.js
1 Clazz.declarePackage ("javax.swing");
2 c$ = Clazz.decorateAsClass (function () {
3 this.a = null;
4 Clazz.instantialize (this, arguments);
5 }, javax.swing, "SizeSequence");
6 Clazz.makeConstructor (c$, 
7 function () {
8 this.a = javax.swing.SizeSequence.emptyArray;
9 });
10 Clazz.makeConstructor (c$, 
11 function (numEntries) {
12 this.construct (numEntries, 0);
13 }, "~N");
14 Clazz.makeConstructor (c$, 
15 function (numEntries, value) {
16 this.construct ();
17 this.insertEntries (0, numEntries, value);
18 }, "~N,~N");
19 Clazz.makeConstructor (c$, 
20 function (sizes) {
21 this.construct ();
22 this.setSizes (sizes);
23 }, "~A");
24 Clazz.defineMethod (c$, "setSizes", 
25 function (length, size) {
26 if (this.a.length != length) {
27 this.a =  Clazz.newIntArray (length, 0);
28 }this.setSizes (0, length, size);
29 }, "~N,~N");
30 Clazz.defineMethod (c$, "setSizes", 
31  function (from, to, size) {
32 if (to <= from) {
33 return 0;
34 }var m = Clazz.doubleToInt ((from + to) / 2);
35 this.a[m] = size + this.setSizes (from, m, size);
36 return this.a[m] + this.setSizes (m + 1, to, size);
37 }, "~N,~N,~N");
38 Clazz.defineMethod (c$, "setSizes", 
39 function (sizes) {
40 if (this.a.length != sizes.length) {
41 this.a =  Clazz.newIntArray (sizes.length, 0);
42 }this.setSizes (0, this.a.length, sizes);
43 }, "~A");
44 Clazz.defineMethod (c$, "setSizes", 
45  function (from, to, sizes) {
46 if (to <= from) {
47 return 0;
48 }var m = Clazz.doubleToInt ((from + to) / 2);
49 this.a[m] = sizes[m] + this.setSizes (from, m, sizes);
50 return this.a[m] + this.setSizes (m + 1, to, sizes);
51 }, "~N,~N,~A");
52 Clazz.defineMethod (c$, "getSizes", 
53 function () {
54 var n = this.a.length;
55 var sizes =  Clazz.newIntArray (n, 0);
56 this.getSizes (0, n, sizes);
57 return sizes;
58 });
59 Clazz.defineMethod (c$, "getSizes", 
60  function (from, to, sizes) {
61 if (to <= from) {
62 return 0;
63 }var m = Clazz.doubleToInt ((from + to) / 2);
64 sizes[m] = this.a[m] - this.getSizes (from, m, sizes);
65 return this.a[m] + this.getSizes (m + 1, to, sizes);
66 }, "~N,~N,~A");
67 Clazz.defineMethod (c$, "getPosition", 
68 function (index) {
69 return this.getPosition (0, this.a.length, index);
70 }, "~N");
71 Clazz.defineMethod (c$, "getPosition", 
72  function (from, to, index) {
73 if (to <= from) {
74 return 0;
75 }var m = Clazz.doubleToInt ((from + to) / 2);
76 if (index <= m) {
77 return this.getPosition (from, m, index);
78 } else {
79 return this.a[m] + this.getPosition (m + 1, to, index);
80 }}, "~N,~N,~N");
81 Clazz.defineMethod (c$, "getIndex", 
82 function (position) {
83 return this.getIndex (0, this.a.length, position);
84 }, "~N");
85 Clazz.defineMethod (c$, "getIndex", 
86  function (from, to, position) {
87 if (to <= from) {
88 return from;
89 }var m = Clazz.doubleToInt ((from + to) / 2);
90 var pivot = this.a[m];
91 if (position < pivot) {
92 return this.getIndex (from, m, position);
93 } else {
94 return this.getIndex (m + 1, to, position - pivot);
95 }}, "~N,~N,~N");
96 Clazz.defineMethod (c$, "getSize", 
97 function (index) {
98 return this.getPosition (index + 1) - this.getPosition (index);
99 }, "~N");
100 Clazz.defineMethod (c$, "setSize", 
101 function (index, size) {
102 this.changeSize (0, this.a.length, index, size - this.getSize (index));
103 }, "~N,~N");
104 Clazz.defineMethod (c$, "changeSize", 
105  function (from, to, index, delta) {
106 if (to <= from) {
107 return;
108 }var m = Clazz.doubleToInt ((from + to) / 2);
109 if (index <= m) {
110 this.a[m] += delta;
111 this.changeSize (from, m, index, delta);
112 } else {
113 this.changeSize (m + 1, to, index, delta);
114 }}, "~N,~N,~N,~N");
115 Clazz.defineMethod (c$, "insertEntries", 
116 function (start, length, value) {
117 var sizes = this.getSizes ();
118 var end = start + length;
119 var n = this.a.length + length;
120 this.a =  Clazz.newIntArray (n, 0);
121 for (var i = 0; i < start; i++) {
122 this.a[i] = sizes[i];
123 }
124 for (var i = start; i < end; i++) {
125 this.a[i] = value;
126 }
127 for (var i = end; i < n; i++) {
128 this.a[i] = sizes[i - length];
129 }
130 this.setSizes (this.a);
131 }, "~N,~N,~N");
132 Clazz.defineMethod (c$, "removeEntries", 
133 function (start, length) {
134 var sizes = this.getSizes ();
135 var end = start + length;
136 var n = this.a.length - length;
137 this.a =  Clazz.newIntArray (n, 0);
138 for (var i = 0; i < start; i++) {
139 this.a[i] = sizes[i];
140 }
141 for (var i = start; i < n; i++) {
142 this.a[i] = sizes[i + length];
143 }
144 this.setSizes (this.a);
145 }, "~N,~N");
146 Clazz.defineStatics (c$,
147 "emptyArray",  Clazz.newIntArray (0, 0));