1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["java.awt.LayoutManager2", "javax.swing.Spring", "java.util.ArrayList", "$.HashMap"], "javax.swing.SpringLayout", ["java.util.Collections", "$.HashSet", "java.awt.Component", "$.Dimension", "javax.swing.JComponent", "javax.swing.Spring.HeightSpring", "$.SpringMap", "$.WidthSpring"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.componentConstraints = null;
5 this.cyclicReference = null;
6 this.cyclicSprings = null;
7 this.acyclicSprings = null;
8 Clazz.instantialize (this, arguments);
9 }, javax.swing, "SpringLayout", null, java.awt.LayoutManager2);
10 Clazz.prepareFields (c$, function () {
11 this.componentConstraints = new java.util.HashMap ();
12 this.cyclicReference = javax.swing.Spring.constant (-2147483648);
14 Clazz.makeConstructor (c$,
17 Clazz.defineMethod (c$, "resetCyclicStatuses",
19 this.cyclicSprings = new java.util.HashSet ();
20 this.acyclicSprings = new java.util.HashSet ();
22 Clazz.defineMethod (c$, "setParent",
24 this.resetCyclicStatuses ();
25 var pc = this.getConstraints (p);
26 pc.setX (javax.swing.Spring.constant (0));
27 pc.setY (javax.swing.Spring.constant (0));
28 var width = pc.getWidth ();
29 if (Clazz.instanceOf (width, javax.swing.Spring.WidthSpring) && (width).c === p) {
30 pc.setWidth (javax.swing.Spring.constant (0, 0, 2147483647));
31 }var height = pc.getHeight ();
32 if (Clazz.instanceOf (height, javax.swing.Spring.HeightSpring) && (height).c === p) {
33 pc.setHeight (javax.swing.Spring.constant (0, 0, 2147483647));
34 }}, "java.awt.Container");
35 Clazz.defineMethod (c$, "isCyclic",
39 }if (this.cyclicSprings.contains (s)) {
41 }if (this.acyclicSprings.contains (s)) {
43 }this.cyclicSprings.add (s);
44 var result = s.isCyclic (this);
46 this.acyclicSprings.add (s);
47 this.cyclicSprings.remove (s);
49 System.err.println (s + " is cyclic. ");
51 }, "javax.swing.Spring");
52 Clazz.defineMethod (c$, "abandonCycles",
54 return this.isCyclic (s) ? this.cyclicReference : s;
55 }, "javax.swing.Spring");
56 Clazz.defineMethod (c$, "addLayoutComponent",
58 }, "~S,java.awt.Component");
59 Clazz.overrideMethod (c$, "removeLayoutComponent",
61 this.componentConstraints.remove (c);
62 }, "java.awt.Component");
63 c$.addInsets = Clazz.defineMethod (c$, "addInsets",
64 function (width, height, p) {
65 var i = p.getInsets ();
66 return new java.awt.Dimension (width + i.left + i.right, height + i.top + i.bottom);
67 }, "~N,~N,java.awt.Container");
68 Clazz.overrideMethod (c$, "minimumLayoutSize",
70 this.setParent (parent);
71 var pc = this.getConstraints (parent);
72 return javax.swing.SpringLayout.addInsets (this.abandonCycles (pc.getWidth ()).getMinimumValue (), this.abandonCycles (pc.getHeight ()).getMinimumValue (), parent);
73 }, "java.awt.Container");
74 Clazz.overrideMethod (c$, "preferredLayoutSize",
76 this.setParent (parent);
77 var pc = this.getConstraints (parent);
78 return javax.swing.SpringLayout.addInsets (this.abandonCycles (pc.getWidth ()).getPreferredValue (), this.abandonCycles (pc.getHeight ()).getPreferredValue (), parent);
79 }, "java.awt.Container");
80 Clazz.overrideMethod (c$, "maximumLayoutSize",
82 this.setParent (parent);
83 var pc = this.getConstraints (parent);
84 return javax.swing.SpringLayout.addInsets (this.abandonCycles (pc.getWidth ()).getMaximumValue (), this.abandonCycles (pc.getHeight ()).getMaximumValue (), parent);
85 }, "java.awt.Container");
86 Clazz.defineMethod (c$, "addLayoutComponent",
87 function (component, constraints) {
88 if (Clazz.instanceOf (constraints, javax.swing.SpringLayout.Constraints)) {
89 this.putConstraints (component, constraints);
90 }}, "java.awt.Component,~O");
91 Clazz.overrideMethod (c$, "getLayoutAlignmentX",
94 }, "java.awt.Container");
95 Clazz.overrideMethod (c$, "getLayoutAlignmentY",
98 }, "java.awt.Container");
99 Clazz.overrideMethod (c$, "invalidateLayout",
101 }, "java.awt.Container");
102 Clazz.defineMethod (c$, "putConstraint",
103 function (e1, c1, pad, e2, c2) {
104 this.putConstraint (e1, c1, javax.swing.Spring.constant (pad), e2, c2);
105 }, "~S,java.awt.Component,~N,~S,java.awt.Component");
106 Clazz.defineMethod (c$, "putConstraint",
107 function (e1, c1, s, e2, c2) {
108 this.putConstraint (e1, c1, javax.swing.Spring.sum (s, this.getConstraint (e2, c2)));
109 }, "~S,java.awt.Component,javax.swing.Spring,~S,java.awt.Component");
110 Clazz.defineMethod (c$, "putConstraint",
113 this.getConstraints (c).setConstraint (e, s);
114 }}, "~S,java.awt.Component,javax.swing.Spring");
115 Clazz.defineMethod (c$, "applyDefaults",
116 function (c, constraints) {
117 if (constraints == null) {
118 constraints = new javax.swing.SpringLayout.Constraints ();
119 }if (constraints.c == null) {
121 }if (constraints.horizontalHistory.size () < 2) {
122 this.applyDefaults (constraints, "West", javax.swing.Spring.constant (0), "Width", javax.swing.Spring.width (c), constraints.horizontalHistory);
123 }if (constraints.verticalHistory.size () < 2) {
124 this.applyDefaults (constraints, "North", javax.swing.Spring.constant (0), "Height", javax.swing.Spring.height (c), constraints.verticalHistory);
126 }, "java.awt.Component,javax.swing.SpringLayout.Constraints");
127 Clazz.defineMethod (c$, "applyDefaults",
128 function (constraints, name1, spring1, name2, spring2, history) {
129 if (history.size () == 0) {
130 constraints.setConstraint (name1, spring1);
131 constraints.setConstraint (name2, spring2);
133 if (constraints.getConstraint (name2) == null) {
134 constraints.setConstraint (name2, spring2);
136 constraints.setConstraint (name1, spring1);
137 }java.util.Collections.rotate (history, 1);
138 }}, "javax.swing.SpringLayout.Constraints,~S,javax.swing.Spring,~S,javax.swing.Spring,java.util.List");
139 Clazz.defineMethod (c$, "putConstraints",
140 function (component, constraints) {
141 this.componentConstraints.put (component, this.applyDefaults (component, constraints));
142 }, "java.awt.Component,javax.swing.SpringLayout.Constraints");
143 Clazz.defineMethod (c$, "getConstraints",
145 var result = this.componentConstraints.get (c);
146 if (result == null) {
147 if (Clazz.instanceOf (c, javax.swing.JComponent)) {
148 var cp = (c).getClientProperty (javax.swing.SpringLayout);
149 if (Clazz.instanceOf (cp, javax.swing.SpringLayout.Constraints)) {
150 return this.applyDefaults (c, cp);
151 }}result = new javax.swing.SpringLayout.Constraints ();
152 this.putConstraints (c, result);
154 }, "java.awt.Component");
155 Clazz.defineMethod (c$, "getConstraint",
156 function (edgeName, c) {
157 edgeName = edgeName.intern ();
158 return new javax.swing.SpringLayout.SpringProxy (edgeName, c, this);
159 }, "~S,java.awt.Component");
160 Clazz.overrideMethod (c$, "layoutContainer",
162 this.setParent (parent);
163 var n = parent.getComponentCount ();
164 this.getConstraints (parent).reset ();
165 for (var i = 0; i < n; i++) {
166 this.getConstraints (parent.getComponent (i)).reset ();
168 var insets = parent.getInsets ();
169 var pc = this.getConstraints (parent);
170 this.abandonCycles (pc.getX ()).setValue (0);
171 this.abandonCycles (pc.getY ()).setValue (0);
172 this.abandonCycles (pc.getWidth ()).setValue (parent.getWidth () - insets.left - insets.right);
173 this.abandonCycles (pc.getHeight ()).setValue (parent.getHeight () - insets.top - insets.bottom);
174 for (var i = 0; i < n; i++) {
175 var c = parent.getComponent (i);
176 var cc = this.getConstraints (c);
177 var x = this.abandonCycles (cc.getX ()).getValue ();
178 var y = this.abandonCycles (cc.getY ()).getValue ();
179 var width = this.abandonCycles (cc.getWidth ()).getValue ();
180 var height = this.abandonCycles (cc.getHeight ()).getValue ();
181 c.setBounds (insets.left + x, insets.top + y, width, height);
183 }, "java.awt.Container");
185 c$ = Clazz.decorateAsClass (function () {
192 this.horizontalCenter = null;
193 this.verticalCenter = null;
194 this.baseline = null;
195 this.horizontalHistory = null;
196 this.verticalHistory = null;
198 Clazz.instantialize (this, arguments);
199 }, javax.swing.SpringLayout, "Constraints");
200 Clazz.prepareFields (c$, function () {
201 this.horizontalHistory = new java.util.ArrayList (2);
202 this.verticalHistory = new java.util.ArrayList (2);
204 Clazz.makeConstructor (c$,
207 Clazz.makeConstructor (c$,
211 }, "javax.swing.Spring,javax.swing.Spring");
212 Clazz.makeConstructor (c$,
213 function (a, b, c, d) {
218 }, "javax.swing.Spring,javax.swing.Spring,javax.swing.Spring,javax.swing.Spring");
219 Clazz.makeConstructor (c$,
222 this.setX (javax.swing.Spring.constant (a.getX ()));
223 this.setY (javax.swing.Spring.constant (a.getY ()));
224 this.setWidth (javax.swing.Spring.width (a));
225 this.setHeight (javax.swing.Spring.height (a));
226 }, "java.awt.Component");
227 Clazz.defineMethod (c$, "pushConstraint",
230 var e = c ? this.horizontalHistory : this.verticalHistory;
231 if (e.contains (a)) {
234 } else if (e.size () == 2 && b != null) {
240 var f = c ? javax.swing.SpringLayout.ALL_HORIZONTAL : javax.swing.SpringLayout.ALL_VERTICAL;
241 for (var g = 0; g < f.length; g++) {
243 if (!e.contains (h)) {
244 this.setConstraint (h, null);
246 }}, "~S,javax.swing.Spring,~B");
247 Clazz.defineMethod (c$, "sum",
249 return (a == null || b == null) ? null : javax.swing.Spring.sum (a, b);
250 }, "javax.swing.Spring,javax.swing.Spring");
251 Clazz.defineMethod (c$, "difference",
253 return (a == null || b == null) ? null : javax.swing.Spring.difference (a, b);
254 }, "javax.swing.Spring,javax.swing.Spring");
255 Clazz.defineMethod (c$, "scale",
257 return (a == null) ? null : javax.swing.Spring.scale (a, b);
258 }, "javax.swing.Spring,~N");
259 Clazz.defineMethod (c$, "getBaselineFromHeight",
262 return -this.c.getBaseline (this.c.getPreferredSize ().width, -a);
263 }return this.c.getBaseline (this.c.getPreferredSize ().width, a);
265 Clazz.defineMethod (c$, "getHeightFromBaseLine",
267 var b = this.c.getPreferredSize ();
269 var d = this.c.getBaseline (b.width, c);
272 }switch (this.c.getBaselineResizeBehavior ()) {
273 case java.awt.Component.BaselineResizeBehavior.CONSTANT_DESCENT:
275 case java.awt.Component.BaselineResizeBehavior.CENTER_OFFSET:
276 return c + 2 * (a - d);
277 case java.awt.Component.BaselineResizeBehavior.CONSTANT_ASCENT:
282 Clazz.defineMethod (c$, "heightToRelativeBaseline",
284 return ((Clazz.isClassDefined ("javax.swing.SpringLayout$Constraints$1") ? 0 : javax.swing.SpringLayout.Constraints.$SpringLayout$Constraints$1$ ()), Clazz.innerTypeInstance (javax.swing.SpringLayout$Constraints$1, this, null, a));
285 }, "javax.swing.Spring");
286 Clazz.defineMethod (c$, "relativeBaselineToHeight",
288 return ((Clazz.isClassDefined ("javax.swing.SpringLayout$Constraints$2") ? 0 : javax.swing.SpringLayout.Constraints.$SpringLayout$Constraints$2$ ()), Clazz.innerTypeInstance (javax.swing.SpringLayout$Constraints$2, this, null, a));
289 }, "javax.swing.Spring");
290 Clazz.defineMethod (c$, "defined",
292 return a.contains (b) && a.contains (c);
293 }, "java.util.List,~S,~S");
294 Clazz.defineMethod (c$, "setX",
297 this.pushConstraint ("West", a, true);
298 }, "javax.swing.Spring");
299 Clazz.defineMethod (c$, "getX",
301 if (this.x == null) {
302 if (this.defined (this.horizontalHistory, "East", "Width")) {
303 this.x = this.difference (this.east, this.width);
304 } else if (this.defined (this.horizontalHistory, "HorizontalCenter", "Width")) {
305 this.x = this.difference (this.horizontalCenter, this.scale (this.width, 0.5));
306 } else if (this.defined (this.horizontalHistory, "HorizontalCenter", "East")) {
307 this.x = this.difference (this.scale (this.horizontalCenter, 2), this.east);
310 Clazz.defineMethod (c$, "setY",
313 this.pushConstraint ("North", a, false);
314 }, "javax.swing.Spring");
315 Clazz.defineMethod (c$, "getY",
317 if (this.y == null) {
318 if (this.defined (this.verticalHistory, "South", "Height")) {
319 this.y = this.difference (this.south, this.height);
320 } else if (this.defined (this.verticalHistory, "VerticalCenter", "Height")) {
321 this.y = this.difference (this.verticalCenter, this.scale (this.height, 0.5));
322 } else if (this.defined (this.verticalHistory, "VerticalCenter", "South")) {
323 this.y = this.difference (this.scale (this.verticalCenter, 2), this.south);
324 } else if (this.defined (this.verticalHistory, "Baseline", "Height")) {
325 this.y = this.difference (this.baseline, this.heightToRelativeBaseline (this.height));
326 } else if (this.defined (this.verticalHistory, "Baseline", "South")) {
327 this.y = this.scale (this.difference (this.baseline, this.heightToRelativeBaseline (this.south)), 2);
330 Clazz.defineMethod (c$, "setWidth",
333 this.pushConstraint ("Width", a, true);
334 }, "javax.swing.Spring");
335 Clazz.defineMethod (c$, "getWidth",
337 if (this.width == null) {
338 if (this.horizontalHistory.contains ("East")) {
339 this.width = this.difference (this.east, this.getX ());
340 } else if (this.horizontalHistory.contains ("HorizontalCenter")) {
341 this.width = this.scale (this.difference (this.horizontalCenter, this.getX ()), 2);
344 Clazz.defineMethod (c$, "setHeight",
347 this.pushConstraint ("Height", a, false);
348 }, "javax.swing.Spring");
349 Clazz.defineMethod (c$, "getHeight",
351 if (this.height == null) {
352 if (this.verticalHistory.contains ("South")) {
353 this.height = this.difference (this.south, this.getY ());
354 } else if (this.verticalHistory.contains ("VerticalCenter")) {
355 this.height = this.scale (this.difference (this.verticalCenter, this.getY ()), 2);
356 } else if (this.verticalHistory.contains ("Baseline")) {
357 this.height = this.relativeBaselineToHeight (this.difference (this.baseline, this.getY ()));
358 }}return this.height;
360 Clazz.defineMethod (c$, "setEast",
363 this.pushConstraint ("East", a, true);
364 }, "javax.swing.Spring");
365 Clazz.defineMethod (c$, "getEast",
367 if (this.east == null) {
368 this.east = this.sum (this.getX (), this.getWidth ());
371 Clazz.defineMethod (c$, "setSouth",
374 this.pushConstraint ("South", a, false);
375 }, "javax.swing.Spring");
376 Clazz.defineMethod (c$, "getSouth",
378 if (this.south == null) {
379 this.south = this.sum (this.getY (), this.getHeight ());
382 Clazz.defineMethod (c$, "getHorizontalCenter",
384 if (this.horizontalCenter == null) {
385 this.horizontalCenter = this.sum (this.getX (), this.scale (this.getWidth (), 0.5));
386 }return this.horizontalCenter;
388 Clazz.defineMethod (c$, "setHorizontalCenter",
390 this.horizontalCenter = a;
391 this.pushConstraint ("HorizontalCenter", a, true);
392 }, "javax.swing.Spring");
393 Clazz.defineMethod (c$, "getVerticalCenter",
395 if (this.verticalCenter == null) {
396 this.verticalCenter = this.sum (this.getY (), this.scale (this.getHeight (), 0.5));
397 }return this.verticalCenter;
399 Clazz.defineMethod (c$, "setVerticalCenter",
401 this.verticalCenter = a;
402 this.pushConstraint ("VerticalCenter", a, false);
403 }, "javax.swing.Spring");
404 Clazz.defineMethod (c$, "getBaseline",
406 if (this.baseline == null) {
407 this.baseline = this.sum (this.getY (), this.heightToRelativeBaseline (this.getHeight ()));
408 }return this.baseline;
410 Clazz.defineMethod (c$, "setBaseline",
413 this.pushConstraint ("Baseline", a, false);
414 }, "javax.swing.Spring");
415 Clazz.defineMethod (c$, "setConstraint",
420 } else if (a === "North") {
422 } else if (a === "East") {
424 } else if (a === "South") {
426 } else if (a === "HorizontalCenter") {
427 this.setHorizontalCenter (b);
428 } else if (a === "Width") {
430 } else if (a === "Height") {
432 } else if (a === "VerticalCenter") {
433 this.setVerticalCenter (b);
434 } else if (a === "Baseline") {
435 this.setBaseline (b);
436 }}, "~S,javax.swing.Spring");
437 Clazz.defineMethod (c$, "getConstraint",
440 return (a === "West") ? this.getX () : (a === "North") ? this.getY () : (a === "East") ? this.getEast () : (a === "South") ? this.getSouth () : (a === "Width") ? this.getWidth () : (a === "Height") ? this.getHeight () : (a === "HorizontalCenter") ? this.getHorizontalCenter () : (a === "VerticalCenter") ? this.getVerticalCenter () : (a === "Baseline") ? this.getBaseline () : null;
442 Clazz.defineMethod (c$, "reset",
444 var a = Clazz.newArray (-1, [this.x, this.y, this.width, this.height, this.east, this.south, this.horizontalCenter, this.verticalCenter, this.baseline]);
445 for (var b = 0; b < a.length; b++) {
448 c.setValue (-2147483648);
451 c$.$SpringLayout$Constraints$1$ = function () {
453 c$ = Clazz.declareAnonymous (javax.swing, "SpringLayout$Constraints$1", javax.swing.Spring.SpringMap);
454 Clazz.overrideMethod (c$, "map",
456 return this.b$["javax.swing.SpringLayout.Constraints"].getBaselineFromHeight (a);
458 Clazz.overrideMethod (c$, "inv",
460 return this.b$["javax.swing.SpringLayout.Constraints"].getHeightFromBaseLine (a);
464 c$.$SpringLayout$Constraints$2$ = function () {
466 c$ = Clazz.declareAnonymous (javax.swing, "SpringLayout$Constraints$2", javax.swing.Spring.SpringMap);
467 Clazz.overrideMethod (c$, "map",
469 return this.b$["javax.swing.SpringLayout.Constraints"].getHeightFromBaseLine (a);
471 Clazz.overrideMethod (c$, "inv",
473 return this.b$["javax.swing.SpringLayout.Constraints"].getBaselineFromHeight (a);
479 c$ = Clazz.decorateAsClass (function () {
480 this.edgeName = null;
483 Clazz.instantialize (this, arguments);
484 }, javax.swing.SpringLayout, "SpringProxy", javax.swing.Spring);
485 Clazz.makeConstructor (c$,
487 Clazz.superConstructor (this, javax.swing.SpringLayout.SpringProxy, []);
491 }, "~S,java.awt.Component,javax.swing.SpringLayout");
492 Clazz.defineMethod (c$, "getConstraint",
494 return this.l.getConstraints (this.c).getConstraint (this.edgeName);
496 Clazz.defineMethod (c$, "getMinimumValue",
498 return this.getConstraint ().getMinimumValue ();
500 Clazz.defineMethod (c$, "getPreferredValue",
502 return this.getConstraint ().getPreferredValue ();
504 Clazz.defineMethod (c$, "getMaximumValue",
506 return this.getConstraint ().getMaximumValue ();
508 Clazz.defineMethod (c$, "getValue",
510 return this.getConstraint ().getValue ();
512 Clazz.defineMethod (c$, "setValue",
514 this.getConstraint ().setValue (a);
516 Clazz.overrideMethod (c$, "isCyclic",
518 return a.isCyclic (this.getConstraint ());
519 }, "javax.swing.SpringLayout");
520 Clazz.overrideMethod (c$, "toString",
522 return "SpringProxy for " + this.edgeName + " edge of " + this.c.getName () + ".";
525 Clazz.defineStatics (c$,
530 "HORIZONTAL_CENTER", "HorizontalCenter",
531 "VERTICAL_CENTER", "VerticalCenter",
532 "BASELINE", "Baseline",
535 c$.ALL_HORIZONTAL = c$.prototype.ALL_HORIZONTAL = Clazz.newArray (-1, ["West", "Width", "East", "HorizontalCenter"]);
536 c$.ALL_VERTICAL = c$.prototype.ALL_VERTICAL = Clazz.newArray (-1, ["North", "Height", "South", "VerticalCenter", "Baseline"]);