d2dd071ed4a446867dff7ac1f57031ff12b40e51
[jalviewjs.git] / site / j2s / javax / swing / Spring.js
1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (null, "javax.swing.Spring", ["java.lang.NullPointerException"], function () {
3 c$ = Clazz.declareType (javax.swing, "Spring");
4 Clazz.makeConstructor (c$, 
5 function () {
6 });
7 Clazz.defineMethod (c$, "range", 
8  function (contract) {
9 return contract ? (this.getPreferredValue () - this.getMinimumValue ()) : (this.getMaximumValue () - this.getPreferredValue ());
10 }, "~B");
11 Clazz.defineMethod (c$, "getStrain", 
12 function () {
13 var delta = (this.getValue () - this.getPreferredValue ());
14 return delta / this.range (this.getValue () < this.getPreferredValue ());
15 });
16 Clazz.defineMethod (c$, "setStrain", 
17 function (strain) {
18 this.setValue (this.getPreferredValue () + Clazz.doubleToInt (strain * this.range (strain < 0)));
19 }, "~N");
20 Clazz.defineMethod (c$, "isCyclic", 
21 function (l) {
22 return false;
23 }, "javax.swing.SpringLayout");
24 c$.constant = Clazz.defineMethod (c$, "constant", 
25 function (pref) {
26 return javax.swing.Spring.constant (pref, pref, pref);
27 }, "~N");
28 c$.constant = Clazz.defineMethod (c$, "constant", 
29 function (min, pref, max) {
30 return  new javax.swing.Spring.StaticSpring (min, pref, max);
31 }, "~N,~N,~N");
32 c$.minus = Clazz.defineMethod (c$, "minus", 
33 function (s) {
34 return  new javax.swing.Spring.NegativeSpring (s);
35 }, "javax.swing.Spring");
36 c$.sum = Clazz.defineMethod (c$, "sum", 
37 function (s1, s2) {
38 return  new javax.swing.Spring.SumSpring (s1, s2);
39 }, "javax.swing.Spring,javax.swing.Spring");
40 c$.max = Clazz.defineMethod (c$, "max", 
41 function (s1, s2) {
42 return  new javax.swing.Spring.MaxSpring (s1, s2);
43 }, "javax.swing.Spring,javax.swing.Spring");
44 c$.difference = Clazz.defineMethod (c$, "difference", 
45 function (s1, s2) {
46 return javax.swing.Spring.sum (s1, javax.swing.Spring.minus (s2));
47 }, "javax.swing.Spring,javax.swing.Spring");
48 c$.scale = Clazz.defineMethod (c$, "scale", 
49 function (s, factor) {
50 javax.swing.Spring.checkArg (s);
51 return  new javax.swing.Spring.ScaleSpring (s, factor);
52 }, "javax.swing.Spring,~N");
53 c$.width = Clazz.defineMethod (c$, "width", 
54 function (c) {
55 javax.swing.Spring.checkArg (c);
56 return  new javax.swing.Spring.WidthSpring (c);
57 }, "java.awt.Component");
58 c$.height = Clazz.defineMethod (c$, "height", 
59 function (c) {
60 javax.swing.Spring.checkArg (c);
61 return  new javax.swing.Spring.HeightSpring (c);
62 }, "java.awt.Component");
63 c$.checkArg = Clazz.defineMethod (c$, "checkArg", 
64  function (s) {
65 if (s == null) {
66 throw  new NullPointerException ("Argument must not be null");
67 }}, "~O");
68 Clazz.pu$h(self.c$);
69 c$ = Clazz.decorateAsClass (function () {
70 this.size = -2147483648;
71 Clazz.instantialize (this, arguments);
72 }, javax.swing.Spring, "AbstractSpring", javax.swing.Spring);
73 Clazz.overrideMethod (c$, "getValue", 
74 function () {
75 return this.size != -2147483648 ? this.size : this.getPreferredValue ();
76 });
77 Clazz.overrideMethod (c$, "setValue", 
78 function (a) {
79 if (this.size == a) {
80 return;
81 }if (a == -2147483648) {
82 this.clear ();
83 } else {
84 this.setNonClearValue (a);
85 }}, "~N");
86 Clazz.defineMethod (c$, "clear", 
87 function () {
88 this.size = -2147483648;
89 });
90 Clazz.defineMethod (c$, "setNonClearValue", 
91 function (a) {
92 this.size = a;
93 }, "~N");
94 c$ = Clazz.p0p ();
95 Clazz.pu$h(self.c$);
96 c$ = Clazz.decorateAsClass (function () {
97 this.min = 0;
98 this.pref = 0;
99 this.$max = 0;
100 Clazz.instantialize (this, arguments);
101 }, javax.swing.Spring, "StaticSpring", javax.swing.Spring.AbstractSpring);
102 Clazz.makeConstructor (c$, 
103 function (a) {
104 this.construct (a, a, a);
105 }, "~N");
106 Clazz.makeConstructor (c$, 
107 function (a, b, c) {
108 Clazz.superConstructor (this, javax.swing.Spring.StaticSpring, []);
109 this.min = a;
110 this.pref = b;
111 this.$max = c;
112 }, "~N,~N,~N");
113 Clazz.overrideMethod (c$, "toString", 
114 function () {
115 return "StaticSpring [" + this.min + ", " + this.pref + ", " + this.$max + "]";
116 });
117 Clazz.overrideMethod (c$, "getMinimumValue", 
118 function () {
119 return this.min;
120 });
121 Clazz.overrideMethod (c$, "getPreferredValue", 
122 function () {
123 return this.pref;
124 });
125 Clazz.overrideMethod (c$, "getMaximumValue", 
126 function () {
127 return this.$max;
128 });
129 c$ = Clazz.p0p ();
130 Clazz.pu$h(self.c$);
131 c$ = Clazz.decorateAsClass (function () {
132 this.s = null;
133 Clazz.instantialize (this, arguments);
134 }, javax.swing.Spring, "NegativeSpring", javax.swing.Spring);
135 Clazz.makeConstructor (c$, 
136 function (a) {
137 Clazz.superConstructor (this, javax.swing.Spring.NegativeSpring, []);
138 this.s = a;
139 }, "javax.swing.Spring");
140 Clazz.defineMethod (c$, "getMinimumValue", 
141 function () {
142 return -this.s.getMaximumValue ();
143 });
144 Clazz.defineMethod (c$, "getPreferredValue", 
145 function () {
146 return -this.s.getPreferredValue ();
147 });
148 Clazz.defineMethod (c$, "getMaximumValue", 
149 function () {
150 return -this.s.getMinimumValue ();
151 });
152 Clazz.defineMethod (c$, "getValue", 
153 function () {
154 return -this.s.getValue ();
155 });
156 Clazz.defineMethod (c$, "setValue", 
157 function (a) {
158 this.s.setValue (-a);
159 }, "~N");
160 Clazz.defineMethod (c$, "isCyclic", 
161 function (a) {
162 return this.s.isCyclic (a);
163 }, "javax.swing.SpringLayout");
164 c$ = Clazz.p0p ();
165 Clazz.pu$h(self.c$);
166 c$ = Clazz.decorateAsClass (function () {
167 this.s = null;
168 this.factor = 0;
169 Clazz.instantialize (this, arguments);
170 }, javax.swing.Spring, "ScaleSpring", javax.swing.Spring);
171 Clazz.makeConstructor (c$, 
172  function (a, b) {
173 Clazz.superConstructor (this, javax.swing.Spring.ScaleSpring, []);
174 this.s = a;
175 this.factor = b;
176 }, "javax.swing.Spring,~N");
177 Clazz.defineMethod (c$, "getMinimumValue", 
178 function () {
179 return Math.round ((this.factor < 0 ? this.s.getMaximumValue () : this.s.getMinimumValue ()) * this.factor);
180 });
181 Clazz.defineMethod (c$, "getPreferredValue", 
182 function () {
183 return Math.round (this.s.getPreferredValue () * this.factor);
184 });
185 Clazz.defineMethod (c$, "getMaximumValue", 
186 function () {
187 return Math.round ((this.factor < 0 ? this.s.getMinimumValue () : this.s.getMaximumValue ()) * this.factor);
188 });
189 Clazz.defineMethod (c$, "getValue", 
190 function () {
191 return Math.round (this.s.getValue () * this.factor);
192 });
193 Clazz.defineMethod (c$, "setValue", 
194 function (a) {
195 if (a == -2147483648) {
196 this.s.setValue (-2147483648);
197 } else {
198 this.s.setValue (Math.round (a / this.factor));
199 }}, "~N");
200 Clazz.defineMethod (c$, "isCyclic", 
201 function (a) {
202 return this.s.isCyclic (a);
203 }, "javax.swing.SpringLayout");
204 c$ = Clazz.p0p ();
205 Clazz.pu$h(self.c$);
206 c$ = Clazz.decorateAsClass (function () {
207 this.c = null;
208 Clazz.instantialize (this, arguments);
209 }, javax.swing.Spring, "WidthSpring", javax.swing.Spring.AbstractSpring);
210 Clazz.makeConstructor (c$, 
211 function (a) {
212 Clazz.superConstructor (this, javax.swing.Spring.WidthSpring, []);
213 this.c = a;
214 }, "java.awt.Component");
215 Clazz.overrideMethod (c$, "getMinimumValue", 
216 function () {
217 return this.c.getMinimumSize ().width;
218 });
219 Clazz.overrideMethod (c$, "getPreferredValue", 
220 function () {
221 return this.c.getPreferredSize ().width;
222 });
223 Clazz.overrideMethod (c$, "getMaximumValue", 
224 function () {
225 return Math.min (32767, this.c.getMaximumSize ().width);
226 });
227 c$ = Clazz.p0p ();
228 Clazz.pu$h(self.c$);
229 c$ = Clazz.decorateAsClass (function () {
230 this.c = null;
231 Clazz.instantialize (this, arguments);
232 }, javax.swing.Spring, "HeightSpring", javax.swing.Spring.AbstractSpring);
233 Clazz.makeConstructor (c$, 
234 function (a) {
235 Clazz.superConstructor (this, javax.swing.Spring.HeightSpring, []);
236 this.c = a;
237 }, "java.awt.Component");
238 Clazz.overrideMethod (c$, "getMinimumValue", 
239 function () {
240 return this.c.getMinimumSize ().height;
241 });
242 Clazz.overrideMethod (c$, "getPreferredValue", 
243 function () {
244 return this.c.getPreferredSize ().height;
245 });
246 Clazz.overrideMethod (c$, "getMaximumValue", 
247 function () {
248 return Math.min (32767, this.c.getMaximumSize ().height);
249 });
250 c$ = Clazz.p0p ();
251 Clazz.pu$h(self.c$);
252 c$ = Clazz.decorateAsClass (function () {
253 this.s = null;
254 Clazz.instantialize (this, arguments);
255 }, javax.swing.Spring, "SpringMap", javax.swing.Spring);
256 Clazz.makeConstructor (c$, 
257 function (a) {
258 Clazz.superConstructor (this, javax.swing.Spring.SpringMap, []);
259 this.s = a;
260 }, "javax.swing.Spring");
261 Clazz.defineMethod (c$, "getMinimumValue", 
262 function () {
263 return this.map (this.s.getMinimumValue ());
264 });
265 Clazz.defineMethod (c$, "getPreferredValue", 
266 function () {
267 return this.map (this.s.getPreferredValue ());
268 });
269 Clazz.defineMethod (c$, "getMaximumValue", 
270 function () {
271 return Math.min (32767, this.map (this.s.getMaximumValue ()));
272 });
273 Clazz.defineMethod (c$, "getValue", 
274 function () {
275 return this.map (this.s.getValue ());
276 });
277 Clazz.defineMethod (c$, "setValue", 
278 function (a) {
279 if (a == -2147483648) {
280 this.s.setValue (-2147483648);
281 } else {
282 this.s.setValue (this.inv (a));
283 }}, "~N");
284 Clazz.defineMethod (c$, "isCyclic", 
285 function (a) {
286 return this.s.isCyclic (a);
287 }, "javax.swing.SpringLayout");
288 c$ = Clazz.p0p ();
289 Clazz.pu$h(self.c$);
290 c$ = Clazz.decorateAsClass (function () {
291 this.s1 = null;
292 this.s2 = null;
293 Clazz.instantialize (this, arguments);
294 }, javax.swing.Spring, "CompoundSpring", javax.swing.Spring.StaticSpring);
295 Clazz.makeConstructor (c$, 
296 function (a, b) {
297 Clazz.superConstructor (this, javax.swing.Spring.CompoundSpring, [-2147483648]);
298 this.s1 = a;
299 this.s2 = b;
300 }, "javax.swing.Spring,javax.swing.Spring");
301 Clazz.overrideMethod (c$, "toString", 
302 function () {
303 return "CompoundSpring of " + this.s1 + " and " + this.s2;
304 });
305 Clazz.defineMethod (c$, "clear", 
306 function () {
307 Clazz.superCall (this, javax.swing.Spring.CompoundSpring, "clear", []);
308 this.min = this.pref = this.$max = -2147483648;
309 this.s1.setValue (-2147483648);
310 this.s2.setValue (-2147483648);
311 });
312 Clazz.overrideMethod (c$, "getMinimumValue", 
313 function () {
314 if (this.min == -2147483648) {
315 this.min = this.op (this.s1.getMinimumValue (), this.s2.getMinimumValue ());
316 }return this.min;
317 });
318 Clazz.overrideMethod (c$, "getPreferredValue", 
319 function () {
320 if (this.pref == -2147483648) {
321 this.pref = this.op (this.s1.getPreferredValue (), this.s2.getPreferredValue ());
322 }return this.pref;
323 });
324 Clazz.overrideMethod (c$, "getMaximumValue", 
325 function () {
326 if (this.$max == -2147483648) {
327 this.$max = this.op (this.s1.getMaximumValue (), this.s2.getMaximumValue ());
328 }return this.$max;
329 });
330 Clazz.overrideMethod (c$, "getValue", 
331 function () {
332 if (this.size == -2147483648) {
333 this.size = this.op (this.s1.getValue (), this.s2.getValue ());
334 }return this.size;
335 });
336 Clazz.overrideMethod (c$, "isCyclic", 
337 function (a) {
338 return a.isCyclic (this.s1) || a.isCyclic (this.s2);
339 }, "javax.swing.SpringLayout");
340 c$ = Clazz.p0p ();
341 Clazz.pu$h(self.c$);
342 c$ = Clazz.declareType (javax.swing.Spring, "SumSpring", javax.swing.Spring.CompoundSpring);
343 Clazz.overrideMethod (c$, "op", 
344 function (a, b) {
345 return a + b;
346 }, "~N,~N");
347 Clazz.defineMethod (c$, "setNonClearValue", 
348 function (a) {
349 Clazz.superCall (this, javax.swing.Spring.SumSpring, "setNonClearValue", [a]);
350 this.s1.setStrain (this.getStrain ());
351 this.s2.setValue (a - this.s1.getValue ());
352 }, "~N");
353 c$ = Clazz.p0p ();
354 Clazz.pu$h(self.c$);
355 c$ = Clazz.declareType (javax.swing.Spring, "MaxSpring", javax.swing.Spring.CompoundSpring);
356 Clazz.overrideMethod (c$, "op", 
357 function (a, b) {
358 return Math.max (a, b);
359 }, "~N,~N");
360 Clazz.defineMethod (c$, "setNonClearValue", 
361 function (a) {
362 Clazz.superCall (this, javax.swing.Spring.MaxSpring, "setNonClearValue", [a]);
363 this.s1.setValue (a);
364 this.s2.setValue (a);
365 }, "~N");
366 c$ = Clazz.p0p ();
367 Clazz.defineStatics (c$,
368 "UNSET", -2147483648);
369 });