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$,
7 Clazz.defineMethod (c$, "range",
9 return contract ? (this.getPreferredValue () - this.getMinimumValue ()) : (this.getMaximumValue () - this.getPreferredValue ());
11 Clazz.defineMethod (c$, "getStrain",
13 var delta = (this.getValue () - this.getPreferredValue ());
14 return delta / this.range (this.getValue () < this.getPreferredValue ());
16 Clazz.defineMethod (c$, "setStrain",
18 this.setValue (this.getPreferredValue () + Clazz.doubleToInt (strain * this.range (strain < 0)));
20 Clazz.defineMethod (c$, "isCyclic",
23 }, "javax.swing.SpringLayout");
24 c$.constant = Clazz.defineMethod (c$, "constant",
26 return javax.swing.Spring.constant (pref, pref, pref);
28 c$.constant = Clazz.defineMethod (c$, "constant",
29 function (min, pref, max) {
30 return new javax.swing.Spring.StaticSpring (min, pref, max);
32 c$.minus = Clazz.defineMethod (c$, "minus",
34 return new javax.swing.Spring.NegativeSpring (s);
35 }, "javax.swing.Spring");
36 c$.sum = Clazz.defineMethod (c$, "sum",
38 return new javax.swing.Spring.SumSpring (s1, s2);
39 }, "javax.swing.Spring,javax.swing.Spring");
40 c$.max = Clazz.defineMethod (c$, "max",
42 return new javax.swing.Spring.MaxSpring (s1, s2);
43 }, "javax.swing.Spring,javax.swing.Spring");
44 c$.difference = Clazz.defineMethod (c$, "difference",
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",
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",
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",
66 throw new NullPointerException ("Argument must not be null");
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",
75 return this.size != -2147483648 ? this.size : this.getPreferredValue ();
77 Clazz.overrideMethod (c$, "setValue",
81 }if (a == -2147483648) {
84 this.setNonClearValue (a);
86 Clazz.defineMethod (c$, "clear",
88 this.size = -2147483648;
90 Clazz.defineMethod (c$, "setNonClearValue",
96 c$ = Clazz.decorateAsClass (function () {
100 Clazz.instantialize (this, arguments);
101 }, javax.swing.Spring, "StaticSpring", javax.swing.Spring.AbstractSpring);
102 Clazz.makeConstructor (c$,
104 this.construct (a, a, a);
106 Clazz.makeConstructor (c$,
108 Clazz.superConstructor (this, javax.swing.Spring.StaticSpring, []);
113 Clazz.overrideMethod (c$, "toString",
115 return "StaticSpring [" + this.min + ", " + this.pref + ", " + this.$max + "]";
117 Clazz.overrideMethod (c$, "getMinimumValue",
121 Clazz.overrideMethod (c$, "getPreferredValue",
125 Clazz.overrideMethod (c$, "getMaximumValue",
131 c$ = Clazz.decorateAsClass (function () {
133 Clazz.instantialize (this, arguments);
134 }, javax.swing.Spring, "NegativeSpring", javax.swing.Spring);
135 Clazz.makeConstructor (c$,
137 Clazz.superConstructor (this, javax.swing.Spring.NegativeSpring, []);
139 }, "javax.swing.Spring");
140 Clazz.defineMethod (c$, "getMinimumValue",
142 return -this.s.getMaximumValue ();
144 Clazz.defineMethod (c$, "getPreferredValue",
146 return -this.s.getPreferredValue ();
148 Clazz.defineMethod (c$, "getMaximumValue",
150 return -this.s.getMinimumValue ();
152 Clazz.defineMethod (c$, "getValue",
154 return -this.s.getValue ();
156 Clazz.defineMethod (c$, "setValue",
158 this.s.setValue (-a);
160 Clazz.defineMethod (c$, "isCyclic",
162 return this.s.isCyclic (a);
163 }, "javax.swing.SpringLayout");
166 c$ = Clazz.decorateAsClass (function () {
169 Clazz.instantialize (this, arguments);
170 }, javax.swing.Spring, "ScaleSpring", javax.swing.Spring);
171 Clazz.makeConstructor (c$,
173 Clazz.superConstructor (this, javax.swing.Spring.ScaleSpring, []);
176 }, "javax.swing.Spring,~N");
177 Clazz.defineMethod (c$, "getMinimumValue",
179 return Math.round ((this.factor < 0 ? this.s.getMaximumValue () : this.s.getMinimumValue ()) * this.factor);
181 Clazz.defineMethod (c$, "getPreferredValue",
183 return Math.round (this.s.getPreferredValue () * this.factor);
185 Clazz.defineMethod (c$, "getMaximumValue",
187 return Math.round ((this.factor < 0 ? this.s.getMinimumValue () : this.s.getMaximumValue ()) * this.factor);
189 Clazz.defineMethod (c$, "getValue",
191 return Math.round (this.s.getValue () * this.factor);
193 Clazz.defineMethod (c$, "setValue",
195 if (a == -2147483648) {
196 this.s.setValue (-2147483648);
198 this.s.setValue (Math.round (a / this.factor));
200 Clazz.defineMethod (c$, "isCyclic",
202 return this.s.isCyclic (a);
203 }, "javax.swing.SpringLayout");
206 c$ = Clazz.decorateAsClass (function () {
208 Clazz.instantialize (this, arguments);
209 }, javax.swing.Spring, "WidthSpring", javax.swing.Spring.AbstractSpring);
210 Clazz.makeConstructor (c$,
212 Clazz.superConstructor (this, javax.swing.Spring.WidthSpring, []);
214 }, "java.awt.Component");
215 Clazz.overrideMethod (c$, "getMinimumValue",
217 return this.c.getMinimumSize ().width;
219 Clazz.overrideMethod (c$, "getPreferredValue",
221 return this.c.getPreferredSize ().width;
223 Clazz.overrideMethod (c$, "getMaximumValue",
225 return Math.min (32767, this.c.getMaximumSize ().width);
229 c$ = Clazz.decorateAsClass (function () {
231 Clazz.instantialize (this, arguments);
232 }, javax.swing.Spring, "HeightSpring", javax.swing.Spring.AbstractSpring);
233 Clazz.makeConstructor (c$,
235 Clazz.superConstructor (this, javax.swing.Spring.HeightSpring, []);
237 }, "java.awt.Component");
238 Clazz.overrideMethod (c$, "getMinimumValue",
240 return this.c.getMinimumSize ().height;
242 Clazz.overrideMethod (c$, "getPreferredValue",
244 return this.c.getPreferredSize ().height;
246 Clazz.overrideMethod (c$, "getMaximumValue",
248 return Math.min (32767, this.c.getMaximumSize ().height);
252 c$ = Clazz.decorateAsClass (function () {
254 Clazz.instantialize (this, arguments);
255 }, javax.swing.Spring, "SpringMap", javax.swing.Spring);
256 Clazz.makeConstructor (c$,
258 Clazz.superConstructor (this, javax.swing.Spring.SpringMap, []);
260 }, "javax.swing.Spring");
261 Clazz.defineMethod (c$, "getMinimumValue",
263 return this.map (this.s.getMinimumValue ());
265 Clazz.defineMethod (c$, "getPreferredValue",
267 return this.map (this.s.getPreferredValue ());
269 Clazz.defineMethod (c$, "getMaximumValue",
271 return Math.min (32767, this.map (this.s.getMaximumValue ()));
273 Clazz.defineMethod (c$, "getValue",
275 return this.map (this.s.getValue ());
277 Clazz.defineMethod (c$, "setValue",
279 if (a == -2147483648) {
280 this.s.setValue (-2147483648);
282 this.s.setValue (this.inv (a));
284 Clazz.defineMethod (c$, "isCyclic",
286 return this.s.isCyclic (a);
287 }, "javax.swing.SpringLayout");
290 c$ = Clazz.decorateAsClass (function () {
293 Clazz.instantialize (this, arguments);
294 }, javax.swing.Spring, "CompoundSpring", javax.swing.Spring.StaticSpring);
295 Clazz.makeConstructor (c$,
297 Clazz.superConstructor (this, javax.swing.Spring.CompoundSpring, [-2147483648]);
300 }, "javax.swing.Spring,javax.swing.Spring");
301 Clazz.overrideMethod (c$, "toString",
303 return "CompoundSpring of " + this.s1 + " and " + this.s2;
305 Clazz.defineMethod (c$, "clear",
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);
312 Clazz.overrideMethod (c$, "getMinimumValue",
314 if (this.min == -2147483648) {
315 this.min = this.op (this.s1.getMinimumValue (), this.s2.getMinimumValue ());
318 Clazz.overrideMethod (c$, "getPreferredValue",
320 if (this.pref == -2147483648) {
321 this.pref = this.op (this.s1.getPreferredValue (), this.s2.getPreferredValue ());
324 Clazz.overrideMethod (c$, "getMaximumValue",
326 if (this.$max == -2147483648) {
327 this.$max = this.op (this.s1.getMaximumValue (), this.s2.getMaximumValue ());
330 Clazz.overrideMethod (c$, "getValue",
332 if (this.size == -2147483648) {
333 this.size = this.op (this.s1.getValue (), this.s2.getValue ());
336 Clazz.overrideMethod (c$, "isCyclic",
338 return a.isCyclic (this.s1) || a.isCyclic (this.s2);
339 }, "javax.swing.SpringLayout");
342 c$ = Clazz.declareType (javax.swing.Spring, "SumSpring", javax.swing.Spring.CompoundSpring);
343 Clazz.overrideMethod (c$, "op",
347 Clazz.defineMethod (c$, "setNonClearValue",
349 Clazz.superCall (this, javax.swing.Spring.SumSpring, "setNonClearValue", [a]);
350 this.s1.setStrain (this.getStrain ());
351 this.s2.setValue (a - this.s1.getValue ());
355 c$ = Clazz.declareType (javax.swing.Spring, "MaxSpring", javax.swing.Spring.CompoundSpring);
356 Clazz.overrideMethod (c$, "op",
358 return Math.max (a, b);
360 Clazz.defineMethod (c$, "setNonClearValue",
362 Clazz.superCall (this, javax.swing.Spring.MaxSpring, "setNonClearValue", [a]);
363 this.s1.setValue (a);
364 this.s2.setValue (a);
367 Clazz.defineStatics (c$,
368 "UNSET", -2147483648);